:root {
  color-scheme: light;
  font-family: "Avenir Next", "Segoe UI", system-ui, sans-serif;
  --paper: #f5f6f8;
  --card: #fff;
  --ink: #171d2d;
  --muted: #535d6e;
  --border: #dbe0e9;
  --nav: #181d2e;
  --accent: #aa301f;
  --accent-dark: #842415;
  --accent-light: #ff886d;
  --radius: 16px;
}

*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; background: var(--paper); color: var(--ink); line-height: 1.55; }
a { color: var(--accent); text-underline-offset: .16em; }
p { margin: 0 0 .9rem; }
button, input, textarea { font: inherit; }
button, [type="file"] { cursor: pointer; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid #3171b7; outline-offset: 3px; }
h1, h2 { line-height: 1.1; margin: 0; letter-spacing: -.035em; }
h1 { font-size: clamp(2.1rem, 5vw, 3.6rem); }
h2 { font-size: 1.35rem; }
fieldset { display: grid; gap: .85rem; border: 0; padding: 0; margin: 0; min-width: 0; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.logo { display: inline-block; font-size: 1.65rem; font-weight: 790; letter-spacing: -.095em; line-height: 1; }
.logo span { color: var(--accent-light); margin: 0 .025em; }
.brand { color: inherit; text-decoration: none; }
.card { padding: clamp(1.1rem, 3vw, 1.75rem); background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); }
.card > h2 { margin-bottom: 1.05rem; }
.muted-text, small { color: var(--muted); }
.mono { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: .88rem; }
.break { overflow-wrap: anywhere; }
.notice { padding: .7rem .9rem; border: 1px solid #d7e2dd; border-radius: 8px; background: #f0f7f3; color: #234e42; font-size: .94rem; }
.notice.error { background: #fff1ed; border-color: #efc8be; color: #842817; }
.empty { padding: 1.4rem 0 .35rem; color: var(--muted); }
.toast { position: fixed; z-index: 5; inset: auto 1.25rem 1.25rem auto; border-radius: 10px; background: var(--nav); color: #fff; padding: .75rem 1rem; box-shadow: 0 6px 30px #181d2e45; }
.button { align-items: center; background: transparent; border: 1px solid transparent; border-radius: 9px; color: inherit; display: inline-flex; font-size: .91rem; font-weight: 670; justify-content: center; min-height: 42px; padding: .57rem .84rem; text-decoration: none; }
.button.primary { background: var(--accent); color: #fff; }
.button.primary:hover { background: var(--accent-dark); }
.button.secondary { background: #fff; border-color: var(--border); }
.button.secondary:hover { background: #f0f2f6; }
.button.text-button:hover { background: #8882; }
.button.danger { color: var(--accent); }
.button:disabled { cursor: wait; opacity: .6; }
.buttons { display: flex; align-items: center; gap: .55rem; flex-wrap: wrap; }
.badge { border-radius: 999px; background: #eaf6ef; color: #215940; display: inline-block; font-size: .82rem; font-weight: 700; padding: .23rem .62rem; white-space: nowrap; }
.badge.muted { background: #eff1f5; color: #515b6d; }

.layout { display: grid; grid-template-columns: 213px minmax(0, 1fr); min-height: 100vh; }
.sidebar { display: flex; flex-direction: column; gap: 2.5rem; background: var(--nav); color: #fff; padding: 2.1rem 1.25rem; }
.sidebar .brand { padding-left: .65rem; }
.sidebar nav { display: grid; gap: .4rem; }
.sidebar nav a { color: #dbe0ed; font-weight: 600; text-decoration: none; border-radius: 9px; padding: .64rem .75rem; }
.sidebar nav a:hover, .sidebar nav a[aria-current="page"] { background: #30374c; color: #fff; }
.sidebar nav a[aria-current="page"] { box-shadow: inset 3px 0 var(--accent-light); }
.logout { margin-top: auto; }
.logout button { color: #dbe0ed; }
.main { padding: clamp(1rem, 4vw, 3.4rem); width: 100%; max-width: 1340px; }
.page-head { margin-bottom: 1.6rem; }
.page-head p { margin: .5rem 0 0; color: var(--muted); }
.stats, .tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; margin-bottom: 1rem; }
.stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.stat span { display: block; color: var(--muted); font-weight: 620; }
.stat strong { display: block; font-size: 2.5rem; line-height: 1.2; }
.action-tile { display: block; text-decoration: none; color: inherit; }
.action-tile:hover { border-color: #aa301f75; }
.action-tile p { color: var(--muted); margin-bottom: 1rem; }
.action-tile span { color: var(--accent); font-weight: 690; }
.split { display: grid; gap: 1rem; grid-template-columns: minmax(260px, .88fr) minmax(0, 1.4fr); align-items: start; }
.details { margin-bottom: 1rem; }
.detail-head { display: flex; justify-content: space-between; align-items: start; gap: .75rem; margin-bottom: 1rem; }
.detail-head h2 { margin-bottom: .45rem; }
.detail-head .mono { overflow-wrap: anywhere; }
.form-stack, .auth-form { display: grid; gap: .85rem; }
.form-stack .button { justify-self: start; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .7rem; align-items: end; }
label { display: grid; gap: .3rem; font-size: .91rem; font-weight: 650; }
label small { font-size: .84rem; font-weight: 500; }
input:not([type="hidden"]), textarea { display: block; border: 1px solid #cbd2de; border-radius: 8px; width: 100%; min-width: 0; padding: .62rem .7rem; min-height: 44px; color: var(--ink); background: #fff; }
input::placeholder, textarea::placeholder { color: #687184; }
textarea { resize: vertical; }
.field-prefix { display: flex; align-items: stretch; border: 1px solid #cbd2de; border-radius: 8px; }
.field-prefix span { display: grid; place-items: center; padding: 0 .7rem; background: #eef1f6; color: #394354; border-radius: 7px 0 0 7px; }
.field-prefix input { border: 0; border-radius: 0 7px 7px 0; }
.inline-action { margin-top: 1rem; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; text-align: left; }
th, td { border-bottom: 1px solid var(--border); padding: .68rem .55rem; vertical-align: middle; }
th { color: var(--muted); font-size: .82rem; font-weight: 700; }
tbody tr:last-child td { border-bottom: 0; }
td .muted-text { display: block; font-size: .83rem; }
.row-title { display: block; font-weight: 680; overflow-wrap: anywhere; }
td form { margin: 0; }
td button, td .button { white-space: nowrap; }
.activity { margin: 0; padding: 0; list-style: none; }
.activity li { padding: .44rem 0; border-bottom: 1px solid var(--border); }
.activity li:last-child { border-bottom: 0; }
.chart { display: grid; gap: .42rem; max-width: 540px; }
.chart-row { display: grid; align-items: center; grid-template-columns: 4.6rem 1fr 2rem; gap: .7rem; font-size: .9rem; }
meter { width: 100%; accent-color: var(--accent); }
meter::-webkit-meter-optimum-value { background: var(--accent); }
meter::-moz-meter-bar { background: var(--accent); }

.login-body { background: var(--nav); }
.login-layout { min-height: 100svh; display: grid; grid-template-columns: 1.1fr 1fr; }
.login-intro { display: flex; flex-direction: column; justify-content: center; padding: clamp(2rem, 7vw, 8rem); color: #fff; background: radial-gradient(ellipse at 92% 85%, #412837, transparent 61%), var(--nav); }
.login-intro .brand { margin-bottom: clamp(2rem, 7vh, 5rem); }
.login-intro h1 { font-size: clamp(3rem, 7vw, 6.9rem); max-width: 8ch; line-height: .98; letter-spacing: -.067em; }
.login-intro h1 span { color: var(--accent-light); }
.login-intro p { margin: 1.6rem 0 0; color: #e0e3ef; max-width: 29ch; font-size: 1.12rem; }
.login-panel { background: var(--paper); display: grid; place-items: center; padding: clamp(1.25rem, 6vw, 5rem); }
.auth-form { width: min(100%, 440px); gap: 1.12rem; padding: clamp(1.4rem, 4vw, 2.8rem); }
.auth-form h2 { font-size: 1.85rem; margin-bottom: .25rem; }
.auth-form button { margin-top: .3rem; }
.guest-shell { max-width: 670px; margin: 0 auto; padding: clamp(1.25rem, 6vw, 4rem); }
.guest-shell .brand { margin-bottom: 1.4rem; }
.guest-card h1 { font-size: clamp(1.9rem, 5vw, 3rem); margin-bottom: .75rem; }
.guest-card h2 { margin: 0 0 .65rem; overflow-wrap: anywhere; }
.request-note { white-space: pre-wrap; overflow-wrap: anywhere; }
.file-picker input { border-style: dashed; background: #f5f6fa; }
.file-picker input::file-selector-button { border: 1px solid var(--border); border-radius: 6px; background: #fff; padding: .35rem .65rem; margin-right: .55rem; color: var(--ink); }
progress { width: 100%; accent-color: var(--accent); }

@media (max-width: 1020px) {
  .split { grid-template-columns: 1fr; }
}
@media (max-width: 700px) {
  .layout, .login-layout { grid-template-columns: 1fr; }
  .sidebar { display: grid; gap: .8rem; grid-template-columns: 1fr auto; padding: .95rem 1rem; }
  .sidebar .brand { padding-left: 0; align-self: center; }
  .sidebar nav { display: flex; grid-column: 1 / -1; grid-row: 2; flex-wrap: wrap; }
  .sidebar nav a[aria-current="page"] { box-shadow: inset 0 -3px var(--accent-light); }
  .logout { grid-row: 1; grid-column: 2; }
  .login-intro { padding: 1.7rem 1.25rem 2rem; }
  .login-intro .brand { margin-bottom: 1.45rem; }
  .login-intro h1 { max-width: 14ch; }
  .login-intro p { margin-top: .85rem; }
  .login-panel { align-items: start; padding: 1rem; }
  .stats, .tiles { grid-template-columns: 1fr; }
  .detail-head { flex-direction: column; }
}
