/* ============================================================
   thesun — interface styles
   Teal and sand on a near white ground, the Zorixo palette.
   ============================================================ */

:root {
  --bg: #f6faf8;
  --surface: #ffffff;
  --surface-2: #f0f6f3;
  --sidebar: #12201d;
  --sidebar-2: #1b2d29;
  --line: #e0eae5;
  --line-soft: #eef4f1;
  --ink: #12201d;
  --ink-2: #33473f;
  --soft: #556b63;
  --faint: #8aa096;
  --teal: #4ECDC4;
  --teal-deep: #1f8a7d;
  --teal-text: #14705f;
  --teal-soft: #e6f7f4;
  --sand: #FFE1A8;
  --sand-deep: #9a6b12;
  --sand-soft: #fff6e4;
  --red: #b3392a;
  --red-soft: #fbe9e6;
  --green: #1b7a45;
  --green-soft: #e8f7ee;
  --blue: #1d5fa8;
  --blue-soft: #eaf2fb;
  --purple: #6b3fa0;
  --purple-soft: #f2ecfb;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(18, 32, 29, .05), 0 12px 28px -20px rgba(18, 32, 29, .45);
  --display: 'Bricolage Grotesque', 'Archivo', system-ui, sans-serif;
  --body: 'IBM Plex Sans', system-ui, -apple-system, sans-serif;
  --mono: 'IBM Plex Mono', ui-monospace, Menlo, monospace;
}

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

body {
  font-family: var(--body);
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

[hidden] { display: none !important; }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.muted { color: var(--faint); }
.soft { color: var(--soft); }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.center { text-align: center; }
.grow { flex: 1; }
.stack { display: flex; flex-direction: column; gap: 1rem; }
.row { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- login ---------- */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: var(--sidebar); padding: 1.5rem; }
.login-card { background: #fff; border-radius: 18px; padding: 2.4rem; width: 400px; max-width: 100%; }
.login-card .logo { width: 52px; height: 52px; border-radius: 15px; background: var(--teal); color: var(--sidebar); display: flex; align-items: center; justify-content: center; margin-bottom: 1rem; }
.login-card h1 { font-family: var(--display); font-size: 1.5rem; }
.login-card p.sub { color: var(--faint); margin-bottom: 1.4rem; }
.hint { background: var(--teal-soft); border: 1px solid #cdeee7; border-radius: 10px; padding: .8rem .9rem; font-size: .78rem; color: var(--ink-2); margin-top: 1.1rem; line-height: 1.6; }
.err { color: var(--red); font-size: .84rem; margin-top: .6rem; min-height: 1.1rem; font-weight: 600; }

/* ---------- shell ---------- */
.app { display: flex; min-height: 100vh; }

.sidebar {
  width: 236px; flex-shrink: 0; background: var(--sidebar); color: #c3d2cc;
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.sb-brand { display: flex; gap: .7rem; align-items: center; padding: 1.1rem 1.2rem; border-bottom: 1px solid #27403a; }
.sb-logo { width: 38px; height: 38px; border-radius: 11px; background: var(--teal); color: var(--sidebar); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.sb-brand h1 { font-size: .95rem; color: #fff; font-family: var(--display); }
.sb-brand .sub { font-size: .6rem; letter-spacing: .1em; color: #7d938c; text-transform: uppercase; }
.sb-nav { flex: 1; padding: .8rem .7rem; }
.sb-group { font-size: .62rem; letter-spacing: .1em; text-transform: uppercase; color: #6f857e; margin: 1rem .6rem .3rem; font-weight: 700; }
.sb-link { display: flex; align-items: center; gap: .55rem; padding: .55rem .7rem; border-radius: 9px; font-size: .86rem; color: #bccac4; cursor: pointer; border: none; background: none; width: 100%; text-align: left; font-family: inherit; }
.sb-link:hover { background: var(--sidebar-2); color: #fff; }
.sb-link.active { background: var(--teal); color: var(--sidebar); font-weight: 700; }
.sb-link .ic { width: 1.1rem; text-align: center; opacity: .9; }
.sb-foot { padding: .9rem 1.2rem; border-top: 1px solid #27403a; font-size: .76rem; color: #7d938c; }
.sb-foot b { color: #dce6e2; display: block; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { min-height: 58px; display: flex; align-items: center; gap: 1rem; padding: .6rem 1.6rem; border-bottom: 1px solid var(--line); background: var(--bg); position: sticky; top: 0; z-index: 8; }
.content { padding: 1.5rem 1.6rem 3rem; flex: 1; }

.eyebrow { font-size: .68rem; letter-spacing: .12em; text-transform: uppercase; color: var(--teal-text); font-weight: 700; }
.page-title { font-family: var(--display); font-size: 1.6rem; font-weight: 800; letter-spacing: -.01em; }
.page-sub { color: var(--faint); margin-top: .15rem; margin-bottom: 1.2rem; }
.page-head { display: flex; align-items: flex-start; gap: 1rem; margin-bottom: 1.2rem; }
.page-head .actions { margin-left: auto; display: flex; gap: .5rem; flex-wrap: wrap; }

/* ---------- buttons ---------- */
.btn { border: 1px solid var(--line); background: #fff; border-radius: 9px; padding: .5rem .85rem; font-size: .84rem; font-weight: 600; cursor: pointer; font-family: inherit; color: var(--ink); white-space: nowrap; }
.btn:hover { background: var(--surface-2); }
.btn-teal { background: var(--teal-deep); color: #fff; border-color: var(--teal-deep); }
.btn-teal:hover { background: var(--teal-text); }
.btn-sm { padding: .3rem .6rem; font-size: .76rem; }
.btn-danger { color: var(--red); border-color: #f0d3ce; }
.btn-danger:hover { background: var(--red-soft); }
.btn-wide { width: 100%; padding: .7rem; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-link { border: none; background: none; color: var(--teal-text); font-weight: 600; cursor: pointer; padding: 0; font-family: inherit; font-size: inherit; text-decoration: underline; }

/* ---------- cards, grids ---------- */
.grid { display: grid; gap: 1rem; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.gauto { grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.2rem; }
.card.pad0 { padding: 0; overflow: hidden; }
.card-h { display: flex; justify-content: space-between; align-items: center; gap: .8rem; padding: .95rem 1.2rem; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.card-h h3 { font-family: var(--display); font-size: 1rem; font-weight: 700; }
.card-h .sub { font-size: .78rem; color: var(--faint); }
.card-b { padding: 1.2rem; }

.stat .v { font-family: var(--display); font-size: 1.7rem; font-weight: 800; line-height: 1.15; font-variant-numeric: tabular-nums; }
.stat .l { color: var(--faint); font-size: .8rem; margin-top: .2rem; }
.stat .d { font-size: .74rem; color: var(--soft); margin-top: .35rem; }
.stat.hot .v { color: var(--red); }
.stat.good .v { color: var(--green); }

/* ---------- pills ---------- */
.pill { display: inline-flex; align-items: center; gap: .3rem; padding: .18rem .6rem; border-radius: 99px; font-size: .71rem; font-weight: 700; white-space: nowrap; }
.pill.gray { background: #eef2f0; color: #566962; }
.pill.blue { background: var(--blue-soft); color: var(--blue); }
.pill.green { background: var(--green-soft); color: var(--green); }
.pill.amber { background: var(--sand-soft); color: var(--sand-deep); }
.pill.red { background: var(--red-soft); color: var(--red); }
.pill.teal { background: var(--teal-soft); color: var(--teal-text); }
.pill.purple { background: var(--purple-soft); color: var(--purple); }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
thead th { text-align: left; font-size: .68rem; text-transform: uppercase; letter-spacing: .06em; color: var(--faint); font-weight: 700; padding: .65rem 1.2rem; border-bottom: 1px solid var(--line); white-space: nowrap; background: var(--surface); }
tbody td { padding: .7rem 1.2rem; border-bottom: 1px solid var(--line-soft); font-size: .86rem; color: var(--ink-2); vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: #fafdfb; }
tbody tr.clickable { cursor: pointer; }
td.strong, th.strong { color: var(--ink); font-weight: 700; }
.row-actions { display: flex; gap: .35rem; justify-content: flex-end; }
.empty-row { padding: 2.6rem 1.2rem; text-align: center; color: var(--faint); }

/* ---------- filter bar (every list has one) ---------- */
.filters { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; margin-bottom: 1rem; }
.filters input, .filters select { border: 1px solid var(--line); border-radius: 9px; padding: .45rem .7rem; font-size: .84rem; font-family: inherit; background: #fff; color: var(--ink); }
.filters input[type="search"] { min-width: 230px; }
.filters .count { margin-left: auto; font-size: .78rem; color: var(--faint); }
.tabs { display: flex; gap: .25rem; flex-wrap: wrap; background: var(--surface-2); padding: .25rem; border-radius: 10px; }
.tab { border: none; background: none; padding: .38rem .7rem; border-radius: 8px; font-size: .8rem; font-weight: 600; color: var(--soft); cursor: pointer; font-family: inherit; }
.tab:hover { color: var(--ink); }
.tab.active { background: #fff; color: var(--ink); box-shadow: 0 1px 2px rgba(18,32,29,.12); }
.tab .n { color: var(--faint); font-weight: 600; margin-left: .25rem; }

/* ---------- forms ---------- */
/* Every text box and dropdown looks the same, inside a .field or not:
   in tables, next to a search, in a one-line row. */
input:not([type]), input[type="text"], input[type="number"], input[type="email"], input[type="date"],
input[type="search"], input[type="password"], input[type="tel"], input[type="url"], select, textarea {
  border: 1px solid var(--line); border-radius: 9px; padding: .5rem .7rem;
  font-size: .86rem; font-family: inherit; background: #fff; color: var(--ink); max-width: 100%;
}
input:not([type]):focus, input[type="text"]:focus, input[type="number"]:focus, input[type="email"]:focus, input[type="date"]:focus,
input[type="search"]:focus, input[type="password"]:focus, input[type="tel"]:focus, input[type="url"]:focus, select:focus, textarea:focus {
  outline: 2px solid var(--teal); outline-offset: -1px; border-color: transparent;
}
input:disabled, select:disabled, textarea:disabled { background: var(--surface-2); color: var(--soft); }
td input:not([type="checkbox"]):not([type="color"]):not([type="file"]), td select { padding: .38rem .6rem; font-size: .84rem; border-radius: 8px; }

.field { margin-bottom: .9rem; }
.field label { display: block; font-size: .78rem; font-weight: 600; color: var(--soft); margin-bottom: .25rem; }
.field input, .field select, .field textarea {
  width: 100%; border: 1px solid var(--line); border-radius: 9px; padding: .6rem .75rem;
  font-size: .88rem; font-family: inherit; background: #fff; color: var(--ink);
}
.field textarea { resize: vertical; min-height: 64px; }
.field input:focus, .field select:focus, .field textarea:focus { outline: 2px solid var(--teal); outline-offset: -1px; border-color: transparent; }
.field .help { font-size: .74rem; color: var(--faint); margin-top: .25rem; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 .9rem; }
.form-grid .span2 { grid-column: 1 / -1; }
.check { display: flex; align-items: center; gap: .5rem; font-size: .84rem; font-weight: 600; color: var(--ink-2); margin-bottom: .5rem; }
.check input { width: auto; accent-color: var(--teal-deep); }

/* ---------- the role tree ---------- */
.role-group { padding: .45rem 0; border-top: 1px solid var(--line); }
.role-group:first-child { border-top: 0; padding-top: 0; }
.role-opt.parent { font-weight: 700; color: var(--ink); }
.role-opt.full { font-weight: 700; }
.role-kids { border-left: 2px solid var(--line); padding-left: .7rem; }
/* greyed out because something ticked above already includes it */
.role-opt.covered { opacity: .55; }
.role-opt.covered span { text-decoration: underline dotted var(--line); }

/* ---------- timeline ---------- */
.tl { position: relative; padding-left: 1.9rem; }
.tl::before { content: ''; position: absolute; left: 8px; top: 8px; bottom: 8px; width: 2px; background: var(--line); }
.tl-item { position: relative; padding: .5rem 0; }
.tl-dot { position: absolute; left: -1.55rem; top: .7rem; width: 17px; height: 17px; border-radius: 50%; border: 3px solid var(--bg); }
.tl-item .nm { font-weight: 600; display: flex; gap: .4rem; align-items: center; flex-wrap: wrap; }
.tl-item .meta { font-size: .76rem; color: var(--faint); margin-top: .1rem; }

/* ---------- key value list ---------- */
.kv { display: flex; justify-content: space-between; gap: 1rem; padding: .45rem 0; border-bottom: 1px solid var(--line-soft); font-size: .86rem; }
.kv:last-child { border-bottom: none; }
.kv .k { color: var(--faint); }
.kv .v { font-weight: 600; text-align: right; }

/* ---------- banners ---------- */
.banner { background: var(--sand-soft); border: 1px solid #edd6a4; border-radius: 10px; padding: .7rem 1rem; font-size: .85rem; color: var(--sand-deep); margin-bottom: 1rem; display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; }
.banner.red { background: var(--red-soft); border-color: #f0cfc9; color: var(--red); }
.banner.green { background: var(--green-soft); border-color: #c4e6d1; color: var(--green); }
.banner.blue { background: var(--blue-soft); border-color: #cbdff5; color: var(--blue); }
.banner .grow { flex: 1; }

/* ---------- modal ---------- */
.modal-back { position: fixed; inset: 0; background: rgba(18, 32, 29, .45); display: flex; align-items: flex-start; justify-content: center; padding: 3rem 1rem; z-index: 40; overflow-y: auto; }
.modal { background: #fff; border-radius: 16px; width: 560px; max-width: 100%; box-shadow: var(--shadow); }
.modal.wide { width: 860px; }
.modal-h { display: flex; align-items: center; gap: .8rem; padding: 1.1rem 1.3rem; border-bottom: 1px solid var(--line); }
.modal-h h3 { font-family: var(--display); font-size: 1.1rem; font-weight: 700; }
.modal-b { padding: 1.3rem; max-height: 65vh; overflow-y: auto; }
.modal-f { display: flex; gap: .5rem; justify-content: flex-end; padding: .9rem 1.3rem; border-top: 1px solid var(--line); background: var(--surface-2); border-radius: 0 0 16px 16px; }
.icon-btn { border: none; background: none; font-size: 1.4rem; line-height: 1; color: var(--faint); cursor: pointer; padding: .1rem .3rem; }
.icon-btn:hover { color: var(--ink); }

/* ---------- toast ---------- */
.toast { position: fixed; bottom: 1.5rem; left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff; padding: .7rem 1.2rem; border-radius: 10px; font-size: .85rem; font-weight: 600; z-index: 60; opacity: 0; transition: opacity .2s; pointer-events: none; max-width: 90vw; }
.toast.show { opacity: 1; }
.toast.bad { background: var(--red); }

/* ---------- misc ---------- */
.bar { height: 8px; background: var(--surface-2); border-radius: 99px; overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--teal-deep); }
.chip-row { display: flex; gap: .4rem; flex-wrap: wrap; }
.chip { background: var(--surface-2); border: 1px solid var(--line); border-radius: 99px; padding: .2rem .65rem; font-size: .76rem; color: var(--ink-2); cursor: pointer; }
.chip.on { background: var(--teal-deep); border-color: var(--teal-deep); color: #fff; }
.thumb { width: 54px; height: 54px; border-radius: 9px; object-fit: cover; border: 1px solid var(--line); background: var(--surface-2); }
.file-row { display: flex; align-items: center; gap: .6rem; padding: .5rem 0; border-bottom: 1px solid var(--line-soft); font-size: .84rem; }
.file-row:last-child { border-bottom: none; }
.loading { padding: 2.5rem; text-align: center; color: var(--faint); }

@media (max-width: 1100px) {
  .g4, .g5 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .g3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
/* the menu button, only on a phone */
.menu-btn { display: none; background: none; border: 1px solid var(--line); border-radius: 8px;
  font-size: 1.1rem; line-height: 1; padding: .35rem .55rem; cursor: pointer; color: var(--ink); }

@media (max-width: 760px) {
  /* The floor works from a phone, so the work comes first and the menu
     folds away until it is asked for. */
  .app { flex-direction: column; }
  .menu-btn { display: inline-flex; }
  .sidebar { width: 100%; height: auto; position: static; display: none; }
  .app.menu-open .sidebar { display: block; }
  .sb-nav { display: flex; flex-wrap: wrap; gap: .3rem; }
  .sb-link { width: auto; }
  .sb-group { width: 100%; margin: .5rem .4rem .2rem; }
  .content { padding: 1rem .8rem 3rem; }
  .g2, .g3, .g4, .g5 { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .topbar { position: sticky; top: 0; z-index: 30; gap: .6rem; }
  .page-head { flex-direction: column; align-items: flex-start; gap: .6rem; }
  .page-head .actions { width: 100%; display: flex; flex-wrap: wrap; gap: .4rem; }

  /* A table is unreadable at this width, so each row becomes a card and
     each cell says which column it is. */
  .table-wrap:not(.tight) { overflow: visible; }
  .table-wrap:not(.tight) table, .table-wrap:not(.tight) thead, .table-wrap:not(.tight) tbody,
  .table-wrap:not(.tight) tr, .table-wrap:not(.tight) td { display: block; width: 100%; }
  .table-wrap:not(.tight) thead { display: none; }
  .table-wrap:not(.tight) tbody tr { border: 1px solid var(--line); border-radius: 10px; margin-bottom: .6rem;
    padding: .2rem .1rem; background: var(--surface); }
  .table-wrap:not(.tight) tbody td { border: none; display: flex; justify-content: space-between;
    align-items: baseline; gap: 1rem; padding: .32rem .7rem; text-align: left !important; }
  .table-wrap:not(.tight) tbody td::before { content: attr(data-label); color: var(--soft); font-size: .74rem;
    text-transform: uppercase; letter-spacing: .04em; flex: 0 0 8.5rem; }
  .table-wrap:not(.tight) tbody td:empty { display: none; }
  .table-wrap:not(.tight) tbody tr[data-group] td::before { content: none; }
  .table-wrap.tight { overflow-x: auto; }
  .table-wrap.tight td, .table-wrap.tight th { padding: .4rem .5rem; font-size: .86rem; }
  .row-actions { display: flex; flex-wrap: wrap; gap: .35rem; justify-content: flex-end; }
  .row-actions .btn { min-height: 2.1rem; }
  .empty-row { text-align: center !important; }
  .empty-row::before { content: none !important; }

  /* fingers, not a mouse */
  .btn, .chip, .tab { min-height: 2.2rem; }
  input, select, textarea { font-size: 16px; }   /* stops the phone zooming in */
  .filters { flex-wrap: wrap; }
  .filters input, .filters select { flex: 1 1 100%; }
}

/* an on/off switch, used for Published */
.switch { position: relative; display: inline-flex; align-items: center; gap: .45rem; cursor: pointer; font-size: .8rem; font-weight: 600; color: var(--ink-2); user-select: none; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch .track { width: 34px; height: 20px; border-radius: 99px; background: var(--line); position: relative; transition: background .15s; flex: none; }
.switch .track::after { content: ''; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.25); transition: transform .15s; }
.switch input:checked + .track { background: var(--teal-deep); }
.switch input:checked + .track::after { transform: translateX(14px); }
.switch input:focus-visible + .track { outline: 2px solid var(--teal-deep); outline-offset: 2px; }

/* a Delete in a modal footer sits on the left, away from Save */
.modal-f .btn-danger:first-child { margin-right: auto; }

/* a roster name or number: click to copy */
.copy-cell { cursor: copy; border-bottom: 1px dashed var(--line); }
.copy-cell:hover { color: var(--teal-deep, #0f6b63); border-bottom-color: currentColor; }

/* a size heading inside a roster or a grouped table */
tr[data-group] td { background: var(--surface-2); border-top: 1px solid var(--line); }
tr[data-group] td:first-child { letter-spacing: .04em; }

/* Every other size in a roster sits on a darker band, so the designer
   can see at a glance where one size finishes and the next starts. */
tr[data-band] td { background: var(--surface-2); }
