/* SRIP — "regulatory ledger" design system
   Ink navy on paper, clinical teal action color, IBM Plex Mono for
   anything that is *data* (numbers, dates, citations, state codes). */

:root {
  --ink: #182430;
  --ink-soft: #46586b;
  --paper: #f4f5f2;
  --card: #ffffff;
  --line: #dde2dc;
  --teal: #0d6d66;
  --teal-dark: #0a534e;
  --amber: #a35c0a;
  --amber-bg: #fdf1de;
  --red: #a52a2a;
  --red-bg: #fbe9e7;
  --green-bg: #e6f2ec;
  --sans: 'IBM Plex Sans', system-ui, sans-serif;
  --mono: 'IBM Plex Mono', ui-monospace, monospace;
}

* { box-sizing: border-box; }
body { margin: 0; font-family: var(--sans); color: var(--ink); background: var(--paper); font-size: 15px; line-height: 1.5; }
a { color: var(--teal); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.5rem; font-weight: 700; letter-spacing: -0.01em; margin: 0; }
h2 { font-size: 0.8rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.09em; color: var(--ink-soft); margin: 0 0 0.9rem; }
.mono { font-family: var(--mono); font-size: 0.92em; }
.minor { color: var(--ink-soft); font-size: 0.83rem; }
:focus-visible { outline: 2px solid var(--teal); outline-offset: 2px; }

/* ---- shell ---- */
.shell { display: flex; min-height: 100vh; }
.sidebar { width: 232px; flex-shrink: 0; background: var(--ink); color: #e8ecef; display: flex; flex-direction: column; padding: 1.4rem 0; position: sticky; top: 0; height: 100vh; }
.brand { padding: 0 1.3rem 1.4rem; border-bottom: 1px solid rgba(255,255,255,0.12); }
.brand-mark { font-family: var(--mono); font-weight: 600; font-size: 1.35rem; letter-spacing: 0.14em; color: #fff; display: block; }
.brand-mark.big { font-size: 1.9rem; color: var(--ink); }
.brand-sub { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.08em; color: rgba(232,236,239,0.65); line-height: 1.5; display: block; margin-top: 0.3rem; }
.sidebar nav { display: flex; flex-direction: column; padding: 0.9rem 0.6rem; gap: 2px; flex: 1; }
.sidebar nav a { color: rgba(232,236,239,0.82); padding: 0.5rem 0.7rem; border-radius: 6px; font-size: 0.9rem; }
.sidebar nav a:hover { background: rgba(255,255,255,0.08); text-decoration: none; }
.sidebar nav a.active { background: var(--teal); color: #fff; font-weight: 600; }
.sidebar-foot { padding: 0.9rem 1.3rem 0; border-top: 1px solid rgba(255,255,255,0.12); font-size: 0.85rem; }
.sidebar-foot .who { margin-bottom: 0.4rem; display: flex; flex-direction: column; gap: 0.25rem; }
.sidebar-foot a.minor { color: rgba(232,236,239,0.65); display: block; margin-bottom: 0.2rem; }
.content { flex: 1; padding: 2rem 2.4rem 3rem; max-width: 1180px; }

/* ---- page head ---- */
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.4rem; }
.page-sub { color: var(--ink-soft); margin: 0.25rem 0 0; font-size: 0.9rem; }
.head-actions { display: flex; gap: 0.6rem; align-items: center; }

/* ---- stats ---- */
.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 0.9rem; margin-bottom: 1.4rem; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 0.95rem 1.1rem; border-top: 3px solid var(--line); }
.stat-ok { border-top-color: var(--teal); }
.stat-warn { border-top-color: var(--amber); }
.stat-bad { border-top-color: var(--red); }
.stat-num { font-size: 1.7rem; font-weight: 600; display: block; }
.stat-label { font-size: 0.76rem; text-transform: uppercase; letter-spacing: 0.07em; color: var(--ink-soft); }

/* ---- panels & tables ---- */
.panel { background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 1.2rem 1.3rem; margin-bottom: 1.3rem; }
.panel.narrow { max-width: 640px; }
table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
th { text-align: left; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.07em; color: var(--ink-soft); font-weight: 600; padding: 0.45rem 0.7rem; border-bottom: 1.5px solid var(--ink); }
td { padding: 0.6rem 0.7rem; border-bottom: 1px solid var(--line); vertical-align: top; }
tr:last-child td { border-bottom: none; }
.row-muted { opacity: 0.55; }
.row-actions { white-space: nowrap; display: flex; gap: 0.7rem; align-items: baseline; }
.state-code { background: var(--ink); color: #fff; border-radius: 4px; padding: 0.1rem 0.4rem; font-size: 0.78rem; margin-right: 0.3rem; }
.cite { font-size: 0.8rem; color: var(--ink-soft); }
.empty { color: var(--ink-soft); padding: 0.6rem 0; margin: 0; }

/* ---- chips ---- */
.chip { display: inline-block; font-size: 0.74rem; font-weight: 600; padding: 0.14rem 0.55rem; border-radius: 999px; background: var(--paper); border: 1px solid var(--line); white-space: nowrap; }
.chip-ok { background: var(--green-bg); border-color: #bcd9cb; color: var(--teal-dark); }
.chip-warn, .chip-due { background: var(--amber-bg); border-color: #ecd3ab; color: var(--amber); }
.chip-bad, .chip-expired { background: var(--red-bg); border-color: #eec6c1; color: var(--red); }
.chip-inactive, .chip-nodate { color: var(--ink-soft); }
.role-chip { display: inline-block; font-family: var(--mono); font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.06em; padding: 0.1rem 0.5rem; border-radius: 4px; background: rgba(13,109,102,0.14); color: #7fd0c9; width: fit-content; }
.content .role-chip { color: var(--teal-dark); }

/* ---- renewal runway (signature element) ---- */
.runway { position: relative; height: 22px; min-width: 190px; background: var(--paper); border: 1px solid var(--line); border-radius: 4px; overflow: hidden; }
.runway-fill { height: 100%; background: var(--teal); opacity: 0.28; }
.runway.due .runway-fill { background: var(--amber); }
.runway.expired .runway-fill { background: var(--red); width: 100% !important; opacity: 0.18; }
.runway-label { position: absolute; inset: 0; display: flex; align-items: center; padding-left: 0.5rem; font-size: 0.72rem; font-weight: 500; }
.runway.due .runway-label { color: var(--amber); }
.runway.expired .runway-label { color: var(--red); }

/* ---- forms ---- */
.stack { display: flex; flex-direction: column; gap: 0.85rem; }
label { display: flex; flex-direction: column; gap: 0.3rem; font-size: 0.82rem; font-weight: 600; color: var(--ink-soft); }
input, select, textarea { font-family: var(--sans); font-size: 0.92rem; color: var(--ink); padding: 0.5rem 0.6rem; border: 1px solid var(--line); border-radius: 6px; background: #fff; }
input.mono { font-family: var(--mono); }
input:focus, select:focus, textarea:focus { border-color: var(--teal); outline: none; box-shadow: 0 0 0 3px rgba(13,109,102,0.15); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0.85rem; }
.form-actions { display: flex; gap: 0.6rem; margin-top: 0.3rem; }
.user-new { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 0.7rem; align-items: end; }
.inline { display: inline-flex; gap: 0.4rem; align-items: center; }
.inline select { font-size: 0.82rem; padding: 0.3rem 0.4rem; }
.inline-details { display: inline-block; font-size: 0.85rem; }
.inline-details summary { cursor: pointer; color: var(--teal); }
.inline-details input { font-size: 0.8rem; padding: 0.3rem 0.4rem; width: 160px; }

/* ---- buttons ---- */
.btn { display: inline-block; font-family: var(--sans); font-size: 0.88rem; font-weight: 600; padding: 0.5rem 1rem; border-radius: 6px; border: 1px solid var(--line); background: #fff; color: var(--ink); cursor: pointer; }
.btn:hover { text-decoration: none; border-color: var(--ink-soft); }
.btn-primary { background: var(--teal); border-color: var(--teal); color: #fff; }
.btn-primary:hover { background: var(--teal-dark); border-color: var(--teal-dark); }
.btn-small { padding: 0.3rem 0.7rem; font-size: 0.78rem; }
.linklike { background: none; border: none; padding: 0; font: inherit; font-size: 0.88rem; color: var(--teal); cursor: pointer; }
.linklike:hover { text-decoration: underline; }
.linklike.danger { color: var(--red); }

/* ---- alerts ---- */
.alert { padding: 0.6rem 0.9rem; border-radius: 6px; font-size: 0.88rem; margin-bottom: 1rem; }
.alert-error { background: var(--red-bg); color: var(--red); border: 1px solid #eec6c1; }
.alert-ok { background: var(--green-bg); color: var(--teal-dark); border: 1px solid #bcd9cb; }

/* ---- login ---- */
.login-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; background:
  linear-gradient(160deg, var(--paper) 55%, #e5ebe4 100%); }
.login-card { background: var(--card); border: 1px solid var(--line); border-top: 4px solid var(--teal); border-radius: 10px; padding: 2.2rem 2.4rem; width: 380px; max-width: calc(100vw - 2rem); box-shadow: 0 10px 30px rgba(24,36,48,0.08); }
.login-brand { margin-bottom: 1.4rem; }
.login-brand .brand-sub { color: var(--ink-soft); }
.login-foot { margin-top: 1.2rem; font-size: 0.8rem; color: var(--ink-soft); text-align: center; }

/* ---- responsive ---- */
@media (max-width: 820px) {
  .shell { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: static; flex-direction: row; flex-wrap: wrap; align-items: center; padding: 0.7rem 1rem; gap: 0.5rem; }
  .brand { border: none; padding: 0; }
  .brand-sub { display: none; }
  .sidebar nav { flex-direction: row; flex-wrap: wrap; padding: 0; }
  .sidebar-foot { border: none; padding: 0; margin-left: auto; display: flex; gap: 0.8rem; align-items: center; }
  .sidebar-foot .who strong { display: none; }
  .content { padding: 1.2rem; }
  .grid2 { grid-template-columns: 1fr; }
  table { display: block; overflow-x: auto; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* ---- v2: audit tabs ---- */
.tab-row { display: flex; gap: 0.4rem; margin-bottom: 1rem; border-bottom: 1.5px solid var(--line); }
.tab { padding: 0.45rem 1rem; font-size: 0.88rem; font-weight: 600; color: var(--ink-soft); border: 1px solid transparent; border-bottom: none; border-radius: 6px 6px 0 0; }
.tab:hover { text-decoration: none; color: var(--ink); }
.tab-active { background: var(--card); border-color: var(--line); color: var(--ink); margin-bottom: -1.5px; border-bottom: 1.5px solid var(--card); }

/* ---- v2: delete-with-justification ---- */
.danger-link { color: var(--red); cursor: pointer; }
.delete-form { display: flex; flex-direction: column; gap: 0.4rem; padding: 0.6rem; margin-top: 0.4rem; background: var(--red-bg); border: 1px solid #eec6c1; border-radius: 6px; max-width: 300px; }
.delete-form input { font-size: 0.82rem; }
.danger-btn { background: var(--red); border-color: var(--red); color: #fff; }
.danger-btn:hover { background: #8c2020; border-color: #8c2020; }

/* ---- v2: uploads & documents ---- */
.upload-form { display: flex; flex-direction: column; gap: 0.6rem; margin-top: 1rem; padding-top: 1rem; border-top: 1px dashed var(--line); }
.upload-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 0.7rem; align-items: end; }
.detail-cell { font-size: 0.82rem; max-width: 420px; }
.notes-cell { font-size: 0.82rem; color: var(--ink-soft); max-width: 220px; }
.due-date { color: var(--amber); font-weight: 600; }
.due-preview { font-family: var(--mono); font-size: 0.8rem; color: var(--teal-dark); background: var(--green-bg); border: 1px solid #bcd9cb; border-radius: 6px; padding: 0.45rem 0.7rem; }
.due-preview:empty { display: none; }

/* ---- v2: access editor ---- */
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 1.3rem; align-items: start; }
.check-list { display: flex; flex-direction: column; gap: 0.3rem; margin-top: 0.4rem; }
.check-row { flex-direction: row; align-items: center; gap: 0.5rem; font-weight: 500; color: var(--ink); font-size: 0.9rem; cursor: pointer; }
.check-row input { accent-color: var(--teal); width: 15px; height: 15px; }
.check-row.emphasis { font-weight: 600; padding-bottom: 0.5rem; border-bottom: 1px dashed var(--line); margin-bottom: 0.4rem; }
@media (max-width: 900px) { .two-col { grid-template-columns: 1fr; } }
.brand-logo { display: block; width: 100%; max-width: 190px; height: auto;
  background: #fff; border-radius: 8px; padding: 8px 10px; margin-bottom: 0.6rem; }
.login-logo { display: block; max-width: 260px; height: auto; margin: 0 auto 1rem; }
.login-brand { text-align: center; }

/* status color bands: red <=60d, yellow 61-100d, green >100d */
.chip-red { background: var(--red-bg); border-color: #eec6c1; color: var(--red); }
.chip-yellow { background: var(--amber-bg); border-color: #ecd3ab; color: var(--amber); }
.chip-green { background: var(--green-bg); border-color: #bcd9cb; color: var(--teal-dark); }
