/* =====================================================================
   Studio Planner - Flat Design
   Teal primary + orange accent, no shadows, no gradients, hairline
   borders, 3-4px radii, 150ms transitions, dense dashboard spacing.
   ===================================================================== */

/* ---------------------------------------------------------- tokens ---- */
:root {
  --bg:        #eef6f5;
  --surface:   #ffffff;
  --surface-2: #f2f7f7;
  --surface-3: #e4eeed;
  --line:      #d5e3e1;
  --line-2:    #b9d3d0;
  --ink:       #000000;
  --ink-2:     #2e2e2e;
  --muted:     #4a4a4a;
  --placeholder: #5f5f5f;

  --primary:     #0f766e;
  --primary-ink: #ffffff;
  --primary-700:  #115e59;
  --primary-dim: #d6f2ef;
  --accent:      #c2410c;
  --accent-ink:  #ffffff;
  --accent-dim:  #fdeadf;
  --good:        #0f8a5f;
  --good-dim:    #d9f2e7;
  --warn:        #b45309;
  --warn-dim:    #fbeeda;
  --bad:         #dc2626;
  --bad-dim:     #fbe3e3;

  --r:    4px;
  --r-sm: 3px;
  --r-lg: 6px;
  --h:    34px;
  --t:    150ms;

  --sans: "Plus Jakarta Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;

  /* dense / dashboard spacing scale (8-32) */
  --s1: 4px;  --s2: 8px;  --s3: 12px; --s4: 16px; --s5: 24px; --s6: 32px;
  --side-w: 208px;
  --veil: rgba(15, 23, 28, .45);
}

/* Dark: near-neutral greys with a faint cool cast. Tinting the whole surface
   teal turned everything muddy green - the teal belongs on the accents only. */
html[data-theme="dark"] {
  --bg:        #0e1113;
  --surface:   #15181c;
  --surface-2: #1b1f24;
  --surface-3: #23282e;
  --line:      #262b31;
  --line-2:    #363c44;
  --ink:       #ffffff;
  --ink-2:     #dcdcdc;
  --muted:     #b8b8b8;
  --placeholder: #9a9a9a;

  --primary:     #2dd4bf;
  --primary-ink: #05201d;
  --primary-700: #5ae3d2;
  --primary-dim: #10312e;
  --accent:      #fb923c;
  --accent-ink:  #2a1505;
  --accent-dim:  #33230f;
  --good:        #34d399;
  --good-dim:    #102d24;
  --warn:        #fbbf24;
  --warn-dim:    #322915;
  --bad:         #f87171;
  --bad-dim:     #341e1e;
  --veil: rgba(0, 0, 0, .62);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 13.5px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
.ico { flex: none; display: block; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; border-radius: var(--r-sm); }
::selection { background: var(--primary); color: var(--primary-ink); }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--line-2); }
::-webkit-scrollbar-track { background: transparent; }

/* ----------------------------------------------------------- shell ---- */
.shell { display: grid; grid-template-columns: var(--side-w) 1fr; min-height: 100vh; }

.side {
  background: var(--surface);
  border-right: 1px solid var(--line);
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh; z-index: 50;
}
.sbrand {
  display: flex; align-items: center; gap: var(--s2);
  padding: 0 var(--s3); height: 52px;
  border-bottom: 1px solid var(--line); flex: none;
}
.slogo {
  width: 26px; height: 26px; flex: none;
  background: var(--primary); color: var(--primary-ink);
  display: grid; place-items: center; border-radius: var(--r);
}
.sname { font-weight: 700; font-size: 14px; letter-spacing: -.02em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sbrand .sclose { display: none; margin-left: auto; }

.snav { padding: var(--s2); display: flex; flex-direction: column; gap: 1px; overflow-y: auto; flex: 1; }
.tab {
  display: flex; align-items: center; gap: 10px;
  background: none; border: 0; color: var(--ink-2);
  padding: 8px 10px; border-radius: var(--r); cursor: pointer;
  font: inherit; font-size: 13px; font-weight: 500; text-align: left; width: 100%;
  transition: background var(--t), color var(--t);
}
.tab .ico { opacity: .72; }
.tab:hover { background: var(--surface-2); color: var(--ink); }
.tab.on { background: var(--primary); color: var(--primary-ink); font-weight: 600; }
.tab.on .ico { opacity: 1; }

.sfoot { padding: var(--s2); border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: var(--s2); flex: none; }
.who {
  display: flex; align-items: center; gap: var(--s2); min-width: 0;
  padding: 6px 8px; border-radius: var(--r); cursor: default;
  border: 1px solid var(--line);
}
.wav {
  width: 22px; height: 22px; flex: none; border-radius: var(--r-sm);
  background: var(--primary); color: var(--primary-ink);
  display: grid; place-items: center; font-size: 10px; font-weight: 700;
}
.wtxt { min-width: 0; font-size: 12.5px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.iconbtn {
  width: 30px; height: 30px; flex: none;
  display: grid; place-items: center; cursor: pointer;
  background: none; border: 1px solid var(--line); border-radius: var(--r);
  color: var(--ink-2); transition: background var(--t), color var(--t), border-color var(--t);
}
.iconbtn:hover { background: var(--surface-2); color: var(--ink); border-color: var(--line-2); }
.topbar .menubtn { display: none; }
.sideveil { display: none; }

/* main column */
.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; gap: var(--s3);
  height: 52px; padding: 0 var(--s4);
  background: var(--surface); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 30;
}
.ptitle { margin: 0; font-size: 15px; font-weight: 700; letter-spacing: -.02em; }
.topbar .counts { margin-left: auto; }
.counts { color: var(--muted); font-size: 12px; }

.filterbar {
  display: flex; gap: var(--s2); align-items: center; flex-wrap: wrap;
  padding: var(--s2) var(--s4);
  background: var(--surface); border-bottom: 1px solid var(--line);
}
.searchwrap { position: relative; display: flex; align-items: center; }
.searchwrap .ico { position: absolute; left: 9px; color: var(--muted); pointer-events: none; }
.searchwrap .inp { padding-left: 30px; width: 210px; }

main#app { padding: var(--s4); flex: 1; min-width: 0; }

/* --------------------------------------------------------- controls --- */
.inp, select.inp, textarea.inp {
  background: var(--surface); color: var(--ink);
  border: 1px solid var(--line); border-radius: var(--r-sm);
  height: var(--h); padding: 0 10px;
  font: inherit; font-size: 13px; outline: none; min-width: 0;
  transition: border-color var(--t);
}
select.inp {
  appearance: none; padding-right: 26px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%234a4a4a' stroke-width='2.5' stroke-linecap='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 8px center;
}
html[data-theme="dark"] select.inp {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23b8b8b8' stroke-width='2.5' stroke-linecap='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
}
.inp::placeholder { color: var(--placeholder); }
.inp:hover { border-color: var(--line-2); }
.inp:focus { border-color: var(--primary); }
textarea.inp { width: 100%; resize: vertical; min-height: 80px; height: auto; padding: 8px 10px; line-height: 1.55; }
input[type=color].inp { padding: 2px; width: 40px; cursor: pointer; }
input[type=checkbox], input[type=radio] { accent-color: var(--primary); width: 15px; height: 15px; }

label { display: block; font-size: 12px; font-weight: 600; color: var(--ink-2); margin-bottom: var(--s3); }
label > .inp, label > input, label > select, label > textarea { width: 100%; margin-top: 5px; font-weight: 400; }

.btn {
  background: var(--surface); color: var(--ink);
  border: 1px solid var(--line); border-radius: var(--r-sm);
  height: var(--h); padding: 0 12px;
  font: inherit; font-size: 13px; font-weight: 600; cursor: pointer;
  white-space: nowrap;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  transition: background var(--t), border-color var(--t), color var(--t);
}
.btn:hover { background: var(--surface-2); border-color: var(--line-2); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
.btn.primary:hover { background: var(--primary-700); border-color: var(--primary-700); }
.btn.accent { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--ink-2); }
.btn.ghost:hover { background: var(--surface-2); color: var(--ink); border-color: transparent; }
.btn.danger { background: transparent; border-color: transparent; color: var(--bad); }
.btn.danger:hover { background: var(--bad-dim); }
.btn.block { width: 100%; }
.btn.sm { height: 27px; padding: 0 9px; font-size: 12px; gap: 5px; }
.btn[disabled] { opacity: .45; pointer-events: none; }

.row { display: flex; gap: var(--s3); align-items: center; flex-wrap: wrap; }
.row.tight { gap: var(--s1); }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: var(--s3); }
.grid3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: var(--s3); }
.cardgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: var(--s3); align-items: start; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: var(--s4); }
.card.struct { padding: 0; overflow: hidden; display: flex; flex-direction: column; }
.card.struct > .pad { padding: var(--s3) var(--s4); }

h2.vh { margin: 0 0 2px; font-size: 17px; font-weight: 700; letter-spacing: -.02em; }
p.vsub { margin: 0 0 var(--s4); color: var(--muted); font-size: 12.5px; max-width: 74ch; }
.sectionhead { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--s3); margin-bottom: var(--s3); flex-wrap: wrap; }
.sectionhead .vsub { margin-bottom: 0; }
.empty { text-align: center; color: var(--muted); padding: 48px 24px; border: 1px dashed var(--line-2); border-radius: var(--r); background: var(--surface); }
.empty h3 { color: var(--ink); margin: 0 0 4px; font-size: 15px; font-weight: 700; }

/* card internals */
.chead { display: flex; align-items: center; gap: 10px; padding: var(--s3) var(--s4); border-bottom: 1px solid var(--line); }
.chead .ttl { flex: 1; min-width: 0; }
.chead .ttl b { display: block; font-size: 14px; font-weight: 700; letter-spacing: -.015em; }
.chead .ttl .sub { color: var(--muted); font-size: 11.5px; margin-top: 1px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chead .acts { display: flex; gap: var(--s1); flex: none; }

.statgrid { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; border-bottom: 1px solid var(--line); background: var(--surface-2); }
.statgrid > div { padding: 9px 12px; border-right: 1px solid var(--line); }
.statgrid > div:last-child { border-right: 0; }
.statgrid .n { font-size: 17px; font-weight: 700; letter-spacing: -.03em; font-variant-numeric: tabular-nums; line-height: 1.2; }
.statgrid .n.late { color: var(--bad); }
.statgrid .n.zero { color: var(--muted); font-weight: 600; }
.statgrid .l { font-size: 9.5px; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); font-weight: 700; margin-top: 2px; }

.seclabel { font-size: 9.5px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 700; margin-bottom: var(--s2); }
.cfoot { margin-top: auto; padding: 10px var(--s4); border-top: 1px solid var(--line); background: var(--surface-2); }

.planrow { border: 1px solid var(--line); border-radius: var(--r-sm); padding: 10px; margin-bottom: var(--s2); }
.planrow:last-child { margin-bottom: 0; }
.prtop { display: flex; align-items: center; gap: var(--s2); margin-bottom: var(--s2); }
.prtop b { font-size: 12.5px; font-weight: 700; }
.prtop .acts { margin-left: auto; display: flex; gap: 2px; flex: none; }
.prchips { display: flex; flex-wrap: wrap; gap: var(--s1); }
.prchip {
  display: inline-flex; align-items: center; gap: 5px;
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: var(--r-sm); padding: 2px 7px; font-size: 11.5px; color: var(--ink-2);
}
.prchip b { font-weight: 700; color: var(--ink); }
.prchip .day { color: var(--muted); }
.prdate { font-size: 11.5px; color: var(--muted); margin-top: var(--s2); }
.caprow { display: flex; align-items: center; gap: var(--s2); font-size: 12px; color: var(--ink-2); }
.caprow .bar { flex: 1; }

/* -------------------------------------------------------- calendar ---- */
.calhead { display: flex; align-items: center; gap: var(--s1); margin-bottom: var(--s3); flex-wrap: wrap; }
.calhead h2 { margin: 0 var(--s2); font-size: 16px; font-weight: 700; min-width: 168px; letter-spacing: -.02em; }
.cal {
  display: grid; grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 1px; background: var(--line);
  border: 1px solid var(--line); border-radius: var(--r); overflow: hidden;
}
.caldow {
  text-align: center; font-size: 9.5px; letter-spacing: .09em; text-transform: uppercase;
  font-weight: 700; color: var(--muted); padding: 7px 0; background: var(--surface);
}
.calcell { background: var(--surface); min-height: 118px; padding: 5px; display: flex; flex-direction: column; gap: 3px; }
.calcell.weekend, .calcell.out { background: var(--surface-2); }
.calcell.out .caldate { opacity: .38; }
.calcell.out .chip { opacity: .5; }
.calcell.holiday { background: repeating-linear-gradient(135deg, var(--surface-2), var(--surface-2) 6px, var(--surface-3) 6px, var(--surface-3) 12px); }
.calcell.drop { background: var(--primary-dim); box-shadow: inset 0 0 0 2px var(--primary); }
.caldate { display: flex; align-items: center; justify-content: space-between; font-size: 11.5px; color: var(--ink-2); min-height: 19px; }
.caldate .n { font-weight: 700; font-variant-numeric: tabular-nums; padding-left: 2px; }
.calcell.today .caldate .n {
  background: var(--primary); color: var(--primary-ink);
  min-width: 19px; height: 19px; border-radius: var(--r-sm);
  display: grid; place-items: center; font-size: 11px; padding: 0;
}
.caldate .add {
  opacity: 0; border: 0; background: none; color: var(--muted);
  cursor: pointer; padding: 1px; border-radius: var(--r-sm); display: grid; place-items: center;
  transition: opacity var(--t), color var(--t);
}
.calcell:hover .add { opacity: 1; }
.caldate .add:hover { color: var(--primary); }

.chip {
  --c: var(--muted);
  display: flex; align-items: center; gap: 5px;
  padding: 3px 5px 3px 3px; border-radius: var(--r-sm); cursor: pointer;
  background: color-mix(in srgb, var(--c) 13%, var(--surface));
  border-left: 3px solid var(--c);
  font-size: 11.5px; line-height: 1.3;
  transition: background var(--t);
}
.chip:hover { background: color-mix(in srgb, var(--c) 26%, var(--surface)); }
.chip.sel { box-shadow: inset 0 0 0 2px var(--accent); }
.chip .ct { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.chip .dot { width: 6px; height: 6px; border-radius: 50%; flex: none; }
.chip .av { width: 16px; height: 16px; border-radius: var(--r-sm); flex: none; font-size: 8px; font-weight: 700; color: rgba(0,0,0,.72); display: grid; place-items: center; }
.chip.done .ct { text-decoration: line-through; opacity: .55; }
.chip .av.more2 { background: var(--surface-3); color: var(--ink-2); }
.more { font-size: 10.5px; color: var(--muted); cursor: pointer; padding: 1px 4px; font-weight: 600; }
.more:hover { color: var(--primary); }

.mono {
  flex: none; display: grid; place-items: center;
  width: 18px; height: 18px; border-radius: var(--r-sm);
  font-size: 8.5px; font-weight: 800; color: #fff;
}
.mono.lg { width: 32px; height: 32px; border-radius: var(--r); font-size: 12px; }

/* ------------------------------------------------------------ board --- */
.board { display: flex; gap: var(--s2); overflow-x: auto; padding-bottom: var(--s2); align-items: flex-start; }
.bcol {
  background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r);
  width: 268px; flex: none; display: flex; flex-direction: column; max-height: calc(100vh - 210px);
}
.bcol.drop { background: var(--primary-dim); box-shadow: inset 0 0 0 2px var(--primary); }
.bchead { padding: 9px 11px; display: flex; align-items: center; gap: var(--s2); position: sticky; top: 0; background: inherit; z-index: 1; }
.bchead .nm { font-weight: 700; font-size: 12px; }
.bchead .ct2 { margin-left: auto; color: var(--ink-2); font-size: 11px; font-weight: 700; background: var(--surface); padding: 0 6px; border-radius: var(--r-sm); font-variant-numeric: tabular-nums; }
.bcbody { padding: 0 8px 8px; display: flex; flex-direction: column; gap: var(--s1); overflow-y: auto; }
.bcbody > * { flex: 0 0 auto; }
.bcard { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-sm); padding: 0; cursor: pointer; overflow: hidden; transition: border-color var(--t); }
.bcard:hover { border-color: var(--line-2); }
.bcard .bctop { display: flex; align-items: center; gap: 6px; padding: 8px 9px 0; font-size: 10.5px; color: var(--muted); font-weight: 600; }
.bcard .bctop .cn { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bcard .t { font-size: 12.5px; font-weight: 600; line-height: 1.35; padding: 5px 9px 9px; }
.bcard .meta { display: flex; align-items: center; gap: 6px; font-size: 10.5px; color: var(--muted); padding: 6px 9px; border-top: 1px solid var(--line); background: var(--surface-2); }
.bcard.late .meta .d { color: var(--bad); font-weight: 700; }
.prio { font-size: 9px; font-weight: 800; letter-spacing: .05em; text-transform: uppercase; padding: 1px 4px; border-radius: var(--r-sm); margin-left: auto; flex: none; }
.prio.high { background: var(--bad-dim); color: var(--bad); }
.prio.low { background: var(--surface-3); color: var(--muted); }

/* ------------------------------------------------------------ table --- */
.tablewrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); }
table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
th, td { padding: 8px 12px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
th {
  color: var(--muted); font-size: 9.5px; text-transform: uppercase; letter-spacing: .08em;
  font-weight: 700; background: var(--surface-2); position: sticky; top: 0; cursor: pointer;
  border-bottom: 1px solid var(--line); z-index: 1;
}
th:hover:not(.nosort) { color: var(--ink); }
th.nosort { cursor: default; }
tbody tr { transition: background var(--t); }
tbody tr:hover { background: var(--surface-2); }
tbody tr:last-child td { border-bottom: 0; }
td.wrap { white-space: normal; min-width: 220px; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.pill { display: inline-flex; align-items: center; gap: 5px; padding: 1px 8px; border-radius: var(--r-sm); font-size: 11px; font-weight: 700; }
.tag { display: inline-block; padding: 1px 6px; border-radius: var(--r-sm); font-size: 10.5px; font-weight: 700; }
.late { color: var(--bad); }
.bar { height: 5px; border-radius: 2px; background: var(--surface-3); overflow: hidden; min-width: 68px; }
.bar > i { display: block; height: 100%; transition: width .3s; }

/* -------------------------------------------------------- dashboard --- */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: var(--s2); margin-bottom: var(--s4); }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: var(--s3) var(--s4); }
.kpi .k { color: var(--muted); font-size: 9.5px; text-transform: uppercase; letter-spacing: .08em; font-weight: 700; }
.kpi .v { font-size: 26px; font-weight: 800; letter-spacing: -.035em; margin-top: 3px; font-variant-numeric: tabular-nums; line-height: 1.1; }
.kpi .v.late { color: var(--bad); }
.kpi .v.warn { color: var(--warn); }
.kpi .s { color: var(--ink-2); font-size: 11.5px; margin-top: 2px; }
.kpi.kclick { cursor: pointer; transition: border-color var(--t), background var(--t); }
.kpi.kclick:hover { border-color: var(--primary); background: var(--surface-2); }

.tlines { display: flex; flex-direction: column; }
.tline {
  display: flex; align-items: center; gap: var(--s2);
  padding: 8px var(--s4); border-bottom: 1px solid var(--line);
  cursor: pointer; font-size: 12.5px; transition: background var(--t);
}
.tline:last-child { border-bottom: 0; }
.tline:hover { background: var(--surface-2); }
.tline .tl-t { flex: 1; min-width: 0; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tline .tl-c { color: var(--muted); font-weight: 400; margin-left: 6px; font-size: 11px; }
.tline .tl-d { color: var(--muted); font-size: 11px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.tline .avstack { flex: none; }
.tline.tmore { justify-content: center; color: var(--muted); font-size: 11.5px; font-weight: 700; }
.tline.tmore:hover { color: var(--primary); }
.tline.flagrow .fn { font-size: 16px; font-weight: 800; min-width: 24px; font-variant-numeric: tabular-nums; }
.tempty { padding: 22px var(--s4); text-align: center; color: var(--muted); font-size: 12px; }

.daystrip { display: flex; overflow-x: auto; }
.dayblk { flex: 1 0 148px; border-right: 1px solid var(--line); padding: 10px; min-width: 148px; }
.dayblk:last-child { border-right: 0; }
.dayhd { display: flex; align-items: center; gap: 5px; margin-bottom: var(--s2); font-size: 11px; color: var(--muted); }
.dayhd b { color: var(--ink); font-size: 12px; font-weight: 700; }
.dayhd .ct2 { margin-left: auto; background: var(--surface-2); color: var(--ink-2); padding: 0 6px; border-radius: var(--r-sm); font-size: 10.5px; font-weight: 700; }
.daychips { display: flex; flex-direction: column; gap: var(--s1); }

/* ---------------------------------------------------------- reports --- */
.stack { display: flex; height: 8px; border-radius: 2px; overflow: hidden; background: var(--surface-3); gap: 1px; }
.stack > i { display: block; height: 100%; }
.legend { display: flex; gap: var(--s3); flex-wrap: wrap; margin-top: var(--s3); color: var(--ink-2); font-size: 11.5px; }
.legend span { display: inline-flex; align-items: center; gap: 5px; }
.legend b { width: 8px; height: 8px; border-radius: 2px; display: inline-block; }
.spark { display: flex; align-items: flex-end; gap: 4px; height: 110px; }
.spark > div { flex: 1; background: var(--primary); border-radius: 2px 2px 0 0; min-height: 2px; transition: background var(--t); }
.spark > div:hover { background: var(--accent); }
.sparkx { display: flex; gap: 4px; margin-top: 6px; color: var(--muted); font-size: 9.5px; }
.sparkx > div { flex: 1; text-align: center; overflow: hidden; }

/* ----------------------------------------------------------- modal ---- */
.modal {
  position: fixed; inset: 0; z-index: 90;
  background: var(--veil);
  display: grid; place-items: start center; padding: 5vh var(--s4) var(--s6); overflow-y: auto;
}
.modalcard {
  background: var(--surface); border: 1px solid var(--line-2); border-radius: var(--r-lg);
  width: min(600px, 100%); overflow: hidden;
}
.modalcard.wide { width: min(880px, 100%); }
.mhead { display: flex; align-items: center; gap: var(--s2); padding: var(--s3) var(--s4); border-bottom: 1px solid var(--line); }
.mhead h3 { margin: 0; font-size: 14.5px; font-weight: 700; flex: 1; letter-spacing: -.02em; }
.mbody { padding: var(--s4); }
.mbody > :last-child { margin-bottom: 0; }
.mfoot { display: flex; gap: var(--s2); justify-content: flex-end; padding: var(--s3) var(--s4); border-top: 1px solid var(--line); background: var(--surface-2); }
.mfoot .left { margin-right: auto; }
.x { background: none; border: 0; color: var(--muted); cursor: pointer; width: 26px; height: 26px; border-radius: var(--r-sm); display: grid; place-items: center; }
.x:hover { color: var(--ink); background: var(--surface-2); }

/* task editor split */
.mbody.tsplit { display: grid; grid-template-columns: 1fr 286px; gap: 0; padding: 0; }
.tsplit .tmain { padding: var(--s4); min-width: 0; }
.tsplit .tside { padding: var(--s4); background: var(--surface-2); border-left: 1px solid var(--line); min-width: 0; }
.tsplit .tside .grid2 { grid-template-columns: 1fr 1fr; gap: var(--s2); }
.tsplit textarea.inp { min-height: 72px; }
.tsplit textarea.inp.tbig { min-height: 128px; }
.tsplit .crewbox { padding: 8px; }
.tsplit .crewadd .inp { height: 27px; font-size: 12px; }
.tsplit .spick { padding: 3px 8px; font-size: 11.5px; }
details.hist summary { cursor: pointer; color: var(--ink-2); font-weight: 700; font-size: 11.5px; list-style: none; }
details.hist summary::-webkit-details-marker { display: none; }
details.hist summary::before { content: "+ "; color: var(--muted); }
details.hist[open] summary::before { content: "- "; }
.hist { margin-top: var(--s4); border-top: 1px solid var(--line); padding-top: var(--s3); font-size: 11.5px; color: var(--muted); }
.hist div { padding: 2px 0; }

.statuspick { display: flex; flex-wrap: wrap; gap: var(--s1); margin-top: 5px; }
.spick {
  border: 1px solid var(--line); background: var(--surface); border-radius: var(--r-sm);
  padding: 4px 10px; cursor: pointer; font: inherit; font-size: 12px; font-weight: 600; color: var(--ink-2);
  display: inline-flex; align-items: center; gap: 5px; transition: border-color var(--t), color var(--t);
}
.spick:hover { border-color: var(--line-2); color: var(--ink); }
.spick.on { color: #fff; border-color: transparent; }

.srow { display: grid; grid-template-columns: .95fr 1fr 1.1fr 58px 1.5fr 30px; gap: var(--s2); align-items: center; }
.srow .inp { width: 100%; }
.multi { display: flex; flex-wrap: wrap; gap: var(--s1); }
.mtog {
  border: 1px solid var(--line); background: var(--surface); border-radius: var(--r-sm);
  padding: 3px 9px; font: inherit; font-size: 11.5px; font-weight: 600; cursor: pointer; color: var(--ink-2);
  transition: border-color var(--t), background var(--t);
}
.mtog:hover { border-color: var(--line-2); }
.mtog.on { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
.preview { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-sm); padding: 10px 12px; font-size: 12px; color: var(--ink-2); }
.preview b { color: var(--ink); font-weight: 700; }
.pitem { border: 1px solid var(--line); border-radius: var(--r); padding: 10px; margin-bottom: var(--s2); background: var(--surface-2); }
.pcrew { display: flex; align-items: center; gap: var(--s2); flex-wrap: wrap; margin-top: var(--s2); padding-top: var(--s2); border-top: 1px dashed var(--line-2); }
.pcrew .multi { flex: 1; min-width: 120px; }
.inp.sm { height: 27px; font-size: 12px; padding: 0 8px; }

/* crew */
.avstack { display: inline-flex; align-items: center; }
.avstack .av { box-shadow: 0 0 0 2px var(--surface); margin-left: -4px; }
.avstack .av:first-child { margin-left: 0; }
tbody tr:hover .avstack .av { box-shadow: 0 0 0 2px var(--surface-2); }
.av { border-radius: var(--r-sm); display: grid; place-items: center; font-weight: 700; color: rgba(0,0,0,.72); flex: none; }
.crewbox { border: 1px solid var(--line); border-radius: var(--r-sm); padding: 8px; margin-top: 5px; background: var(--surface); }
.crewrow { display: flex; align-items: center; gap: var(--s2); background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-sm); padding: 4px 5px; margin-bottom: var(--s1); }
.crewrow .cnm { flex: 1; font-size: 12px; font-weight: 600; color: var(--ink); }
.crewadd { margin-top: 2px; }
.crewadd .inp { height: 28px; font-size: 12px; flex: 1; }

/* ---------------------------------------------------------- bulkbar --- */
.bulkbar {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: var(--s4); z-index: 70;
  background: var(--ink); border-radius: var(--r); padding: 8px 10px;
  display: flex; gap: var(--s1); align-items: center; flex-wrap: wrap;
}
.bulkbar #bulkCount { font-weight: 700; font-size: 12px; margin: 0 6px; color: var(--surface); }
.bulkbar .inp { background: transparent; color: var(--surface); border-color: rgba(255,255,255,.22); height: 28px; font-size: 12px; }
.bulkbar .inp option { color: var(--ink); background: var(--surface); }
.bulkbar .btn { height: 28px; font-size: 12px; background: transparent; border-color: rgba(255,255,255,.22); color: var(--surface); }
.bulkbar .btn:hover { background: rgba(255,255,255,.12); }
.bulkbar .btn.danger { color: #fca5a5; border-color: transparent; }

/* ----------------------------------------------------------- toasts --- */
.toasts { position: fixed; right: var(--s4); bottom: var(--s4); z-index: 120; display: flex; flex-direction: column; gap: var(--s2); }
.toast { background: var(--ink); color: var(--surface); border-radius: var(--r-sm); padding: 9px 13px; font-size: 12.5px; font-weight: 600; max-width: 330px; border-left: 3px solid var(--good); }
.toast.err { border-left-color: var(--bad); }

/* read-only accounts */
body.readonly .mfoot [data-save],
body.readonly .mfoot [data-del],
body.readonly .bulkbar,
body.readonly .tsplit .crewadd,
body.readonly .caldate .add { display: none !important; }
body.readonly .mbody .inp, body.readonly .mbody textarea,
body.readonly .mbody select, body.readonly .statuspick { pointer-events: none; opacity: .8; }
.rolebadge { background: var(--accent-dim); color: var(--accent); text-transform: uppercase; font-size: 8.5px; font-weight: 800; letter-spacing: .06em; padding: 1px 4px; border-radius: 2px; margin-left: 4px; }
.pwcell { display: inline-flex; align-items: center; gap: 3px; }
.pwdots { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 11.5px; min-width: 96px; display: inline-block; }

/* ------------------------------------------------------------ login --- */
.loginpage { display: grid; place-items: center; min-height: 100vh; background: var(--bg); }
.loginbox { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 28px; width: min(360px, 92vw); }
.loginbox h1 { margin: 0 0 3px; font-size: 19px; font-weight: 800; letter-spacing: -.025em; }
.loginbox .sub { margin: 0 0 22px; color: var(--muted); font-size: 12.5px; }
.loginmark { width: 34px; height: 34px; border-radius: var(--r); margin-bottom: var(--s3); background: var(--primary); color: var(--primary-ink); display: grid; place-items: center; }
.loginerr { background: var(--bad-dim); color: var(--bad); border-radius: var(--r-sm); padding: 8px 11px; font-size: 12px; font-weight: 600; margin-bottom: var(--s3); }
.loginbox .btn { height: 38px; }
.hint { color: var(--muted); font-size: 11px; text-align: center; margin: var(--s3) 0 0; }
code { background: var(--surface-2); padding: 1px 5px; border-radius: 2px; font-size: 11.5px; font-family: ui-monospace, Menlo, Consolas, monospace; }

/* ------------------------------------------------------------ misc ---- */
.dot9 { width: 8px; height: 8px; border-radius: 2px; display: inline-block; flex: none; }
.avatar { width: 26px; height: 26px; border-radius: var(--r-sm); display: grid; place-items: center; font-size: 10px; font-weight: 700; color: rgba(0,0,0,.72); flex: none; }
.muted { color: var(--muted); }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.hidden { display: none !important; }
[hidden] { display: none !important; }

/* ------------------------------------------------------ responsive ---- */
@media (max-width: 1080px) {
  :root { --side-w: 180px; }
  .searchwrap .inp { width: 150px; }
}
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .side {
    position: fixed; left: 0; top: 0; width: 240px;
    transform: translateX(-100%); transition: transform var(--t);
  }
  body.sideopen .side { transform: none; }
  body.sideopen .sideveil { display: block; position: fixed; inset: 0; background: var(--veil); z-index: 45; }
  .sbrand .sclose, .topbar .menubtn { display: grid; }
  .topbar { padding: 0 var(--s3); }
  .filterbar { padding: var(--s2) var(--s3); }
  main#app { padding: var(--s3); padding-bottom: 88px; }
  .searchwrap, .searchwrap .inp { width: 100%; }
  .grid2, .grid3, .cardgrid { grid-template-columns: 1fr; }
  .calcell { min-height: 78px; padding: 3px; }
  .chip .av, .chip .mono { display: none; }
  .srow { grid-template-columns: 1fr 1fr; }
  .mbody.tsplit { grid-template-columns: 1fr; }
  .tsplit .tside { border-left: 0; border-top: 1px solid var(--line); }
  .modal { padding: 0; place-items: stretch; }
  .modalcard, .modalcard.wide { width: 100%; border-radius: 0; min-height: 100vh; border: 0; }
  .bulkbar { left: var(--s2); right: var(--s2); transform: none; justify-content: center; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
@media print {
  .side, .topbar, .filterbar, .bulkbar, .toasts, .calhead .btn { display: none !important; }
  .shell { grid-template-columns: 1fr; }
  body { background: #fff; color: #000; }
  main#app { padding: 0; }
  .calcell { break-inside: avoid; min-height: 96px; }
}

/* ------------------------------------------------------ storyboard --- */
.modalcard.xl { width: min(1180px, 100%); }
.sbbody { padding: var(--s3); max-height: 74vh; overflow-y: auto; }
.sbgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(236px, 1fr)); gap: var(--s2); }
.sbtotal { font-size: 12px; color: var(--muted); margin-left: auto; white-space: nowrap; }
.sbtotal b { color: var(--ink); }
.sbtotal .okc { color: var(--good); font-weight: 700; }

.sbframe { border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); display: flex; flex-direction: column; }
.sbframe.ok  { border-color: var(--good); }
.sbframe.chg { border-color: var(--bad); }
.sbhd { display: flex; align-items: center; gap: 6px; padding: 6px 8px; border-bottom: 1px solid var(--line); }
.sbn { width: 19px; height: 19px; border-radius: var(--r-sm); background: var(--ink); color: var(--surface); display: grid; place-items: center; font-size: 10.5px; font-weight: 800; flex: none; }
.sbtime { font-size: 10.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.sbstate { margin-left: auto; font-size: 9px; font-weight: 800; text-transform: uppercase; letter-spacing: .05em; padding: 1px 5px; border-radius: 2px; }
.sbstate.ok { background: var(--good-dim); color: var(--good); }
.sbstate.chg { background: var(--bad-dim); color: var(--bad); }
.sbhd .sbdel { margin-left: auto; }
.sbstate + .sbdel { margin-left: 0; }

.sbshot { position: relative; aspect-ratio: 16 / 10; background: var(--surface-2); border-bottom: 1px solid var(--line); overflow: hidden; }
.sbshot img { width: 100%; height: 100%; object-fit: cover; display: block; }
.sbshot.over { box-shadow: inset 0 0 0 2px var(--primary); background: var(--primary-dim); }
.sbph { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; padding: 10px; color: var(--muted); font-size: 11px; }
.sbclear { position: absolute; top: 4px; right: 4px; padding: 0 5px; height: 22px; }

.sbfields { padding: 7px; display: flex; flex-direction: column; gap: 5px; }
.sbfields .inp { width: 100%; }
.sbfields textarea.inp { min-height: 42px; font-size: 12px; padding: 6px 8px; }
.sbfields .sbsec { width: 62px; flex: none; text-align: center; }
.sbfields .sbshotin { flex: 1; }
.sbfields .sbtext { font-weight: 700; }
.sbupload {
  display: flex; align-items: center; justify-content: center; gap: 5px; margin: 2px 0 0;
  border: 1px dashed var(--line-2); border-radius: var(--r-sm); padding: 5px;
  font-size: 11.5px; font-weight: 600; color: var(--ink-2); cursor: pointer;
  transition: border-color var(--t), color var(--t);
}
.sbupload:hover { border-color: var(--primary); color: var(--primary); }

.sbapprove { display: flex; gap: 4px; padding: 7px; border-top: 1px solid var(--line); }
.sbapprove .btn { flex: 1; }
.sbcomment { padding: 7px 9px; border-top: 1px solid var(--line); font-size: 11.5px; color: var(--ink-2); background: var(--surface-2); }

.sbbadge {
  display: inline-flex; align-items: center; gap: 3px; flex: none;
  background: var(--surface-3); color: var(--ink-2);
  border-radius: 2px; padding: 0 4px; font-size: 9.5px; font-weight: 800;
}
.sbbadge.ok { background: var(--good-dim); color: var(--good); }
.sbrow { margin-bottom: var(--s3); }

@media (max-width: 860px) {
  .sbgrid { grid-template-columns: 1fr 1fr; }
  .sbbody { max-height: none; }
}
@media (max-width: 520px) { .sbgrid { grid-template-columns: 1fr; } }

/* ----------------------------------------------------- idea backlog --- */
.calsplit { display: grid; grid-template-columns: 1fr 260px; gap: var(--s3); align-items: start; }

.idearail {
  border: 1px solid var(--line); border-radius: var(--r); background: var(--surface);
  display: flex; flex-direction: column; overflow: hidden;
  position: sticky; top: 112px; max-height: calc(100vh - 140px);
}
.idearail.drop { border-color: var(--primary); box-shadow: inset 0 0 0 2px var(--primary); }
.irhead { display: flex; align-items: center; gap: var(--s2); padding: 9px 11px; border-bottom: 1px solid var(--line); }
.irhead b { font-size: 12.5px; font-weight: 700; }
.irhead .ct2 {
  color: var(--ink-2); font-size: 11px; font-weight: 700;
  background: var(--surface-2); padding: 0 6px; border-radius: var(--r-sm); font-variant-numeric: tabular-nums;
}
.irhead [data-add] { margin-left: auto; }
.irbody { padding: 8px; display: flex; flex-direction: column; gap: 6px; overflow-y: auto; }
.irbody > * { flex: 0 0 auto; }
.irfoot { padding: 8px 11px; border-top: 1px solid var(--line); font-size: 10.5px; line-height: 1.4; background: var(--surface-2); }

.ideacard {
  --c: var(--muted);
  border: 1px solid var(--line); border-left: 3px solid var(--c);
  border-radius: var(--r-sm); background: var(--surface);
  padding: 7px 8px; cursor: pointer; transition: border-color var(--t), background var(--t);
}
.ideacard:hover { background: var(--surface-2); border-color: var(--line-2); border-left-color: var(--c); }
.ictop { display: flex; align-items: center; gap: 5px; margin-bottom: 5px; font-size: 10.5px; color: var(--muted); }
.ictop .icn { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.ict { font-size: 12.5px; font-weight: 600; line-height: 1.35; margin-bottom: 6px; }
.icfoot { display: flex; align-items: center; gap: 5px; }

.ideatag {
  display: inline-block; background: var(--warn-dim); color: var(--warn);
  font-size: 9.5px; font-weight: 800; text-transform: uppercase; letter-spacing: .06em;
  padding: 1px 5px; border-radius: 2px;
}
.datewrap { margin-top: 5px; }
.dhint { font-size: 11px; display: block; margin-top: 4px; }

@media (max-width: 1100px) { .calsplit { grid-template-columns: 1fr 220px; } }
@media (max-width: 860px) {
  .calsplit { grid-template-columns: 1fr; }
  .idearail { position: static; max-height: none; }
}

/* ------------------------------------------- calendar card detail ---- */
/* Compact chips: the middle of the row was empty, so the client name fills it
   and drops out first when the column gets narrow. */
.chip .cn {
  flex: 0 1 auto; min-width: 0; margin-left: 2px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  color: var(--muted); font-size: 10.5px; font-weight: 600;
}
.chip .ct { flex: 0 0 auto; }
.chip .avstack { flex: none; margin-left: auto; }
.chip .avstack:empty { margin-left: auto; }
.chip .dot { margin-left: 4px; }
.chip .avstack:not(:empty) + .dot { margin-left: 2px; }

/* Detailed cards */
.caldetail .calcell { min-height: 150px; }
.chip.det {
  display: block; padding: 7px 8px; border-left-width: 3px;
  background: color-mix(in srgb, var(--c) 9%, var(--surface));
}
.chip.det:hover { background: color-mix(in srgb, var(--c) 18%, var(--surface)); }
.chip.det .dtop { display: flex; align-items: center; gap: 5px; margin-bottom: 4px; }
.chip.det .dcn {
  flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-size: 10.5px; font-weight: 700; color: var(--ink-2);
}
.chip.det .dttl { font-size: 12.5px; font-weight: 700; line-height: 1.3; margin-bottom: 3px; }
.chip.det.done .dttl { text-decoration: line-through; opacity: .55; }
.chip.det .dsnip {
  font-size: 10.5px; color: var(--muted); line-height: 1.35; margin-bottom: 5px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.chip.det .dfoot { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.chip.det .dfoot .dav { margin-left: auto; }
.chip.det .dfoot .muted { font-size: 10px; }

@media (max-width: 1280px) { .chip .cn { display: none; } }
@media (max-width: 860px) {
  .caldetail .calcell { min-height: 120px; }
  .chip.det .dsnip { display: none; }
}
