/* ===== RESET & BASE ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #F4F6F9;
  --surface: #FFFFFF;
  --ink: #101828;
  --ink-soft: #475467;
  --ink-faint: #98A2B3;
  --navy: #16274D;
  --navy-bright: #2C4A85;
  --navy-pale: #EBEFF6;
  --navy-mid: #1D3461;
  --line: #E4E7EC;
  --negative: #B3261E;
  --positive: #1B7A5A;
  --radius: 12px;
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 14px;
  line-height: 1.5;
}

.hidden { display: none !important; }

.shell {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 24px;
}

/* ===== TOP STRIPE ===== */
.topstripe {
  height: 5px;
  background: linear-gradient(90deg, var(--navy), var(--navy-bright));
  width: 100%;
}

/* ===== AUTH SCREEN ===== */
.auth-screen {
  min-height: 100vh;
  display: flex !important;
  align-items: center;
  justify-content: center;
  background: linear-gradient(160deg, #0f1e3d 0%, #1a326b 50%, #0f1e3d 100%);
  padding: 24px;
}

.auth-card {
  background: var(--surface);
  border-radius: 20px;
  padding: 44px 40px 40px;
  width: 100%;
  max-width: 440px;
  box-shadow: 0 24px 80px rgba(0,0,0,0.3);
}

.auth-logo {
  margin-bottom: 24px;
}

.auth-logo-img {
  height: 48px;
  width: auto;
  object-fit: contain;
}

.auth-eyebrow {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 10.5px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--navy);
  background: var(--navy-pale);
  display: inline-block;
  padding: 4px 10px;
  border-radius: 20px;
  font-weight: 600;
  margin-bottom: 12px;
}

.auth-title {
  font-family: 'Sora', sans-serif;
  font-size: 26px;
  font-weight: 700;
  color: var(--ink);
  line-height: 1.25;
  margin-bottom: 10px;
  letter-spacing: -0.02em;
}

.auth-sub {
  font-size: 13.5px;
  color: var(--ink-soft);
  margin-bottom: 28px;
}

.auth-error {
  background: #FEF2F2;
  border: 1px solid #FECACA;
  border-radius: 8px;
  color: #991B1B;
  font-size: 13px;
  padding: 10px 14px;
  margin-bottom: 16px;
}

.auth-footer {
  margin-top: 20px;
  text-align: center;
  font-size: 12px;
  color: var(--ink-faint);
}

.setup-badge {
  background: #eef2ff;
  color: #3730a3;
}

.setup-success {
  background: #F0FDF4;
  border: 1px solid #BBF7D0;
  border-radius: 8px;
  color: #166534;
  font-size: 13px;
  padding: 10px 14px;
  margin-bottom: 16px;
}

/* ===== FORMS ===== */
.form-field {
  margin-bottom: 16px;
}

.form-field label {
  display: block;
  font-size: 12.5px;
  color: var(--ink-soft);
  margin-bottom: 6px;
  font-weight: 500;
}

.form-field input[type=text],
.form-field input[type=email],
.form-field input[type=number],
.form-field input[type=password],
.form-field select,
.form-field textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  font-size: 14px;
  font-family: 'Inter', sans-serif;
  color: var(--ink);
  transition: border-color 0.15s, box-shadow 0.15s;
  appearance: auto;
}

.form-field input[type=number] {
  font-family: 'IBM Plex Mono', monospace;
}

.form-field input:focus,
.form-field select:focus,
.form-field textarea:focus {
  outline: none;
  border-color: var(--navy);
  box-shadow: 0 0 0 3px var(--navy-pale);
}

.form-field textarea {
  resize: vertical;
  min-height: 76px;
}

.row2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.field-note {
  font-size: 11.5px;
  color: var(--ink-faint);
  margin: -10px 0 16px;
  line-height: 1.5;
}

/* ===== BUTTONS ===== */
.btn-primary {
  background: var(--navy);
  color: #fff;
  border: none;
  padding: 11px 20px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  font-family: 'Inter', sans-serif;
  cursor: pointer;
  transition: background 0.15s;
}
.btn-primary:hover { background: var(--navy-bright); }
.btn-primary:disabled { opacity: 0.45; cursor: default; }

.btn-full { width: 100%; padding: 13px; font-size: 15px; }

.btn-ghost {
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--ink-soft);
  padding: 11px 18px;
  border-radius: 10px;
  font-size: 13.5px;
  font-family: 'Inter', sans-serif;
  cursor: pointer;
  transition: border-color 0.15s;
}
.btn-ghost:hover { border-color: var(--ink-faint); }

.btn-navy-sm {
  background: var(--navy);
  color: #fff;
  border: none;
  padding: 8px 14px;
  border-radius: 20px;
  font-size: 12.5px;
  font-weight: 600;
  font-family: 'Inter', sans-serif;
  cursor: pointer;
  transition: background 0.15s;
  white-space: nowrap;
}
.btn-navy-sm:hover { background: var(--navy-bright); }

.btn-ghost-sm {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--ink-soft);
  padding: 7px 13px;
  border-radius: 20px;
  font-size: 12.5px;
  font-family: 'Inter', sans-serif;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
  white-space: nowrap;
}
.btn-ghost-sm:hover { border-color: var(--navy); color: var(--navy); }

/* ===== HEADER ===== */
.app-header {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  padding: 14px 0;
  position: sticky;
  top: 0;
  z-index: 20;
  box-shadow: 0 1px 6px rgba(16,24,40,0.06);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 16px;
}

.header-logo {
  height: 38px;
  width: auto;
  object-fit: contain;
}

.header-title-block {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.header-eyebrow {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 9.5px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--navy);
  font-weight: 600;
}

.header-title {
  font-family: 'Sora', sans-serif;
  font-size: 17px;
  font-weight: 700;
  color: var(--ink);
  letter-spacing: -0.01em;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.analyst-input {
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  width: 190px;
  background: var(--surface);
  color: var(--ink);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.analyst-input:focus { outline: none; border-color: var(--navy); box-shadow: 0 0 0 3px var(--navy-pale); }

/* ===== MAIN CONTENT ===== */
.main-content {
  padding-top: 36px;
  padding-bottom: 80px;
}

.section-label {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 10.5px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--navy);
  font-weight: 600;
  padding-bottom: 10px;
  margin-bottom: 20px;
  border-bottom: 2px solid var(--navy-pale);
}

/* ===== CALC GRID ===== */
.calc-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 40px;
  align-items: start;
}

@media (max-width: 880px) {
  .calc-grid { grid-template-columns: 1fr; }
  .row2 { grid-template-columns: 1fr; }
  .header-right { gap: 8px; }
  .analyst-input { width: 150px; }
}

/* ===== OUTPUT SURFACE ===== */
.output-surface {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 28px;
  box-shadow: 0 1px 2px rgba(16,24,40,0.04), 0 4px 16px rgba(16,24,40,0.05);
}

.output-client-name {
  font-family: 'Sora', sans-serif;
  font-size: 20px;
  font-weight: 700;
  color: var(--ink);
  margin-bottom: 4px;
}

.output-meta {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 12px;
  color: var(--ink-faint);
  margin-bottom: 22px;
}

/* ===== BRIDGE ===== */
.bridge {
  background: var(--navy-pale);
  border-radius: 12px;
  padding: 24px 18px 16px;
  margin-bottom: 22px;
}

.bridge-ruler {
  position: relative;
  height: 8px;
  background: #fff;
  border-radius: 20px;
  margin: 0 4px 34px;
  box-shadow: inset 0 1px 2px rgba(16,24,40,0.06);
  overflow: visible;
}

.bridge-fill {
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, var(--navy-bright), var(--navy));
  border-radius: 20px;
}

.bridge-marker {
  position: absolute;
  top: 50%;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #fff;
  border: 3px solid var(--navy);
  transform: translate(-50%, -50%);
  box-shadow: 0 2px 6px rgba(16,39,77,0.35);
  transition: left 0.3s ease;
}

.bridge-chip {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--navy);
  color: #fff;
  font-family: 'Sora', sans-serif;
  font-weight: 700;
  font-size: 15px;
  padding: 5px 12px;
  border-radius: 8px;
  white-space: nowrap;
  pointer-events: none;
}

.bridge-chip::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 5px solid transparent;
  border-top-color: var(--navy);
}

.bridge-vals {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
}

.bv-side { text-align: left; }
.bv-side.right { text-align: right; }

.bv-label {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-faint);
  margin-bottom: 2px;
}

.bv-val {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 15px;
  color: var(--ink-soft);
  font-weight: 600;
}

.bridge-caption {
  text-align: center;
  font-size: 11px;
  color: var(--ink-faint);
  margin-top: 10px;
}

/* ===== METHOD TABLE ===== */
.method-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
}

.method-table th {
  text-align: left;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-faint);
  font-weight: 600;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
}

.method-table th:last-child { text-align: right; }

.method-table td {
  text-align: right;
  padding: 9px 0;
  border-bottom: 1px solid var(--line);
  font-family: 'IBM Plex Mono', monospace;
}

.method-table td:first-child {
  text-align: left;
  font-family: 'Inter', sans-serif;
  color: var(--ink-soft);
}

.method-table tr.row-total td {
  border-top: 2px solid var(--navy);
  border-bottom: none;
  font-weight: 700;
  color: var(--navy);
  padding-top: 10px;
}

.method-table tr.row-total td:first-child { color: var(--navy); }

/* ===== BUTTON ROW ===== */
.btn-row {
  display: flex;
  gap: 8px;
  margin-top: 22px;
}

.btn-save {
  flex: 1.4;
  background: var(--navy);
  color: #fff;
  border: none;
  padding: 13px;
  border-radius: 10px;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  font-family: 'Inter', sans-serif;
  transition: background 0.15s;
}
.btn-save:hover { background: var(--navy-bright); }
.btn-save:disabled { opacity: 0.45; cursor: default; }

.btn-pdf {
  flex: 1;
  background: var(--surface);
  color: var(--navy);
  border: 1.5px solid var(--navy);
  padding: 13px;
  border-radius: 10px;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  font-family: 'Inter', sans-serif;
  transition: background 0.15s;
}
.btn-pdf:hover { background: var(--navy-pale); }
.btn-pdf:disabled { opacity: 0.45; cursor: default; }

.btn-share {
  flex: 1;
  background: var(--navy-pale);
  color: var(--navy);
  border: 1.5px solid var(--navy-pale);
  padding: 13px;
  border-radius: 10px;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  font-family: 'Inter', sans-serif;
  transition: background 0.15s, border-color 0.15s;
}
.btn-share:hover { background: #dde4f2; border-color: #dde4f2; }
.btn-share:disabled { opacity: 0.45; cursor: default; }

.save-note {
  font-size: 11.5px;
  color: var(--ink-faint);
  margin-top: 10px;
  text-align: center;
}

/* ===== HISTORY ===== */
.history-section {
  margin-top: 56px;
}

.history-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 16px;
}

.history-title {
  font-family: 'Sora', sans-serif;
  font-size: 20px;
  font-weight: 700;
  color: var(--ink);
}

.history-count {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11.5px;
  color: var(--ink-faint);
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: 0 1px 2px rgba(16,24,40,0.04);
}

.hist-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
  min-width: 780px;
}

.hist-table th {
  text-align: left;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--navy);
  font-weight: 600;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--navy-pale);
  white-space: nowrap;
}

.hist-table th:first-child { border-top-left-radius: 14px; }
.hist-table th:last-child { border-top-right-radius: 14px; }

.hist-table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  font-family: 'IBM Plex Mono', monospace;
  vertical-align: top;
}

.hist-table td.name-cell {
  font-family: 'Inter', sans-serif;
  font-weight: 500;
}

.hist-table td.notes-cell {
  font-family: 'Inter', sans-serif;
  font-size: 12px;
  color: var(--ink-soft);
  max-width: 200px;
  white-space: pre-wrap;
  word-break: break-word;
}

.hist-table tr:last-child td { border-bottom: none; }
.hist-table tr:hover { background: #FAFBFC; }

.del-btn {
  background: none;
  border: none;
  color: var(--ink-faint);
  cursor: pointer;
  font-size: 13px;
  padding: 2px 6px;
  border-radius: 4px;
  transition: color 0.15s;
}
.del-btn:hover { color: var(--negative); }

.empty-state {
  padding: 36px;
  text-align: center;
  color: var(--ink-faint);
  font-size: 13px;
}

/* ===== FOOTER ===== */
.footer-note {
  margin-top: 44px;
  font-size: 11.5px;
  color: var(--ink-faint);
  border-top: 1px solid var(--line);
  padding-top: 16px;
  line-height: 1.6;
}

/* ===== DRAWER ===== */
.drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(16,24,40,0.5);
  z-index: 50;
  display: flex;
  justify-content: flex-end;
  backdrop-filter: blur(2px);
}

.drawer {
  background: var(--bg);
  width: min(660px, 94vw);
  height: 100%;
  overflow-y: auto;
  padding: 30px 30px 80px;
  box-shadow: -14px 0 40px rgba(16,24,40,0.2);
}

.drawer-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.drawer-title {
  font-family: 'Sora', sans-serif;
  font-size: 22px;
  font-weight: 700;
  color: var(--ink);
}

.close-btn {
  background: var(--navy-pale);
  border: none;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  font-size: 18px;
  cursor: pointer;
  color: var(--navy);
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.close-btn:hover { background: #dde4f2; }

.drawer-sub {
  font-size: 13px;
  color: var(--ink-soft);
  margin-bottom: 24px;
}

.config-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px 16px;
  margin-bottom: 8px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px;
}

.config-grid label {
  display: block;
  font-size: 12px;
  color: var(--ink-soft);
  margin-bottom: 5px;
  font-weight: 500;
}

.config-grid input {
  width: 100%;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 13px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--bg);
  color: var(--ink);
}

.config-grid input:focus {
  outline: none;
  border-color: var(--navy);
  box-shadow: 0 0 0 3px var(--navy-pale);
}

.band-section-label {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--navy);
  font-weight: 600;
  margin: 22px 0 10px;
}

.band-head {
  display: grid;
  grid-template-columns: 1fr 1fr 90px 30px;
  gap: 8px;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-faint);
  font-family: 'IBM Plex Mono', monospace;
  margin-bottom: 6px;
}

.band-row {
  display: grid;
  grid-template-columns: 1fr 1fr 90px 30px;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
}

.band-row input {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 12.5px;
  padding: 7px 8px;
  border: 1px solid var(--line);
  border-radius: 7px;
  width: 100%;
  background: var(--surface);
  color: var(--ink);
}

.band-row input:focus {
  outline: none;
  border-color: var(--navy);
}

.icon-btn {
  background: transparent;
  border: none;
  color: var(--ink-faint);
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  padding: 4px;
  border-radius: 4px;
  transition: color 0.15s;
}
.icon-btn:hover { color: var(--negative); }

.btn-add-band {
  background: var(--surface);
  border: 1.5px dashed var(--ink-faint);
  padding: 10px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 12.5px;
  color: var(--navy);
  font-weight: 600;
  width: 100%;
  margin-top: 4px;
  font-family: 'Inter', sans-serif;
  transition: border-color 0.15s, background 0.15s;
}
.btn-add-band:hover { border-color: var(--navy); background: var(--navy-pale); }

.drawer-actions {
  display: flex;
  gap: 10px;
  margin-top: 28px;
  flex-wrap: wrap;
}

/* ===== USER MGMT ===== */
.user-add-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 6px;
}

.user-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  border: 1px solid var(--line);
  border-radius: 10px;
  margin-bottom: 8px;
  background: var(--surface);
}

.user-info { display: flex; flex-direction: column; gap: 2px; }
.user-name { font-weight: 600; font-size: 14px; color: var(--ink); }
.user-email { font-size: 12px; color: var(--ink-faint); font-family: 'IBM Plex Mono', monospace; }

.btn-remove {
  background: none;
  border: 1px solid #FECACA;
  color: var(--negative);
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 12.5px;
  cursor: pointer;
  font-family: 'Inter', sans-serif;
  transition: background 0.15s;
}
.btn-remove:hover { background: #FEF2F2; }

/* ===== PDF MODAL ===== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(16,24,40,0.6);
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  backdrop-filter: blur(3px);
}

.pdf-modal-inner {
  background: var(--surface);
  border-radius: 16px;
  width: 100%;
  max-width: 900px;
  height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 24px 80px rgba(0,0,0,0.4);
}

.pdf-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
  background: var(--navy-pale);
  gap: 12px;
  flex-wrap: wrap;
}

.pdf-modal-title {
  font-family: 'Sora', sans-serif;
  font-size: 16px;
  font-weight: 700;
  color: var(--navy);
}

.pdf-modal-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.pdf-iframe {
  flex: 1;
  border: none;
  width: 100%;
}

/* ===== TOAST ===== */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--navy);
  color: #fff;
  padding: 11px 22px;
  border-radius: 24px;
  font-size: 13px;
  font-weight: 500;
  z-index: 100;
  box-shadow: 0 8px 24px rgba(16,24,40,0.28);
  white-space: nowrap;
  animation: fadeInUp 0.2s ease;
}

@keyframes fadeInUp {
  from { opacity: 0; transform: translateX(-50%) translateY(10px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* ===== MONO UTIL ===== */
.mono { font-family: 'IBM Plex Mono', monospace; font-variant-numeric: tabular-nums; }
