/* GTD 2 staff app. Colours are set once here and switch with the system theme. */

:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --raised: #fbfbfc;
  --text: #1b2330;
  --muted: #647084;
  --border: #dfe3ea;
  --accent: #2457c5;
  --accent-text: #ffffff;
  --danger: #b3261e;
  --shadow: 0 8px 30px rgba(20, 30, 50, .16);
  /* State colours: background then text. */
  --allocation-bg: #fff1cc; --allocation-fg: #6b4a00;
  --open-bg: #e7ebf2;       --open-fg: #37445a;
  --progress-bg: #dbe8ff;   --progress-fg: #173f93;
  --waiting-bg: #ffe0d6;    --waiting-fg: #8f2a0c;
  --verify-bg: #ecdfff;     --verify-fg: #4d2a91;
  --done-bg: #d9f2e1;       --done-fg: #175c33;
  --closed-bg: #e9e9ec;     --closed-fg: #4a4f5a;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12151b;
    --surface: #1a1e26;
    --raised: #20252f;
    --text: #e6e9ef;
    --muted: #97a1b3;
    --border: #2d3441;
    --accent: #6f9bff;
    --accent-text: #0c1322;
    --danger: #ff8a80;
    --shadow: 0 8px 30px rgba(0, 0, 0, .5);
    --allocation-bg: #4a3a0c; --allocation-fg: #ffdf8a;
    --open-bg: #2b3340;       --open-fg: #c5cfdf;
    --progress-bg: #1c3464;   --progress-fg: #b9d0ff;
    --waiting-bg: #5a2415;    --waiting-fg: #ffc2ae;
    --verify-bg: #3a2664;     --verify-fg: #d9c4ff;
    --done-bg: #173d27;       --done-fg: #a8e6bf;
    --closed-bg: #2c3038;     --closed-fg: #b8bdc8;
  }
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

h1 { font-size: 22px; margin: 0; display: flex; align-items: center; gap: 10px; }
h2 { font-size: 18px; margin: 0 0 8px; }
h3 { font-size: 12px; margin: 0 0 8px; text-transform: uppercase; letter-spacing: .05em;
     color: var(--muted); }
p { margin: 0 0 10px; }
a { color: var(--accent); }
small { color: var(--muted); display: block; }

.muted { color: var(--muted); }
.pre { white-space: pre-wrap; overflow-wrap: anywhere; }
.clip { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2;
        line-clamp: 2; overflow: hidden; overflow-wrap: anywhere; }
.boot, .empty { color: var(--muted); padding: 32px; text-align: center; }
.error-box { margin: 16px 0; padding: 12px 14px; border: 1px solid var(--danger);
             border-radius: 8px; color: var(--danger); background: var(--surface); }

/* ---- frame */

.shell { display: grid; grid-template-columns: 216px minmax(0, 1fr); height: 100vh; }

.side { display: flex; flex-direction: column; gap: 4px; padding: 14px 10px;
        background: var(--surface); border-right: 1px solid var(--border); overflow-y: auto; }
.brand { display: flex; align-items: center; gap: 9px; padding: 4px 8px 14px; font-size: 17px;
         font-weight: 650; color: var(--text); text-decoration: none; }
.brand img { width: 24px; height: 24px; }
.links { display: flex; flex-direction: column; gap: 2px; }
.links a { display: flex; align-items: center; justify-content: space-between; gap: 8px;
           padding: 8px 10px; border-radius: 7px; color: var(--text); text-decoration: none; }
.links a:hover { background: var(--bg); }
.links a.selected { background: var(--progress-bg); color: var(--progress-fg); font-weight: 600; }
.count { min-width: 22px; padding: 1px 7px; border-radius: 10px; background: var(--accent);
         color: var(--accent-text); font-size: 12px; font-weight: 600; text-align: center; }
.me { margin-top: auto; padding: 12px 8px 2px; border-top: 1px solid var(--border); }
.me-name { font-weight: 600; }
.me-links { display: flex; gap: 14px; margin-top: 8px; }

.main { overflow: auto; }
.outlet { padding: 22px 26px 60px; }

.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px;
             flex-wrap: wrap; margin-bottom: 12px; }
.head-actions { display: flex; gap: 8px; }
.description { max-width: 110ch; white-space: pre-wrap; overflow-wrap: anywhere; }
.meta-line { font-size: 13px; }
.filters { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 14px 0 10px; }
.filters input { width: min(340px, 100%); }

/* ---- controls */

.button { display: inline-flex; align-items: center; justify-content: center; padding: 7px 13px;
          border: 1px solid var(--border); border-radius: 7px; background: var(--surface);
          color: var(--text); font: inherit; font-weight: 550; text-decoration: none;
          cursor: pointer; white-space: nowrap; }
.button:hover { border-color: var(--accent); }
.button:disabled { opacity: .55; cursor: default; }
.button.primary { background: var(--accent); border-color: var(--accent);
                  color: var(--accent-text); }
.button.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.button.quiet { border-color: transparent; background: none; color: var(--muted); }
.button.wide { width: 100%; }
.button.link, button.link { padding: 0; border: 0; background: none; color: var(--accent);
                            font: inherit; cursor: pointer; text-align: left; }
.button.link:hover, button.link:hover { text-decoration: underline; }

input, select, textarea { padding: 7px 9px; border: 1px solid var(--border); border-radius: 7px;
                          background: var(--surface); color: var(--text); font: inherit;
                          max-width: 100%; }
textarea { width: 100%; resize: vertical; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

.keybadge { display: inline-block; padding: 2px 8px; border-radius: 6px; background: var(--open-bg);
            color: var(--open-fg); font-size: 12px; font-weight: 650; letter-spacing: .02em; }

.pill { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px;
        font-weight: 600; white-space: nowrap; background: var(--open-bg); color: var(--open-fg); }
.pill.s-allocation { background: var(--allocation-bg); color: var(--allocation-fg); }
.pill.s-in_progress { background: var(--progress-bg); color: var(--progress-fg); }
.pill.s-waiting { background: var(--waiting-bg); color: var(--waiting-fg); }
.pill.s-verify { background: var(--verify-bg); color: var(--verify-fg); }
.pill.s-complete { background: var(--done-bg); color: var(--done-fg); }
.pill.s-closed, .pill.s-cancelled { background: var(--closed-bg); color: var(--closed-fg); }
.flag { display: inline-block; margin-left: 6px; padding: 1px 6px; border: 1px solid
        var(--waiting-fg); border-radius: 5px; color: var(--waiting-fg); font-size: 11px; }
.chips { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.chip { display: inline-block; padding: 0 6px; border: 1px solid var(--border);
        border-radius: 5px; color: var(--muted); font-size: 11px; }

/* ---- lists page */

.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 14px; }
.card { display: flex; flex-direction: column; gap: 8px; padding: 14px 16px;
        border: 1px solid var(--border); border-radius: 10px; background: var(--surface);
        color: var(--text); text-decoration: none; }
.card:hover { border-color: var(--accent); }
.card-head { display: flex; align-items: center; gap: 9px; font-size: 15px; }
.card p { margin: 0; }
.counts { display: flex; flex-wrap: wrap; gap: 5px; }
.card-foot { margin-top: auto; font-size: 12px; }

/* ---- the items table */

.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 10px;
              background: var(--surface); }
table.items { width: 100%; border-collapse: collapse; font-size: 13px; }
.items th { position: sticky; top: 0; padding: 8px 10px; background: var(--raised);
            border-bottom: 1px solid var(--border); color: var(--muted); font-size: 11px;
            font-weight: 650; letter-spacing: .04em; text-align: left; text-transform: uppercase;
            white-space: nowrap; }
.items td { padding: 8px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
.items tr:last-child td { border-bottom: 0; }
.items .row { cursor: pointer; }
.items .row:hover, .items .row:focus-visible { background: var(--raised); }
.items .key { white-space: nowrap; font-weight: 600; }
.items .key small, .items .latest small { font-size: 11px; font-weight: 400; }
.items .task { min-width: 260px; max-width: 420px; padding-left: calc(10px + var(--depth, 0) * 20px); }
/* Long task text is cut to three lines here; the item panel shows all of it. */
.items .task-title { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 3;
                     line-clamp: 3; overflow: hidden; overflow-wrap: anywhere; }
.items .k-backlog .task-title { font-weight: 650; }
.items .step { margin-right: 5px; color: var(--muted); }
.items .state { white-space: nowrap; }
.items .who, .items .date, .items .num { white-space: nowrap; }
.items .num { text-align: right; font-variant-numeric: tabular-nums; }
.items .latest { min-width: 240px; max-width: 380px; }
.items .approval { max-width: 170px; color: var(--muted); }
.items .s-complete .task-title, .items .s-closed .task-title,
.items .s-cancelled .task-title { color: var(--muted); }
.items .s-cancelled .task-title { text-decoration: line-through; }
.items .act { white-space: nowrap; cursor: default; }
.row-actions { display: flex; gap: 6px; }

/* ---- running order */

.items .order { min-width: 44px; }
.items .position { color: var(--muted); }
.items .grip-cell { width: 36px; padding: 5px 0 5px 8px; cursor: default; }
.grip { display: inline-flex; align-items: center; justify-content: center; width: 28px;
        height: 28px; border: 1px solid transparent; border-radius: 6px; background: none;
        color: var(--muted); font-size: 15px; line-height: 1; cursor: grab;
        touch-action: none; }
.grip:hover, .grip:focus-visible { border-color: var(--border); color: var(--text); }
.items tr.dragging { opacity: .45; }
.items tr.drop-before td { box-shadow: inset 0 3px 0 var(--accent); }
.items tr.drop-after td { box-shadow: inset 0 -3px 0 var(--accent); }
.reordering, .reordering .grip { cursor: grabbing; user-select: none; }

/* ---- item panel */

.panel { position: fixed; top: 0; right: 0; bottom: 0; width: min(620px, 100%); overflow-y: auto;
         background: var(--surface); border-left: 1px solid var(--border);
         box-shadow: var(--shadow); z-index: 5; }
.panel[hidden] { display: none; }
.panel-body { padding: 16px 20px 60px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.panel-body h2 { overflow-wrap: anywhere; }
.state-line { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.actions { display: flex; flex-wrap: wrap; gap: 7px; margin: 10px 0; }
.facts { display: grid; grid-template-columns: max-content 1fr; gap: 6px 14px; margin: 14px 0;
         padding: 12px 14px; border: 1px solid var(--border); border-radius: 9px;
         background: var(--raised); }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; overflow-wrap: anywhere; }
.facts select { padding: 3px 6px; }
.panel section { margin-top: 20px; }
.steps, .events { margin: 0 0 10px; padding: 0; list-style: none; }
.steps li { padding: 4px 0; }
.event { padding: 9px 0; border-top: 1px solid var(--border); }
.event:first-child { border-top: 0; }
.event.e-status .pre { color: var(--muted); }
.event.e-rejection .pre { color: var(--danger); }

.flow-steps { margin: 0 0 10px; padding-left: 22px; }
.flow-steps li { padding: 4px 0 4px 6px; }
.flow-steps li.here { border-left: 3px solid var(--progress-fg); padding-left: 8px;
                      margin-left: -5px; }
.chip.flow { border-color: var(--progress-fg); color: var(--progress-fg); }
.facts.payload { margin: 8px 0 10px; }
.clip2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
         overflow: hidden; }

.request { margin-bottom: 10px; padding: 11px 13px; border: 1px solid var(--border);
           border-radius: 9px; background: var(--raised); }
.request.open { border-color: var(--waiting-fg); }
.request .outcome { margin-top: 6px; font-weight: 550; }
.request-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.stack { display: flex; flex-direction: column; gap: 4px; max-width: 760px; }
.card-like { background: var(--surface); }

/* ---- agents page */

.agent { margin: 18px 0 30px; }
.agent-head { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.agent-head h2 { margin: 0; }
.agent .counts { margin: 8px 0; }

/* ---- dialogs, toasts, sign-in */

.dialog { width: min(560px, calc(100% - 24px)); padding: 0; border: 1px solid var(--border);
          border-radius: 12px; background: var(--surface); color: var(--text);
          box-shadow: var(--shadow); }
.dialog::backdrop { background: rgba(10, 15, 25, .45); }
.dialog form { display: flex; flex-direction: column; gap: 12px; padding: 20px 22px; }
.field { display: flex; flex-direction: column; gap: 4px; }
.field .label { font-weight: 600; }
.field.check { flex-direction: row; align-items: center; gap: 8px; }
.form-error { margin: 0; color: var(--danger); font-weight: 550; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }

.toast { position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%); z-index: 20;
         max-width: min(560px, calc(100% - 24px)); padding: 10px 16px; border-radius: 9px;
         background: var(--text); color: var(--bg); box-shadow: var(--shadow); }
.toast.error { background: var(--danger); color: #fff; }

.signin { display: flex; flex-direction: column; align-items: stretch; gap: 10px;
          width: min(380px, calc(100% - 32px)); margin: 12vh auto 0; padding: 28px;
          border: 1px solid var(--border); border-radius: 14px; background: var(--surface);
          text-align: center; }
.signin h1 { justify-content: center; }
.signin-icon { width: 44px; height: 44px; margin: 0 auto; }
.profiles { display: flex; flex-direction: column; gap: 8px; }
.notice { padding: 10px 12px; border-radius: 8px; background: var(--allocation-bg);
          color: var(--allocation-fg); text-align: left; }

/* ---- online or offline, capture, files */

.net { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; margin-bottom: 10px;
       font-size: 12px; color: var(--muted); }
.net .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--done-fg); }
.net.off .dot { background: var(--waiting-fg); }
.net.off { color: var(--waiting-fg); font-weight: 600; }
.net a { flex-basis: 100%; }
.net.trouble a { color: var(--danger); font-weight: 600; }
.banner { padding: 9px 26px; background: var(--waiting-bg); color: var(--waiting-fg);
          font-weight: 550; }
.banner[hidden] { display: none; }

.capture { display: flex; flex-wrap: wrap; gap: 8px; margin: 14px 0 18px; }
.capture input[type="text"] { flex: 1 1 280px; padding: 10px 12px; font-size: 16px; }
.button.listening { border-color: var(--danger); color: var(--danger); }
.button.small { padding: 3px 9px; font-size: 12px; }
.unsent { margin-bottom: 16px; padding: 10px 14px; border: 1px dashed var(--waiting-fg);
          border-radius: 9px; }
.flag.calm { border-color: var(--muted); color: var(--muted); }

.files { margin: 0 0 10px; padding: 0; list-style: none; }
.files li { display: flex; align-items: center; gap: 10px; padding: 6px 0;
            border-top: 1px solid var(--border); }
.files li:first-child { border-top: 0; }
.file-name { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.thumb { display: block; width: 56px; height: 56px; border: 1px solid var(--border);
         border-radius: 6px; object-fit: cover; }
.scan-video { width: 100%; max-height: 50vh; border-radius: 8px; background: #000; }

/* ---- narrow screens: the menu moves to the top */

@media (max-width: 820px) {
  .shell { grid-template-columns: 1fr; grid-template-rows: auto minmax(0, 1fr); }
  .side { flex-direction: row; align-items: center; gap: 8px; padding: 8px 10px;
          border-right: 0; border-bottom: 1px solid var(--border); overflow-x: auto; }
  .brand { padding: 0 6px 0 2px; }
  .links { flex-direction: row; }
  .links a { white-space: nowrap; }
  .me { margin: 0 0 0 auto; padding: 0 4px; border: 0; white-space: nowrap; }
  .me-name, .me .muted { display: none; }
  .me { display: flex; align-items: center; gap: 10px; }
  .net { margin: 0; flex-wrap: nowrap; }
  .net a { flex-basis: auto; }
  .banner { padding: 8px 12px; }
  .me-links { margin: 0; }
  .outlet { padding: 16px 12px 60px; }
}

.config-page { max-width: 820px; }
.config-page .card h2 { margin: 0; }
.https-instructions li { margin-bottom: 12px; }
.https-certificate-details { margin-top: 20px; }
.https-certificate-details code { overflow-wrap: anywhere; }
