:root {
  color-scheme: light;
  --ink: #172033;
  --muted: #667085;
  --line: #e4e7ec;
  --surface: #ffffff;
  --canvas: #f5f7f8;
  --navy: #132a3a;
  --teal: #0f766e;
  --teal-soft: #dff5f1;
  --gold: #d99a25;
  --danger: #c2413b;
  --shadow: 0 10px 30px rgba(18, 35, 48, 0.07);
}

* { box-sizing: border-box; }
body { margin: 0; overflow-x: hidden; font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; color: var(--ink); background: var(--canvas); }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
.auth-screen { min-height: 100vh; padding: 32px 18px; display: grid; place-items: center; background: radial-gradient(circle at top left, #dff5f1, transparent 38%), linear-gradient(145deg, #f7faf9, #edf2f4); }
.auth-card { width: min(920px, 100%); display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(320px, .95fr); gap: 36px; padding: clamp(28px, 5vw, 56px); border: 1px solid rgba(210,220,224,.9); border-radius: 25px; background: rgba(255,255,255,.96); box-shadow: 0 25px 70px rgba(18,35,48,.12); }
.auth-brand { min-width: 0; display: flex; align-items: flex-start; gap: 18px; padding-right: 24px; border-right: 1px solid var(--line); }
.auth-brand .brand-mark { flex: 0 0 48px; width: 48px; height: 48px; }
.auth-brand h1 { margin: 2px 0 14px; font-size: clamp(30px, 5vw, 48px); }
.auth-brand > div > p:last-child { max-width: 440px; color: var(--muted); line-height: 1.6; }
.auth-panel { min-width: 0; align-self: center; }
.auth-panel h2 { margin-bottom: 5px; font-size: 25px; }
.auth-panel > div > p { margin-bottom: 20px; }
.auth-form { display: grid; gap: 13px; }
.auth-form label { display: grid; gap: 7px; color: #4b5565; font-size: 12px; font-weight: 750; }
.auth-form input { width: 100%; min-width: 0; min-height: 45px; padding: 10px 12px; border: 1px solid #d8dde3; border-radius: 10px; outline: none; }
.auth-form input:focus { border-color: #26a69a; box-shadow: 0 0 0 3px rgba(38,166,154,.12); }
.auth-form button { margin-top: 3px; min-height: 45px; }
.text-button { padding: 10px 0; border: 0; color: var(--teal); background: transparent; font-size: 12px; font-weight: 800; }
.profile-list { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 16px; }
.profile-chip { padding: 7px 10px; border: 1px solid #cfe3df; border-radius: 999px; color: #235e58; background: #eff9f7; font-size: 11px; font-weight: 750; }
.auth-message { grid-column: 2; min-height: 18px; margin: -20px 0 0; color: var(--danger); font-size: 12px; font-weight: 700; }
.auth-footnote { grid-column: 1 / -1; margin: -12px 0 0; padding-top: 18px; border-top: 1px solid var(--line); color: var(--muted); font-size: 11px; text-align: center; }
.app-shell { min-height: 100vh; display: grid; grid-template-columns: 250px 1fr; }
.sidebar { position: sticky; top: 0; height: 100vh; padding: 26px 18px; color: white; background: linear-gradient(180deg, #142d3f 0%, #0d2533 100%); display: flex; flex-direction: column; }
.brand { display: flex; align-items: center; gap: 12px; padding: 0 8px 30px; }
.brand-mark { display: block; width: 42px; height: 42px; border-radius: 13px; background: #132a3a; object-fit: cover; box-shadow: 0 6px 18px rgba(13,37,51,.16); }
.brand strong, .brand small { display: block; }
.brand small { margin-top: 3px; color: #b9cbd5; font-size: 12px; }
nav { display: grid; gap: 6px; }
.nav-item { width: 100%; padding: 12px 14px; border: 0; border-radius: 10px; text-align: left; color: #c9d8df; background: transparent; }
.nav-item:hover, .nav-item.active { color: white; background: rgba(255,255,255,.1); }
.offline-note { margin-top: auto; padding: 14px 10px 0; color: #b9cbd5; font-size: 12px; border-top: 1px solid rgba(255,255,255,.1); }
.offline-note span { display: inline-block; width: 8px; height: 8px; margin-right: 7px; border-radius: 50%; background: #34d399; }
.session-box { margin-top: auto; padding: 14px 8px 0; border-top: 1px solid rgba(255,255,255,.1); display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.session-box > div { min-width: 0; }
.session-box span { display: inline-block; width: 8px; height: 8px; margin-right: 5px; border-radius: 50%; background: #34d399; }
.session-box small { color: #b9cbd5; font-size: 10px; }
.session-box strong { display: block; max-width: 130px; margin-top: 4px; overflow: hidden; color: white; font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.session-box button { padding: 7px 9px; border: 1px solid rgba(255,255,255,.18); border-radius: 8px; color: white; background: rgba(255,255,255,.08); font-size: 11px; }
.main-content { min-width: 0; padding: 34px clamp(20px, 4vw, 54px) 60px; }
.topbar { min-width: 0; display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 28px; }
.eyebrow { margin: 0 0 7px; color: var(--teal); font-size: 11px; font-weight: 800; letter-spacing: .12em; }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: clamp(27px, 4vw, 38px); letter-spacing: -.04em; }
h2 { margin-bottom: 0; font-size: 19px; }
.month-control { flex: 0 0 auto; display: grid; gap: 6px; color: var(--muted); font-size: 12px; font-weight: 700; }
.month-control input { min-width: 170px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: white; color: var(--ink); }
.hero-panel { min-height: 165px; padding: 30px; border-radius: 20px; background: linear-gradient(120deg, #0f766e, #154e56); color: white; box-shadow: var(--shadow); display: flex; justify-content: space-between; align-items: center; gap: 24px; }
.hero-panel p { margin-bottom: 8px; color: #c8f0ea; font-weight: 700; }
.hero-panel strong { display: block; margin-bottom: 8px; font-size: clamp(34px, 5vw, 52px); letter-spacing: -.05em; }
.hero-panel span { color: #c8f0ea; font-size: 13px; }
.primary-button { padding: 12px 18px; border: 0; border-radius: 11px; background: white; color: var(--teal); font-weight: 800; box-shadow: 0 5px 15px rgba(0,0,0,.12); }
.primary-button.teal { color: white; background: var(--teal); box-shadow: none; }
.secondary-button, .danger-button, .table-button { padding: 10px 14px; border: 1px solid var(--line); border-radius: 10px; background: white; color: var(--ink); font-weight: 750; }
.danger-button { color: var(--danger); border-color: #f1cbc8; }
.table-button { padding: 6px 9px; font-size: 11px; }
.button-row { display: flex; flex-wrap: wrap; gap: 9px; align-items: center; }
.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 15px; margin: 18px 0; }
.metric-card, .panel { min-width: 0; background: var(--surface); border: 1px solid rgba(228,231,236,.9); box-shadow: var(--shadow); }
.metric-card { padding: 20px; border-radius: 15px; }
.metric-card span, .metric-card small { display: block; color: var(--muted); }
.metric-card span { margin-bottom: 11px; font-size: 13px; font-weight: 650; }
.metric-card strong { display: block; margin-bottom: 6px; font-size: 23px; letter-spacing: -.03em; }
.metric-card small { font-size: 11px; }
.content-grid { min-width: 0; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 18px; }
.content-grid > * { min-width: 0; }
.panel { min-height: 260px; padding: 22px; border-radius: 16px; }
.panel.compact { min-height: auto; }
.panel-heading { display: flex; justify-content: space-between; align-items: center; gap: 14px; margin-bottom: 22px; }
.panel-heading p:last-child { margin: 5px 0 0; color: var(--muted); font-size: 12px; }
.empty-state { display: grid; place-items: center; min-height: 150px; padding: 24px; border: 1px dashed #cfd6dc; border-radius: 13px; color: var(--muted); text-align: center; font-size: 13px; background: #fafbfb; }
.form-panel { margin-bottom: 18px; }
.form-grid { width: 100%; min-width: 0; display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 14px; align-items: end; }
.field { min-width: 0; grid-column: span 3; display: grid; gap: 7px; color: #4b5565; font-size: 12px; font-weight: 700; }
.field.span-2 { grid-column: span 2; }
.field.span-4 { grid-column: span 4; }
.field.span-5 { grid-column: span 5; }
.field.span-6 { grid-column: span 6; }
.field.span-12 { grid-column: span 12; }
.field input, .field select, .field textarea { width: 100%; min-width: 0; max-width: 100%; min-height: 42px; padding: 10px 11px; border: 1px solid #d8dde3; border-radius: 10px; color: var(--ink); background: white; outline: none; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: #26a69a; box-shadow: 0 0 0 3px rgba(38,166,154,.12); }
.field textarea { min-height: 76px; resize: vertical; }
.field.check { display: flex; align-items: center; gap: 8px; min-height: 42px; }
.field.check input { width: 18px; min-height: 18px; }
.form-actions { min-width: 0; grid-column: span 2; display: flex; align-items: end; }
.form-actions.wide { grid-column: span 3; }
.form-actions.large { grid-column: span 4; }
.form-actions.half { grid-column: span 6; }
.form-actions button { width: 100%; max-width: 100%; min-height: 42px; padding-inline: 10px; white-space: normal; overflow-wrap: anywhere; }
.credit-payment-fields { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 14px; padding: 15px; border: 1px solid #bce7df; border-radius: 13px; background: #f2fbf9; }
.table-wrap { width: 100%; min-width: 0; max-width: 100%; overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; }
table { width: 100%; border-collapse: collapse; min-width: 700px; background: white; }
th, td { padding: 12px 13px; border-bottom: 1px solid #edf0f2; text-align: left; font-size: 12px; vertical-align: middle; }
th { color: #596273; background: #f8fafb; font-size: 10px; letter-spacing: .06em; text-transform: uppercase; white-space: nowrap; }
td.number, th.number { text-align: right; }
tr:last-child td { border-bottom: 0; }
.muted { color: var(--muted); }
.positive { color: var(--teal); }
.negative { color: var(--danger); }
.status { display: inline-flex; align-items: center; padding: 4px 8px; border-radius: 999px; background: #eef2f4; color: #4b5565; font-size: 10px; font-weight: 800; }
.status.green { background: #dcfce7; color: #166534; }
.status.amber { background: #fef3c7; color: #92400e; }
.section-stack { display: grid; gap: 18px; }
.summary-strip { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin: 18px 0; }
.summary-item { min-width: 0; padding: 16px 18px; border-radius: 13px; border: 1px solid var(--line); background: white; }
.summary-item span, .summary-item small { display: block; color: var(--muted); font-size: 11px; }
.summary-item strong { display: block; margin: 7px 0 3px; font-size: 20px; overflow-wrap: anywhere; }
.bar-list { display: grid; gap: 14px; }
.bar-row { display: grid; grid-template-columns: minmax(90px, 150px) 1fr auto; align-items: center; gap: 11px; font-size: 12px; }
.bar-track { height: 9px; border-radius: 999px; background: #edf1f2; overflow: hidden; }
.bar-fill { height: 100%; border-radius: inherit; background: linear-gradient(90deg, #0f766e, #2dd4bf); }
.forecast-list { display: grid; gap: 10px; }
.forecast-row { display: grid; grid-template-columns: 80px 1fr auto; align-items: center; gap: 10px; font-size: 12px; }
.forecast-track { height: 8px; background: #edf1f2; border-radius: 999px; overflow: hidden; }
.forecast-fill { height: 100%; background: #d99a25; border-radius: inherit; }
.alert-list { display: grid; gap: 9px; margin: 18px 0; }
.alert-card { padding: 13px 15px; border-radius: 12px; color: #66480c; background: #fff6dd; border: 1px solid #f5dfaa; font-size: 12px; }
.alert-card.good { color: #115e59; background: #e9f8f5; border-color: #bce7df; }
.day-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(155px, 1fr)); gap: 10px; }
.day-card { padding: 14px; border-radius: 12px; background: #f8fafb; border: 1px solid var(--line); }
.day-card span { color: var(--muted); font-size: 11px; }
.day-card strong { display: block; margin-top: 5px; }
.card-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.credit-card { min-height: 140px; padding: 20px; border-radius: 17px; color: white; background: linear-gradient(135deg, #18384c, #0f766e); display: flex; flex-direction: column; justify-content: space-between; box-shadow: var(--shadow); }
.credit-card:nth-child(2n) { background: linear-gradient(135deg, #3e3153, #704b67); }
.credit-card small { color: rgba(255,255,255,.75); }
.credit-card strong { display: block; font-size: 20px; }
.credit-card .card-meta { display: flex; justify-content: space-between; align-items: end; gap: 15px; }
.installment-outlook { margin: 18px 0; }
.installment-insights { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.installment-insights > div { padding: 15px; border: 1px solid var(--line); border-radius: 12px; background: #f8fafb; }
.installment-insights span, .installment-insights small { display: block; color: var(--muted); font-size: 11px; }
.installment-insights strong { display: block; margin: 6px 0 3px; font-size: 21px; }
.ending-list { display: grid; gap: 8px; margin-top: 12px; }
.ending-list > span { padding: 11px 13px; border-radius: 10px; color: #66480c; background: #fff6dd; border: 1px solid #f5dfaa; font-size: 12px; }
.info-box { min-width: 0; padding: 16px; border-radius: 12px; background: #eef8f6; color: #285f5a; font-size: 12px; line-height: 1.55; overflow-wrap: anywhere; }
.danger-zone { padding: 16px; border: 1px solid #f1cbc8; background: #fffafa; border-radius: 12px; }
.toast { position: fixed; right: 20px; bottom: 20px; z-index: 20; max-width: 340px; padding: 13px 16px; border-radius: 11px; color: white; background: #172033; box-shadow: 0 12px 35px rgba(0,0,0,.2); opacity: 0; transform: translateY(10px); pointer-events: none; transition: .2s ease; font-size: 13px; }
.toast.show { opacity: 1; transform: translateY(0); }
.hidden { display: none !important; }

@media (max-width: 950px) {
  .auth-card { grid-template-columns: 1fr; gap: 24px; }
  .auth-brand { padding: 0 0 24px; border-right: 0; border-bottom: 1px solid var(--line); }
  .auth-message { grid-column: 1; margin-top: -8px; }
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: static; width: 100%; height: auto; padding: 16px; }
  .brand { padding-bottom: 14px; }
  nav { display: flex; overflow-x: auto; padding-bottom: 4px; }
  .nav-item { width: auto; white-space: nowrap; }
  .offline-note { display: none; }
  .session-box { margin-top: 12px; }
  .metric-grid { grid-template-columns: repeat(2, 1fr); }
  .summary-strip { grid-template-columns: repeat(2, 1fr); }
  .field, .field.span-2, .field.span-4, .field.span-5, .field.span-6 { grid-column: span 6; }
  .credit-payment-fields .field, .credit-payment-fields .field.span-2, .credit-payment-fields .field.span-3, .credit-payment-fields .field.span-4 { grid-column: span 6; }
  .form-actions, .form-actions.wide, .form-actions.large, .form-actions.half { grid-column: span 6; }
}
@media (max-width: 650px) {
  html { scroll-behavior: smooth; scroll-padding-top: calc(62px + env(safe-area-inset-top)); }
  body { background: #eef2f3; overscroll-behavior-y: auto; -webkit-overflow-scrolling: touch; }
  .auth-screen { padding: 0; align-items: stretch; }
  .auth-card { min-height: 100dvh; gap: 18px; padding: max(24px, env(safe-area-inset-top)) 18px calc(24px + env(safe-area-inset-bottom)); border: 0; border-radius: 0; }
  .auth-brand { display: flex; align-items: center; gap: 12px; padding: 0 0 18px; }
  .auth-brand .brand-mark { flex-basis: 42px; width: 42px; height: 42px; margin: 0; }
  .auth-brand h1 { margin-bottom: 7px; font-size: 30px; }
  .auth-brand > div > p:last-child { margin-bottom: 0; font-size: 13px; line-height: 1.45; }
  .app-shell { display: block; width: 100%; min-height: 100dvh; padding-bottom: calc(72px + env(safe-area-inset-bottom)); }
  .sidebar { position: sticky; top: 0; z-index: 30; width: 100%; height: auto; padding: calc(8px + env(safe-area-inset-top)) 12px 8px; display: flex; align-items: center; gap: 10px; box-shadow: 0 8px 25px rgba(13,37,51,.16); }
  .brand { flex: 1; min-width: 0; gap: 9px; padding: 0; }
  .brand .brand-mark { flex: 0 0 36px; width: 36px; height: 36px; border-radius: 11px; font-size: 14px; }
  .brand strong { font-size: 13px; }
  .brand small { display: none; }
  .session-box { margin: 0; padding: 0; border: 0; gap: 6px; }
  .session-box span, .session-box small { display: none; }
  .session-box strong { max-width: 86px; margin: 0; font-size: 11px; }
  .session-box button { min-height: 38px; padding: 7px 10px; }
  nav { position: fixed; right: 0; bottom: 0; left: 0; z-index: 35; display: flex; gap: 4px; overflow-x: auto; padding: 8px 10px calc(8px + env(safe-area-inset-bottom)); background: #0d2533; box-shadow: 0 -8px 25px rgba(13,37,51,.18); scroll-snap-type: x proximity; scrollbar-width: none; }
  nav::-webkit-scrollbar { display: none; }
  .nav-item { flex: 0 0 auto; width: auto; min-height: 44px; padding: 10px 12px; font-size: 12px; white-space: nowrap; scroll-snap-align: start; }
  .nav-item.active { background: var(--teal); }
  .main-content { width: 100%; padding: 18px 12px 30px; overflow: visible; }
  .topbar { align-items: stretch; flex-direction: column; gap: 12px; margin-bottom: 16px; }
  .topbar h1 { font-size: 26px; }
  .topbar .eyebrow { margin-bottom: 5px; font-size: 9px; }
  .month-control { width: 100%; margin-left: 0; font-size: 10px; }
  .month-control input { width: 100%; min-width: 0; min-height: 44px; padding: 9px 11px; }
  .hero-panel { min-height: 0; padding: 20px; align-items: stretch; flex-direction: column; gap: 15px; }
  .hero-panel > div:first-child { min-width: 0; }
  .hero-panel strong { font-size: 32px; }
  .hero-panel span { display: block; line-height: 1.35; }
  .hero-action { flex: 0 0 auto; width: 100%; }
  .hero-action .primary-button { width: 100%; padding: 10px 9px; font-size: 12px; }
  .metric-grid { grid-template-columns: 1fr; gap: 8px; margin: 10px 0; }
  .metric-card { padding: 14px; }
  .metric-card span { margin-bottom: 7px; font-size: 11px; }
  .metric-card strong { font-size: 19px; }
  .content-grid { grid-template-columns: 1fr; gap: 12px; }
  .summary-strip { grid-template-columns: 1fr; gap: 8px; margin: 12px 0; }
  .summary-item { padding: 13px; }
  .summary-item strong { font-size: 17px; }
  .panel { min-height: auto; padding: 16px; border-radius: 14px; }
  .panel-heading { align-items: stretch; flex-direction: column; margin-bottom: 16px; }
  .form-panel { margin-bottom: 12px; }
  .form-grid { gap: 10px; }
  .field, .field.span-2, .field.span-3, .field.span-4, .field.span-5, .field.span-6, .field.span-12 { grid-column: span 12; }
  .field input, .field select, .field textarea { min-height: 44px; padding: 10px; font-size: 16px; }
  .form-actions, .form-actions.wide, .form-actions.large, .form-actions.half { grid-column: span 12; }
  .credit-payment-fields { gap: 10px; padding: 12px; }
  .credit-payment-fields .field, .credit-payment-fields .field.span-2, .credit-payment-fields .field.span-3, .credit-payment-fields .field.span-4 { grid-column: span 12; }
  .installment-insights { grid-template-columns: 1fr; gap: 8px; }
  .installment-insights > div { padding: 10px; }
  .installment-insights strong { font-size: 17px; }
  .installment-insights small { font-size: 9px; }
  .table-wrap { -webkit-overflow-scrolling: touch; }
  table { min-width: 560px; }
  th, td { padding: 10px; }
  .toast { right: 12px; bottom: calc(78px + env(safe-area-inset-bottom)); left: 12px; max-width: none; }
  .bar-row { grid-template-columns: 90px 1fr; }
  .bar-row strong { grid-column: 2; }
}
