:root {
  --ink: #17211e;
  --muted: #4d5b55;
  --spruce: #14312b;
  --spruce-deep: #0d2420;
  --spruce-mid: #1d453c;
  --brass: #a6843d;
  --brass-soft: #e6c98a;
  --paper: #f3efe7;
  --paper-deep: #e7e1d6;
  --card: #fffcf8;
  --line: #e0d8cc;
  --line-strong: #cfc4b4;
  --danger: #8f2a22;
  --ok: #145c38;
  --shadow: 0 16px 40px rgba(20, 32, 28, 0.06);
  --sans: Inter, "Segoe UI", "Liberation Sans", sans-serif;
  --serif: "Source Serif 4", "Liberation Serif", Georgia, serif;
  --radius: 16px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: var(--paper);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.5;
}
h1, h2, h3, .brand-name { font-family: var(--serif); font-weight: 600; letter-spacing: -0.02em; }
h1 { font-size: 2rem; line-height: 1.15; margin: 0; }
h2 { font-size: 1.25rem; margin: 0 0 8px; }
p { margin: 0; }
a { color: #17483d; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--brass); outline-offset: 2px; }
.skip {
  position: absolute;
  left: 12px;
  top: -40px;
  background: white;
  padding: 8px 12px;
  z-index: 5;
}
.skip:focus { top: 12px; }

.nav-toggle {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.shell {
  display: grid;
  grid-template-columns: 252px minmax(0, 1fr);
  min-height: 100vh;
}
.side {
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  background:
    radial-gradient(1200px 400px at -10% -10%, rgba(230, 201, 138, 0.16), transparent 50%),
    var(--spruce-deep);
  color: #f6f1e8;
}
.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 22px 18px 14px;
  color: inherit;
  text-decoration: none;
}
.brand-mark {
  width: 40px;
  height: 40px;
  flex: 0 0 auto;
  color: var(--brass-soft);
}
.brand-name { display: block; font-size: 1.35rem; line-height: 1; color: white; }
.brand-sub { display: block; margin-top: 4px; color: rgba(246, 241, 232, 0.72); font-size: 0.78rem; font-family: var(--sans); letter-spacing: 0; font-weight: 500; }
.side-nav { display: flex; flex-direction: column; gap: 4px; padding: 8px 12px; }
.nav-link {
  display: flex;
  align-items: center;
  min-height: 40px;
  padding: 8px 12px;
  border-radius: 10px;
  color: rgba(246, 241, 232, 0.88);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.95rem;
}
.nav-link:hover { background: rgba(255, 255, 255, 0.06); color: white; }
.nav-link.is-active { background: rgba(230, 201, 138, 0.16); color: white; box-shadow: inset 3px 0 0 var(--brass-soft); }
.side-label {
  margin: 14px 12px 4px;
  padding: 0 12px;
  color: rgba(246, 241, 232, 0.5);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.side-user {
  margin-top: auto;
  padding: 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}
.who { display: flex; gap: 10px; align-items: center; margin-bottom: 12px; }
.avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: rgba(230, 201, 138, 0.18);
  color: var(--brass-soft);
  font-weight: 700;
  font-size: 0.8rem;
}
.who strong { display: block; font-size: 0.92rem; }
.who span { display: block; color: rgba(246, 241, 232, 0.65); font-size: 0.75rem; overflow-wrap: anywhere; }
.logout {
  width: 100%;
  min-height: 36px;
  border-radius: 9px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: transparent;
  color: white;
  cursor: pointer;
}
.logout:hover { background: rgba(255, 255, 255, 0.06); }
.side-foot {
  padding: 0 16px 16px;
  color: rgba(246, 241, 232, 0.45);
  font-size: 0.75rem;
}

.workspace { min-width: 0; }
.mobile-bar { display: none; }
.page { max-width: 1180px; margin: 0 auto; padding: 28px 32px 72px; }

.page-head, .detail-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  margin-bottom: 18px;
}
.lede { margin-top: 6px; color: var(--muted); max-width: 62ch; }
.eyebrow {
  margin: 0 0 6px;
  color: var(--brass);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.back { color: var(--muted); text-decoration: none; font-size: 0.92rem; font-weight: 600; }
.back:hover { color: var(--spruce); }

.button, button.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  padding: 0 16px;
  border-radius: 11px;
  border: 1px solid transparent;
  background: var(--spruce);
  color: white;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
}
.button:hover { background: var(--spruce-mid); }
.button.secondary { background: white; color: var(--ink); border-color: var(--line-strong); }
.button.secondary:hover { background: #f7f4ee; }
.button.small { min-height: 36px; padding: 0 12px; font-size: 0.92rem; }

.flash, .notice, .form-errors {
  border-radius: 12px;
  padding: 12px 14px;
  margin-bottom: 16px;
}
.flash-success { background: #e5f4ec; color: var(--ok); }
.flash-warning, .notice { background: #fff4df; color: #7a4b05; }
.flash-error, .form-errors { background: #fde8e4; color: var(--danger); }
.form-errors ul { margin: 6px 0 0; padding-left: 18px; }

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(132px, 1fr));
  gap: 10px;
  margin-bottom: 18px;
}
.stat {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-height: 78px;
  padding: 10px 12px 12px;
  border-radius: 14px;
  background: var(--card);
  border: 1px solid var(--line);
  border-top: 3px solid var(--c, var(--spruce));
  text-decoration: none;
  color: inherit;
  box-shadow: var(--shadow);
}
.stat:hover { border-color: var(--line-strong); }
.stat.is-active { box-shadow: 0 0 0 2px var(--spruce); }
.stat-count {
  font-family: var(--serif);
  font-size: 1.7rem;
  line-height: 1;
  color: var(--c, var(--spruce));
  font-variant-numeric: tabular-nums;
}
.stat-label { color: var(--muted); font-size: 0.82rem; font-weight: 600; }

.filters {
  display: grid;
  grid-template-columns: minmax(220px, 1.4fr) minmax(160px, 0.8fr) minmax(180px, 0.9fr) auto;
  gap: 10px;
  align-items: end;
  margin-bottom: 14px;
  padding: 14px;
  background: rgba(255, 252, 248, 0.7);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field.span-2 { grid-column: span 2; }
label, .label { font-size: 0.86rem; font-weight: 600; }
code { font-family: ui-monospace, "Cascadia Mono", monospace; font-size: 0.92em; }
.req { color: var(--danger); }
.hint { color: var(--muted); font-size: 0.82rem; }
input:not([type]),
input[type="text"], input[type="email"], input[type="password"], input[type="url"], input[type="date"], input[type="number"], input[type="search"],
select, textarea {
  width: 100%;
  min-height: 42px;
  padding: 8px 11px;
  border-radius: 10px;
  border: 1px solid var(--line-strong);
  background: white;
}
textarea { min-height: 110px; resize: vertical; line-height: 1.45; }
input:focus, select:focus, textarea:focus { border-color: var(--spruce); outline: 3px solid rgba(166, 132, 61, 0.35); outline-offset: 0; }
.check { display: flex; gap: 8px; align-items: center; font-weight: 600; }
.check input { width: 18px; height: 18px; }
.filter-actions { display: flex; gap: 8px; align-items: center; }
.results-bar { display: flex; justify-content: space-between; gap: 12px; align-items: baseline; margin: 4px 2px 8px; color: var(--muted); font-size: 0.92rem; }
.filter-summary { color: var(--ink); }

.table-wrap {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: auto;
}
table { width: 100%; border-collapse: collapse; }
.requests { min-width: 920px; }
th {
  text-align: left;
  font-size: 0.75rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 700;
  padding: 12px 14px;
  background: #f7f3ec;
  border-bottom: 1px solid var(--line);
}
td { padding: 13px 14px; border-top: 1px solid var(--line); vertical-align: middle; }
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: #fbf8f3; }
.client-name { font-weight: 700; }
.subject-cell { color: var(--muted); max-width: 280px; }
.email-cell { max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 0.92rem; }
.num, .request-number { font-variant-numeric: tabular-nums; white-space: nowrap; }
.request-number { color: var(--spruce); font-weight: 700; text-decoration: none; }
.request-number:hover { text-decoration: underline; }
.muted { color: var(--muted); }
.empty {
  padding: 42px 24px;
  text-align: center;
  background: var(--card);
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
}
.empty h2 { margin-bottom: 6px; }
.empty p { color: var(--muted); margin-bottom: 16px; }

.badge {
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  padding: 3px 9px;
  border-radius: 999px;
  background: #e7e2d8;
  color: var(--ink);
  background: color-mix(in srgb, var(--c, #6b7280) 16%, white);
  color: color-mix(in srgb, var(--c, #6b7280) 78%, #14110d);
  border: 1px solid color-mix(in srgb, var(--c, #6b7280) 34%, white);
  font-size: 0.78rem;
  font-weight: 700;
  line-height: 1.3;
  white-space: nowrap;
}

.drive-banner {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: center;
  margin-bottom: 18px;
  padding: 18px 18px;
  border-radius: var(--radius);
  background:
    linear-gradient(180deg, rgba(166, 132, 61, 0.14), rgba(166, 132, 61, 0.04)),
    var(--card);
  border: 1px solid #e4d3ae;
  box-shadow: var(--shadow);
}
.drive-banner.is-empty { background: var(--card); border-style: dashed; }
.drive-kicker { color: var(--brass); font-size: 0.78rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; }
.drive-banner h2 { margin-top: 2px; }
.drive-copy { color: var(--muted); margin: 4px 0 8px; max-width: 62ch; }
.drive-banner > div,
.drive-actions { min-width: 0; max-width: 100%; }
.drive-url {
  display: block;
  max-width: 100%;
  color: var(--muted);
  font-size: 0.85rem;
  overflow-wrap: anywhere;
}
.drive-actions { display: flex; flex-direction: column; gap: 8px; width: min(100%, 320px); }
.drive-actions input { background: white; }
.inline-actions { display: flex; flex-wrap: wrap; gap: 8px; }

.detail-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 18px;
  align-items: start;
}
.stack { display: flex; flex-direction: column; gap: 16px; }
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 16px 18px;
  box-shadow: var(--shadow);
}
.card h2 { font-family: var(--sans); font-size: 1rem; letter-spacing: 0; }
.prose { white-space: pre-wrap; overflow-wrap: anywhere; }
.meta { display: flex; flex-wrap: wrap; gap: 8px 14px; margin-top: 10px; color: var(--muted); font-size: 0.92rem; }
.client-line { margin-top: 8px; font-size: 1.05rem; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-actions { display: flex; justify-content: flex-end; margin-top: 14px; }
.history { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.history-item { padding-bottom: 12px; border-bottom: 1px solid var(--line); }
.history-item:last-child { border-bottom: 0; padding-bottom: 0; }
.history-meta { color: var(--muted); font-size: 0.85rem; margin-bottom: 6px; }
.history-change { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.history-note {
  margin-top: 8px;
  padding-left: 10px;
  border-left: 3px solid var(--paper-deep);
  color: var(--ink);
}
.source-mail { display: flex; flex-direction: column; gap: 4px; margin-top: 8px; overflow-wrap: anywhere; }
.side-card .button, .side-card button { margin-top: 10px; }

.user-card, .status-card { display: flex; flex-direction: column; gap: 12px; }
.user-card + .user-card, .status-card + .status-card { margin-top: 12px; }
.status-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: end; }
.status-row .grow { flex: 1 1 180px; }
.color-input { width: 56px; min-height: 42px; padding: 4px; background: white; border: 1px solid var(--line-strong); border-radius: 10px; }
.add-card { margin-bottom: 16px; }

.login-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1.15fr 0.85fr;
  background: var(--paper);
}
.login-hero {
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 48px 56px;
  color: #f6f1e8;
  background:
    radial-gradient(900px 500px at 0% 0%, rgba(230, 201, 138, 0.2), transparent 55%),
    var(--spruce);
}
.login-hero h1 { font-size: clamp(2.5rem, 4vw, 3.8rem); max-width: 10em; color: white; }
.login-hero .lede { color: rgba(246, 241, 232, 0.82); font-size: 1.1rem; max-width: 38ch; margin-top: 16px; }
.hero-mark {
  position: absolute;
  right: -40px;
  bottom: -50px;
  width: 380px;
  height: 380px;
  color: rgba(230, 201, 138, 0.13);
}
.hero-foot { position: relative; color: rgba(246, 241, 232, 0.7); }
.login-panel { display: grid; place-items: center; padding: 32px 20px; }
.login-card { width: min(420px, 100%); }
.login-card h2 { font-size: 2rem; margin-bottom: 6px; }
.login-form { display: flex; flex-direction: column; gap: 14px; margin-top: 22px; }
.demo {
  margin-top: 18px;
  padding: 12px 14px;
  border-radius: 12px;
  background: white;
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.88rem;
}
.demo strong { color: var(--ink); }
.standalone {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.standalone .card { width: min(480px, 100%); }

@media (max-width: 980px) {
  .filters { grid-template-columns: 1fr 1fr; }
  .filter-actions { grid-column: 1 / -1; }
  .detail-grid { grid-template-columns: 1fr; }
  .login-shell { grid-template-columns: 1fr; }
  .login-hero { min-height: 280px; padding: 32px 24px; }
  .hero-mark { width: 220px; height: 220px; }
}
@media (max-width: 860px) {
  .shell { display: flex; flex-direction: column; }
  .workspace { display: contents; }
  .side { display: none; position: static; height: auto; order: 2; }
  .nav-toggle:checked ~ .shell .side { display: flex; }
  main { order: 3; }
  .mobile-bar {
    display: flex;
    order: 1;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: var(--spruce-deep);
    color: white;
    position: sticky;
    top: 0;
    z-index: 2;
  }
  .drive-actions { width: 100%; }
  .nav-burger {
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 9px;
    padding: 6px 10px;
    cursor: pointer;
    font-weight: 700;
  }
  .page { padding: 18px 16px 48px; }
  .page-head, .detail-head, .drive-banner { flex-direction: column; }
  .form-grid { grid-template-columns: 1fr; }
  .field.span-2 { grid-column: auto; }
}
@media (max-width: 640px) {
  .filters { grid-template-columns: 1fr; }
}
