:root {
  --navy-950: #07172e;
  --navy-900: #0b2345;
  --navy-800: #12345f;
  --navy-700: #1a4a7a;
  --blue-600: #2463a9;
  --blue-500: #2f75c4;
  --blue-100: #eaf3ff;
  --gold-500: #d6a84b;
  --gold-100: #fff6df;
  --teal-600: #087c75;
  --green-600: #16815d;
  --red-600: #b42338;
  --orange-600: #b65c09;
  --ink-900: #172033;
  --ink-700: #364152;
  --ink-500: #667085;
  --ink-400: #98a2b3;
  --line: #e4e8ef;
  --surface: #ffffff;
  --surface-soft: #f7f9fc;
  --surface-blue: #f2f7fd;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .06);
  --shadow-md: 0 12px 32px rgba(16, 35, 66, .12);
  --shadow-lg: 0 24px 60px rgba(7, 23, 46, .22);
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 22px;
  --sidebar-width: 270px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink-900);
  background: var(--surface-soft);
  font-synthesis: none;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; margin: 0; }
body { background: var(--surface-soft); }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
a { color: var(--blue-600); }
.hidden { display: none !important; }
.muted { color: var(--ink-500); }
.eyebrow { margin: 0 0 6px; color: var(--blue-600); font-size: 11px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }

.login-shell { min-height: 100vh; display: grid; grid-template-columns: minmax(420px, 1.1fr) minmax(420px, .9fr); background: var(--surface); }
.login-brand { position: relative; overflow: hidden; display: flex; flex-direction: column; justify-content: center; padding: clamp(48px, 8vw, 120px); color: #fff; background: radial-gradient(circle at 80% 20%, rgba(47,117,196,.55), transparent 35%), linear-gradient(145deg, var(--navy-950), var(--navy-800)); }
.login-brand::before, .login-brand::after { content: ""; position: absolute; border: 1px solid rgba(255,255,255,.1); border-radius: 50%; }
.login-brand::before { width: 420px; height: 420px; right: -210px; bottom: -100px; }
.login-brand::after { width: 240px; height: 240px; right: 80px; top: -120px; }
.login-brand .eyebrow { color: #b8d8ff; margin-top: 34px; }
.login-brand h1 { max-width: 680px; margin: 0; font-size: clamp(38px, 5vw, 68px); line-height: 1.04; letter-spacing: -.045em; }
.login-copy { max-width: 640px; margin: 24px 0 30px; color: #d8e6f7; font-size: 18px; line-height: 1.7; }
.login-features { display: flex; flex-wrap: wrap; gap: 10px; }
.login-features span { padding: 9px 12px; border: 1px solid rgba(255,255,255,.16); border-radius: 999px; background: rgba(255,255,255,.07); font-size: 13px; }
.login-panel { display: flex; flex-direction: column; justify-content: center; align-items: center; padding: 42px; background: #fbfcfe; }
.login-card { width: min(430px, 100%); padding: 40px; border: 1px solid var(--line); border-radius: var(--radius-lg); background: #fff; box-shadow: var(--shadow-md); }
.login-card h2 { margin: 0; font-size: 34px; letter-spacing: -.03em; }
.login-footer { color: var(--ink-500); font-size: 12px; margin-top: 20px; }
.mobile-brand { display: none; align-items: center; gap: 10px; margin-bottom: 30px; }
.brand-mark { display: grid; place-items: center; flex: 0 0 auto; width: 42px; height: 42px; border-radius: 12px; color: #fff; background: linear-gradient(145deg, var(--gold-500), #b77e25); font-weight: 900; box-shadow: 0 8px 20px rgba(214,168,75,.25); }
.brand-mark-large { width: 66px; height: 66px; border-radius: 18px; font-size: 28px; }
.stack { display: grid; gap: 18px; margin-top: 26px; }
.password-wrap { display: flex; }
.password-wrap input { border-radius: var(--radius-sm) 0 0 var(--radius-sm); }
.password-wrap .icon-button { width: auto; padding: 0 14px; border: 1px solid #cfd6e2; border-left: 0; border-radius: 0 var(--radius-sm) var(--radius-sm) 0; color: var(--blue-600); background: var(--surface); font-size: 12px; font-weight: 700; }
.text-button { border: 0; padding: 0; margin-top: 20px; color: var(--blue-600); background: transparent; font-size: 13px; font-weight: 700; }
.connection-status { margin-top: 18px; padding: 10px 12px; border-radius: var(--radius-sm); color: var(--ink-700); background: var(--surface-soft); font-size: 12px; overflow-wrap: anywhere; }

.app-shell { min-height: 100vh; }
.sidebar { position: fixed; inset: 0 auto 0 0; z-index: 30; display: flex; flex-direction: column; width: var(--sidebar-width); padding: 20px 16px; color: #fff; background: linear-gradient(180deg, var(--navy-950), var(--navy-900)); box-shadow: 12px 0 40px rgba(7,23,46,.12); }
.sidebar-header { display: flex; align-items: center; gap: 12px; min-height: 58px; padding: 0 8px 20px; border-bottom: 1px solid rgba(255,255,255,.09); }
.sidebar-header strong { display: block; font-size: 15px; }
.sidebar-header small { display: block; margin-top: 3px; color: #9db6d4; font-size: 11px; }
.sidebar-close { display: none; margin-left: auto; color: #fff !important; }
.nav-list { display: grid; gap: 4px; margin-top: 22px; overflow: auto; }
.nav-item { display: flex; align-items: center; gap: 12px; width: 100%; padding: 11px 12px; border: 0; border-radius: 10px; color: #c8d8ea; background: transparent; text-align: left; transition: .16s ease; }
.nav-item:hover { color: #fff; background: rgba(255,255,255,.07); }
.nav-item.active { color: #fff; background: linear-gradient(90deg, rgba(47,117,196,.55), rgba(47,117,196,.18)); box-shadow: inset 3px 0 var(--gold-500); }
.nav-icon { display: grid; place-items: center; width: 22px; font-weight: 800; }
.sidebar-footer { margin-top: auto; padding-top: 18px; border-top: 1px solid rgba(255,255,255,.09); }
.api-pill { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; color: #bcd0e5; font-size: 11px; overflow: hidden; }
.api-pill span:last-child { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: #42d392; box-shadow: 0 0 0 4px rgba(66,211,146,.13); }
.sidebar .button-ghost { color: #dce8f5; border-color: rgba(255,255,255,.18); }
.sidebar-backdrop { display: none; }
.main-area { min-height: 100vh; margin-left: var(--sidebar-width); }
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between; min-height: 82px; padding: 14px clamp(20px, 3vw, 40px); border-bottom: 1px solid var(--line); background: rgba(255,255,255,.92); backdrop-filter: blur(14px); }
.topbar-title { display: flex; align-items: center; gap: 12px; }
.topbar-title h2 { margin: 0; font-size: 25px; letter-spacing: -.025em; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.menu-button { display: none; }
.avatar-button { width: 40px; height: 40px; border: 0; border-radius: 50%; color: #fff; background: var(--navy-800); font-size: 12px; font-weight: 800; }
.page-content { width: min(1500px, 100%); margin: 0 auto; padding: 28px clamp(18px, 3vw, 40px) 60px; }
.system-banner { margin: 16px clamp(18px, 3vw, 40px) 0; padding: 12px 16px; border: 1px solid #f3ce76; border-radius: var(--radius-sm); color: #7a4b00; background: var(--gold-100); font-size: 13px; }

.page-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin-bottom: 22px; }
.page-heading h3 { margin: 0; font-size: 22px; letter-spacing: -.02em; }
.page-heading p { margin: 6px 0 0; color: var(--ink-500); }
.action-row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.metric-card { position: relative; overflow: hidden; min-height: 134px; padding: 20px; border: 1px solid var(--line); border-radius: var(--radius-md); background: var(--surface); box-shadow: var(--shadow-sm); }
.metric-card::after { content: ""; position: absolute; right: -30px; bottom: -35px; width: 110px; height: 110px; border-radius: 50%; background: var(--surface-blue); }
.metric-card button { position: absolute; inset: 0; z-index: 2; border: 0; background: transparent; }
.metric-label { position: relative; z-index: 1; color: var(--ink-500); font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; }
.metric-value { position: relative; z-index: 1; display: block; margin-top: 15px; font-size: clamp(24px, 2.2vw, 34px); font-weight: 800; letter-spacing: -.04em; }
.metric-note { position: relative; z-index: 1; display: block; margin-top: 8px; color: var(--ink-500); font-size: 12px; }
.content-grid { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(300px, .75fr); gap: 18px; margin-top: 18px; }
.card { border: 1px solid var(--line); border-radius: var(--radius-md); background: var(--surface); box-shadow: var(--shadow-sm); }
.card-header { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 18px 20px; border-bottom: 1px solid var(--line); }
.card-header h4 { margin: 0; font-size: 16px; }
.card-body { padding: 20px; }
.quick-actions { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.quick-action { display: flex; flex-direction: column; gap: 6px; padding: 14px; border: 1px solid var(--line); border-radius: 10px; color: var(--ink-900); background: var(--surface); text-align: left; transition: .15s ease; }
.quick-action:hover { border-color: #b7cee9; background: var(--surface-blue); transform: translateY(-1px); }
.quick-action strong { font-size: 13px; }
.quick-action span { color: var(--ink-500); font-size: 11px; }
.kpi-list { display: grid; gap: 14px; }
.kpi-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding-bottom: 12px; border-bottom: 1px dashed var(--line); }
.kpi-row:last-child { border-bottom: 0; padding-bottom: 0; }
.kpi-row span { color: var(--ink-500); font-size: 12px; }
.kpi-row strong { font-size: 14px; }

.button { display: inline-flex; align-items: center; justify-content: center; min-height: 40px; padding: 9px 15px; border: 1px solid transparent; border-radius: var(--radius-sm); font-weight: 750; font-size: 13px; transition: .15s ease; }
.button:disabled { cursor: not-allowed; opacity: .55; }
.button-primary { color: #fff; background: linear-gradient(135deg, var(--blue-600), var(--navy-700)); box-shadow: 0 7px 16px rgba(36,99,169,.18); }
.button-primary:hover { filter: brightness(1.04); transform: translateY(-1px); }
.button-secondary { color: var(--navy-800); border-color: #cfd9e7; background: #fff; }
.button-secondary:hover { background: var(--surface-blue); }
.button-danger { color: #fff; background: var(--red-600); }
.button-ghost { color: var(--ink-700); border-color: var(--line); background: transparent; }
.button-block { width: 100%; }
.button-small { min-height: 32px; padding: 6px 10px; font-size: 11px; }
.icon-button { display: grid; place-items: center; width: 38px; height: 38px; border: 0; border-radius: 8px; color: var(--ink-700); background: transparent; font-size: 20px; }
.icon-button:hover { background: var(--surface-soft); }

.field { display: grid; gap: 7px; }
.field > span, .field-label { color: var(--ink-700); font-size: 12px; font-weight: 750; }
.field small { color: var(--ink-500); }
input, select, textarea { width: 100%; min-height: 42px; padding: 10px 12px; border: 1px solid #cfd6e2; border-radius: var(--radius-sm); outline: none; color: var(--ink-900); background: #fff; transition: .15s ease; }
textarea { min-height: 94px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--blue-500); box-shadow: 0 0 0 3px rgba(47,117,196,.12); }
input[type="file"] { padding: 8px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 16px; }
.form-grid-3 { grid-template-columns: repeat(3, minmax(0,1fr)); }
.form-span-2 { grid-column: span 2; }
.form-span-3 { grid-column: span 3; }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--line); }
.inline-form { display: flex; flex-wrap: wrap; align-items: end; gap: 12px; }
.inline-form .field { min-width: 170px; flex: 1; }
.search-box { position: relative; min-width: 240px; }
.search-box input { padding-left: 35px; }
.search-box::before { content: "⌕"; position: absolute; top: 8px; left: 12px; color: var(--ink-400); font-size: 18px; z-index: 1; }
.checkbox-line { display: flex; align-items: center; gap: 8px; }
.checkbox-line input { width: auto; min-height: 0; }

.table-wrap { width: 100%; overflow: auto; }
table { width: 100%; border-collapse: collapse; font-size: 12px; }
th { position: sticky; top: 0; z-index: 1; padding: 11px 12px; color: var(--ink-500); background: #f8fafc; font-size: 10px; font-weight: 800; letter-spacing: .045em; text-align: left; text-transform: uppercase; white-space: nowrap; }
td { padding: 12px; border-top: 1px solid var(--line); color: var(--ink-700); vertical-align: middle; white-space: nowrap; }
tbody tr:hover { background: #fbfdff; }
td strong { color: var(--ink-900); }
.numeric { text-align: right; font-variant-numeric: tabular-nums; }
.table-actions { display: flex; gap: 6px; }
.empty-state { padding: 42px 20px; text-align: center; }
.empty-state strong { display: block; margin-bottom: 6px; }
.empty-state p { margin: 0; color: var(--ink-500); }
.badge { display: inline-flex; align-items: center; min-height: 24px; padding: 4px 8px; border-radius: 999px; font-size: 10px; font-weight: 800; letter-spacing: .025em; }
.badge-green { color: #086744; background: #e7f7ef; }
.badge-red { color: #9d1831; background: #fdecef; }
.badge-orange { color: #965008; background: #fff0dc; }
.badge-blue { color: #1e5e9f; background: #eaf3ff; }
.badge-gray { color: #536071; background: #eef1f5; }
.badge-purple { color: #6e3ea3; background: #f3eafa; }

.modal-root { position: fixed; inset: 0; z-index: 80; display: grid; place-items: center; padding: 20px; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(7,23,46,.55); backdrop-filter: blur(5px); }
.modal { position: relative; width: min(900px, 100%); max-height: calc(100vh - 40px); overflow: hidden; border-radius: var(--radius-lg); background: #fff; box-shadow: var(--shadow-lg); }
.modal.modal-wide { width: min(1220px, 100%); }
.modal-header { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 20px 24px; border-bottom: 1px solid var(--line); }
.modal-header h3 { margin: 0; font-size: 21px; }
.modal-body { max-height: calc(100vh - 124px); padding: 24px; overflow: auto; }
.detail-grid { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 12px; }
.detail-item { padding: 13px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-soft); }
.detail-item span { display: block; color: var(--ink-500); font-size: 10px; font-weight: 800; letter-spacing: .04em; text-transform: uppercase; }
.detail-item strong { display: block; margin-top: 6px; font-size: 13px; overflow-wrap: anywhere; }
.section-title { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 24px 0 10px; }
.section-title h4 { margin: 0; }
.document-links { display: flex; flex-wrap: wrap; gap: 8px; }
.document-link { padding: 8px 11px; border: 1px solid #bfd1e6; border-radius: 8px; text-decoration: none; font-size: 11px; font-weight: 750; background: var(--surface-blue); }

.loading-overlay { position: fixed; inset: 0; z-index: 120; display: grid; place-items: center; align-content: center; gap: 14px; color: #fff; background: rgba(7,23,46,.68); backdrop-filter: blur(3px); }
.loading-overlay p { margin: 0; font-weight: 700; }
.spinner { width: 42px; height: 42px; border: 4px solid rgba(255,255,255,.25); border-top-color: #fff; border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.toast-root { position: fixed; z-index: 140; right: 20px; bottom: 20px; display: grid; gap: 10px; width: min(380px, calc(100vw - 40px)); }
.toast { padding: 13px 15px; border-radius: 10px; color: #fff; background: var(--navy-900); box-shadow: var(--shadow-lg); animation: toast-in .18s ease-out; }
.toast.error { background: var(--red-600); }
.toast.success { background: var(--green-600); }
@keyframes toast-in { from { transform: translateY(8px); opacity: 0; } }

.report-toolbar { display: grid; grid-template-columns: 1.2fr repeat(3, minmax(150px,.7fr)) auto; gap: 10px; align-items: end; }
.report-summary { display: flex; flex-wrap: wrap; gap: 12px; margin: 16px 0; }
.summary-chip { padding: 10px 12px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface); }
.summary-chip span { color: var(--ink-500); font-size: 10px; text-transform: uppercase; }
.summary-chip strong { display: block; margin-top: 3px; }
.pre-box { padding: 16px; border: 1px solid var(--line); border-radius: 10px; background: #0c1e38; color: #d9e8fa; white-space: pre-wrap; font: 12px/1.6 ui-monospace, SFMono-Regular, Menlo, monospace; }

@media (max-width: 1180px) {
  .metric-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .detail-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .report-toolbar { grid-template-columns: repeat(2, minmax(0,1fr)); }
}

@media (max-width: 900px) {
  .login-shell { grid-template-columns: 1fr; }
  .login-brand { display: none; }
  .login-panel { min-height: 100vh; padding: 24px; }
  .mobile-brand { display: flex; }
  .sidebar { transform: translateX(-105%); transition: transform .2s ease; }
  .sidebar.open { transform: translateX(0); }
  .sidebar-close, .menu-button { display: grid; }
  .sidebar-backdrop { position: fixed; inset: 0; z-index: 25; background: rgba(7,23,46,.45); }
  .sidebar-backdrop.open { display: block; }
  .main-area { margin-left: 0; }
  .content-grid { grid-template-columns: 1fr; }
  .form-grid-3 { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .form-span-3 { grid-column: span 2; }
}

@media (max-width: 620px) {
  .topbar { min-height: 72px; padding: 12px 14px; }
  .topbar-title .eyebrow { display: none; }
  .topbar-title h2 { font-size: 19px; }
  .topbar-actions .button { display: none; }
  .page-content { padding: 18px 12px 46px; }
  .page-heading { flex-direction: column; }
  .page-heading .action-row { width: 100%; }
  .page-heading .action-row .button { flex: 1; }
  .metric-grid { grid-template-columns: 1fr; }
  .metric-card { min-height: 112px; }
  .quick-actions { grid-template-columns: 1fr; }
  .form-grid, .form-grid-3 { grid-template-columns: 1fr; }
  .form-span-2, .form-span-3 { grid-column: auto; }
  .modal-root { padding: 0; align-items: end; }
  .modal, .modal.modal-wide { width: 100%; max-height: 94vh; border-radius: 20px 20px 0 0; }
  .modal-body { padding: 18px; }
  .detail-grid { grid-template-columns: 1fr 1fr; }
  .report-toolbar { grid-template-columns: 1fr; }
  .search-box { min-width: 100%; width: 100%; }
}

@media print {
  .sidebar, .topbar, .system-banner, .page-heading .action-row, .button, .search-box { display: none !important; }
  .main-area { margin: 0; }
  .page-content { padding: 0; }
  .card { box-shadow: none; break-inside: avoid; }
  body { background: #fff; }
}

.branding-grid { display: grid; grid-template-columns: 220px minmax(0,1fr); gap: 24px; align-items: start; }
.logo-preview { min-height: 180px; display: grid; place-items: center; align-content: center; gap: 8px; padding: 18px; border: 1px dashed #b9c6d8; border-radius: 14px; color: var(--ink-500); background: var(--surface-soft); text-align: center; }
.logo-preview img { max-width: 100%; max-height: 150px; object-fit: contain; }
.logo-preview strong { font-size: 28px; color: var(--navy-800); }
@media (max-width: 760px) { .branding-grid { grid-template-columns: 1fr; } .logo-preview { min-height: 130px; } }
.brand-mark.brand-mark-image { padding: 4px; background: #fff; overflow: hidden; }
.brand-mark.brand-mark-image img { width: 100%; height: 100%; object-fit: contain; border-radius: 8px; }
