/* Foreman admin — one plain stylesheet, desktop-first, information-dense. */

:root {
  --ink: #1a1d21; --muted: #6b7280; --line: #e2e5e9; --line-soft: #f0f2f4;
  --bg: #f7f8fa; --surface: #fff; --surface-2: #fbfcfd; --hover: #f4f7fb;
  --chip: #eef0f3; --kbd: #eceef1; --grip: #b6bcc4;
  --accent: #1f6feb; --accent-strong: #1f6feb; --accent-bg: #eaf1fd;
  --accent-border: #c4d9f9; --accent-bg2: #e2ecfa;
  --danger: #c62828; --danger-bg: #fde3e1; --ok: #0a7d33; --ok-bg: #e2f3e8;
  --warn-bg: #fdf1dc;
  --toast-bg: #2b2f36; --overlay: rgba(15,18,22,.45); --shadow: rgba(0,0,0,.25);
  --red: #d3392f; --blue: #1f6feb; --green: #0a7d33; --orange: #e8710a;
  --purple: #7c3aed; --teal: #0d9488; --gray: #6b7280;
}
/* Night theme — set data-theme="dark" on <html> (a tiny head script does this
   before first paint, so there's no white flash). Only the variables change;
   every rule below reads them, so the whole app switches at once. */
[data-theme="dark"] {
  --ink: #e6e8eb; --muted: #99a2ad; --line: #2b3139; --line-soft: #242a32;
  --bg: #0f1216; --surface: #181c22; --surface-2: #1e232b; --hover: #232a33;
  --chip: #272d36; --kbd: #2a313b; --grip: #59626f;
  --accent: #4d9bff; --accent-strong: #2f6fd6; --accent-bg: #17304f;
  --accent-border: #2b4d72; --accent-bg2: #1b2d45;
  --danger: #d9463d; --danger-bg: #3a2020; --ok: #4ec877; --ok-bg: #153a23;
  --warn-bg: #3b2f16;
  --toast-bg: #2a313b; --overlay: rgba(0,0,0,.6); --shadow: rgba(0,0,0,.55);
  --red: #e0574d; --blue: #4d9bff; --green: #3fb865; --orange: #f0862a;
  --purple: #a07cf0; --teal: #2bb3a3; --gray: #8a929e;
  color-scheme: dark;
}
* { box-sizing: border-box; }
[x-cloak] { display: none !important; }
body {
  margin: 0; color: var(--ink); background: var(--bg);
  font: 13px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif;
}
h1 { font-size: 18px; margin: 0; } h2 { font-size: 15px; margin: 0; }
h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .04em;
     color: var(--muted); margin: 18px 0 6px; }
a { color: var(--accent); text-decoration: none; }
kbd { background: var(--kbd); border: 1px solid var(--line); border-radius: 3px;
      padding: 0 5px; font-size: 11px; }
.muted { color: var(--muted); } .strong { font-weight: 600; }
.hint { font-weight: normal; text-transform: none; letter-spacing: 0;
        color: var(--muted); font-size: 12px; }
.error { color: var(--danger); font-size: 12px; margin: 4px 0; }
.empty { color: var(--muted); text-align: center; padding: 24px !important; }

/* ---- top bar ---- */
.topbar {
  display: flex; align-items: center; gap: 14px; padding: 8px 16px;
  background: var(--surface); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 20;
}
.brand { font-weight: 700; font-size: 15px; color: var(--ink); margin-right: 4px; }
.ws-pills { display: flex; gap: 4px; }
.pill { padding: 3px 10px; border-radius: 99px; color: var(--ink);
        border: 1px solid transparent; }
.pill:hover { background: var(--bg); }
.pill-on { background: var(--accent-bg); border-color: var(--accent-border); color: var(--accent); }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%;
       margin-right: 5px; vertical-align: 1px; background: var(--gray); }
.dot-red { background: var(--red); } .dot-blue { background: var(--blue); }
.dot-green { background: var(--green); } .dot-orange { background: var(--orange); }
.dot-purple { background: var(--purple); } .dot-teal { background: var(--teal); }
.search { margin-left: auto; }
.search input { width: 220px; padding: 5px 9px; border: 1px solid var(--line);
                border-radius: 6px; background: var(--bg); }
.mainnav { display: flex; gap: 12px; }
.mainnav a { color: var(--ink); } .mainnav a.muted { color: var(--muted); }

/* ---- layout ---- */
.layout { display: flex; }
.content { flex: 1; min-width: 0; padding: 16px 20px; }
.page-head { display: flex; align-items: baseline; gap: 12px; margin-bottom: 10px; }

.panel { width: 0; transition: width .15s; background: var(--surface);
         border-left: 1px solid var(--line); overflow-y: auto;
         position: sticky; top: 41px; height: calc(100vh - 41px); }
/* JS adds .open whenever content lands in the panel — a class toggle works in
   every browser (the previous :has() selector silently failed in older ones,
   leaving the panel invisible). */
.panel.open { width: 440px; }
.panel-inner { padding: 14px 16px; }
.panel-head { display: flex; align-items: center; justify-content: space-between;
              gap: 8px; margin-bottom: 8px; }
.panel-foot { margin-top: 22px; border-top: 1px solid var(--line); padding-top: 12px; }
.back { font-size: 12px; }

/* ---- tables ---- */
table.dense { width: 100%; border-collapse: collapse; background: var(--surface);
              border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
table.dense.narrow { max-width: 560px; }
/* NOTE: no `position: sticky` here. A sticky header with top:41px floated down
   over the FIRST body row and hid it — that was the real cause of "Cascade
   Properties looks empty" (one project = the hidden first row) and "can't see
   Dustin" (first worker alphabetically). Plain headers show every row. */
table.dense th { text-align: left; font-size: 11px; text-transform: uppercase;
                 letter-spacing: .05em; color: var(--muted); font-weight: 600;
                 padding: 7px 10px; border-bottom: 1px solid var(--line);
                 background: var(--surface-2); }
table.dense th a { color: var(--muted); }
table.dense td { padding: 6px 10px; border-bottom: 1px solid var(--line-soft); }
tr.row { cursor: pointer; }
tr.row:hover { background: var(--hover); }
tr.row.kbd-selected { outline: 2px solid var(--accent); outline-offset: -2px; }
tr.row:focus { outline: 2px solid var(--accent); outline-offset: -2px; }

.tag { padding: 1px 8px; border-radius: 99px; font-size: 11px; color: #fff;
       background: var(--gray); }
.tag-red { background: var(--red); } .tag-blue { background: var(--blue); }
.tag-green { background: var(--green); } .tag-orange { background: var(--orange); }
.tag-purple { background: var(--purple); } .tag-teal { background: var(--teal); }
.tag-gray { background: var(--gray); }

.badge { padding: 1px 7px; border-radius: 4px; font-size: 11px; background: var(--chip); }
.badge-active { background: var(--ok-bg); color: var(--ok); }
.badge-paused { background: var(--warn-bg); color: var(--orange); }
.badge-done { background: var(--ok-bg); color: var(--ok); }
.badge-archived { background: var(--chip); color: var(--muted); }
.badge-blocked { background: var(--danger-bg); color: var(--danger); font-weight: 600; }
.badge-proposed { background: var(--warn-bg); color: var(--orange); }
.badge-approved { background: var(--ok-bg); color: var(--ok); }
.badge-sent { background: var(--chip); color: var(--muted); }

/* Worker-panel "Phone app" controls (magic link / revoke) */
.panel-sub { margin: 18px 0 6px; font-size: 13px; color: var(--muted); }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }
.copy-row { display: flex; gap: 6px; margin-top: 8px; }
.copy-row input { flex: 1; font-size: 12px; }

.chip { font-size: 11px; background: var(--chip); border-radius: 4px; padding: 0 6px; }
.chip-high { background: var(--danger-bg); color: var(--danger); }
.chip-low { background: var(--chip); color: var(--muted); }

/* ---- forms ---- */
.new-row { display: flex; gap: 6px; margin: 0 0 12px; flex-wrap: wrap; }
input, select, textarea, button {
  font: inherit; color: inherit; border: 1px solid var(--line);
  border-radius: 6px; padding: 5px 8px; background: var(--surface);
}
button { cursor: pointer; background: var(--accent-strong); color: #fff; border: 0; }
button:hover { filter: brightness(1.08); }
button.icon { background: transparent; color: var(--muted); padding: 2px 6px; }
button.icon:hover { color: var(--danger); }
button.danger { background: var(--danger); }
select.mini { padding: 1px 4px; font-size: 11px; }

.fields { display: grid; grid-template-columns: 130px 1fr; gap: 4px 10px; margin: 0; }
.fields dt { color: var(--muted); padding-top: 3px; }
.fields dd { margin: 0; }
.editable { border-bottom: 1px dashed transparent; cursor: text;
            display: inline-block; min-width: 40px; min-height: 17px; }
.editable:hover { border-bottom-color: var(--accent); background: var(--hover); }
.inline-form div { display: inline-block; }
.inline-form label { display: none; }
.inline-form textarea { width: 100%; }
.inline-actions button { padding: 3px 7px; }
.inline-form .errorlist { color: var(--danger); font-size: 11px; list-style: none;
                          margin: 2px 0 0; padding: 0; }

/* ---- task tree ---- */
.tree-head { display: flex; gap: 10px; align-items: baseline; }
ul.tree { list-style: none; margin: 0; padding-left: 0; min-height: 6px; }
ul.tree ul.tree { padding-left: 22px; }
.node-row { display: flex; align-items: center; gap: 7px; padding: 4px 6px;
            border-radius: 6px; border: 1px solid transparent; }
.node-row:hover { background: var(--hover); }
.node-name { cursor: pointer; font-weight: 500; }
.node-name:hover { color: var(--accent); }
.node-meta { margin-left: auto; display: flex; gap: 6px; align-items: center; }
.grip { cursor: grab; color: var(--grip); user-select: none; }
.node-row.drop-into { background: var(--accent-bg); border-color: var(--accent); }
.node-row.drop-before { box-shadow: 0 -2px 0 0 var(--accent); }
.node-row.drop-after { box-shadow: 0 2px 0 0 var(--accent); }
.add-task input { width: 100%; margin-top: 6px; background: var(--bg); }
.dep-list { list-style: none; padding: 0; margin: 4px 0; }
.dep-list li { padding: 2px 0; }
.dep-add { display: flex; gap: 6px; margin-top: 6px; }
.dep-add select { max-width: 260px; }
details.weather { margin: 14px 0; }
details.weather summary { cursor: pointer; color: var(--muted); }

.chip-worker { background: var(--accent-bg2); color: var(--accent); }
.add-task-more { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px;
                 align-items: center; }
.add-task-more textarea { width: 100%; }
.add-task-more .hours { display: flex; gap: 6px; align-items: center;
                        color: var(--muted); font-size: 12px; }
.add-task-more .hours input { width: 70px; }

.toast { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%);
         background: var(--toast-bg); color: #fff; padding: 10px 16px; border-radius: 8px;
         max-width: 560px; z-index: 60; box-shadow: 0 4px 18px var(--shadow);
         font-size: 13px; }

.theme-toggle { font-size: 15px; line-height: 1; }

/* ---- scheduling: at-risk, timeline, settings ---- */
.chip-risk { background: var(--danger-bg); color: var(--danger); font-weight: 600; }
.badge-risk { background: var(--danger-bg); color: var(--danger); font-weight: 600; }
.risk-text { color: var(--danger); font-weight: 600; }
.mini-link { font-size: 11px; font-weight: 500; text-transform: none; letter-spacing: 0; }
.plain-list { list-style: none; padding-left: 0; }
.plain-list li { padding: 2px 0; }

.gantt { position: relative; margin-top: 10px; border: 1px solid var(--line);
         border-radius: 8px; padding: 10px 0; background: var(--surface); overflow: hidden; }
.gantt-today { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--accent);
               z-index: 2; opacity: .8; }
.gantt-row { display: flex; align-items: center; height: 30px; }
.gantt-label { width: 190px; flex: none; padding: 0 10px; white-space: nowrap;
               overflow: hidden; text-overflow: ellipsis; cursor: pointer; font-weight: 500; }
.gantt-label:hover { color: var(--accent); }
.gantt-label.risk { color: var(--danger); }
.gantt-track { position: relative; flex: 1; height: 100%; border-left: 1px solid var(--line); }
.gantt-bar { position: absolute; top: 6px; height: 18px; background: var(--accent);
             border-radius: 4px; min-width: 8px; display: flex; align-items: center; }
.gantt-bar.risk { background: var(--danger); }
.gantt-date { color: #fff; font-size: 10px; padding: 0 6px; white-space: nowrap; }

.settings-form { max-width: 460px; display: flex; flex-direction: column; gap: 16px; }
.settings-form fieldset { border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; }
.settings-form legend { font-weight: 600; padding: 0 6px; }
.settings-form label { display: block; margin: 6px 0; }
.settings-form label.chk { display: inline-flex; align-items: center; gap: 6px;
                           margin-right: 14px; }
.settings-form input[type=number] { width: 80px; margin-left: 6px; }
.settings-form button { align-self: flex-start; }

/* ---- keyboard overlay ---- */
.keys-overlay { position: fixed; inset: 0; background: var(--overlay);
                display: flex; align-items: center; justify-content: center; z-index: 50; }
.keys-card { background: var(--surface); border-radius: 10px; padding: 18px 24px; min-width: 340px; }
.keys-card table td { padding: 4px 10px 4px 0; }

/* ---- login ---- */
.login-page { display: flex; align-items: center; justify-content: center;
              min-height: 100vh; }
.login-card { background: var(--surface); border: 1px solid var(--line); border-radius: 10px;
              padding: 28px 32px; width: 320px; display: flex;
              flex-direction: column; gap: 12px; }
.login-card h1 { text-align: center; }
.login-card label { display: flex; flex-direction: column; gap: 4px;
                    font-size: 12px; color: var(--muted); }
