:root {
  --app-bg: #eef2f7;
  --toolbar-bg: #0e2a3f;
  --toolbar-text: #f4f7fb;
  --panel-bg: #ffffff;
  --panel-border: #cfd6e2;
  --accent: #f4b740;
  --muted: #6b7280;
  --shadow: 0 18px 40px rgba(12, 24, 40, 0.18);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Arial, sans-serif;
  background: radial-gradient(circle at top, #f7f9fc 0%, #e5ebf4 58%, #dde4ef 100%);
  color: #0b1220;
}

#app {
  min-height: 100vh;
}

.app-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 20px;
  background: var(--toolbar-bg);
  color: var(--toolbar-text);
}

.toolbar-title {
  font-size: 18px;
  letter-spacing: 0.6px;
  font-weight: 700;
}

.toolbar-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

button {
  border: none;
  padding: 8px 14px;
  border-radius: 8px;
  background: #f0f2f7;
  color: #1b2a3c;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

button:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 16px rgba(15, 23, 42, 0.15);
}

button.primary {
  background: var(--accent);
  color: #1a1204;
}

.content {
  display: flex;
  flex-direction: column;
  gap: 24px;
  padding: 24px;
}

.sheet-wrapper {
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 18px;
  overflow: auto;
  touch-action: pan-x pan-y;
}

.sheet-scaler {
  position: relative;
  width: max-content;
  height: max-content;
}

.sheet-grid {
  display: grid;
  background: #fff;
  transform-origin: top left;
}

.cell {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  padding: 2px 4px;
  overflow: hidden;
  white-space: nowrap;
  line-height: 1.1;
}

.cell span {
  display: inline-block;
  width: 100%;
}

.cell input {
  width: 100%;
  height: 100%;
  border: none;
  background: transparent;
  font: inherit;
  color: inherit;
  padding: 0;
  outline: none;
  text-align: inherit;
}

.calc-panel {
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 16px;
}

.calc-panel h2 {
  margin: 0 0 12px 0;
  font-size: 16px;
}

.calc-modal {
  position: fixed;
  inset: 0;
  background: rgba(12, 18, 28, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 20;
}

.calc-card {
  width: min(900px, 100%);
  max-height: 80vh;
  overflow: auto;
  background: #ffffff;
  border-radius: 16px;
  box-shadow: var(--shadow);
  border: 1px solid #d8dee8;
  padding: 16px;
}

.calc-body {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.calc-sheet {
  background: #ffffff;
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  padding: 12px;
  box-shadow: var(--shadow);
  overflow: auto;
  max-height: 45vh;
  touch-action: pan-x pan-y;
}

.calc-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.calc-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.calc-table th,
.calc-table td {
  border-bottom: 1px solid #e5e7eb;
  text-align: left;
  padding: 6px 8px;
  vertical-align: top;
}

.calc-table th {
  color: var(--muted);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-size: 11px;
}

.signature-line-block {
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 6px;
  background: #ffffff;
  border: 2px solid #111827;
  border-radius: 12px;
  padding: 12px;
}

.signature-line {
  border-bottom: 2px solid #111827;
  height: 0;
  width: 100%;
}

.signature-label {
  font-size: 12px;
  font-weight: 700;
  color: #111827;
}

.hidden {
  display: none;
}

.auth-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.auth-card {
  width: min(420px, 100%);
  background: #ffffff;
  border-radius: 18px;
  padding: 28px;
  box-shadow: var(--shadow);
  border: 1px solid #d8dee8;
}

.auth-card h1 {
  margin: 0 0 6px 0;
  font-size: 20px;
}

.auth-card p {
  margin: 0 0 16px 0;
  color: var(--muted);
  font-size: 13px;
}

.auth-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
}

.auth-field input {
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid #cfd6e2;
  font-size: 14px;
}

.auth-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.auth-error {
  color: #b91c1c;
  font-size: 12px;
  min-height: 16px;
}

@media (max-width: 900px) {
  .toolbar {
    flex-direction: column;
    align-items: flex-start;
  }

  .content {
    padding: 16px;
  }

  .sheet-wrapper {
    padding: 12px;
  }
}
