/* Castell workspace ----------------------------------------------------------------
   Every colour comes from a theme variable. Themes are switched with data-theme on <html>
   (and can be nested, which is how the Appearance page previews them). */

:root, [data-theme] {
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --bg: #f3f5f4;
  --surface: #ffffff;
  --surface-2: #f7f9f8;
  --hover: #eef3f0;
  --ink: #16201b;
  --muted: #5d6a64;
  --faint: #8a9690;
  --line: #e2e8e5;
  --line-strong: #cbd4d0;
  --accent: #1f6b52;
  --accent-strong: #165540;
  --accent-soft: #e3f1ea;
  --accent-text: #1a6049;
  --on-accent: #ffffff;
  --focus: #f2b705;

  --red: #b42318;   --red-soft: #fdeceb;
  --amber: #8a5a00; --amber-soft: #fff3d9;
  --blue: #1d4f91;  --blue-soft: #e8f0fb;
  --green: #1f6b52; --green-soft: #e3f1ea;
  --neutral-soft: #eef1f0;

  --side-bg: #1a2029;
  --side-ink: #e7eaef;
  --side-muted: #98a2b0;
  --side-hover: rgba(255, 255, 255, .06);
  --side-active: rgba(255, 255, 255, .1);
  --side-active-ink: #ffffff;
  --side-line: rgba(255, 255, 255, .09);
  --side-mark: #45b184;
  --side-pattern: none;

  --radius: 8px;
  --radius-sm: 6px;
  --shadow: 0 1px 2px rgba(16, 24, 20, .05);
  --shadow-lg: 0 10px 32px rgba(16, 24, 20, .16);
  color-scheme: light;
}

[data-theme="blueprint"] {
  --font: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --bg: #f1f4f9;
  --surface-2: #f6f8fc;
  --hover: #ecf1fa;
  --ink: #0f1b2d;
  --muted: #56647a;
  --faint: #8592a6;
  --line: #e0e6ef;
  --line-strong: #c8d2e0;
  --accent: #1d5fd1;
  --accent-strong: #164aa6;
  --accent-soft: #e5edfc;
  --accent-text: #1a55bb;
  --green: #17704f; --green-soft: #e2f3ea;
  --neutral-soft: #edf0f5;
  --side-bg: #0d2242;
  --side-ink: #e5edff;
  --side-muted: #93a7c8;
  --side-mark: #7fb2ff;
  --side-pattern: linear-gradient(rgba(255, 255, 255, .045) 1px, transparent 1px) 0 0 / 22px 22px,
                  linear-gradient(90deg, rgba(255, 255, 255, .045) 1px, transparent 1px) 0 0 / 22px 22px;
  --radius: 8px;
  --radius-sm: 6px;
}

[data-theme="concrete"] {
  --font: "Barlow", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --bg: #f2f1ee;
  --surface-2: #f8f7f4;
  --hover: #f1eee8;
  --ink: #1c1b19;
  --muted: #625f58;
  --faint: #8f8b82;
  --line: #e5e1d9;
  --line-strong: #d0cbc0;
  --accent: #c2410c;
  --accent-strong: #9a3412;
  --accent-soft: #fdeee5;
  --accent-text: #a8390b;
  --green: #2f6b3a; --green-soft: #e6f1e7;
  --neutral-soft: #eeece7;
  --side-bg: #1d1f22;
  --side-ink: #ecebe7;
  --side-muted: #a29f98;
  --side-active: rgba(255, 138, 76, .16);
  --side-mark: #ff8a4c;
  --bar: #57534e;
  --side-pattern: repeating-linear-gradient(135deg, transparent 0 14px, rgba(255, 255, 255, .025) 14px 28px);
  --radius: 6px;
  --radius-sm: 4px;
}

[data-theme="daylight"] {
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --bg: #f7f7f8;
  --surface-2: #fafafb;
  --hover: #f3f3f6;
  --ink: #18181b;
  --muted: #5f5f69;
  --faint: #8e8e98;
  --line: #e7e7eb;
  --line-strong: #d4d4da;
  --accent: #4f46e5;
  --accent-strong: #4338ca;
  --accent-soft: #eef0fe;
  --accent-text: #4338ca;
  --green: #15803d; --green-soft: #e7f6ec;
  --neutral-soft: #f0f0f3;
  --side-bg: #ffffff;
  --side-ink: #27272a;
  --side-muted: #71717a;
  --side-hover: #f4f4f6;
  --side-active: #eef0fe;
  --side-active-ink: #4338ca;
  --side-line: #ececf0;
  --side-mark: #4f46e5;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(24, 24, 27, .04), 0 4px 16px rgba(24, 24, 27, .04);
}

[data-theme="night"] {
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --bg: #0d1211;
  --surface: #151c1a;
  --surface-2: #19211f;
  --hover: #1e2926;
  --ink: #e5ece9;
  --muted: #98a8a1;
  --faint: #6f817a;
  --line: #24302d;
  --line-strong: #34423e;
  --accent: #3fbf8f;
  --accent-strong: #63d3a8;
  --accent-soft: #163128;
  --accent-text: #5fd0a4;
  --on-accent: #04140e;
  --focus: #f2c94c;
  --red: #ff8f85;   --red-soft: #3a1c1a;
  --amber: #f0c060; --amber-soft: #352a12;
  --blue: #8ab4ff;  --blue-soft: #18243c;
  --green: #5fd0a4; --green-soft: #163128;
  --neutral-soft: #212b28;
  --side-bg: #090d0c;
  --side-ink: #dbe5e1;
  --side-muted: #7d8f88;
  --side-line: rgba(255, 255, 255, .07);
  --side-mark: #3fbf8f;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3);
  --shadow-lg: 0 12px 40px rgba(0, 0, 0, .55);
  color-scheme: dark;
}

/* Base ----------------------------------------------------------------------------- */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font: 15px/1.55 var(--font);
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent-text); text-decoration: none; text-underline-offset: 3px; }
a:hover { color: var(--accent-strong); text-decoration: underline; }
.btn:hover, .side-nav a:hover, .side-links a:hover, .brand:hover, .kpi:hover, .dash-item:hover, .dept-row:hover, .trade-card:hover, .nudge:hover, .tabs a:hover, .view-switch a:hover, .item-title:hover, .tag:hover, .skip-link:hover { text-decoration: none; }
h1, h2, h3 { line-height: 1.3; margin: 0 0 .5rem; letter-spacing: -.01em; }
h1 { font-size: 1.4rem; font-weight: 600; letter-spacing: -.02em; }
h2 { font-size: 1.05rem; font-weight: 600; }
h3 { font-size: .95rem; font-weight: 600; }
p { margin: 0 0 .75rem; }
small, .muted { color: var(--muted); }
.pre { white-space: pre-wrap; }
hr { border: 0; border-top: 1px solid var(--line); }
.icon { flex: none; display: block; }

/* App shell --------------------------------------------------------------------------- */
.shell { min-height: 100vh; }
.sidebar {
  position: fixed; inset: 0 auto 0 0; z-index: 30; width: 256px;
  display: flex; flex-direction: column; gap: 10px;
  padding: 16px 12px 12px;
  background: var(--side-pattern), var(--side-bg);
  color: var(--side-ink);
  border-right: 1px solid var(--side-line);
  overflow: hidden;
}
.app { margin-left: 256px; min-width: 0; }
main { max-width: none; margin: 0; padding: 16px clamp(14px, 1.2vw, 20px) 40px; }

.brand { display: inline-flex; align-items: center; gap: .6rem; color: inherit; text-decoration: none; font-weight: 700; }
.brand:hover { color: inherit; }
.brand-mark {
  width: 32px; height: 32px; border-radius: 9px; flex: none;
  background: var(--accent) url("icon-mark.5f67b73b4f73.svg") center / 20px no-repeat;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .12);
}
.brand-text { display: flex; flex-direction: column; line-height: 1.1; font-size: 1.02rem; letter-spacing: -.01em; }
.brand-text small { font-size: .72rem; font-weight: 500; color: var(--side-muted); letter-spacing: .04em; text-transform: uppercase; margin-top: 2px; }

.side-top { display: flex; align-items: center; justify-content: space-between; padding: 0 4px; }
.side-project { display: flex; flex-direction: column; gap: 4px; padding: 10px 12px; border: 1px solid var(--side-line); border-radius: var(--radius-sm); }
.side-project label, .side-label-inline { font-size: .7rem; text-transform: uppercase; letter-spacing: .06em; color: var(--side-muted); font-weight: 600; margin: 0; }
.side-project select { background: transparent; color: var(--side-ink); border: 0; padding: 0; font-weight: 600; min-height: 0; }
.side-project select option { color: #111; }
.side-new { justify-content: center; }

.side-nav { flex: 1 1 auto; min-height: 0; overflow-y: auto; overflow-x: hidden; display: flex; flex-direction: column; gap: 2px; margin: 0 -6px; padding: 0 6px; }
.side-group { display: flex; flex-direction: column; gap: 2px; }
.side-label {
  display: flex; align-items: center; justify-content: space-between; gap: .4rem;
  font-size: .68rem; text-transform: uppercase; letter-spacing: .07em; color: var(--side-muted); font-weight: 700;
  padding: 10px 10px 5px; cursor: pointer; user-select: none; list-style: none; border-radius: var(--radius-sm);
}
.side-label::-webkit-details-marker, .side-label::marker { display: none; content: ""; }
.side-label:hover { color: var(--side-ink); }
.side-label .icon { opacity: .6; transition: transform .15s ease; }
.side-group:not([open]) > .side-label { padding-bottom: 9px; }
.side-group:not([open]) > .side-label .icon { transform: rotate(-90deg); }
.side-nav a, .side-links a, .side-signout {
  position: relative; display: flex; align-items: center; gap: 10px;
  padding: 7px 10px; border-radius: var(--radius-sm);
  color: var(--side-ink); text-decoration: none; font-weight: 500; font-size: .9rem;
  opacity: .88;
}
.side-nav a:hover, .side-links a:hover, .side-signout:hover { background: var(--side-hover); color: var(--side-ink); opacity: 1; }
.side-nav a.active, .side-links a.active { background: var(--side-active); color: var(--side-active-ink); opacity: 1; font-weight: 600; }
.side-nav a.active::before { content: ""; position: absolute; left: -12px; top: 7px; bottom: 7px; width: 3px; border-radius: 0 3px 3px 0; background: var(--side-mark); }
.side-nav .pill {
  margin-left: auto; min-width: 1.4rem; padding: 0 .4rem; border-radius: 99px; text-align: center;
  background: var(--side-mark); color: var(--side-bg); font-size: .72rem; font-weight: 700; line-height: 1.4rem;
}
.side-nav .pill.alert { background: var(--red); color: #fff; }
[data-theme="daylight"] .side-nav .pill { color: #fff; }

.side-foot { margin-top: auto; border-top: 1px solid var(--side-line); padding-top: 12px; display: flex; flex-direction: column; gap: 6px; }
.side-user { display: flex; align-items: center; gap: 10px; padding: 4px 8px 6px; min-width: 0; }
.side-user .avatar { background: var(--side-active); color: var(--side-ink); }
.side-user-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.side-user-text strong { font-size: .9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.side-user-text small { color: var(--side-muted); font-size: .76rem; }
.side-links { display: flex; flex-direction: column; gap: 2px; }
.side-links form { margin: 0; }
.side-signout { width: 100%; justify-content: flex-start; min-height: 0; box-shadow: none; background: none; border: 0; font: inherit; font-size: .94rem; cursor: pointer; text-align: left; }

.appbar {
  display: flex; align-items: center; gap: 16px; position: sticky; top: 0; z-index: 20;
  height: 58px; padding: 0 clamp(16px, 1.5vw, 26px);
  background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.appbar #menu-toggle, .appbar .brand, .appbar .appbar-new { display: none; }
.appbar-search { position: relative; flex: 1 1 auto; max-width: none; display: flex; align-items: center; margin: 0; }
.appbar-search .icon { position: absolute; left: 12px; color: var(--faint); pointer-events: none; }
.appbar-search input[type=search] { padding-left: 36px; min-height: 38px; border-radius: 99px; background: var(--surface); }
.appbar-date { color: var(--muted); font-size: .86rem; font-weight: 500; white-space: nowrap; }
.appbar-title { display: none; margin: 0; font-size: 1.02rem; font-weight: 600; letter-spacing: -.01em; white-space: nowrap; color: var(--ink); }
.appbar-new-btn { display: none; white-space: nowrap; }
.appbar-back { display: none; }
@media (min-width: 1101px) {
  .appbar-title { display: block; }
  .appbar-new-btn { display: inline-flex; }
  .appbar-back { display: inline-flex; }
}
.icon-btn {
  display: inline-grid; place-items: center; width: 42px; height: 42px; border-radius: 10px;
  background: transparent; border: 0; color: inherit; cursor: pointer; padding: 0;
}
.icon-btn:hover { background: var(--side-hover); color: inherit; }
.sidebar .side-close { display: none; color: var(--side-ink); }
.scrim { position: fixed; inset: 0; z-index: 25; background: rgba(8, 12, 10, .45); }
.scrim[hidden] { display: none; }

.public-bar { display: flex; align-items: center; padding: 14px 24px; background: var(--side-bg); color: var(--side-ink); }
.public-main { max-width: 1000px; }
.auth-main { max-width: none; padding: 0; }

/* Page structure -------------------------------------------------------------------------- */
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: .9rem; margin-bottom: .9rem; }
.page-head h1 { margin: 0; }
.page-head .sub { color: var(--muted); margin-top: .3rem; }
.page-head .muted a { text-decoration: none; }
.actions { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.split { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 14px;
}
.card > h2:first-child, .card > h3:first-child { margin-top: 0; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: .75rem; margin-bottom: .75rem; }
.card-head h2, .card-head h3 { margin: 0; }
.card-head a { font-size: .88rem; font-weight: 500; }
.empty { color: var(--muted); padding: .5rem 0; }
.eyebrow { color: var(--muted); font-size: .78rem; font-weight: 600; letter-spacing: .07em; text-transform: uppercase; margin-bottom: .3rem; }

/* Tables ------------------------------------------------------------------------------- */
.table-wrap { overflow-x: auto; margin: 0 -20px; padding: 0 20px; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: .6rem .7rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600; background: transparent; border-bottom: 1px solid var(--line-strong); }
tbody tr:hover td { background: var(--hover); }
tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.zero { color: var(--faint); }

/* Item rows ------------------------------------------------------------------------------- */
.items { list-style: none; margin: 0 -8px; padding: 0; }
.item-row {
  display: grid;
  grid-template-columns: 3.6rem minmax(0, 1fr) 10.5rem 7.5rem;
  gap: .25rem 1rem;
  padding: .85rem 8px;
  border-bottom: 1px solid var(--line);
  border-radius: var(--radius-sm);
  align-items: start;
}
.item-row:hover { background: var(--surface-2); }
.item-row:last-child { border-bottom: 0; }
.item-num { color: var(--faint); font-variant-numeric: tabular-nums; font-weight: 500; padding-top: 1px; }
.item-title { font-weight: 600; text-decoration: none; color: var(--ink); }
.item-title:hover { color: var(--accent-text); }
.item-meta { font-size: .84rem; color: var(--muted); margin-top: .3rem; display: flex; flex-wrap: wrap; gap: .3rem; align-items: center; }
.item-meta .sep { margin: 0 .1rem; }
.item-side { font-size: .86rem; color: var(--muted); }
.item-date { font-size: .86rem; text-align: right; font-variant-numeric: tabular-nums; }

/* Badges and tags --------------------------------------------------------------------------- */
.badge {
  display: inline-flex; align-items: center; gap: .3rem;
  padding: .1rem .55rem; border-radius: 99px;
  font-size: .74rem; font-weight: 600; line-height: 1.5;
  background: var(--neutral-soft); color: var(--muted); white-space: nowrap;
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .85; }
.badge.open { background: var(--blue-soft); color: var(--blue); }
.badge.waiting { background: var(--amber-soft); color: var(--amber); }
.badge.ready { background: var(--green-soft); color: var(--green); }
.badge.closed { background: var(--neutral-soft); color: var(--muted); }
.badge.overdue { background: var(--red-soft); color: var(--red); }
.badge.draft { background: var(--amber-soft); color: var(--amber); }
.badge.approved { background: var(--green-soft); color: var(--green); }
.badge.replaced { background: var(--neutral-soft); color: var(--muted); text-decoration: line-through; }
.tag {
  display: inline-block; padding: .05rem .5rem;
  border: 1px solid var(--line); border-radius: 6px;
  font-size: .76rem; color: var(--muted); background: var(--surface);
  text-decoration: none; margin: 0 .15rem .15rem 0; line-height: 1.6;
}
a.tag:hover { border-color: var(--accent); color: var(--accent-text); }
.overdue-text { color: var(--red); font-weight: 600; }
.pill { display: inline-block; min-width: 1.4em; padding: 0 .4em; border-radius: 99px; background: var(--accent); color: var(--on-accent); font-size: .74rem; font-weight: 700; text-align: center; }

/* Buttons --------------------------------------------------------------------------------- */
.btn, button {
  display: inline-flex; align-items: center; justify-content: center; gap: .45rem;
  font: inherit; font-weight: 600; font-size: .92rem; line-height: 1.3;
  min-height: 38px; padding: .45rem .95rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong);
  background: var(--surface); color: var(--ink);
  text-decoration: none; cursor: pointer;
  transition: background .12s, border-color .12s, color .12s;
}
.btn:hover, button:hover { border-color: var(--accent); color: var(--accent-text); background: var(--surface); }
.btn.primary, button.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn.primary:hover, button.primary:hover { background: var(--accent-strong); border-color: var(--accent-strong); color: var(--on-accent); }
.btn.danger, button.danger { color: var(--red); }
.btn.danger:hover, button.danger:hover { border-color: var(--red); color: var(--red); }
.btn.small, button.small { min-height: 32px; padding: .25rem .65rem; font-size: .84rem; font-weight: 500; }
.btn.link, button.link { border: 0; background: none; padding: 0; min-height: 0; color: var(--accent-text); font-weight: 500; box-shadow: none; }
form.inline { display: inline; }

/* Forms ----------------------------------------------------------------------------------- */
label { display: block; font-weight: 600; font-size: .88rem; margin-bottom: .35rem; }
input[type=text], input[type=password], input[type=email], input[type=date], input[type=search],
input[type=number], input[type=file], select, textarea {
  width: 100%; font: inherit; min-height: 40px;
  padding: .5rem .7rem;
  border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--ink);
  transition: border-color .12s, box-shadow .12s;
}
textarea { min-height: 96px; }
input[type=file] { padding: .3rem; color: var(--muted); font-size: .88rem; }
input[type=file]::file-selector-button {
  font: inherit; font-weight: 600; font-size: .85rem; margin-right: .7rem; padding: .35rem .8rem; cursor: pointer;
  border: 1px solid var(--line-strong); border-radius: calc(var(--radius-sm) - 2px); background: var(--surface-2); color: var(--ink);
}
input[type=file]::file-selector-button:hover { border-color: var(--accent); color: var(--accent-text); }
input:hover, select:hover, textarea:hover { border-color: var(--faint); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
select[multiple] { min-height: 9rem; }
input[type=checkbox], input[type=radio] { accent-color: var(--accent); width: 16px; height: 16px; }
.field { margin-bottom: 1.1rem; }
.field .help { font-size: .8rem; color: var(--muted); margin-top: .3rem; }
.field .errorlist, .errorlist { color: var(--red); list-style: none; padding: 0; margin: .3rem 0 0; font-size: .85rem; }
.field.checkbox label { display: flex; gap: .55rem; align-items: center; font-weight: 600; }
.field.checkbox input { width: auto; }
.checks { display: flex; flex-wrap: wrap; gap: .35rem .5rem; }
.checks div { display: contents; }
.checks label {
  display: inline-flex; gap: .45rem; align-items: center; font-weight: 500; font-size: .88rem;
  padding: .35rem .7rem; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface-2); cursor: pointer; margin: 0;
}
.checks label:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-text); }
.checks input { width: auto; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 18px; }
.form-grid .wide { grid-column: 1 / -1; }
.form-actions { display: flex; gap: .5rem; flex-wrap: wrap; margin-top: .75rem; }
.filters { display: grid; grid-template-columns: 2fr repeat(3, minmax(0, 1fr)) auto; gap: 10px; align-items: end; }
.filters label { font-size: .74rem; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }

/* Tabs and switches ---------------------------------------------------------------------- */
.tabs { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 14px; border-bottom: 1px solid var(--line); }
.tabs a {
  padding: .5rem .85rem; margin-bottom: -1px; text-decoration: none; color: var(--muted); font-weight: 500; font-size: .92rem;
  border-bottom: 2px solid transparent;
}
.tabs a:hover { color: var(--ink); }
.tabs a.active { color: var(--accent-text); border-bottom-color: var(--accent); font-weight: 600; }

.view-switch { display: inline-flex; padding: 3px; gap: 2px; border: 1px solid var(--line); border-radius: calc(var(--radius-sm) + 3px); background: var(--surface); }
.view-switch a { display: inline-flex; align-items: center; min-height: 32px; padding: .3rem .85rem; border-radius: var(--radius-sm); color: var(--muted); text-decoration: none; font-weight: 600; font-size: .88rem; }
.view-switch a:hover { color: var(--ink); background: var(--hover); }
.view-switch a.active { background: var(--accent); color: var(--on-accent); }

.route { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 14px; margin-bottom: 12px; background: var(--surface-2); }
.route > .field.checkbox { margin-bottom: .5rem; }
.route .route-body { padding-left: 1.6rem; }

/* Messages and notices ------------------------------------------------------------------- */
.messages { list-style: none; padding: 0; margin: 0 0 18px; }
.messages li { padding: .7rem 1rem; border-radius: var(--radius-sm); margin-bottom: .5rem; background: var(--green-soft); color: var(--green); border: 1px solid color-mix(in srgb, var(--green) 25%, transparent); font-weight: 500; }
.messages li.error { background: var(--red-soft); color: var(--red); border-color: color-mix(in srgb, var(--red) 25%, transparent); }
.messages li.info { background: var(--blue-soft); color: var(--blue); border-color: color-mix(in srgb, var(--blue) 25%, transparent); }
.notice { padding: .75rem 1rem; border-radius: var(--radius-sm); background: var(--amber-soft); color: var(--amber); margin-bottom: 1rem; }

/* Lists, details, files ------------------------------------------------------------------ */
.lines { list-style: none; padding: 0; margin: 0; }
.lines li { display: flex; justify-content: space-between; gap: .75rem; padding: .55rem 0 .55rem 1.6rem; border-bottom: 1px solid var(--line); position: relative; }
.lines li:last-child { border-bottom: 0; }
.lines li::before { content: ""; position: absolute; left: .45rem; top: 1.12rem; width: 6px; height: 6px; border-radius: 50%; background: var(--accent); opacity: .75; }
.lines .tag { margin-left: .25rem; }
.line-actions { display: flex; gap: .6rem; align-items: start; font-size: .85rem; white-space: nowrap; }

dl.facts { display: grid; grid-template-columns: 9.5rem minmax(0, 1fr); gap: .65rem 1rem; margin: 0; }
dl.facts dt { color: var(--muted); font-size: .86rem; padding-top: 1px; }
dl.facts dd { margin: 0; }
.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li { padding: .7rem 0 .7rem 1.1rem; border-left: 2px solid var(--line); position: relative; }
.timeline li::before { content: ""; position: absolute; left: -5px; top: 1.05rem; width: 8px; height: 8px; border-radius: 50%; background: var(--surface); border: 2px solid var(--accent); }
.timeline .who { font-size: .8rem; color: var(--muted); }
.outcome { border-left: 3px solid var(--green); padding: .55rem .85rem; margin-bottom: .75rem; background: var(--surface-2); border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }
.outcome.draft { border-left-color: var(--amber); }
.outcome.replaced { border-left-color: var(--faint); opacity: .75; }
.outcome .outcome-head { display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; font-size: .84rem; color: var(--muted); margin-bottom: .25rem; }
.files { list-style: none; padding: 0; margin: 0; }
.files li { display: flex; justify-content: space-between; gap: .5rem; padding: .35rem 0; border-bottom: 1px dashed var(--line); font-size: .9rem; }
.files li:last-child { border-bottom: 0; }
.share-box { display: flex; gap: .5rem; }
.share-box input { font-size: .85rem; }

.trade-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 10px; }
.trade-card {
  display: block; padding: 12px 14px; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-sm); text-decoration: none; color: var(--ink); transition: border-color .12s, transform .12s;
}
.trade-card:hover { border-color: var(--accent); color: var(--ink); }
.trade-card .code { color: var(--faint); font-variant-numeric: tabular-nums; margin-right: .3rem; font-weight: 500; }
.trade-card .counts { font-size: .8rem; color: var(--muted); margin-top: .25rem; }

/* Sign-in ------------------------------------------------------------------------------- */
.auth {
  min-height: 100vh; display: grid; place-content: center; justify-items: center; gap: 18px;
  padding: 32px 20px;
  background:
    radial-gradient(900px 520px at 50% -5%, rgba(255, 255, 255, .12), transparent 62%),
    linear-gradient(rgba(255, 255, 255, .05) 1px, transparent 1px) 0 0 / 26px 26px,
    linear-gradient(90deg, rgba(255, 255, 255, .05) 1px, transparent 1px) 0 0 / 26px 26px,
    linear-gradient(160deg, #16543f, #1f6b52 55%, #11382b);
}
.auth-card {
  width: 100%; max-width: 420px; padding: 32px;
  background: var(--surface); border-radius: 16px;
  box-shadow: 0 24px 60px rgba(6, 18, 13, .38), 0 2px 6px rgba(6, 18, 13, .18);
}
.auth-brand { display: flex; align-items: center; justify-content: center; gap: .6rem; margin-bottom: 1.6rem; }
.auth-brand .brand-mark { width: 40px; height: 40px; border-radius: 11px; }
.auth-brand-text { display: flex; flex-direction: column; line-height: 1.1; }
.auth-brand-text strong { font-size: 1.2rem; letter-spacing: -.02em; }
.auth-brand-text span { font-size: .7rem; letter-spacing: .09em; text-transform: uppercase; color: var(--muted); }
.auth-title { text-align: center; font-size: 1.5rem; margin: 0 0 .3rem; }
.auth-sub { text-align: center; color: var(--muted); margin: 0 0 1.5rem; font-size: .95rem; }
.auth-submit { width: 100%; min-height: 46px; margin-top: .35rem; font-size: .96rem; }
.auth-divider { display: flex; align-items: center; gap: .75rem; margin: 1.5rem 0 .9rem; color: var(--muted); font-size: .72rem; text-transform: uppercase; letter-spacing: .08em; font-weight: 700; }
.auth-divider::before, .auth-divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.auth-foot { color: rgba(255, 255, 255, .72); font-size: .82rem; margin: 0; }

.demo-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.demo-grid form { margin: 0; }
.demo-btn {
  width: 100%; min-height: 44px; padding: .4rem .7rem; text-align: left; justify-content: flex-start;
  display: flex; flex-direction: column; align-items: flex-start; gap: 0; line-height: 1.25;
  background: var(--surface-2); border: 1px solid var(--line); color: var(--ink);
}
.demo-btn:hover { background: var(--surface); border-color: var(--accent); color: var(--accent-text); }
.demo-name { font-weight: 600; font-size: .88rem; }
.demo-dept { font-size: .72rem; color: var(--muted); }

/* Accessibility ------------------------------------------------------------------------ */
.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;
}
.skip-link {
  position: absolute; left: 16px; top: -60px; z-index: 50;
  background: var(--surface); color: var(--accent-text); padding: .55rem 1rem; border-radius: var(--radius-sm); font-weight: 600;
  box-shadow: var(--shadow-lg);
}
.skip-link:focus { top: 10px; }
main:focus { outline: none; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: none; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; scroll-behavior: auto !important; } }

/* Dashboard ---------------------------------------------------------------------------- */
.dash-head h1 { font-size: 1.5rem; }
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 14px; }
.kpi {
  --k: var(--accent); --k-soft: var(--accent-soft);
  display: grid; grid-template-columns: 1fr auto; grid-template-rows: auto auto; gap: 2px 12px; align-items: start;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 14px 16px; text-decoration: none; color: var(--ink); position: relative; overflow: hidden;
  transition: border-color .12s;
}
.kpi:hover { border-color: var(--k); color: var(--ink); }
.kpi-icon { grid-column: 2; grid-row: 1 / 3; width: 36px; height: 36px; border-radius: 8px; display: grid; place-items: center; background: var(--k-soft); color: var(--k); }
.kpi-icon svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.kpi-num { grid-column: 1; grid-row: 1; font-size: 1.75rem; font-weight: 600; line-height: 1.1; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.kpi-label { grid-column: 1; grid-row: 2; color: var(--muted); font-size: .86rem; font-weight: 500; }
.kpi.is-late { --k: var(--red); --k-soft: var(--red-soft); }
.kpi.is-late .kpi-num { color: var(--red); }
.kpi.is-soon { --k: var(--blue); --k-soft: var(--blue-soft); }
.kpi.is-wait { --k: var(--amber); --k-soft: var(--amber-soft); }

.nudges { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 18px; }
.nudge {
  display: inline-flex; align-items: center; gap: .6rem; padding: .5rem .85rem; border-radius: var(--radius-sm);
  background: var(--surface); color: var(--ink); text-decoration: none; font-size: .9rem;
  border: 1px solid var(--line);
}
.nudge:hover { color: var(--ink); border-color: var(--accent); }

.dash-grid {
  display: grid; gap: 16px; align-items: start;
  grid-template-columns: minmax(0, 1.65fr) minmax(0, 1fr);
  grid-template-areas: "follow depts" "follow agenda" "follow activity";
}
.dash-grid > .card { margin: 0; }
.dash-follow { grid-area: follow; }
.dash-depts { grid-area: depts; }
.dash-agenda { grid-area: agenda; }
.dash-activity { grid-area: activity; }

.list-title { display: flex; align-items: center; gap: .5rem; font-size: .74rem; font-weight: 700; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); margin: 1.2rem 0 .3rem; }
.card-head + .list-title { margin-top: .3rem; }
.list-title.late { color: var(--red); }
.list-title .count { background: var(--neutral-soft); color: var(--muted); border-radius: 99px; padding: 0 .5rem; font-size: .72rem; }
.list-title.late .count { background: var(--red-soft); color: var(--red); }
.empty-state { color: var(--muted); background: var(--surface-2); border: 1px dashed var(--line-strong); border-radius: var(--radius-sm); padding: .8rem 1rem; margin: .3rem 0 0; font-size: .92rem; }
.more { display: inline-block; margin-top: .5rem; font-size: .88rem; font-weight: 500; }

.dash-list { list-style: none; margin: 0; padding: 0; }
.dash-list li + li { border-top: 1px solid var(--line); }
.dash-item {
  display: flex; justify-content: space-between; align-items: flex-start; gap: 12px;
  padding: .75rem .6rem; margin: 0 -.6rem; border-radius: var(--radius-sm); text-decoration: none; color: var(--ink);
}
.dash-item:hover { background: var(--hover); color: var(--ink); }
.dash-item-main { min-width: 0; display: flex; flex-direction: column; gap: .15rem; }
.dash-item-title { font-weight: 600; overflow-wrap: anywhere; }
.dash-item-title .num, .agenda-mini .num { color: var(--faint); font-weight: 500; font-variant-numeric: tabular-nums; }
.dash-item-meta { color: var(--muted); font-size: .84rem; }
.wait-text { color: var(--amber); }

.due { flex: none; font-size: .76rem; font-weight: 600; padding: .18rem .6rem; border-radius: 99px; white-space: nowrap; background: var(--neutral-soft); color: var(--muted); }
.due.late { background: var(--red-soft); color: var(--red); }
.due.today { background: var(--amber-soft); color: var(--amber); }
.due.soon { background: var(--blue-soft); color: var(--blue); }

.legend { display: inline-flex; align-items: center; gap: .3rem; font-size: .78rem; color: var(--muted); }
.sw { display: inline-block; width: .65rem; height: .65rem; border-radius: 3px; margin-left: .45rem; }
.sw-open { background: var(--bar, var(--accent)); }
.sw-late { background: var(--red); }
.dept-list { list-style: none; margin: 0; padding: 0; }
.dept-row {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "name num" "bar bar" "meta meta";
  gap: .35rem .75rem; padding: .65rem .6rem; margin: 0 -.6rem; border-radius: var(--radius-sm); text-decoration: none; color: var(--ink);
}
a.dept-row:hover { background: var(--hover); color: var(--ink); }
.dept-name { grid-area: name; font-weight: 600; }
.dept-num { grid-area: num; font-weight: 700; font-variant-numeric: tabular-nums; }
.bar { grid-area: bar; height: 8px; border-radius: 99px; background: var(--neutral-soft); overflow: hidden; }
.bar-fill { display: block; height: 100%; background: var(--bar, var(--accent)); border-radius: 99px; min-width: 8px; }
.bar-late { display: block; height: 100%; background: var(--red); }
.dept-meta { grid-area: meta; display: flex; flex-wrap: wrap; gap: .2rem .8rem; font-size: .8rem; color: var(--muted); }
.late-text { color: var(--red); font-weight: 600; }
.quiet { color: var(--muted); font-size: .8rem; margin: .7rem 0 0; }
.h-note { font-size: .74rem; font-weight: 500; margin-left: .3rem; text-transform: none; letter-spacing: 0; }

.agenda-mini { list-style: none; margin: 0; padding: 0; }
.agenda-mini li { display: flex; justify-content: space-between; align-items: flex-start; gap: .75rem; padding: .6rem 0; border-top: 1px solid var(--line); }
.agenda-mini li:first-child { border-top: 0; }
.agenda-mini a { color: var(--ink); text-decoration: none; font-weight: 500; overflow-wrap: anywhere; }
.agenda-mini a:hover { color: var(--accent-text); text-decoration: underline; }

.feed { list-style: none; margin: 0; padding: 0; }
.feed li { display: flex; gap: .75rem; padding: .7rem 0; border-top: 1px solid var(--line); }
.feed li:first-child { border-top: 0; }
.avatar {
  flex: none; width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent-text); font-size: .74rem; font-weight: 700;
}
.feed-body { min-width: 0; font-size: .9rem; overflow-wrap: anywhere; }
.feed-text { color: var(--ink); opacity: .85; white-space: pre-line; }
.feed time { font-size: .78rem; }

.view-note { margin: .3rem 0 0; font-size: .9rem; }
.send-trade .check { display: flex; gap: .55rem; align-items: flex-start; font-size: .9rem; font-weight: 500; margin: .6rem 0 .85rem; }
.send-trade .check input { margin-top: .2rem; }
.send-trade hr { margin: 1.1rem 0; }

/* Appearance --------------------------------------------------------------------------- */
.theme-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 18px; }
.theme-card { padding: 0; overflow: hidden; margin: 0; display: flex; flex-direction: column; }
.theme-card.is-current { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft), var(--shadow); }
.theme-body { padding: 16px 18px 18px; display: flex; flex-direction: column; gap: .6rem; flex: 1; }
.theme-body h2 { margin: 0; display: flex; align-items: center; gap: .5rem; }
.theme-body p { margin: 0; color: var(--muted); font-size: .9rem; flex: 1; }
.theme-body form { margin: 0; }
.theme-body button { width: 100%; }
.current-badge { font-size: .72rem; font-weight: 700; color: var(--accent-text); background: var(--accent-soft); padding: .1rem .5rem; border-radius: 99px; }
.swatches { display: flex; gap: 6px; }
.swatches span { width: 22px; height: 22px; border-radius: 50%; border: 1px solid rgba(0, 0, 0, .08); }

/* Mini mock-up drawn with the previewed theme's own variables. */
.mock {
  display: grid; grid-template-columns: 30% 1fr; height: 190px; font-family: var(--font);
  background: var(--bg); color: var(--ink); border-bottom: 1px solid var(--line); pointer-events: none;
}
.mock-side { background: var(--side-pattern), var(--side-bg); padding: 12px 9px; display: flex; flex-direction: column; gap: 5px; border-right: 1px solid var(--side-line); }
.mock-brand { display: flex; align-items: center; gap: 5px; color: var(--side-ink); font-weight: 700; font-size: .7rem; margin-bottom: 6px; }
.mock-brand i { width: 14px; height: 14px; border-radius: 4px; background: var(--accent); }
.mock-link { height: 8px; border-radius: 4px; background: var(--side-ink); opacity: .22; }
.mock-link.on { opacity: 1; background: var(--side-active); box-shadow: inset 2px 0 0 var(--side-mark); height: 12px; }
.mock-main { padding: 12px; display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.mock-title { font-weight: 700; font-size: .82rem; }
.mock-kpis { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.mock-kpi { background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: 6px; font-size: .78rem; font-weight: 700; box-shadow: inset 0 -2px 0 var(--accent); }
.mock-kpi.late { color: var(--red); box-shadow: inset 0 -2px 0 var(--red); }
.mock-kpi.wait { box-shadow: inset 0 -2px 0 var(--amber); }
.mock-card { background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: 7px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.mock-row { display: flex; align-items: center; gap: 6px; }
.mock-row b { height: 6px; border-radius: 3px; background: var(--ink); opacity: .55; flex: 1; }
.mock-row em { width: 34px; height: 10px; border-radius: 99px; background: var(--red-soft); }
.mock-row em.soon { background: var(--blue-soft); }
.mock-row em.ok { background: var(--accent-soft); }
.mock-btn { align-self: flex-start; padding: 3px 9px; border-radius: 5px; background: var(--accent); color: var(--on-accent); font-size: .66rem; font-weight: 600; }

/* Tablet and phone: the sidebar becomes a drawer ------------------------------------------ */
@media (max-width: 1100px) {
  .app { margin-left: 0; }
  .sidebar {
    width: min(300px, 86vw); transform: translateX(-100%); visibility: hidden;
    transition: transform .2s ease, visibility 0s linear .2s; box-shadow: none;
  }
  body.nav-open .sidebar { transform: none; visibility: visible; transition: transform .2s ease; box-shadow: var(--shadow-lg); }
  body.nav-open { overflow: hidden; }
  .sidebar .side-close { display: inline-grid; }
  .side-nav a, .side-links a, .side-signout { padding: 11px 12px; }
  .appbar {
    gap: 8px; height: auto; padding: 8px 12px; backdrop-filter: none;
    background: var(--side-pattern), var(--side-bg); color: var(--side-ink); border-bottom: 1px solid var(--side-line);
  }
  .appbar #menu-toggle, .appbar .appbar-new { display: inline-grid; }
  .appbar .brand { display: inline-flex; }
  .appbar .brand { margin-right: 8px; }
  .appbar-search { margin-left: auto; }
  .appbar-search .icon { color: var(--side-muted); }
  .appbar-search input[type=search] { background: var(--side-hover); border-color: var(--side-line); color: var(--side-ink); }
  .appbar-search input::placeholder { color: var(--side-muted); }
  .appbar-date { display: none; }
  .appbar .brand-mark { width: 28px; height: 28px; background-size: 17px; }
  main { padding: 22px 20px 56px; }
  .dash-grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); grid-template-areas: "follow follow" "depts agenda" "activity activity"; }
}

@media (max-width: 960px) {
  .split { grid-template-columns: minmax(0, 1fr); }
  .filters { grid-template-columns: 1fr 1fr; }
  .filters .q { grid-column: 1 / -1; }
  .item-row { grid-template-columns: 3rem minmax(0, 1fr) 7rem; }
  .item-side { display: none; }
  .auth { grid-template-columns: minmax(0, 1fr); }
  .auth-side { padding: 28px 24px; }
  .auth-side h1 { font-size: 1.5rem; }
  .auth-points, .auth-side .auth-foot { display: none; }
}

@media (max-width: 720px) {
  body { font-size: 16px; }
  main { padding: 18px 16px 48px; }
  h1 { font-size: 1.4rem; }
  .card { padding: 16px; }
  .table-wrap { margin: 0 -16px; padding: 0 16px; }
  .grid-2, .grid-3, .form-grid { grid-template-columns: minmax(0, 1fr); }
  .item-row { grid-template-columns: minmax(0, 1fr) auto; }
  .item-num { display: none; }
  dl.facts { grid-template-columns: minmax(0, 1fr); gap: 0; }
  dl.facts dt { font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; }
  dl.facts dd { margin-bottom: .75rem; }
  .hide-sm { display: none; }
  .appbar-search { display: none; }
  .appbar .brand { margin-right: auto; }
  .tabs { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin-left: -16px; margin-right: -16px; padding: 0 16px; }
  .tabs a { white-space: nowrap; }
  .page-head { align-items: flex-start; }
}

@media (max-width: 640px) {
  .dash-head { flex-direction: column; align-items: stretch; }
  .dash-head h1 { font-size: 1.5rem; }
  .dash-head .actions { display: grid; grid-template-columns: 1fr 1fr; }
  .dash-head .view-switch { grid-column: 1 / -1; }
  .view-switch a { flex: 1; justify-content: center; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .kpi { padding: 14px; }
  .kpi-icon { width: 32px; height: 32px; }
  .kpi-icon svg { width: 17px; height: 17px; }
  .kpi-num { font-size: 1.65rem; }
  .nudge { width: 100%; justify-content: space-between; border-radius: var(--radius-sm); }
  .dash-grid { grid-template-columns: minmax(0, 1fr); grid-template-areas: "follow" "depts" "agenda" "activity"; }
}

/* Touch screens: thumb-sized targets (44px). */
@media (pointer: coarse) {
  .btn, button, .btn.small, button.small, .dash-item, .dept-row, .tabs a, .more, .card-head a, .agenda-mini a, .view-switch a, .side-nav a, .side-links a, .side-signout { min-height: 44px; }
  .icon-btn { width: 44px; height: 44px; }
  .card-head a, .more, .tabs a { display: inline-flex; align-items: center; }
  .agenda-mini a { display: flex; align-items: center; }
  .btn.link, .page-head .muted a { min-height: 44px; display: inline-flex; align-items: center; }
  .appbar .brand { min-height: 44px; }
  .item-title { display: inline-block; padding: .6rem 0; margin: -.6rem 0; }
}

@media print {
  .sidebar, .appbar, .scrim, .public-bar, .no-print, .messages, .skip-link { display: none !important; }
  .app { margin: 0; }
  body { background: #fff; color: #000; font-size: 12px; }
  main { padding: 0; max-width: none; }
  .card { box-shadow: none; border: 0; padding: 0; }
  a { color: inherit; text-decoration: none; }
}

/* Punch list and approvals statuses */
.badge.done { background: var(--green-soft); color: var(--green); }
.badge.not_started { background: var(--neutral-soft); color: var(--muted); }
.badge.preparing { background: var(--blue-soft); color: var(--blue); }
.badge.submitted { background: var(--blue-soft); color: var(--blue); }
.badge.rejected { background: var(--red-soft); color: var(--red); }

/* Scrollbars ------------------------------------------------------------------------------- */
html { scrollbar-gutter: stable; }
* { scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent; }
::-webkit-scrollbar { width: 13px; height: 13px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--line-strong);
  border: 3px solid transparent;
  background-clip: content-box;
  border-radius: 99px;
}
::-webkit-scrollbar-thumb:hover { background: var(--faint); background-clip: content-box; }
::-webkit-scrollbar-corner { background: transparent; }
.sidebar::-webkit-scrollbar-thumb { background: var(--side-line); background-clip: content-box; }
.sidebar::-webkit-scrollbar-thumb:hover { background: var(--side-muted); background-clip: content-box; }

/* Motion and loading ----------------------------------------------------------------------- */
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes rise { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
main { animation: rise .2s ease; }
.messages li { animation: rise .2s ease; }

.item-row, .trade-card, .dash-item, .dept-row, .tabs a, .side-nav a, .side-links a, .kpi, .nudge {
  transition: background .12s ease, border-color .12s ease, color .12s ease;
}

.btn.is-loading, button.is-loading { pointer-events: none; opacity: .75; }
.btn.is-loading::after, button.is-loading::after {
  content: ""; width: 13px; height: 13px; border-radius: 50%;
  border: 2px solid currentColor; border-right-color: transparent;
  animation: spin .6s linear infinite;
}

#page-progress {
  position: fixed; top: 0; left: 0; height: 2px; width: 0; z-index: 80;
  background: var(--accent); opacity: 0; transition: width .25s ease, opacity .25s ease;
}
#page-progress.on { opacity: 1; }

/* Impersonation ("log in as") --------------------------------------------------------------- */
.impersonate-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: 8px clamp(14px, 1.2vw, 20px);
  background: var(--amber-soft); color: var(--amber);
  border-bottom: 1px solid color-mix(in srgb, var(--amber) 25%, transparent); font-size: .9rem;
}
.impersonate-bar form { margin: 0; }
.side-impersonate { display: flex; flex-direction: column; gap: 4px; padding: 4px 4px 8px; }
.side-impersonate label { display: flex; align-items: center; gap: .35rem; font-size: .68rem; text-transform: uppercase; letter-spacing: .06em; color: var(--side-muted); font-weight: 700; }
.side-impersonate select { width: 100%; min-height: 34px; padding: .3rem .5rem; border: 1px solid var(--side-line); border-radius: var(--radius-sm); background: var(--side-hover); color: var(--side-ink); }
.side-impersonate select option { color: #111; }

/* Modal popups ----------------------------------------------------------------------------- */
.modal {
  position: fixed; inset: 0; z-index: 70; display: grid; place-items: start center;
  padding: 6vh 16px; background: rgba(8, 12, 10, .5); overflow-y: auto;
}
.modal[hidden] { display: none; }
.modal-card {
  width: min(720px, 100%); background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow-lg); padding: 20px;
}
.modal-card .items { max-height: 60vh; overflow-y: auto; }
@media print { .modal { display: none !important; } }
