

:root {
  --navy: #173f63;
  --navy-deep: #0e3458;
  --green: #238a6d;
  --green-dark: #11745a;
  --green-soft: #e7f7f1;
  --amber: #b7791f;
  --amber-soft: #fff4d6;
  --blue-soft: #edf4ff;
  --red: #c24152;
  --red-soft: #fff0f2;
  --page: #f6f8fa;
  --white: #ffffff;
  --ink: #1d2b3c;
  --muted: #667085;
  --border: #dce3e8;
  --shadow: 0 2px 10px rgba(23, 63, 99, 0.05);
  --shadow-lg: 0 18px 50px rgba(14, 52, 88, 0.18);
}

* { box-sizing: border-box; }

html { background: var(--page); }

body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font-family: var(--font-geist-sans), Inter, Arial, Helvetica, sans-serif;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

button, input, select { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .58; }

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

.sidebar {
  width: 240px;
  flex: 0 0 240px;
  min-height: 100vh;
  padding: 28px 10px 20px;
  display: flex;
  flex-direction: column;
  color: #fff;
  background: linear-gradient(180deg, var(--navy) 0%, #10385e 100%);
  position: sticky;
  top: 0;
  height: 100vh;
  z-index: 40;
}

.brand-block { display: flex; align-items: center; gap: 11px; padding: 0 12px 30px; }
.brand-mark { width: 34px; height: 34px; border: 2px solid rgba(255,255,255,.86); border-radius: 7px; display: grid; place-items: center; font-size: 22px; line-height: 1; }
.brand-name { font-size: 20px; font-weight: 700; letter-spacing: -.03em; }
.brand-caption { margin-top: 3px; color: rgba(255,255,255,.66); font-size: 11px; }
.sidebar-nav { display: grid; gap: 6px; }
.nav-item { border: 0; color: rgba(255,255,255,.9); background: transparent; border-radius: 9px; min-height: 48px; padding: 0 14px; display: flex; align-items: center; gap: 13px; text-align: left; transition: background 140ms ease-out, transform 140ms ease-out; }
.nav-item:hover { background: rgba(255,255,255,.1); transform: translateX(1px); }
.nav-item-active { background: var(--green); color: #fff; box-shadow: 0 6px 16px rgba(15, 111, 83, .22); }
.nav-item-active:hover { background: var(--green); transform: none; }
.nav-item .icon { width: 23px; text-align: center; font-size: 20px; line-height: 1; }
.sidebar-footer { margin-top: auto; padding: 14px 14px 3px; display: flex; align-items: center; gap: 8px; color: rgba(255,255,255,.58); font-size: 12px; }
.private-dot { width: 8px; height: 8px; border-radius: 50%; background: #72d8b2; box-shadow: 0 0 0 4px rgba(114,216,178,.12); }

.topbar { min-height: 122px; padding: 30px 40px 24px; display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; background: var(--page); }
.topbar-copy h1 { color: var(--navy); font-size: clamp(27px, 3vw, 38px); line-height: 1.13; letter-spacing: -.035em; margin: 0; font-weight: 700; }
.topbar-copy p { margin: 8px 0 0; color: var(--muted); font-size: 17px; }
.topbar-actions { display: flex; align-items: center; gap: 15px; padding-top: 2px; }
.avatar { width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center; background: #e9eef3; color: var(--navy); font-weight: 700; }
.mobile-menu { display: none; border: 1px solid var(--border); background: var(--white); color: var(--navy); width: 38px; height: 38px; border-radius: 8px; }

.content-area { flex: 1; padding: 0 40px 30px; min-width: 0; }
.view-stack { display: grid; gap: 20px; }
.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 18px; }
.metric-card { min-height: 176px; padding: 27px 21px 20px; background: var(--white); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow); position: relative; overflow: hidden; }
.metric-card::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--navy); }
.metric-green::before { background: var(--green); }
.metric-amber::before { background: #e7ad3a; }
.metric-head { min-height: 35px; display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; color: var(--navy); font-size: 15px; line-height: 1.3; font-weight: 600; }
.metric-icon { color: var(--green); font-size: 27px; line-height: 1; font-weight: 500; }
.metric-amber .metric-icon { color: var(--amber); }
.metric-card strong { display: block; margin-top: 23px; color: var(--navy); font-size: clamp(22px, 2.3vw, 31px); line-height: 1; letter-spacing: -.045em; font-variant-numeric: tabular-nums; white-space: nowrap; }
.metric-card p { margin: 16px 0 0; color: var(--muted); font-size: 12px; }

.panel { background: var(--white); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow); }
.collection-panel { overflow: hidden; }
.panel-heading { padding: 23px 25px 17px; display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; }
.panel-heading h2 { margin: 0; color: var(--navy); font-size: 20px; letter-spacing: -.025em; }
.panel-heading p { margin: 6px 0 0; color: var(--muted); font-size: 12px; }
.table-source { color: var(--muted); font-size: 12px; padding-top: 4px; }
.table-wrap { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; min-width: 700px; }
.data-table th { padding: 0 25px 13px; color: var(--muted); text-align: left; font-size: 12px; font-weight: 600; white-space: nowrap; border-bottom: 1px solid var(--border); }
.data-table td { padding: 15px 25px; color: var(--ink); border-bottom: 1px solid #e7edf1; vertical-align: middle; white-space: nowrap; }
.data-table tbody tr:last-child td { border-bottom: 0; }
.data-table td strong { display: block; color: var(--ink); font-weight: 600; }
.data-table td small { display: block; margin-top: 4px; color: var(--muted); font-size: 11px; }
.compact-table { min-width: 760px; }
.compact-table td { padding-top: 14px; padding-bottom: 14px; }
.clickable-row { transition: background 140ms ease-out; }
.clickable-row:hover { background: #f8fbfd; }
.align-right { text-align: right !important; font-variant-numeric: tabular-nums; }
.empty-cell { text-align: center; color: var(--muted) !important; padding: 36px 20px !important; }
.total-row td { background: #f3f8fb; border-top: 2px solid #cfdee8; font-weight: 600; }
.status-pill { display: inline-flex; align-items: center; min-height: 26px; padding: 4px 10px; border-radius: 7px; font-size: 11px; font-weight: 600; line-height: 1.15; white-space: nowrap; }
.status-green { color: #087451; background: var(--green-soft); }
.status-amber { color: #9a670e; background: var(--amber-soft); }
.status-blue { color: #2459a6; background: var(--blue-soft); }
.status-red { color: #ae3145; background: var(--red-soft); }
.status-neutral { color: #526170; background: #eef2f5; }
.type-chip { display: inline-flex; padding: 4px 7px; border-radius: 5px; background: #eef4f8; color: var(--navy); font-size: 11px; font-weight: 700; }

.dashboard-lower { display: grid; grid-template-columns: 1.25fr .9fr; gap: 20px; }
.insight-panel, .summary-panel { min-height: 210px; }
.count-badge { min-width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: 12px; }
.count-warning { color: #9a670e; background: var(--amber-soft); }
.count-good { color: #087451; background: var(--green-soft); }
.insight-row { padding: 16px 25px; border-top: 1px solid #edf1f3; display: flex; align-items: center; gap: 12px; }
.insight-row > div { flex: 1; min-width: 0; }
.insight-row strong { font-size: 13px; color: var(--navy); }
.insight-row p { margin: 4px 0 0; color: var(--muted); font-size: 11px; line-height: 1.45; }
.insight-icon { flex: 0 0 28px; width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; }
.insight-icon.amber { color: #9a670e; background: var(--amber-soft); }
.insight-icon.green { color: #087451; background: var(--green-soft); }
.summary-list { padding: 0 25px 20px; }
.summary-list > div { display: flex; justify-content: space-between; gap: 10px; padding: 12px 0; border-bottom: 1px dashed #dce3e8; color: #4e5f70; font-size: 12px; }
.summary-list > div:last-child { border-bottom: 0; }
.summary-list strong { color: var(--navy); font-variant-numeric: tabular-nums; }
.summary-dot { width: 8px; height: 8px; display: inline-block; margin-right: 8px; border-radius: 50%; }
.dot-green { background: #4dbf9d; }
.dot-blue { background: #75a8dc; }
.dot-amber { background: #e9b342; }

.button { border: 1px solid transparent; min-height: 42px; padding: 0 17px; border-radius: 8px; display: inline-flex; justify-content: center; align-items: center; gap: 8px; font-weight: 650; font-size: 13px; transition: transform 140ms ease-out, box-shadow 140ms ease-out, background 140ms ease-out, border-color 140ms ease-out; white-space: nowrap; }
.button:hover:not(:disabled) { transform: translateY(-1px); }
.button-primary { color: #fff; background: var(--green); box-shadow: 0 5px 13px rgba(35, 138, 109, .19); }
.button-primary:hover:not(:disabled) { background: var(--green-dark); box-shadow: 0 7px 16px rgba(35, 138, 109, .25); }
.button-secondary { color: var(--navy); background: #fff; border-color: var(--border); }
.button-secondary:hover:not(:disabled) { background: #f8fbfd; }
.button-ghost { color: #205ea8; background: transparent; padding: 0 4px; min-height: 30px; }
.button-ghost:hover:not(:disabled) { color: var(--green-dark); background: #f1f7fa; }
.button-danger { color: var(--red); background: var(--red-soft); }
.button-plus { font-size: 21px; font-weight: 400; line-height: 0; }
.arrow { font-size: 16px; margin-left: 2px; }

.toolbar { min-height: 70px; padding: 13px 17px; display: flex; align-items: center; gap: 12px; }
.toolbar .button { margin-left: auto; }
.toolbar-intro { display: flex; flex-direction: column; gap: 4px; color: var(--navy); }
.toolbar-intro span { color: var(--muted); font-size: 12px; }
.search-box { min-width: 240px; flex: 1; max-width: 510px; height: 42px; padding: 0 12px; border: 1px solid var(--border); border-radius: 8px; display: flex; align-items: center; gap: 8px; color: var(--muted); background: #fff; }
.search-box .icon { font-size: 20px; }
.search-box input { border: 0; outline: 0; flex: 1; min-width: 0; color: var(--ink); background: transparent; }
.toolbar select, .toolbar > select { height: 42px; min-width: 170px; }
.table-panel { overflow: hidden; }
.wide-table { min-width: 1080px; }

.settings-panel { overflow: hidden; }
.settings-grid { padding: 7px 25px 28px; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 24px; }
.field { display: flex; flex-direction: column; gap: 6px; color: var(--navy); font-size: 12px; font-weight: 650; }
.field small { color: var(--muted); font-size: 11px; font-weight: 400; line-height: 1.35; }
.field input, .field select, .toolbar select { width: 100%; min-height: 42px; border: 1px solid #cfd9e1; border-radius: 7px; padding: 0 11px; outline: none; color: var(--ink); background: #fff; transition: border-color 140ms ease-out, box-shadow 140ms ease-out; }
.field input:focus, .field select:focus, .toolbar select:focus, .search-box:focus-within { border-color: #6b9bbb; box-shadow: 0 0 0 3px rgba(63, 131, 173, .13); }
.input-suffix { position: relative; }
.input-suffix input { padding-right: 130px; }
.input-suffix em { position: absolute; right: 11px; top: 13px; color: var(--muted); font-size: 10px; font-style: normal; font-weight: 400; }
.parameter-note { min-height: 70px; padding: 13px 15px; border: 1px solid var(--border); border-radius: 8px; background: #fafcfd; display: flex; flex-direction: column; gap: 5px; }
.parameter-note strong { color: var(--navy); font-size: 12px; }
.parameter-note span { color: var(--muted); font-size: 11px; }

.modal-backdrop { position: fixed; inset: 0; z-index: 100; padding: 24px; display: grid; place-items: center; background: rgba(14, 52, 88, .42); backdrop-filter: blur(3px); animation: fade-in 140ms ease-out; }
.modal-card { width: min(760px, 100%); max-height: min(870px, calc(100vh - 48px)); overflow-y: auto; border-radius: 14px; border: 1px solid #d2dfe6; background: #fff; box-shadow: var(--shadow-lg); animation: modal-in 180ms ease-out; }
.modal-header { padding: 21px 25px 18px; display: flex; justify-content: space-between; gap: 14px; border-bottom: 1px solid #e6edf1; }
.eyebrow { color: var(--green); font-size: 10px; font-weight: 750; letter-spacing: .14em; text-transform: uppercase; }
.modal-header h2 { margin: 7px 0 0; color: var(--navy); font-size: 21px; letter-spacing: -.025em; }
.close-button { width: 34px; height: 34px; border: 0; border-radius: 7px; background: #f2f6f8; color: var(--muted); font-size: 24px; line-height: 1; }
.close-button:hover { background: #e8f0f4; color: var(--navy); }
.modal-form { padding: 22px 25px 25px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 18px; }
.field-wide { grid-column: 1 / -1; }
.switch-row { margin-top: 20px; padding: 14px 15px; border: 1px solid var(--border); border-radius: 8px; display: flex; flex-wrap: wrap; gap: 22px; background: #fafcfd; }
.switch-label { display: inline-flex; align-items: center; gap: 9px; color: var(--navy); font-size: 12px; font-weight: 650; }
.switch-label input { width: 17px; height: 17px; accent-color: var(--green); }
.calculation-preview { margin-top: 21px; padding: 14px; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; border-radius: 9px; background: #f3f8fb; border: 1px solid #dce9ef; }
.calculation-preview > div { min-width: 0; display: flex; flex-direction: column; gap: 5px; }
.calculation-preview span { color: var(--muted); font-size: 10px; }
.calculation-preview strong { color: var(--navy); font-size: 13px; font-variant-numeric: tabular-nums; }
.modal-actions { margin-top: 23px; display: flex; justify-content: flex-end; gap: 10px; }

.notice-bar { margin-bottom: 18px; padding: 10px 12px; display: flex; align-items: center; gap: 9px; border: 1px solid #ead39a; border-radius: 8px; color: #8b651c; background: #fff9e8; font-size: 12px; }
.notice-bar > span { width: 20px; height: 20px; display: grid; place-items: center; border-radius: 50%; color: #fff; background: #d2a53a; font-weight: 700; }
.notice-bar button { margin-left: auto; border: 0; background: transparent; color: #8b651c; font-size: 18px; }
.toast { position: fixed; right: 24px; bottom: 24px; z-index: 120; padding: 12px 16px; display: flex; align-items: center; gap: 9px; border-radius: 9px; color: #fff; background: var(--navy); box-shadow: var(--shadow-lg); animation: toast-in 180ms ease-out; font-size: 13px; }
.toast span { width: 20px; height: 20px; display: grid; place-items: center; border-radius: 50%; color: var(--navy); background: #aee7d1; font-weight: 800; }
.app-footer { margin-top: auto; padding: 18px 40px 20px; display: flex; justify-content: space-between; gap: 15px; color: #7a8792; font-size: 11px; }
.loading-screen { min-height: 100vh; display: grid; place-items: center; align-content: center; gap: 8px; color: var(--navy); background: var(--page); }
.loading-screen h1 { margin: 0; font-size: 22px; }
.loading-screen p { margin: 0; color: var(--muted); }
.loading-mark { width: 50px; height: 50px; display: grid; place-items: center; border-radius: 12px; color: #fff; background: var(--navy); font-size: 30px; animation: pulse 1.4s ease-in-out infinite; }

@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes modal-in { from { opacity: 0; transform: translateY(7px) scale(.99); } to { opacity: 1; transform: translateY(0) scale(1); } }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
@keyframes pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.04); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}

@media (max-width: 1180px) {
  .sidebar { width: 216px; flex-basis: 216px; }
  .topbar, .content-area { padding-left: 26px; padding-right: 26px; }
  .metric-grid { gap: 12px; }
  .metric-card { padding-left: 17px; padding-right: 17px; }
  .metric-card strong { font-size: 24px; }
  .dashboard-lower { grid-template-columns: 1fr; }
}

@media (max-width: 860px) {
  .sidebar { position: fixed; left: 0; transform: translateX(-102%); transition: transform 180ms ease-out; box-shadow: 12px 0 30px rgba(10, 36, 62, .18); }
  .sidebar.sidebar-open { transform: translateX(0); }
  .mobile-menu { display: inline-grid; place-items: center; flex: 0 0 auto; }
  .topbar { min-height: 100px; align-items: center; padding-top: 20px; padding-bottom: 20px; }
  .topbar-copy h1 { font-size: 28px; }
  .topbar-copy p { font-size: 14px; }
  .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .app-footer { padding-left: 26px; padding-right: 26px; }
}

@media (max-width: 620px) {
  .topbar, .content-area { padding-left: 16px; padding-right: 16px; }
  .topbar { gap: 10px; }
  .topbar-actions .button { padding: 0 10px; font-size: 12px; }
  .topbar-actions .avatar { display: none; }
  .topbar-copy h1 { font-size: 23px; }
  .topbar-copy p { margin-top: 4px; font-size: 12px; }
  .metric-grid { grid-template-columns: 1fr; }
  .metric-card { min-height: 142px; padding-top: 20px; }
  .metric-card strong { margin-top: 16px; font-size: 27px; }
  .panel-heading { padding-left: 17px; padding-right: 17px; }
  .data-table th { padding-left: 17px; padding-right: 17px; }
  .data-table td { padding-left: 17px; padding-right: 17px; }
  .toolbar { align-items: stretch; flex-direction: column; padding: 13px; }
  .toolbar .button { margin-left: 0; }
  .search-box { max-width: none; min-width: 0; }
  .toolbar select { width: 100%; }
  .settings-grid { grid-template-columns: 1fr; padding-left: 17px; padding-right: 17px; }
  .form-grid { grid-template-columns: 1fr; }
  .field-wide { grid-column: auto; }
  .modal-backdrop { padding: 10px; }
  .modal-card { max-height: calc(100vh - 20px); }
  .modal-form { padding-left: 17px; padding-right: 17px; }
  .calculation-preview { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .app-footer { flex-direction: column; padding-left: 16px; padding-right: 16px; }
}
