:root {
  color-scheme: light;
  --ink: #202b30;
  --muted: #69777b;
  --line: #dce3e3;
  --paper: #ffffff;
  --canvas: #f1f4f3;
  --sidebar: #1e2b2e;
  --sidebar-muted: #a9b8b8;
  --teal: #087e73;
  --teal-dark: #06675f;
  --green-soft: #e4f1ed;
  --red-soft: #fae9e7;
  font-family: Arial, Helvetica, sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; color: var(--ink); background: var(--canvas); font-size: 14px; }
a { color: inherit; }
button, input { font: inherit; }
.admin-page { min-height: 100vh; }
.sidebar { position: fixed; inset: 0 auto 0 0; width: 242px; display: flex; flex-direction: column; overflow: hidden; padding: 26px 16px 18px; color: #fff; background: var(--sidebar); }
.brand { display: block; padding: 0 12px 26px; color: #fff; text-decoration: none; border-bottom: 1px solid #394649; }
.brand strong, .brand span { display: block; }
.brand strong { font-size: 15px; letter-spacing: .5px; }
.brand span { margin-top: 7px; color: #b0c3bf; font-size: 10px; }
.sidebar nav { min-height: 0; flex: 1 1 auto; overflow-y: auto; overscroll-behavior: contain; padding-top: 18px; scrollbar-width: thin; scrollbar-color: #526263 transparent; }
.nav-caption { padding: 17px 12px 7px; color: var(--sidebar-muted); font-size: 10px; font-weight: 700; }
.nav-link { display: block; margin: 2px 0; padding: 10px 12px; color: #e2e9e8; text-decoration: none; border-left: 3px solid transparent; }
.nav-link:hover, .nav-link.active { color: #fff; background: #2c3d3f; border-left-color: #57b3a0; }
.sidebar-foot { margin-top: auto; padding: 16px 12px 0; color: var(--sidebar-muted); border-top: 1px solid #394649; font-size: 11px; line-height: 1.7; }
.main-area { min-height: 100vh; margin-left: 242px; }
.topbar { min-height: 92px; display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 18px 34px; background: var(--paper); border-bottom: 1px solid var(--line); }
.breadcrumb { color: var(--muted); font-size: 11px; }
.topbar h1 { margin: 5px 0 0; font-size: 23px; font-weight: 600; }
.account { display: flex; align-items: center; gap: 22px; }
.account strong, .account span { display: block; }
.account strong { font-size: 13px; }
.account span { margin-top: 4px; color: var(--muted); font-size: 11px; }
.content { max-width: 1500px; margin: 0 auto; padding: 28px 34px 40px; }
.metric-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 14px; }
.metric { min-height: 112px; padding: 18px; background: var(--paper); border: 1px solid var(--line); }
.metric-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.metric-top svg { width: 18px; height: 18px; color: var(--teal); stroke-width: 1.7; }
.metric-label { color: var(--muted); font-size: 12px; }
.metric-value { display: block; margin-top: 15px; font-size: 22px; font-weight: 600; }
.section-grid { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(280px, .9fr); gap: 16px; margin-top: 20px; }
.dashboard-charts { display: grid; grid-template-columns: minmax(0, 1.65fr) minmax(280px, .85fr); gap: 16px; margin-top: 20px; }
.chart-panel { min-width: 0; }
.chart-heading { align-items: center; }
.chart-note { margin: 5px 0 0; color: var(--muted); font-size: 11px; }
.chart-canvas { position: relative; height: 300px; padding: 12px 16px 18px; }
.status-chart-wrap { position: relative; width: min(100%, 330px); height: 300px; margin: 0 auto; padding: 10px; }
.segmented { display: inline-flex; flex: 0 0 auto; border: 1px solid var(--line); background: #f6f8f7; }
.segmented button { min-height: 32px; padding: 6px 9px; color: #415052; background: transparent; border: 0; cursor: pointer; font-size: 11px; }
.segmented button + button { border-left: 1px solid var(--line); }
.segmented button[aria-pressed="true"] { color: #fff; background: var(--teal); }
.section-panel { min-width: 0; background: var(--paper); border: 1px solid var(--line); }
.panel-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 17px 18px; border-bottom: 1px solid var(--line); }
.panel-heading h2 { margin: 0; font-size: 15px; font-weight: 600; }
.text-link { color: var(--teal-dark); font-size: 12px; text-decoration: none; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; white-space: nowrap; }
th, td { padding: 12px 16px; text-align: left; border-bottom: 1px solid #e9eeee; }
th { color: var(--muted); background: #f8faf9; font-size: 10px; font-weight: 700; text-transform: uppercase; }
td { font-size: 12px; }
tbody tr:last-child td { border-bottom: 0; }
.status { display: inline-block; padding: 4px 7px; color: #42514f; background: #edf1ef; font-size: 10px; }
.status.paid { color: #176b56; background: var(--green-soft); }
.empty-state { padding: 22px 18px; color: var(--muted); font-size: 12px; }
.quick-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 10px; margin-top: 20px; }
.quick-link { min-height: 58px; display: flex; align-items: center; gap: 10px; padding: 12px 14px; color: var(--ink); background: var(--paper); border: 1px solid var(--line); text-decoration: none; font-weight: 600; }
.quick-link svg { width: 17px; height: 17px; flex: 0 0 auto; color: var(--teal); stroke-width: 1.7; }
.quick-link span { min-width: 0; }
.quick-link:hover { border-color: var(--teal); color: var(--teal-dark); }
.quick-link.disabled { color: #879194; background: #f7f8f8; cursor: not-allowed; }
.button { min-height: 36px; padding: 8px 12px; border: 1px solid var(--line); background: #fff; color: var(--ink); cursor: pointer; }
.button.primary { color: #fff; background: var(--teal); border-color: var(--teal); }
.button.primary:hover { background: var(--teal-dark); }
.button.quiet { min-height: 32px; padding: 6px 10px; color: var(--ink); font-size: 12px; }
.button.wide { width: 100%; margin-top: 8px; }
.login-page { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: #edf1ef; }
.login-panel { width: min(100%, 420px); padding: 34px; background: var(--paper); border: 1px solid var(--line); }
.login-brand { color: var(--teal-dark); font-size: 13px; font-weight: 700; }
.login-brand span { display: block; margin-top: 5px; color: var(--muted); font-size: 10px; font-weight: 400; }
.login-panel h1 { margin: 30px 0 6px; font-size: 24px; font-weight: 600; }
.muted { color: var(--muted); }
.login-panel form { margin-top: 26px; }
.login-panel label { display: block; margin: 16px 0 7px; font-size: 12px; font-weight: 600; }
.login-panel input { width: 100%; height: 42px; padding: 9px 11px; border: 1px solid #cbd5d4; background: #fff; }
.login-panel input:focus { outline: 2px solid #9accc2; border-color: var(--teal); }
.notice { margin: 18px 0; padding: 12px; line-height: 1.5; }
.notice.error { color: #7e2d27; background: var(--red-soft); border-left: 3px solid #b8584f; }
.back-link { display: inline-block; margin-top: 22px; color: var(--muted); font-size: 12px; text-decoration: none; }
.module-toolbar { display: flex; align-items: end; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.module-toolbar h2 { margin: 0; font-size: 17px; font-weight: 600; }
.module-actions, .filter-row { display: flex; align-items: end; flex-wrap: wrap; gap: 9px; }
.module-panel { padding: 20px; background: var(--paper); border: 1px solid var(--line); }
.module-form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.module-form .full { grid-column: 1 / -1; }
.module-form label, .filter-row label { display: block; margin-bottom: 6px; color: #354246; font-size: 12px; font-weight: 600; }
.module-form input, .module-form select, .module-form textarea, .filter-row input, .filter-row select { width: 100%; min-height: 38px; padding: 8px 10px; border: 1px solid #cbd5d4; background: #fff; color: var(--ink); }
.module-form textarea { min-height: 82px; resize: vertical; }
.field-check { display: flex; align-items: center; gap: 8px; min-height: 38px; }
.field-check input { width: 16px; min-height: 16px; }
.table-panel { margin-top: 18px; background: var(--paper); border: 1px solid var(--line); }
.table-panel table { min-width: 680px; }
.row-actions { display: flex; gap: 10px; }
.row-actions a, .row-actions button { padding: 0; color: var(--teal-dark); background: transparent; border: 0; text-decoration: underline; cursor: pointer; font-size: 12px; }
.row-actions .danger { color: #9b3c36; }
.pagination { display: flex; align-items: center; justify-content: space-between; padding: 13px 16px; color: var(--muted); border-top: 1px solid var(--line); font-size: 12px; }
.pagination a { color: var(--teal-dark); text-decoration: none; }
.filter-row > div { min-width: 170px; }
.notice.success { color: #176b56; background: var(--green-soft); border-left: 3px solid var(--teal); }
.notice.warning { color: #735b2e; background: #f7f1e4; border-left: 3px solid #b69a5e; }
.detail-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; margin: 16px; }
.detail-grid h3 { margin: 0 0 10px; font-size: 13px; }
.inline-form { display: inline-flex; gap: 6px; align-items: center; }
.inline-form select { min-height: 30px; padding: 4px 6px; border: 1px solid var(--line); background: #fff; font-size: 11px; }
.inline-form button { padding: 6px 8px; color: #fff; background: var(--teal); border: 0; cursor: pointer; font-size: 11px; }
.sidebar-toggle { display: none; }
.invoice-entry .grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.invoice-entry .full { grid-column: 1 / -1; }
.invoice-entry label { display: block; margin: 0 0 6px; color: #354246; font-size: 12px; font-weight: 600; }
.invoice-entry input, .invoice-entry select, .invoice-entry textarea { width: 100%; min-height: 38px; padding: 8px 10px; border: 1px solid #cbd5d4; background: #fff; color: var(--ink); }
.invoice-entry textarea { min-height: 68px; resize: vertical; }
.invoice-entry .items { overflow-x: auto; margin-top: 20px; }
.invoice-entry .items table { min-width: 850px; }
.invoice-entry .items th { color: #fff; background: var(--sidebar); }
.invoice-entry .items td input, .invoice-entry .items td textarea { min-width: 90px; }
.invoice-entry .summary { margin: 16px 0; text-align: right; font-size: 15px; font-weight: 600; }
.invoice-entry .error { margin: 16px 0; padding: 12px; color: #7e2d27; background: var(--red-soft); border-left: 3px solid #b8584f; }
.invoice-entry .hint { margin: 0; color: var(--muted); font-size: 12px; }
.invoice-entry .actions { display: flex; gap: 8px; }
.invoice-entry .add { color: var(--teal-dark); background: var(--green-soft); }
.invoice-entry .words { color: var(--teal-dark); font-weight: 600; }
.invoice-entry .remove { padding: 7px 9px; color: #8b3934; background: #f8eae8; border: 1px solid #ead2cf; cursor: pointer; }

@media (max-width: 1100px) {
  .sidebar { position: relative; inset: auto; width: auto; overflow: visible; padding: 14px 16px; }
  .brand { padding: 0 4px 12px; border: 0; }
  .sidebar-toggle { display: inline-flex; align-items: center; gap: 8px; min-height: 36px; padding: 7px 9px; color: #fff; background: #2c3d3f; border: 1px solid #526263; cursor: pointer; font-size: 12px; }
  .sidebar-toggle svg { width: 16px; height: 16px; stroke-width: 1.8; }
  .sidebar nav { display: none; max-height: min(62vh, 520px); flex: 0 1 auto; flex-direction: column; align-items: stretch; gap: 1px; overflow-y: auto; padding-top: 8px; }
  .sidebar.open nav { display: flex; }
  .nav-caption, .sidebar-foot { display: none; }
  .nav-link { padding: 9px 10px; font-size: 12px; }
  .main-area { margin-left: 0; }
  .metric-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .quick-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .dashboard-charts { grid-template-columns: 1fr; }
  .chart-heading { align-items: flex-start; flex-direction: column; }
}
@media (max-width: 760px) {
  .sidebar { position: relative; width: auto; padding: 14px 16px; }
  .brand { padding: 0 4px 12px; border: 0; }
  .sidebar-toggle { display: inline-flex; align-items: center; gap: 8px; min-height: 36px; padding: 7px 9px; color: #fff; background: #2c3d3f; border: 1px solid #526263; cursor: pointer; font-size: 12px; }
  .sidebar-toggle svg { width: 16px; height: 16px; stroke-width: 1.8; }
  .sidebar nav { display: none; flex-direction: column; align-items: stretch; gap: 1px; padding-top: 8px; }
  .sidebar.open nav { display: flex; }
  .nav-caption, .sidebar-foot { display: none; }
  .nav-link { padding: 9px 10px; font-size: 12px; }
  .main-area { margin-left: 0; }
  .topbar { align-items: flex-start; padding: 16px 18px; }
  .account { gap: 10px; }
  .account strong { max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .content { padding: 18px; }
  .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .section-grid { grid-template-columns: 1fr; }
  .dashboard-charts { grid-template-columns: 1fr; }
  .chart-heading { flex-direction: row; flex-wrap: wrap; }
  .chart-canvas { height: 260px; padding: 8px 10px 14px; }
  .status-chart-wrap { height: 270px; }
  .quick-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .module-toolbar { align-items: flex-start; flex-direction: column; }
  .detail-grid { grid-template-columns: 1fr; }
}
@media (max-width: 420px) {
  .topbar { flex-wrap: wrap; }
  .topbar > div:first-child { width: 100%; }
  .topbar h1 { font-size: 19px; }
  .account { display: flex; width: 100%; align-items: center; justify-content: space-between; text-align: left; }
  .account strong { max-width: none; overflow: visible; white-space: normal; }
  .account form { margin: 0; }
  .metric { padding: 14px; }
  .metric-value { font-size: 18px; }
  .login-panel { padding: 25px; }
  .module-form { grid-template-columns: 1fr; }
  .module-form .full { grid-column: auto; }
  .invoice-entry .grid { grid-template-columns: 1fr; }
  .invoice-entry .full { grid-column: auto; }
  .content { padding: 14px 12px 28px; }
  .metric-grid { grid-template-columns: 1fr; }
  .metric { min-height: 88px; }
  .metric-value { margin-top: 10px; }
  .chart-heading { align-items: flex-start; flex-direction: column; }
  .segmented { width: 100%; }
  .segmented button { flex: 1; }
  .quick-grid { grid-template-columns: 1fr; }
}