:root {
  color: #202422;
  background: #f4f6f5;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
  letter-spacing: 0;
  --ink: #202422;
  --muted: #69716d;
  --line: #dfe4e1;
  --surface: #ffffff;
  --sidebar: #171a19;
  --green: #18794e;
  --green-dark: #0f5f3c;
  --green-soft: #e7f4ed;
  --amber: #a15c00;
  --amber-soft: #fff2da;
  --red: #b42318;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body { margin: 0; background: #f4f6f5; color: var(--ink); }
button, input, textarea, select { font: inherit; letter-spacing: 0; }
button { cursor: pointer; }
[hidden] { display: none !important; }

.login-shell { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: #eef1ef; }
.login-panel { width: min(100%, 420px); padding: 28px; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 16px 40px rgb(32 36 34 / 10%); }
.brand-lockup { display: flex; align-items: center; gap: 12px; }
.brand-lockup div { display: grid; gap: 1px; }
.brand-lockup strong { font-size: 14px; }
.brand-lockup span:not(.brand-mark) { color: var(--muted); font-size: 12px; }
.brand-mark { display: grid; place-items: center; width: 36px; height: 36px; flex: 0 0 36px; border-radius: 7px; background: #d5f0e0; color: #0f5f3c; font-size: 12px; font-weight: 800; }
.login-form { display: grid; gap: 12px; margin-top: 44px; }
.login-form h1 { margin: 0 0 6px; font-size: 25px; }
.login-form p { margin: 0; color: var(--muted); font-size: 13px; }
label { color: #3f4743; font-size: 13px; font-weight: 600; }
input, textarea, select { width: 100%; margin-top: 6px; border: 1px solid #cbd2ce; border-radius: 5px; background: #fff; color: var(--ink); outline: 0; }
input, select { height: 38px; padding: 0 11px; }
textarea { padding: 10px 11px; resize: vertical; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
input:focus, textarea:focus, select:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgb(24 121 78 / 12%); }

.button { min-height: 36px; padding: 0 13px; border: 1px solid #cbd2ce; border-radius: 5px; background: #fff; color: #303633; font-weight: 650; font-size: 13px; }
.button:hover { background: #f3f5f4; }
.button:disabled { cursor: not-allowed; opacity: .55; }
.button-primary { border-color: var(--green); background: var(--green); color: #fff; }
.button-primary:hover { background: var(--green-dark); }
.button-wide { width: 100%; margin-top: 6px; }
.button-quiet { border-color: #3b423f; background: transparent; color: #d9dfdc; }
.button-small { min-height: 30px; padding: 0 10px; font-size: 12px; }
.form-error { min-height: 18px; color: var(--red) !important; font-size: 12px !important; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 224px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; padding: 20px 14px 14px; background: var(--sidebar); color: #f5f7f6; }
.sidebar-brand { padding: 0 6px 22px; }
.sidebar-brand span:not(.brand-mark) { color: #aeb7b2; }
.nav-list { display: grid; gap: 3px; }
.nav-list button { height: 38px; padding: 0 11px; border: 0; border-radius: 5px; background: transparent; color: #c6ceca; text-align: left; font-size: 13px; font-weight: 600; }
.nav-list button:hover { background: #242927; color: #fff; }
.nav-list button.active { background: #d5f0e0; color: #124f34; }
.sidebar-footer { margin-top: auto; display: grid; gap: 10px; padding: 14px 6px 0; border-top: 1px solid #313633; }
.sidebar-footer span { color: #9da7a2; font-size: 12px; text-transform: uppercase; }

.workspace { min-width: 0; }
.topbar { min-height: 78px; display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 14px 28px; border-bottom: 1px solid var(--line); background: rgb(255 255 255 / 92%); }
.topbar h1 { margin: 2px 0 0; font-size: 20px; line-height: 1.2; }
.eyebrow { margin: 0; color: var(--muted); font-size: 11px; font-weight: 700; text-transform: uppercase; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.status-dot { display: inline-flex; align-items: center; gap: 7px; color: var(--muted); font-size: 12px; }
.status-dot i { width: 7px; height: 7px; border-radius: 50%; background: #23a566; box-shadow: 0 0 0 3px #e2f5eb; }
.content { width: 100%; max-width: 1440px; margin: 0 auto; padding: 24px 28px 48px; outline: 0; }
.section-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 14px; }
.section-head h2 { margin: 0; font-size: 16px; }
.section-head p { margin: 4px 0 0; color: var(--muted); font-size: 12px; }
.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.metric { min-height: 104px; display: grid; align-content: space-between; padding: 16px; border: 1px solid var(--line); border-radius: 7px; background: var(--surface); }
.metric span { color: var(--muted); font-size: 12px; font-weight: 650; }
.metric strong { font-size: 28px; line-height: 1; }
.metric-green { border-top: 3px solid var(--green); }
.metric-amber { border-top: 3px solid #d58b20; }
.status-band { display: grid; grid-template-columns: repeat(3, 1fr); margin-top: 18px; border: 1px solid var(--line); border-radius: 7px; background: var(--surface); }
.status-band div { padding: 15px 16px; border-right: 1px solid var(--line); }
.status-band div:last-child { border-right: 0; }
.status-band span { display: block; color: var(--muted); font-size: 11px; }
.status-band strong { display: block; margin-top: 5px; font-size: 13px; }

.toolbar { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px; margin-bottom: 14px; }
.toolbar label { min-width: 160px; }
.toolbar .grow { flex: 1 1 240px; }
.segmented { display: inline-flex; height: 36px; padding: 3px; border: 1px solid #cbd2ce; border-radius: 5px; background: #fff; }
.segmented button { padding: 0 13px; border: 0; border-radius: 3px; background: transparent; color: var(--muted); font-size: 12px; font-weight: 700; }
.segmented button.active { background: #e6ebe8; color: var(--ink); }

.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 7px; background: var(--surface); }
table { width: 100%; border-collapse: collapse; font-size: 12px; }
th, td { min-width: 90px; padding: 11px 12px; border-bottom: 1px solid #e8ecea; text-align: left; vertical-align: middle; }
th { color: #59615d; background: #f7f9f8; font-size: 11px; font-weight: 750; white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: #fbfcfb; }
td strong { font-size: 12px; }
.cell-muted { color: var(--muted); }
.cell-code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 11px; }
.cell-wide { min-width: 220px; max-width: 380px; white-space: normal; overflow-wrap: anywhere; }
.pill { display: inline-flex; align-items: center; min-height: 22px; padding: 0 7px; border-radius: 999px; background: #edf0ee; color: #515955; font-size: 11px; font-weight: 700; }
.pill-green { background: var(--green-soft); color: var(--green-dark); }
.pill-amber { background: var(--amber-soft); color: var(--amber); }
.empty-state, .loading-state, .error-state { padding: 56px 20px; border: 1px solid var(--line); border-radius: 7px; background: #fff; text-align: center; }
.empty-state strong, .error-state strong { display: block; font-size: 14px; }
.empty-state p, .error-state p { margin: 6px 0 0; color: var(--muted); font-size: 12px; }
.loading-state { color: var(--muted); font-size: 13px; }
.pagination { display: flex; align-items: center; justify-content: flex-end; gap: 8px; margin-top: 12px; }
.pagination span { color: var(--muted); font-size: 12px; }

.modal { width: min(680px, calc(100vw - 32px)); padding: 0; border: 0; border-radius: 8px; color: var(--ink); box-shadow: 0 24px 80px rgb(0 0 0 / 24%); }
.modal::backdrop { background: rgb(12 15 13 / 55%); }
.modal form { padding: 22px; }
.modal-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 20px; }
.modal-header h2 { margin: 3px 0 0; font-size: 18px; }
.close-button { width: 32px; height: 32px; border: 0; border-radius: 4px; background: #f1f3f2; color: #59615d; font-size: 23px; line-height: 1; }
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }
.form-span { grid-column: 1 / -1; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; padding-top: 10px; }
.toast { position: fixed; right: 22px; bottom: 22px; z-index: 20; max-width: min(380px, calc(100vw - 44px)); padding: 11px 14px; border-radius: 5px; background: #202422; color: #fff; font-size: 12px; opacity: 0; transform: translateY(8px); pointer-events: none; transition: .18s ease; }
.toast.visible { opacity: 1; transform: translateY(0); }
.toast.error { background: #8f2018; }

@media (max-width: 980px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: relative; width: 100%; min-width: 0; height: auto; overflow: hidden; padding: 12px 14px 0; }
  .sidebar-brand { display: none; }
  .nav-list { display: flex; width: calc(100% - 92px); min-width: 0; overflow-x: auto; padding-bottom: 10px; scrollbar-width: none; }
  .nav-list::-webkit-scrollbar { display: none; }
  .nav-list button { flex: 0 0 auto; padding: 0 14px; }
  .sidebar-footer { position: absolute; top: 12px; right: 14px; width: auto; margin: 0; padding: 0; border: 0; display: flex; align-items: center; }
  .sidebar-footer span { display: none; }
  .sidebar-footer .button { min-height: 32px; }
  .topbar { padding: 14px 20px; }
  .content { padding: 20px 20px 40px; }
  .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 620px) {
  .login-shell { padding: 0; background: #fff; }
  .login-panel { min-height: 100vh; display: flex; flex-direction: column; justify-content: center; border: 0; border-radius: 0; box-shadow: none; }
  .topbar { align-items: flex-start; }
  .status-dot { display: none; }
  .content { padding: 18px 14px 36px; }
  .metric-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
  .metric { min-height: 92px; padding: 13px; }
  .metric strong { font-size: 23px; }
  .status-band { grid-template-columns: 1fr; }
  .status-band div { border-right: 0; border-bottom: 1px solid var(--line); }
  .status-band div:last-child { border-bottom: 0; }
  .toolbar { align-items: stretch; }
  .toolbar label, .toolbar .grow { flex: 1 1 100%; }
  .toolbar .button { flex: 1; }
  .form-grid { grid-template-columns: 1fr; }
  .form-span { grid-column: auto; }
}
