/* RMS Reminders — styled to the RMS brand.
 *
 * Palette, type and radii follow the RMS website: brand blue #1C4F78 on cool
 * paper, Georgia headings against a Segoe UI body, pill buttons, blue-tinted
 * shadows. Dark mode is supported the same way the site does it — an explicit
 * data-theme wins, otherwise the system preference decides.
 *
 * The one thing the brand does not supply is urgency colour, since the site
 * has no status states. Those are tuned to sit with the blue rather than
 * shout over it, and are the only colours in the app that are not brand.
 */

:root {
  --font-heading: Georgia, "Times New Roman", "Nimbus Roman", serif;
  --font-body: "Segoe UI", system-ui, -apple-system, Roboto, Helvetica, Arial, sans-serif;

  --ink-950: #0f2b42;
  --ink-900: #1c4f78;   /* RMS brand blue */
  --ink-800: #24608f;
  --ink-700: #2e74a8;
  --accent-600: #1a6394;
  --accent-500: #5aa7dd;
  --accent-400: #8cc5ea;

  --bg:        #f7f9fb;
  --bg-alt:    #edf1f5;
  --surface:   #ffffff;
  --text:      #3f4a54;
  --heading:   #1c4f78;
  --muted:     #66727e;
  --border:    #dce3ea;

  --tint-weak:   rgba(28, 79, 120, 0.045);
  --tint-mid:    rgba(28, 79, 120, 0.09);

  --btn-primary-bg:       var(--ink-900);
  --btn-primary-bg-hover: var(--ink-800);
  --btn-primary-color:    #ffffff;

  /* urgency — not brand colours, deliberately muted to sit with the blue */
  --danger:      #a92f26;
  --danger-soft: #fbeceb;
  --danger-line: #f0cfcc;
  --warn:        #8a5a0b;
  --warn-soft:   #fbf1e0;
  --warn-line:   #ecd9b8;
  --ok:          #1a6b57;
  --ok-soft:     #e6f2ee;
  --ok-line:     #c6e0d7;

  --shadow-sm: 0 2px 6px rgba(15, 43, 66, 0.05);
  --shadow-md: 0 10px 30px rgba(15, 43, 66, 0.08);
  --shadow-lg: 0 22px 50px rgba(15, 43, 66, 0.16);

  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 22px;
  --radius-pill: 999px;

  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg:        #0b1620;
  --bg-alt:    #101e2a;
  --surface:   #13212e;
  --text:      #ccd6e0;
  --heading:   #ffffff;
  --muted:     #8b98a6;
  --border:    #22374a;

  --tint-weak: rgba(140, 197, 234, 0.05);
  --tint-mid:  rgba(140, 197, 234, 0.1);

  --btn-primary-bg:       var(--accent-500);
  --btn-primary-bg-hover: var(--accent-400);
  --btn-primary-color:    #0b1620;

  --danger:      #f0928a;
  --danger-soft: rgba(240, 146, 138, 0.12);
  --danger-line: rgba(240, 146, 138, 0.3);
  --warn:        #e0aa5e;
  --warn-soft:   rgba(224, 170, 94, 0.12);
  --warn-line:   rgba(224, 170, 94, 0.3);
  --ok:          #74c8ab;
  --ok-soft:     rgba(116, 200, 171, 0.12);
  --ok-line:     rgba(116, 200, 171, 0.3);

  --shadow-sm: 0 2px 6px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 10px 30px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 22px 50px rgba(0, 0, 0, 0.5);
  color-scheme: dark;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg:        #0b1620;
    --bg-alt:    #101e2a;
    --surface:   #13212e;
    --text:      #ccd6e0;
    --heading:   #ffffff;
    --muted:     #8b98a6;
    --border:    #22374a;

    --tint-weak: rgba(140, 197, 234, 0.05);
    --tint-mid:  rgba(140, 197, 234, 0.1);

    --btn-primary-bg:       var(--accent-500);
    --btn-primary-bg-hover: var(--accent-400);
    --btn-primary-color:    #0b1620;

    --danger:      #f0928a;
    --danger-soft: rgba(240, 146, 138, 0.12);
    --danger-line: rgba(240, 146, 138, 0.3);
    --warn:        #e0aa5e;
    --warn-soft:   rgba(224, 170, 94, 0.12);
    --warn-line:   rgba(224, 170, 94, 0.3);
    --ok:          #74c8ab;
    --ok-soft:     rgba(116, 200, 171, 0.12);
    --ok-line:     rgba(116, 200, 171, 0.3);

    --shadow-sm: 0 2px 6px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 10px 30px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 22px 50px rgba(0, 0, 0, 0.5);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 {
  font-family: var(--font-heading);
  font-weight: 700;
  line-height: 1.22;
  color: var(--heading);
}

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid rgba(46, 116, 168, .4); outline-offset: 2px; }
[hidden] { display: none !important; }

/* ── login ───────────────────────────────────────────────────────────── */
#login {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: linear-gradient(135deg, var(--ink-950), var(--ink-800));
}
.login-card {
  width: 100%;
  max-width: 390px;
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 40px 34px;
  box-shadow: var(--shadow-lg);
}
.login-mark {
  width: 46px; height: 46px;
  border-radius: var(--radius-sm);
  background: var(--ink-900);
  color: #f7f9fb;
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 25px;
  display: grid; place-items: center;
  margin-bottom: 18px;
}
.login-card h1 { font-size: 23px; letter-spacing: -.015em; }
.login-card .tag { color: var(--muted); font-size: 13.5px; margin: 5px 0 26px; }

/* ── shell ───────────────────────────────────────────────────────────── */
header.top {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 20;
}
.top-inner {
  max-width: 1140px;
  margin: 0 auto;
  padding: 0 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  min-height: 64px;
  flex-wrap: wrap;
}
.wordmark {
  font-family: var(--font-heading);
  font-size: 17px;
  font-weight: 700;
  color: var(--heading);
  letter-spacing: -.01em;
  display: flex;
  align-items: center;
  gap: 10px;
}
.wordmark .mark {
  width: 30px; height: 30px;
  border-radius: 6px;
  background: var(--ink-900);
  color: #f7f9fb;
  font-size: 17px;
  display: grid; place-items: center;
}
:root[data-theme="dark"] .wordmark .mark { background: var(--accent-500); color: var(--ink-950); }

nav.tabs { display: flex; gap: 2px; margin-left: 8px; flex-wrap: wrap; }
nav.tabs button {
  background: none;
  border: none;
  padding: 8px 14px;
  border-radius: var(--radius-pill);
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  transition: background-color .2s var(--ease), color .2s var(--ease);
}
nav.tabs button:hover { background: var(--tint-weak); }
nav.tabs button[aria-current="page"] { background: var(--tint-mid); color: var(--heading); }
:root[data-theme="dark"] nav.tabs button[aria-current="page"] { color: var(--accent-400); }

.top-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.whoami { font-size: 13px; color: var(--muted); }

main { max-width: 1140px; margin: 0 auto; padding: 30px 20px 80px; }

/* ── page furniture ──────────────────────────────────────────────────── */
h2.page-title { font-size: 26px; letter-spacing: -.015em; }
.page-head {
  display: flex; align-items: flex-start; gap: 16px;
  flex-wrap: wrap; margin-bottom: 22px;
}
.page-head .sub { color: var(--muted); font-size: 14px; margin-top: 4px; }
.page-head .spacer { margin-left: auto; }

.section-label {
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 32px 0 11px;
  display: flex; align-items: center; gap: 9px;
}
.section-label .count {
  background: var(--tint-mid);
  color: var(--heading);
  border-radius: var(--radius-pill);
  padding: 1px 10px;
  font-size: 11px;
  letter-spacing: 0;
}
:root[data-theme="dark"] .section-label .count { color: var(--accent-400); }
.section-label:first-child { margin-top: 0; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
}
.empty {
  padding: 48px 24px;
  text-align: center;
  color: var(--muted);
  font-size: 14px;
}
.empty strong {
  display: block;
  font-family: var(--font-heading);
  color: var(--heading);
  font-size: 17px;
  margin-bottom: 6px;
}

/* ── the reminder row: the most important thing in the app ───────────── */
.due-list { display: flex; flex-direction: column; gap: 9px; }
.due {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px 18px;
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  box-shadow: var(--shadow-sm);
  transition: box-shadow .25s var(--ease), transform .25s var(--ease);
}
.due:hover { box-shadow: var(--shadow-md); }
.due.is-overdue { border-left-color: var(--danger); }
.due.is-soon    { border-left-color: var(--warn); }
.due.is-later   { border-left-color: var(--accent-500); }

.due .what { min-width: 220px; flex: 1 1 260px; }
.due .entity {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 16px;
  color: var(--heading);
  letter-spacing: -.01em;
}
.due .obligation { font-size: 13.5px; margin-top: 2px; }

.due .when { flex: 0 0 auto; min-width: 172px; }
.due .countdown { font-weight: 700; font-size: 14px; }
.due .countdown.overdue { color: var(--danger); }
.due .countdown.soon    { color: var(--warn); }
.due .date { font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.due .statutory {
  font-size: 11.5px;
  color: var(--muted);
  margin-top: 3px;
  border-top: 1px dashed var(--border);
  padding-top: 3px;
}
.due .statutory b { color: var(--text); font-weight: 600; }

.due .who { flex: 0 0 auto; min-width: 130px; font-size: 13px; }
.due .who .none { color: var(--muted); font-style: italic; }
.due .actions { margin-left: auto; display: flex; gap: 6px; align-items: center; }

/* ── buttons ─────────────────────────────────────────────────────────── */
.btn {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: var(--radius-pill);
  padding: 9px 18px;
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  transition: background-color .2s var(--ease), border-color .2s var(--ease),
              box-shadow .2s var(--ease);
}
.btn:hover { background: var(--tint-weak); border-color: var(--ink-700); }
.btn.primary {
  background: var(--btn-primary-bg);
  border-color: var(--btn-primary-bg);
  color: var(--btn-primary-color);
  box-shadow: 0 4px 14px rgba(28, 79, 120, .22);
}
.btn.primary:hover { background: var(--btn-primary-bg-hover); border-color: var(--btn-primary-bg-hover); }
.btn.danger { color: var(--danger); }
.btn.danger:hover { background: var(--danger-soft); border-color: var(--danger-line); }
.btn.small { padding: 6px 13px; font-size: 12.5px; }
.btn.wide { width: 100%; }
.btn:disabled { opacity: .5; cursor: default; }

/* ── status ──────────────────────────────────────────────────────────── */
.status {
  border-radius: var(--radius-pill);
  border: 1px solid var(--border);
  padding: 6px 11px;
  font-size: 12.5px;
  font-weight: 600;
  background: var(--surface);
}
.status[data-v="Done"]        { background: var(--ok-soft);    color: var(--ok);    border-color: var(--ok-line); }
.status[data-v="Submitted"]   { background: var(--tint-mid);   color: var(--heading); }
.status[data-v="In Progress"] { background: var(--warn-soft);  color: var(--warn);  border-color: var(--warn-line); }
:root[data-theme="dark"] .status[data-v="Submitted"] { color: var(--accent-400); }

.pill {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .02em;
  padding: 2px 9px;
  border-radius: var(--radius-pill);
  background: var(--bg-alt);
  color: var(--muted);
}
.pill.statutory { background: var(--tint-mid); color: var(--heading); }
:root[data-theme="dark"] .pill.statutory { color: var(--accent-400); }

/* ── tables ──────────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th {
  text-align: left;
  font-size: 11px;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 700;
  padding: 12px 15px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
td { padding: 13px 15px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--tint-weak); }
td.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
td.right, th.right { text-align: right; }
.dim { color: var(--muted); }
td b { color: var(--heading); font-family: var(--font-heading); font-weight: 700; }

/* ── forms ───────────────────────────────────────────────────────────── */
.field { margin-bottom: 16px; }
.field > label {
  display: block;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 6px;
}
.field .hint { font-size: 12px; color: var(--muted); margin-top: 5px; }
.hint { font-size: 12px; color: var(--muted); }
.inp {
  width: 100%;
  padding: 11px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  font-size: 14px;
  transition: border-color .2s var(--ease), box-shadow .2s var(--ease);
}
.inp:focus { border-color: var(--ink-700); box-shadow: 0 0 0 3px var(--tint-mid); outline: none; }
textarea.inp { min-height: 76px; resize: vertical; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 15px; }
@media (max-width: 560px) { .grid-2 { grid-template-columns: 1fr; } }

.err {
  background: var(--danger-soft);
  color: var(--danger);
  border: 1px solid var(--danger-line);
  border-radius: var(--radius-sm);
  padding: 10px 13px;
  font-size: 13px;
  margin-bottom: 13px;
}
.warn-banner {
  background: var(--warn-soft);
  border: 1px solid var(--warn-line);
  color: var(--warn);
  border-radius: var(--radius-md);
  padding: 13px 16px;
  font-size: 13.5px;
  margin-bottom: 20px;
}

/* ── modal ───────────────────────────────────────────────────────────── */
.overlay {
  position: fixed; inset: 0;
  background: rgba(15, 43, 66, .5);
  display: grid; place-items: center;
  padding: 20px;
  z-index: 60;
}
.modal {
  background: var(--surface);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 540px;
  max-height: 88vh;
  overflow-y: auto;
  padding: 28px 30px;
  box-shadow: var(--shadow-lg);
}
.modal h3 { font-size: 20px; letter-spacing: -.01em; margin-bottom: 4px; }
.modal .modal-sub { color: var(--muted); font-size: 13px; margin-bottom: 22px; }
.modal-actions { display: flex; gap: 10px; margin-top: 24px; }
.modal-actions .btn { flex: 1; }

/* ── toast ───────────────────────────────────────────────────────────── */
#toast {
  position: fixed;
  bottom: 26px; left: 50%;
  transform: translateX(-50%);
  background: var(--ink-950);
  color: #f7f9fb;
  padding: 12px 22px;
  border-radius: var(--radius-pill);
  font-size: 14px;
  font-weight: 500;
  z-index: 80;
  box-shadow: var(--shadow-lg);
}

/* ── stats ───────────────────────────────────────────────────────────── */
.stat-row { display: flex; gap: 13px; flex-wrap: wrap; margin-bottom: 6px; }
.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px 20px;
  min-width: 132px;
  flex: 1 1 132px;
  box-shadow: var(--shadow-sm);
}
.stat .n {
  font-family: var(--font-heading);
  font-size: 30px;
  font-weight: 700;
  letter-spacing: -.02em;
  line-height: 1.1;
  color: var(--heading);
}
.stat .l { font-size: 12.5px; color: var(--muted); margin-top: 3px; }
.stat.bad  .n { color: var(--danger); }
.stat.warn .n { color: var(--warn); }

.spinner { padding: 54px; text-align: center; color: var(--muted); font-size: 14px; }

/* ── entity accordion ────────────────────────────────────────────────── */
.entity-block { margin-bottom: 14px; }
.entity-block > summary {
  cursor: pointer;
  padding: 15px 18px;
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 16px;
  color: var(--heading);
  list-style: none;
  display: flex; align-items: center; gap: 10px;
}
.entity-block > summary::-webkit-details-marker { display: none; }
.entity-block > summary::before { content: "▸"; color: var(--muted); font-size: 12px; }
.entity-block[open] > summary::before { content: "▾"; }
.entity-block > summary .meta {
  margin-left: auto;
  font-family: var(--font-body);
  font-size: 12.5px;
  color: var(--muted);
  font-weight: 400;
}
.entity-body { border-top: 1px solid var(--border); padding: 4px 0; }

/* ── scope switch (mine / everyone) ──────────────────────────────────── */
.scope {
  display: inline-flex;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  padding: 3px;
  gap: 2px;
}
.scope button {
  border: none;
  background: none;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  padding: 6px 15px;
  border-radius: var(--radius-pill);
  transition: background-color .2s var(--ease), color .2s var(--ease);
}
.scope button:hover { color: var(--text); }
.scope button[aria-current="true"] {
  background: var(--surface);
  color: var(--heading);
  box-shadow: var(--shadow-sm);
}
:root[data-theme="dark"] .scope button[aria-current="true"] { color: var(--accent-400); }

/* ── notes ───────────────────────────────────────────────────────────── */
.due.is-waiting { border-left-color: var(--accent-500); background: var(--tint-weak); }

.due .last-note {
  flex-basis: 100%;
  margin-top: 4px;
  padding-top: 9px;
  border-top: 1px solid var(--border);
  font-size: 13px;
  color: var(--text);
}
.due .last-note .who { font-weight: 700; color: var(--heading); }
.due .last-note .when { color: var(--muted); }

.thread { margin-bottom: 20px; display: flex; flex-direction: column; gap: 10px; }
.note {
  background: var(--bg-alt);
  border-radius: var(--radius-sm);
  padding: 11px 14px;
}
.note-head {
  display: flex; align-items: baseline; gap: 9px;
  font-size: 12px; color: var(--muted); margin-bottom: 4px;
}
.note-head b { color: var(--heading); font-size: 13px; }
.note-body { font-size: 13.5px; white-space: pre-wrap; }
.linkish {
  margin-left: auto;
  background: none; border: none; padding: 0;
  color: var(--muted); font-size: 12px; text-decoration: underline;
}
.linkish:hover { color: var(--danger); }
