/* EmotioHours
   Denomination follows audience: hours lead on person surfaces, units on
   business surfaces. Nothing shows a bare number without its unit. */

:root {
  --ground:      #f2f6f6;
  --surface:     #ffffff;
  --surface-2:   #e9f0ef;
  --ink:         #0f1e1d;
  --ink-2:       #3a514e;
  --muted:       #647975;
  --rule:        #d5e0de;
  --rule-2:      #b4c5c2;
  --accent:      #0f7d74;
  --accent-2:    #24bbb6;
  --accent-soft: #dff0ee;
  --over:        #b8442f;
  --over-soft:   #fbe9e5;
  --warn:        #96690f;
  --warn-soft:   #faf0d9;
  --ok:          #276f52;
  --ok-soft:     #e1f0e9;
  --on-accent:   #ffffff;
  --shadow: 0 1px 2px rgba(15,30,29,.05), 0 10px 26px -16px rgba(15,30,29,.24);
  --radius: 4px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ground:      #0a1312;
    --surface:     #111d1c;
    --surface-2:   #182625;
    --ink:         #e2eceb;
    --ink-2:       #b4c7c4;
    --muted:       #819894;
    --rule:        #223432;
    --rule-2:      #33514d;
    --accent:      #3ed0c9;
    --accent-2:    #24bbb6;
    --accent-soft: #0e2e2c;
    --over:        #e8846c;
    --over-soft:   #2a1712;
    --warn:        #d9a747;
    --warn-soft:   #29200f;
    --ok:          #5cbd90;
    --ok-soft:     #0f261c;
    --on-accent:   #08201e;
    --shadow: 0 1px 2px rgba(0,0,0,.4), 0 10px 26px -16px rgba(0,0,0,.7);
  }
}
:root[data-theme="dark"] {
  --ground:#0a1312; --surface:#111d1c; --surface-2:#182625;
  --ink:#e2eceb; --ink-2:#b4c7c4; --muted:#819894;
  --rule:#223432; --rule-2:#33514d;
  --accent:#3ed0c9; --accent-2:#24bbb6; --accent-soft:#0e2e2c;
  --over:#e8846c; --over-soft:#2a1712; --warn:#d9a747; --warn-soft:#29200f;
  --ok:#5cbd90; --ok-soft:#0f261c; --on-accent:#08201e;
  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 10px 26px -16px rgba(0,0,0,.7);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--ground);
  color: var(--ink);
  font: 15px/1.5 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.mono, .num, td.num, input[type="number"] {
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace;
  font-variant-numeric: tabular-nums;
}

h1,h2,h3 { margin: 0; text-wrap: balance; }
h2 { font-size: 1.18rem; letter-spacing: -.01em; }
h3 { font-size: .95rem; }
p  { margin: 0; }
a  { color: var(--accent); }

.hidden { display: none !important; }

/* ---------- chrome ---------- */

header.top {
  position: sticky; top: 0; z-index: 20;
  display: flex; flex-wrap: wrap; gap: 12px 20px; align-items: center;
  padding: 12px 22px;
  background: var(--surface);
  border-bottom: 1px solid var(--rule);
}

.brand { font-weight: 700; letter-spacing: -.02em; font-size: 1.02rem; }
.brand span { color: var(--accent); }

nav.tabs { display: flex; gap: 2px; flex-wrap: wrap; }
nav.tabs button {
  border: 0; background: none; color: var(--muted);
  font: inherit; font-size: .88rem; font-weight: 500;
  padding: 7px 13px; border-radius: var(--radius); cursor: pointer;
}
nav.tabs button:hover { background: var(--surface-2); color: var(--ink); }
nav.tabs button.on { background: var(--accent-soft); color: var(--accent); }

.spacer { margin-left: auto; }

main { padding: 22px; max-width: 1500px; margin: 0 auto; }
section.view { display: flex; flex-direction: column; gap: 20px; }

/* ---------- controls ---------- */

select, input[type="text"], input[type="number"], input[type="password"], input[type="time"] {
  font: inherit; font-size: .88rem;
  padding: 6px 9px;
  color: var(--ink); background: var(--surface);
  border: 1px solid var(--rule-2); border-radius: var(--radius);
}
select:focus-visible, input:focus-visible, button:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 1px;
}
input[type="number"] { width: 78px; text-align: right; }
.tick input[type="number"] {
  flex: 0 0 108px; width: 108px; height: auto;
  padding: 6px 10px; font-size: .9rem; text-align: right;
}
.tick input[type="number"]:disabled { opacity: .45; }
.tick { gap: 10px; }

.btn {
  font: inherit; font-size: .85rem; font-weight: 500;
  padding: 7px 13px; border-radius: var(--radius); cursor: pointer;
  border: 1px solid var(--rule-2); background: var(--surface); color: var(--ink);
}
.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.small { padding: 4px 9px; font-size: .78rem; }
.btn.danger:hover { border-color: var(--over); color: var(--over); }

/* ---------- cards ---------- */

.card {
  background: var(--surface); border: 1px solid var(--rule);
  border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden;
}
.card > header {
  display: flex; flex-wrap: wrap; gap: 8px 16px;
  align-items: baseline; justify-content: space-between;
  padding: 13px 18px; background: var(--surface-2); border-bottom: 1px solid var(--rule);
}
.card > header p { font-size: .82rem; color: var(--muted); }
.card .body { padding: 18px; display: flex; flex-direction: column; gap: 14px; }

/* ---------- stat row ---------- */

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(208px,1fr)); gap: 1px;
  background: var(--rule); border: 1px solid var(--rule); border-radius: var(--radius); overflow: hidden; }
.stat { background: var(--surface); padding: 16px 18px; display: flex; flex-direction: column; gap: 4px; }
.stat .k { font-size: .7rem; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); font-weight: 600; }
.stat .v { font-size: 1.6rem; font-weight: 600; letter-spacing: -.02em;
  font-family: ui-monospace, Menlo, monospace; font-variant-numeric: tabular-nums;
  display: flex; align-items: baseline; flex-wrap: wrap; }
/* the paired denomination — units lead, clock hours ride alongside */
.stat .v .alt { font-size: .95rem; font-weight: 500; color: var(--muted); letter-spacing: 0; }
.stat .v .sep { color: var(--rule-2); font-weight: 400; margin: 0 5px; }
.stat .s { font-size: .8rem; color: var(--muted); }
.stat.good .v { color: var(--ok); }
.stat.bad  .v { color: var(--over); }
.stat.warn .v { color: var(--warn); }

/* ---------- tables ---------- */

.scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .86rem; }
th, td { text-align: left; padding: 9px 13px; border-bottom: 1px solid var(--rule); }
thead th {
  font-size: .68rem; text-transform: uppercase; letter-spacing: .09em;
  color: var(--muted); font-weight: 600; white-space: nowrap;
  background: var(--surface-2); border-bottom: 1px solid var(--rule-2);
  position: sticky; top: 0;
}
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
tbody tr:hover { background: var(--surface-2); }
tr.group td {
  background: var(--surface-2); font-weight: 600; font-size: .74rem;
  text-transform: uppercase; letter-spacing: .09em; color: var(--muted);
}
tr.total td { font-weight: 600; background: var(--accent-soft); }
td .sub { display: block; font-size: .76rem; color: var(--muted); }
.linky { color: var(--accent); cursor: pointer; text-decoration: underline;
  text-underline-offset: 2px; background: none; border: 0; font: inherit; padding: 0; }

/* ---------- capacity table: the most-read thing on the page ---------- */

table.big { font-size: .95rem; }
table.big td { padding: 11px 14px; }
table.big td.spare { font-weight: 700; font-size: 1.02rem; }
table.big td.spare.pos { color: var(--ok); }
table.big td.spare.neg { color: var(--over); }

/* ---------- the sheet: one column per person ---------- */

table.sheet { font-size: .84rem; }
table.sheet th, table.sheet td { padding: 8px 10px; }
table.sheet td.ini {
  font-family: ui-monospace, Menlo, monospace; font-size: .74rem;
  color: var(--muted); font-weight: 600; text-align: center;
}
table.sheet th.person, table.sheet td.person {
  text-align: right; width: 62px;
  border-left: 1px solid var(--rule);
}
table.sheet th.person { font-size: .7rem; color: var(--ink-2); }
table.sheet th.person.gone { color: var(--over); text-decoration: line-through; }
table.sheet td.person b { font-weight: 600; }
table.sheet .nil { color: var(--rule-2); }
table.sheet td.name { min-width: 190px; }
table.sheet tr.hidden { display: none; }

/* ---------- archived + expandable rows ---------- */

tr.archived td { opacity: .5; }
tr.own td { background: var(--accent-soft); }
select:disabled, input:disabled { opacity: .4; cursor: not-allowed; }
tr.archived td:first-child::before { content: 'archived · '; font-size: .7rem; color: var(--muted); }
tr.hidden { display: none; }

tr.ct { cursor: pointer; }
tr.ct td.tw { width: 26px; text-align: center; color: var(--muted); }
tr.ct .caret { font-size: .8rem; }
tr.ct.open { background: var(--surface-2); }
tr.sub-row td { background: var(--surface-2); border-bottom-color: transparent; }
td.indent { padding-left: 26px; color: var(--ink-2); font-size: .84rem; }

/* ---------- pills ---------- */

.pill {
  display: inline-block; font-size: .68rem; font-weight: 600;
  letter-spacing: .05em; text-transform: uppercase;
  padding: 2px 7px; border-radius: 3px; white-space: nowrap;
  font-family: ui-monospace, Menlo, monospace;
}
.pill.ok   { background: var(--ok-soft);   color: var(--ok); }
.pill.bad  { background: var(--over-soft); color: var(--over); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.info { background: var(--accent-soft); color: var(--accent); }
.pill.mute { background: var(--surface-2); color: var(--muted); }

/* ---------- capacity bar ---------- */

.bar { height: 7px; border-radius: 4px; background: var(--surface-2); overflow: hidden; display: flex; min-width: 90px; }
.bar i { display: block; height: 100%; }
.bar i.used { background: var(--accent); }
.bar i.over { background: var(--over); }
.bar i.internal { background: var(--rule-2); }

/* ---------- banner ---------- */

.banner {
  display: flex; gap: 12px; align-items: flex-start;
  padding: 13px 16px; border-radius: var(--radius);
  border: 1px solid var(--rule); border-left: 3px solid var(--warn);
  background: var(--surface); font-size: .86rem; color: var(--ink-2);
}
.banner.bad { border-left-color: var(--over); }
.banner.info { border-left-color: var(--accent); }
.banner b { color: var(--ink); }

/* ---------- contract editor ---------- */

.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px,1fr)); gap: 16px; }
.rowline { display: flex; flex-wrap: wrap; gap: 9px; align-items: center; }
.rowline label { font-size: .8rem; color: var(--muted); min-width: 96px; }
.tick { display: flex; gap: 8px; align-items: center; font-size: .86rem; padding: 3px 0; }
.tick input[type="checkbox"] { width: 15px; height: 15px; accent-color: var(--accent); flex: 0 0 auto; }

.balance {
  display: flex; flex-wrap: wrap; gap: 10px 28px; align-items: baseline;
  padding: 14px 18px; border-radius: var(--radius);
  border: 1px solid var(--rule); border-left: 3px solid var(--ok); background: var(--surface);
}
.balance.bad { border-left-color: var(--over); }
.balance .k { font-size: .7rem; text-transform: uppercase; letter-spacing: .09em; color: var(--muted); font-weight: 600; }
.balance .v { font-size: 1.15rem; font-weight: 600;
  font-family: ui-monospace, Menlo, monospace; font-variant-numeric: tabular-nums; }
.balance .v.bad { color: var(--over); }
.balance .v.ok { color: var(--ok); }
.balance .item { display: flex; flex-direction: column; gap: 2px; }

/* ---------- schedule ---------- */

.weekgrid { display: flex; flex-direction: column; gap: 14px; }
.day { border: 1px solid var(--rule); border-radius: var(--radius); background: var(--surface); overflow: hidden; }
.day > h4 {
  margin: 0; padding: 8px 13px; font-size: .78rem; font-weight: 600;
  background: var(--surface-2); border-bottom: 1px solid var(--rule);
  display: flex; justify-content: space-between; color: var(--ink-2);
}
.blk {
  display: flex; gap: 12px; align-items: baseline;
  padding: 7px 13px; border-bottom: 1px solid var(--rule); font-size: .83rem;
}
.blk:last-child { border-bottom: 0; }
.blk .t { font-family: ui-monospace, Menlo, monospace; font-size: .78rem; color: var(--muted); white-space: nowrap; }
.blk.manual { border-left: 3px solid var(--warn); }
.blk select, .blk input { font-size: .8rem; padding: 4px 7px; }
.blk select.bDate { width: 118px; }
.blk input.bStart { width: 92px; }
.blk input.bH { width: 74px; }
.blk .lbl { flex: 1; min-width: 140px; }
.blk .m { margin-left: auto; font-family: ui-monospace, Menlo, monospace; font-size: .78rem; color: var(--muted); }
.blk.fixed { background: var(--accent-soft); }

/* ---------- login ---------- */

.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login-card {
  background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 34px; width: min(360px, 100%);
  display: flex; flex-direction: column; gap: 14px;
}
.login-card input { width: 100%; }
.err { color: var(--over); font-size: .85rem; }
.muted { color: var(--muted); font-size: .87rem; }

@media (max-width: 700px) {
  main { padding: 14px; }
  header.top { padding: 10px 14px; }
  .stat .v { font-size: 1.35rem; }
}

/* an internal booking that exceeds the utilisation allowance — it eats into
   sellable time, so it is called out where the hours are shown */
.sub.warn { color: var(--warn); }

/* ---- Time view ---------------------------------------------------------- */
.timerbar { display: flex; align-items: center; gap: 10px; padding: 12px 16px; margin-bottom: 16px; flex-wrap: wrap; }
.timerbar.running { border-color: var(--accent); }
.timerbar .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--accent); animation: tpulse 1.6s infinite; }
@keyframes tpulse { 50% { opacity: 0.3; } }
.seg { display: inline-flex; gap: 4px; }

tr.tblock.done td { opacity: 0.75; }
tr.tblock.skipped td { opacity: 0.45; text-decoration: line-through; }
tr.tentry.skip td { opacity: 0.5; }

.tpanel { position: fixed; right: 24px; bottom: 24px; width: 340px; z-index: 60;
  box-shadow: 0 12px 40px rgba(0,0,0,0.18); padding-bottom: 8px; }
.tpanel header { display: flex; justify-content: space-between; align-items: center; }
.tpanel .rowline { padding: 4px 16px; }

/* week calendar */
.tw-card { overflow: hidden; }
.tw-head { display: flex; border-bottom: 1px solid var(--rule); }
.tw-col-head { flex: 1; padding: 8px 10px; border-left: 1px solid var(--rule); }
.tw-col-head.today b { color: var(--accent); }
.tw-col-head .sub { display: block; }
.tw-scroll { max-height: 640px; overflow-y: auto; }
.tw-body { display: flex; }
.tw-gutter { width: 52px; flex: none; position: relative; }
.tw-hlabel { position: absolute; right: 8px; transform: translateY(-7px);
  font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
.tw-day { flex: 1; border-left: 1px solid var(--rule); min-width: 0; }
.tw-loose { padding: 4px; display: flex; flex-wrap: wrap; gap: 4px; }
.tw-chip { font-size: 11px; background: var(--accent-soft, #e3f4f3); color: var(--accent);
  border-radius: 4px; padding: 2px 6px; cursor: pointer; }
.tw-grid { position: relative; }
.tw-hour { position: absolute; left: 0; right: 0; border-top: 1px solid var(--rule); opacity: 0.6; }
.tw-ghost, .tw-entry { position: absolute; left: 3px; right: 3px; border-radius: 6px;
  padding: 3px 6px; font-size: 11px; line-height: 1.25; overflow: hidden; box-sizing: border-box; }
.tw-ghost { border: 1.5px dashed var(--muted); color: var(--muted); background: transparent; }
.tw-ghost.pending { border-color: var(--warn); color: var(--warn); cursor: grab; }
.tw-ghost.done, .tw-ghost.skipped { opacity: 0.35; }
.tw-ghost.skipped { text-decoration: line-through; cursor: pointer; }
.tw-ghost em, .tw-entry em { display: block; font-style: normal; font-weight: 600; }
.tw-entry { background: var(--accent); color: #fff; cursor: grab; z-index: 2;
  box-shadow: 0 1px 4px rgba(0,0,0,0.15); }
.tw-entry.timer { background: #4a7fb5; }
.tw-entry.manual { background: #6f8f4f; }
.tw-entry i { display: block; font-style: italic; opacity: 0.85;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tw-entry.dragging, .tw-ghost.dragging { opacity: 0.85; z-index: 10; cursor: grabbing;
  box-shadow: 0 8px 24px rgba(0,0,0,0.25); }
.tw-resize { position: absolute; left: 0; right: 0; bottom: 0; height: 8px; cursor: ns-resize; }

/* The Time view's control row. Not ".bar" — that is the 7px load meter, and
   borrowing its name squashed every control into a 7px strip. */
.tbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 10px 0 14px; position: sticky; top: 0; z-index: 15;
  background: var(--ground); }
.tbar b { white-space: nowrap; }

/* commit tick on a pending planned block, and the lock on settled days */
.tw-tick { position: absolute; top: 2px; right: 2px; z-index: 3;
  border: none; border-radius: 4px; background: var(--accent); color: #fff;
  width: 18px; height: 18px; font-size: 11px; line-height: 1; cursor: pointer;
  opacity: 0; transition: opacity .12s; }
.tw-ghost:hover .tw-tick { opacity: 1; }
.tw-entry.locked { cursor: pointer; opacity: 0.82;
  background: color-mix(in srgb, var(--accent) 70%, #555); }

.rebrow { display: flex; align-items: center; gap: 8px; padding: 4px 0; font-size: 13px; cursor: pointer; }
.rebrow span { flex: 1; }
.rebrow b { white-space: nowrap; font-variant-numeric: tabular-nums; }
