:root {
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #19312e;
  background: #f3f7f5;
  font-synthesis: none;
  --brand: #173b35;
  --accent: #d8f36a;
  --surface: #ffffff;
  --surface-soft: #e9f1ee;
  --border: #c9d8d3;
  --muted: #5f716d;
  --danger: #a62f2f;
  --focus: #146cba;
}

* { box-sizing: border-box; }
html { min-width: 320px; background: #f3f7f5; }
body { margin: 0; min-height: 100vh; overflow-x: hidden; }
button, input, select, textarea { font: inherit; }
button, input, select { min-height: 48px; }
button { border: 1px solid var(--border); border-radius: 12px; padding: 0.7rem 1rem; background: var(--surface); color: var(--brand); font-weight: 700; cursor: pointer; }
button:hover { border-color: var(--brand); }
button:disabled { cursor: not-allowed; opacity: 0.55; }
button.primary { background: var(--brand); color: white; border-color: var(--brand); }
button.secondary { background: transparent; color: inherit; border-color: currentColor; }
button.danger { background: var(--danger); color: white; border-color: var(--danger); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.skip-link { position: fixed; left: 1rem; top: -5rem; z-index: 100; padding: 0.75rem; background: white; color: var(--brand); }
.skip-link:focus { top: 1rem; }
[hidden] { display: none !important; }
.auth-layout { min-height: 100vh; display: grid; align-content: center; gap: 1rem; padding: max(1rem, env(safe-area-inset-top)) 1rem max(1rem, env(safe-area-inset-bottom)); }
.brand-panel, .auth-card, .panel, .record-card { border: 1px solid var(--border); border-radius: 20px; background: var(--surface); box-shadow: 0 8px 24px rgba(23, 59, 53, 0.06); }
.brand-panel { padding: 1.5rem; background: var(--brand); color: white; }
.brand-panel h1 { margin: 0.25rem 0 0.75rem; font-size: clamp(1.7rem, 8vw, 3rem); }
.eyebrow { margin: 0; letter-spacing: 0.12em; font-size: 0.72rem; font-weight: 800; }
.auth-card { padding: 1rem; }
.tab-list { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.35rem; margin-bottom: 1rem; }
.tab { min-width: 0; padding-inline: 0.35rem; }
.tab.is-active { background: var(--surface-soft); border-color: var(--brand); }
.stack { display: grid; gap: 0.9rem; }
.stack.compact { padding-block: 0.5rem; }
label { display: grid; gap: 0.35rem; color: var(--brand); font-weight: 650; }
input, select, textarea { width: 100%; border: 1px solid var(--border); border-radius: 10px; padding: 0.7rem; color: #142824; background: white; }
textarea { min-height: 96px; resize: vertical; }
.hint, .muted { color: var(--muted); }
.status { min-height: 1.5rem; margin-bottom: 0; }
.status[data-kind="error"], .status-panel[data-kind="error"] { color: #8b2020; background: #fff0f0; border-color: #dfadad; }
.status[data-kind="success"], .status-panel[data-kind="success"] { color: #175b35; background: #e8f8ee; border-color: #9fcfb1; }
.app-layout { min-height: 100vh; }
.app-header { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: max(1rem, env(safe-area-inset-top)) 1rem 1rem; background: var(--brand); color: white; }
.app-header h1 { margin: 0.25rem 0; font-size: 1.25rem; overflow-wrap: anywhere; }
.app-header .muted { color: #d2e2dd; }
.primary-nav { position: sticky; top: 0; z-index: 10; display: flex; flex-wrap: wrap; gap: 0.35rem; padding: 0.65rem 1rem; background: #eaf1ef; border-bottom: 1px solid var(--border); }
.primary-nav button { flex: 1 1 92px; min-height: 44px; padding: 0.45rem; font-size: 0.84rem; }
.primary-nav button[aria-current="page"] { background: var(--brand); color: white; border-color: var(--brand); }
#main-content { max-width: 1180px; margin: 0 auto; padding: 1rem 1rem calc(2rem + env(safe-area-inset-bottom)); }
#main-content:focus { outline: none; }
.status-panel { min-height: 0; margin-bottom: 1rem; border: 1px solid transparent; border-radius: 12px; padding: 0; }
.status-panel:not(:empty) { padding: 0.75rem; }
.page-header { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 0.75rem; align-items: center; margin-bottom: 1rem; }
.page-header h2 { margin: 0; }
.grid { display: grid; gap: 1rem; }
.panel { padding: 1rem; min-width: 0; }
.panel h3, .record-card h3 { margin-top: 0; }
.record-list { display: grid; gap: 0.75rem; padding: 0; list-style: none; }
.record-card { padding: 1rem; overflow-wrap: anywhere; }
.record-card p { margin: 0.3rem 0; }
.record-card.is-archived { opacity: 0.72; background: #f2f2f2; }
.button-row { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.button-row > * { flex: 1 1 130px; }
.metric-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.75rem; }
.metric { border-radius: 16px; padding: 1rem; background: var(--surface-soft); }
.metric strong { display: block; margin-top: 0.3rem; font-size: 1.35rem; }
.badge { display: inline-block; border-radius: 999px; padding: 0.25rem 0.6rem; background: var(--surface-soft); font-size: 0.78rem; font-weight: 750; }
.badge.closed { background: #dceadf; color: #205833; }
.empty-state { border: 1px dashed var(--border); border-radius: 16px; padding: 1.25rem; color: var(--muted); text-align: center; }
.danger-zone { border-color: #dfadad; }
.service-card { border-left: 5px solid var(--brand); }
dialog { width: min(92vw, 460px); border: 1px solid var(--border); border-radius: 18px; padding: 1.25rem; color: #19312e; }
dialog::backdrop { background: rgba(10, 25, 22, 0.55); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

@media (min-width: 700px) {
  .auth-layout { grid-template-columns: minmax(280px, 0.8fr) minmax(360px, 1fr); max-width: 980px; margin: auto; }
  .brand-panel, .auth-card { padding: 2rem; }
  .grid.two { grid-template-columns: minmax(280px, 0.75fr) minmax(0, 1.25fr); align-items: start; }
  .metric-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .primary-nav button { flex: 0 1 auto; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; animation: none !important; }
}
