[hidden] { display: none !important; }
:root {
  --bg: #f6f7f9;
  --panel: #ffffff;
  --text: #1d2330;
  --muted: #6b7280;
  --line: #e2e5ea;
  /* Brand colours from the Sheetem logo */
  --brand-ink: #1b2d3a;
  --accent: #0f7b72;
  --accent-soft: #e2f4ee;
  --danger: #b42318;
  --sel: #0f7b72;
  --parent-bg: #fafbfc;
  --red: #d64545; --yellow: #e0b100; --green: #2f9e5b;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font: 14px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--text); background: var(--bg);
  display: flex; flex-direction: column;
}
button, select, input { font: inherit; }

.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 10px 16px; background: var(--brand-ink); color: #fff;
}
.brand { display: flex; align-items: center; gap: 8px; }
.brand-mark { height: 22px; width: auto; display: block; }
.brand-word { font-weight: 800; font-size: 19px; letter-spacing: -.3px; line-height: 1; }
.brand .local { font-size: 11px; font-weight: 600; background: #2f9e5b; padding: 2px 6px; border-radius: 4px; margin-left: 2px; }
.topbar-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.user-pick { font-size: 12px; opacity: .9; display: flex; align-items: center; gap: 6px; }
.user-pick select { padding: 4px 6px; border-radius: 4px; border: 0; }

.btn {
  border: 1px solid var(--line); background: var(--panel); color: var(--text);
  padding: 6px 12px; border-radius: 6px; cursor: pointer;
}
.btn:hover { border-color: #c5cad3; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.danger { color: var(--danger); }
.btn.ghost { background: transparent; color: #fff; border-color: rgba(255,255,255,.35); }
.btn[disabled] { opacity: .45; cursor: not-allowed; }

.layout { flex: 1; display: flex; min-height: 0; }

/* Subscription notices under the top bar */
.billing-banner { display: flex; align-items: center; justify-content: center; gap: 12px; flex-wrap: wrap;
  padding: 7px 16px; font-size: 13px; background: var(--accent-soft); color: var(--brand-ink); border-bottom: 1px solid #c6e8dc; }
.billing-banner.warn { background: #fff6dd; border-bottom-color: #f0dc9c; }
.billing-banner.stop { background: #fde8e6; border-bottom-color: #f3c3be; }
.billing-banner .btn { padding: 3px 10px; font-size: 12px; }
/* Read-only organization or free licence: nothing to create */
body.no-create #btn-new-sheet, body.no-create #btn-import, body.no-create #btn-new-report, body.no-create #btn-new-dash { display: none; }
.plan-box { border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; margin-bottom: 12px; }
.plan-box .big { font-size: 16px; font-weight: 700; margin-bottom: 2px; }
.plan-grid { display: grid; grid-template-columns: auto 1fr; gap: 4px 16px; font-size: 13px; margin: 8px 0 0; }
.plan-grid dt { color: var(--muted); }
.plan-grid dd { margin: 0; }
.interval-choice { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 12px; }
.interval-option { display: flex; gap: 8px; align-items: flex-start; border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; cursor: pointer; font-size: 13px; }
.interval-option:has(input:checked) { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.interval-option input { margin-top: 2px; }
.interval-option .save { display: inline-block; margin-left: 6px; padding: 0 6px; border-radius: 10px; background: var(--accent); color: #fff; font-size: 11px; font-weight: 600; }
.founding-box { border: 1px solid var(--accent); border-radius: 8px; padding: 10px 12px; margin-bottom: 12px; font-size: 13px; }
@media (max-width: 520px) { .interval-choice { grid-template-columns: 1fr; } }
.sidebar { width: 230px; background: var(--panel); border-right: 1px solid var(--line); overflow: auto; }
.sidebar-title { padding: 14px 16px 6px; font-size: 11px; font-weight: 700; color: var(--muted); text-transform: uppercase; }
#sheet-list { list-style: none; margin: 0; padding: 0 8px 16px; }
#sheet-list li { padding: 7px 10px; border-radius: 6px; cursor: pointer; display: flex; justify-content: space-between; gap: 6px; }
#sheet-list li:hover { background: var(--bg); }
#sheet-list li.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
#sheet-list .r { font-size: 11px; color: var(--muted); font-weight: 400; }

.main { flex: 1; overflow: auto; padding: 16px 20px; min-width: 0; }
.empty { color: var(--muted); margin-top: 60px; text-align: center; }
.sheet-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.sheet-head h1 { font-size: 20px; margin: 0; cursor: text; }
.badge { font-size: 11px; padding: 2px 8px; border-radius: 10px; background: var(--accent-soft); color: var(--accent); text-transform: capitalize; }
.sheet-actions { margin-left: auto; display: flex; gap: 6px; flex-wrap: wrap; }
.view-controls { display: flex; gap: 6px; }
.filter-bar { display: flex; align-items: center; gap: 10px; background: var(--accent-soft); border: 1px solid var(--accent); border-radius: 6px; padding: 5px 12px; margin: 8px 0 4px; font-size: 13px; color: var(--accent); }
.filter-bar-text { flex: 1; }
.hint { color: var(--muted); font-size: 12px; margin: 8px 0 10px; }

.grid-wrap { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; overflow: auto; }
table#grid { border-collapse: separate; border-spacing: 0; min-width: 100%; }
#grid th, #grid td { vertical-align: middle; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); height: 34px; padding: 0 8px; white-space: nowrap; }
#grid th { position: sticky; top: 0; background: #f0f2f5; font-weight: 600; text-align: left; z-index: 2; font-size: 13px; }
#grid th .th { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
#grid th .type { font-size: 10px; color: var(--muted); font-weight: 500; text-transform: uppercase; }
#grid th .colmenu, td.rownum .rowmenu { border: 0; background: none; cursor: pointer; color: var(--muted); padding: 2px 4px; border-radius: 4px; }
#grid th .colmenu:hover, td.rownum .rowmenu:hover { background: #e2e5ea; color: var(--text); }
#grid td { min-width: 120px; max-width: 360px; overflow: hidden; text-overflow: ellipsis; cursor: cell; position: relative; }
#grid td.primary { min-width: 260px; }
#grid td.rownum, #grid th.rownum { min-width: 92px; width: 92px; text-align: right; color: var(--muted); font-size: 12px; cursor: default; background: #f8f9fa; }
#grid th.rownum { z-index: 3; }
td.rownum .rowmenu { visibility: hidden; float: left; }
tr:hover td.rownum .rowmenu { visibility: visible; }
#grid tr.parent td { background: var(--parent-bg); }
#grid tr.parent td.primary { font-weight: 600; }
#grid td.sel { outline: 2px solid var(--sel); outline-offset: -2px; }
#grid td.editing { padding: 0; }
#grid td.editing input, #grid td.editing select { width: 100%; height: 32px; border: 0; padding: 0 8px; outline: 2px solid var(--sel); outline-offset: -2px; background: #fff; }
#grid td.num { text-align: right; font-variant-numeric: tabular-nums; }
#grid td.check { text-align: center; }
.toggle { display: inline-block; width: 16px; cursor: pointer; color: var(--muted); user-select: none; }
.add-col { color: var(--muted); cursor: pointer; text-align: center !important; min-width: 44px; }
.add-col:hover { color: var(--accent); }

.dot { display: inline-block; width: 12px; height: 12px; border-radius: 50%; vertical-align: -1px; margin-right: 6px; }
.dot.Red { background: var(--red); } .dot.Yellow { background: var(--yellow); } .dot.Green { background: var(--green); }
.pri { font-size: 12px; font-weight: 600; padding: 1px 6px; border-radius: 4px; }
.pri.High { background: #fde8e8; color: var(--red); } .pri.Medium { background: #fff6d6; color: #8a6d00; } .pri.Low { background: #e5f5ec; color: var(--green); }
.flag.Flagged { color: var(--red); }
.chip { background: var(--accent-soft); color: var(--accent); border-radius: 10px; padding: 1px 8px; font-size: 12px; }

.menu { position: fixed; z-index: 50; background: #fff; border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 8px 24px rgba(20,33,61,.15); padding: 4px; min-width: 180px; }
.menu button { display: block; width: 100%; text-align: left; border: 0; background: none; padding: 7px 10px; border-radius: 5px; cursor: pointer; }
.menu button:hover { background: var(--bg); }
.menu button.danger { color: var(--danger); }
.menu hr { border: 0; border-top: 1px solid var(--line); margin: 4px 0; }

dialog { border: 0; border-radius: 10px; padding: 20px; width: min(520px, 92vw); box-shadow: 0 20px 60px rgba(0,0,0,.25); }
dialog::backdrop { background: rgba(20,33,61,.35); }
dialog h2 { margin: 0 0 14px; font-size: 17px; }
.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px; }
.field label { font-size: 12px; font-weight: 600; color: var(--muted); }
.field input, .field select, .field textarea { padding: 7px 9px; border: 1px solid var(--line); border-radius: 6px; }
.field textarea { min-height: 90px; resize: vertical; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }
.list { max-height: 300px; overflow: auto; border: 1px solid var(--line); border-radius: 6px; margin-bottom: 12px; }
.list .item { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 8px 10px; border-bottom: 1px solid var(--line); font-size: 13px; }
.list .item:last-child { border-bottom: 0; }
.list .meta { color: var(--muted); font-size: 12px; }

.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: #1b2d3a; color: #fff; padding: 10px 16px; border-radius: 8px; z-index: 100; box-shadow: 0 6px 20px rgba(0,0,0,.2); }
.toast.err { background: var(--danger); }

/* ---------- view toggle ---------- */
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; background: var(--panel); }
.seg button { border: 0; background: none; padding: 6px 12px; cursor: pointer; }
.seg button + button { border-left: 1px solid var(--line); }
.seg button.on { background: var(--accent); color: #fff; }
#zoom { padding: 5px 8px; border: 1px solid var(--line); border-radius: 6px; background: var(--panel); }

/* ---------- calculated cells (parent rows) ---------- */
#grid td.calc { color: var(--muted); font-style: italic; cursor: default; }

/* ---------- Gantt ---------- */
.grid-wrap { position: relative; }
#grid.gantt-mode th { height: 44px; }
#grid th.gantt-head { padding: 0; vertical-align: top; }
.scale { position: relative; height: 44px; }
.scale-top, .scale-bottom { position: absolute; left: 0; right: 0; height: 22px; }
.scale-top { top: 0; border-bottom: 1px solid var(--line); }
.scale-bottom { top: 22px; }
.scale-top span { position: absolute; top: 3px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.scale-top .tick { position: absolute; top: 0; bottom: -22px; border-left: 1px solid #cfd4dc; }
.scale-bottom .cell { position: absolute; top: 3px; text-align: center; font-size: 11px; font-weight: 500; color: var(--muted); border-left: 1px solid var(--line); height: 19px; overflow: hidden; }
#grid td.gantt-cell {
  padding: 0; position: relative; cursor: default; overflow: visible; max-width: none;
  background-image: repeating-linear-gradient(to right, transparent 0, transparent calc(var(--dw) * 5), #f1f3f6 calc(var(--dw) * 5), #f1f3f6 calc(var(--dw) * 7));
}
#grid tr.parent td.gantt-cell { background-color: transparent; }
.gantt-cell .today { position: absolute; top: 0; bottom: -1px; border-left: 2px solid #e5484d; opacity: .55; z-index: 1; }
.bar { position: absolute; top: 8px; height: 18px; border-radius: 4px; background: #148a80; color: #fff; font-size: 11px; line-height: 18px; padding: 0 6px; overflow: hidden; white-space: nowrap; z-index: 2; box-shadow: inset 0 -2px 0 rgba(0,0,0,.12); }
.bar.summary { top: 11px; height: 10px; background: #1b2d3a; border-radius: 2px; box-shadow: none; }
.bar.summary::before, .bar.summary::after { content: ''; position: absolute; bottom: -5px; border: 5px solid transparent; border-top-color: #1b2d3a; }
.bar.summary::before { left: 0; border-left-color: #1b2d3a; }
.bar.summary::after { right: 0; border-right-color: #1b2d3a; }
.milestone { position: absolute; top: 10px; width: 14px; height: 14px; background: #1b2d3a; transform: rotate(45deg); z-index: 2; }
svg.arrows { position: absolute; top: 0; left: 0; pointer-events: none; z-index: 3; overflow: visible; }
svg.arrows path { fill: none; stroke: #5b6474; stroke-width: 1.4; }
svg.arrows .ahead { fill: #5b6474; stroke: none; }

/* Gantt mode: compact, pinned task columns */
#grid.gantt-mode td:not(.gantt-cell):not(.rownum) { min-width: 84px; max-width: 160px; }
#grid.gantt-mode td.primary { min-width: 200px; max-width: 280px; }
#grid.gantt-mode th .type { display: none; }
#grid .stick { position: sticky; z-index: 4; background: var(--panel); }
#grid th.stick { z-index: 6; background: #f0f2f5; }
#grid td.rownum.stick { background: #f8f9fa; }
#grid tr.parent td.stick { background: var(--parent-bg); }
#grid .stick-last { box-shadow: 4px 0 6px -4px rgba(20,33,61,.18); }
#grid th.gantt-head { z-index: 5; }

/* ---------- notifications ---------- */
.bell { position: relative; }
.bell .count { position: absolute; top: -6px; right: -6px; background: #e5484d; color: #fff; font-size: 10px; font-weight: 700; border-radius: 9px; padding: 1px 5px; }
.menu.wide { max-width: 420px; }
.menu.wide button { white-space: normal; font-size: 13px; }

/* ---------- row indicators ---------- */
td.rownum .rowact { border: 0; background: none; cursor: pointer; padding: 0 2px; font-size: 11px; color: var(--muted); }
td.rownum .rowact:hover { color: var(--accent); }
td.rownum .rowact .ic { margin-right: 3px; }

/* ---------- drawer ---------- */
.drawer { position: fixed; top: 54px; right: 0; bottom: 0; width: 400px; max-width: 100vw; background: var(--panel); border-left: 1px solid var(--line); box-shadow: -8px 0 24px rgba(20,33,61,.1); z-index: 30; display: flex; flex-direction: column; }
.drawer-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.drawer-title { font-weight: 700; font-size: 15px; }
.drawer-body { overflow: auto; padding: 4px 16px 20px; flex: 1; }
.drawer-body h3 { font-size: 12px; text-transform: uppercase; color: var(--muted); margin: 16px 0 8px; }
body.drawer-open .main { padding-right: 420px; }
.meta { color: var(--muted); font-size: 12px; }
.empty-note { padding: 6px 0; }
.comment { border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; margin-bottom: 6px; }
.comment.reply { margin-left: 22px; background: #fafbfc; }
.chead { font-size: 13px; margin-bottom: 3px; }
.cbody { white-space: pre-wrap; word-break: break-word; }
.mention { background: var(--accent-soft); color: var(--accent); border-radius: 4px; padding: 0 3px; font-weight: 600; }
.cact { margin-top: 4px; display: flex; gap: 10px; }
.link { border: 0; background: none; padding: 0; color: var(--accent); cursor: pointer; font-size: 12px; }
.link.danger { color: var(--danger); }
.composer { margin-top: 8px; }
.mention-wrap { position: relative; }
.composer textarea { width: 100%; min-height: 70px; padding: 8px; border: 1px solid var(--line); border-radius: 6px; resize: vertical; font: inherit; }
.mention-list { position: absolute; left: 0; right: 0; top: 100%; background: #fff; border: 1px solid var(--line); border-radius: 6px; box-shadow: 0 8px 20px rgba(20,33,61,.15); z-index: 5; }
.mention-list button { display: block; width: 100%; text-align: left; border: 0; background: none; padding: 6px 8px; cursor: pointer; }
.mention-list button.on, .mention-list button:hover { background: var(--accent-soft); }
.composer-actions { display: flex; justify-content: space-between; align-items: center; margin-top: 6px; }
.file { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 7px 0; border-bottom: 1px solid var(--line); }
.file .fname { font-size: 13px; text-align: left; word-break: break-all; }
.upload-zone { display: block; margin-top: 10px; border: 2px dashed var(--line); border-radius: 8px; padding: 14px; text-align: center; color: var(--muted); cursor: pointer; font-size: 13px; }
.upload-zone.over { border-color: var(--accent); background: var(--accent-soft); }

/* ---------- forms manager ---------- */
.btnrow { display: flex; gap: 4px; flex-wrap: wrap; justify-content: flex-end; }
.btnrow .btn { padding: 4px 8px; font-size: 12px; }
.chk { display: flex; align-items: center; gap: 4px; cursor: pointer; }

/* ---------- formulas ---------- */
#grid td.fx::after { content: ''; position: absolute; top: 0; right: 0; border: 4px solid transparent; border-top-color: #8b5cf6; border-right-color: #8b5cf6; }
.ferr { color: var(--danger); font-size: 12px; font-weight: 600; }
.fxhead { color: #8b5cf6; font-weight: 700; font-style: italic; margin-right: 2px; }
#grid td.editing input.fxinput { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; }
.fxtip { position: fixed; z-index: 40; background: #fff; border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 10px 28px rgba(20,33,61,.18); padding: 10px 12px; width: 640px; max-width: calc(100vw - 16px); font-size: 13px; }
table.fxhelp { border-collapse: collapse; margin: 6px 0; width: 100%; }
table.fxhelp td { padding: 3px 8px 3px 0; vertical-align: top; }
table.fxhelp td.meta { white-space: nowrap; }
dialog table.fxhelp td.meta { white-space: normal; }
table.fxhelp code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; background: #f4f2ff; color: #5b21b6; padding: 1px 4px; border-radius: 4px; white-space: nowrap; }
dialog .fxhelp code { white-space: normal; }

/* ---------- sidebar: reports & dashboards ---------- */
.sidebar-title.with-add { display: flex; justify-content: space-between; align-items: center; margin-top: 8px; }
.sidebar-title .add { border: 0; background: none; color: var(--muted); font-size: 16px; cursor: pointer; padding: 0 4px; border-radius: 4px; line-height: 1; }
.sidebar-title .add:hover { background: var(--bg); color: var(--accent); }
.nav-list { list-style: none; margin: 0; padding: 0 8px 8px; }
.nav-list li { padding: 7px 10px; border-radius: 6px; cursor: pointer; display: flex; justify-content: space-between; gap: 6px; }
.nav-list li:hover { background: var(--bg); }
.nav-list li.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.nav-list li.none { color: var(--muted); font-size: 12px; cursor: default; }
.nav-list li.none:hover { background: none; }
.nav-list .r { font-size: 11px; color: var(--muted); font-weight: 400; }
.sidebar-foot { padding: 8px 18px 16px; border-top: 1px solid var(--line); margin-top: 8px; }
.sidebar-foot .link { color: var(--muted); font-size: 13px; }
.sidebar-foot .link:hover { color: var(--accent); }
.trash-list { list-style: none; margin: 0 0 8px; padding: 0; max-height: 50vh; overflow: auto; }
.trash-list li { display: flex; align-items: center; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.trash-list li > div { flex: 1; min-width: 0; }

/* ---------- report table ---------- */
table.rtable { border-collapse: separate; border-spacing: 0; min-width: 100%; }
.rtable th, .rtable td { border-bottom: 1px solid var(--line); padding: 7px 10px; text-align: left; white-space: nowrap; max-width: 320px; overflow: hidden; text-overflow: ellipsis; }
.rtable th { position: sticky; top: 0; background: #f0f2f5; font-size: 13px; z-index: 1; }
.rtable td.num { text-align: right; font-variant-numeric: tabular-nums; }
.rtable tr.rrow { cursor: pointer; }
.rtable tr.rrow:hover td { background: var(--accent-soft); }
.rtable tr.grp td { background: #f6f7f9; font-weight: 700; font-size: 13px; }

/* ---------- builder dialogs ---------- */
dialog:has(.builder) { width: min(760px, 94vw); }
.builder .checks { display: flex; flex-wrap: wrap; gap: 6px 14px; max-height: 140px; overflow: auto; border: 1px solid var(--line); border-radius: 6px; padding: 8px; }
.builder .two { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.builder .inline { display: flex; gap: 6px; }
.builder .inline > * { flex: 1; }
.builder select, .builder input[type=text], .builder input[type=number], .builder textarea { padding: 7px 9px; border: 1px solid var(--line); border-radius: 6px; font: inherit; }
.builder textarea { min-height: 110px; width: 100%; }
.filters .frow { display: grid; grid-template-columns: 1.2fr 1.2fr 1fr auto; gap: 6px; margin-bottom: 6px; }
.filters .frow input[hidden] + button { grid-column: 4; }
.filters .frow-actions { display: flex; gap: 8px; align-items: center; }
.filters .frow-actions select { flex: 1; }

/* ---------- dashboards ---------- */
.dash-grid { display: grid; grid-template-columns: repeat(12, 1fr); gap: 14px; }
.dash-empty { grid-column: span 12; color: var(--muted); text-align: center; padding: 60px 0; border: 2px dashed var(--line); border-radius: 10px; }
.wcard { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; min-width: 0; display: flex; flex-direction: column; }
.wcard.w3 { grid-column: span 3; } .wcard.w4 { grid-column: span 4; } .wcard.w6 { grid-column: span 6; } .wcard.w8 { grid-column: span 8; } .wcard.w12 { grid-column: span 12; }
@media (max-width: 1100px) { .wcard.w3, .wcard.w4 { grid-column: span 6; } .wcard.w6, .wcard.w8 { grid-column: span 12; } }
.dash-grid.editing .wcard { border-style: dashed; border-color: #b8c4d6; }
.whead { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin-bottom: 10px; }
.wtitle { font-weight: 700; font-size: 14px; color: var(--text); }
.wtools { display: flex; gap: 8px; }
.wbody { flex: 1; min-width: 0; }
.werr { padding: 16px 0; }
.wtext { white-space: pre-wrap; color: var(--text); line-height: 1.5; }
.metric .big { font-size: 36px; font-weight: 700; line-height: 1.1; font-variant-numeric: tabular-nums; color: var(--text); }
.progress { height: 8px; background: #eceef2; border-radius: 4px; margin: 10px 0 4px; overflow: hidden; }
.progress > div { height: 100%; background: #2a78d6; border-radius: 4px; }
.bars { display: flex; flex-direction: column; gap: 8px; }
.bar-row { display: grid; grid-template-columns: minmax(80px, 34%) 1fr auto; align-items: center; gap: 10px; padding: 2px 0; }
.bar-label { font-size: 13px; color: #52514e; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-track { height: 14px; }
.bar-fill { height: 100%; border-radius: 0 4px 4px 0; min-width: 2px; }
.bar-val { font-size: 13px; font-variant-numeric: tabular-nums; color: var(--text); min-width: 32px; text-align: right; }
.donut-wrap { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
svg.donut { width: 150px; height: 150px; flex: none; }
svg.donut .seg { stroke: var(--panel); stroke-width: 2; }
svg.donut .seg:hover { opacity: .85; }
svg.donut .dtotal { text-anchor: middle; font-size: 18px; font-weight: 700; fill: #0b0b0b; }
svg.donut .dsub { text-anchor: middle; font-size: 9px; fill: #52514e; }
.legend { display: flex; flex-direction: column; gap: 6px; min-width: 150px; flex: 1; }
.legend .li { display: grid; grid-template-columns: 12px 1fr auto; gap: 8px; align-items: center; font-size: 13px; }
.legend .sw { width: 12px; height: 12px; border-radius: 3px; }
.legend .ll { color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.legend .lv { color: #52514e; font-variant-numeric: tabular-nums; }
.rwidget { overflow: auto; }
.rwidget .rtable th { position: static; }
.rfoot { margin-top: 8px; }
.ctip { position: fixed; z-index: 60; background: #1b2d3a; color: #fff; padding: 6px 9px; border-radius: 6px; font-size: 12px; pointer-events: none; box-shadow: 0 4px 14px rgba(0,0,0,.2); }
#dash-name { cursor: default; }
.dash-grid.editing ~ * #dash-name, #dash-view .editing #dash-name { cursor: text; }

/* ---------- column resizing ---------- */
#grid th { position: sticky; }
#grid th .col-resize { position: absolute; top: 0; right: -3px; width: 7px; height: 100%; cursor: col-resize; z-index: 7; }
#grid th .col-resize:hover, body.col-resizing #grid th .col-resize:hover { background: rgba(15,123,114,.35); }
body.col-resizing, body.col-resizing * { cursor: col-resize !important; user-select: none; }

/* ---------- Gantt extras ---------- */
.btn.toggle { width: auto; color: var(--text); }
.btn.toggle.on { background: #fdeaea; border-color: #d03b3b; color: #a32020; }
#gantt-note { margin-left: 4px; }
.gantt-cell .holiday { position: absolute; top: 0; bottom: 0; background: repeating-linear-gradient(135deg, #eceef2 0 3px, #f7f8fa 3px 6px); z-index: 0; }
.gantt-cell .baseline { position: absolute; top: 28px; height: 4px; border-radius: 2px; background: #9aa3b2; z-index: 1; }
.bar.critical { background: #d03b3b; }
.bar.summary.critical { background: #8f1d1d; }
.bar.summary.critical::before { border-top-color: #8f1d1d; border-left-color: #8f1d1d; }
.bar.summary.critical::after { border-top-color: #8f1d1d; border-right-color: #8f1d1d; }
.milestone.critical { background: #d03b3b; }
svg.arrows path.crit { stroke: #d03b3b; stroke-width: 1.8; }
svg.arrows .ahead.crit { fill: #d03b3b; }
.bar.draggable { cursor: grab; }
.bar.draggable .grip { position: absolute; top: 0; right: 0; width: 7px; height: 100%; cursor: ew-resize; background: rgba(255,255,255,.25); }
.bar.dragging { opacity: .8; cursor: grabbing; box-shadow: 0 2px 8px rgba(20,33,61,.3); }
.drag-tip { position: fixed; z-index: 80; background: #1b2d3a; color: #fff; font-size: 12px; padding: 4px 8px; border-radius: 5px; pointer-events: none; }

.sheet-head .btn, .sheet-head .seg button { white-space: nowrap; }

/* dropdown-style cells show a caret when hovered or selected */
#grid td.picker { padding-right: 20px; }
#grid td.picker:hover::before, #grid td.picker.sel::before { content: '▾'; position: absolute; right: 6px; top: 50%; transform: translateY(-50%); color: var(--muted); font-size: 12px; pointer-events: none; }
#grid td.editing.picker::before { content: none; }

/* New sheet: template picker */
dialog:has(.tpl-picker) { width: min(860px, 94vw); }
.tpl-chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 10px; }
.tpl-chip { border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 4px 12px; font: inherit; font-size: 13px; cursor: pointer; }
.tpl-chip.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.tpl-grid { max-height: min(52vh, 480px); overflow-y: auto; padding-right: 4px; }
.tpl-group h3 { font-size: 13px; margin: 12px 0 6px; color: var(--muted); }
.tpl-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 8px; }
.tpl-card { display: flex; flex-direction: column; gap: 4px; text-align: left; border: 1px solid var(--line); border-radius: 8px; background: #fff; padding: 10px 12px; font: inherit; cursor: pointer; }
.tpl-card:hover { border-color: var(--accent); }
.tpl-card.on { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); background: var(--accent-soft); }
.tpl-card .meta { font-size: 12px; line-height: 1.35; }
.tpl-tags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 2px; }
.tpl-tags span { font-size: 11px; border-radius: 10px; padding: 0 6px; background: var(--accent-soft); color: var(--accent); }
.tpl-examples { display: block; margin-top: 10px; font-size: 13px; }

/* Storage & files dialog */
.storage-dialog .list .item > div:first-child { min-width: 0; overflow-wrap: anywhere; }
.storage-dialog h3 { font-size: 13px; margin: 14px 0 6px; }
.storage-bar > div { background: var(--accent); }
.storage-bar > div.high { background: var(--yellow); }
.storage-bar > div.full { background: var(--danger); }

/* Two-step sign-in */
.setup-steps { padding-left: 20px; margin: 0 0 12px; line-height: 1.5; }
.setup-steps li { margin-bottom: 10px; }
.setup-steps .qr { display: block; margin: 10px 0 8px; border: 1px solid var(--line); border-radius: 6px; }
.setup-key { font-size: 13px; word-break: break-all; background: var(--bg); padding: 1px 4px; border-radius: 4px; }
.backup-codes { list-style: none; padding: 12px; margin: 8px 0 10px; display: grid; grid-template-columns: 1fr 1fr; gap: 6px 16px;
  font: 15px/1.4 ui-monospace, Consolas, monospace; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; text-align: center; }
.check-line { display: flex; align-items: center; gap: 8px; margin: 12px 0 4px; font-size: 13px; }

/* First run: the welcome line above the template picker */
.welcome-intro { margin: 0 0 12px; color: var(--muted); }

/* ---------- card (Kanban) and calendar views ---------- */
#view-options { display: inline-flex; align-items: center; gap: 6px; }
.view-pick { font-size: 13px; color: var(--muted); }
.view-pick select { padding: 5px 8px; border: 1px solid var(--line); border-radius: 6px; background: var(--panel); color: var(--text); }
.alt-view { margin-top: 12px; }
.alt-empty { background: var(--panel); border: 1px dashed var(--line); border-radius: 8px; padding: 28px; text-align: center; color: var(--muted); }
.board { display: flex; gap: 12px; align-items: flex-start; overflow-x: auto; padding-bottom: 8px; }
.lane { flex: 0 0 260px; background: #eef0f3; border-radius: 8px; padding: 8px; min-height: 120px; }
.lane.over { outline: 2px solid var(--accent); outline-offset: -2px; background: var(--accent-soft); }
.lane-head { display: flex; justify-content: space-between; font-weight: 600; font-size: 13px; padding: 2px 4px 8px; }
.lane-head .count { color: var(--muted); font-weight: 500; }
.lane-cards { display: flex; flex-direction: column; gap: 8px; min-height: 40px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 8px 10px; cursor: pointer; user-select: none; box-shadow: 0 1px 2px rgba(20,33,61,.06); }
.card.draggable { cursor: grab; }
.card:hover { border-color: #c5cbd4; }
.card.dragging { opacity: .35; }
.card-ghost { position: fixed; z-index: 60; pointer-events: none; cursor: grabbing; box-shadow: 0 8px 24px rgba(20,33,61,.2); transform: rotate(2deg); }
.card-title { font-weight: 600; font-size: 14px; margin-bottom: 4px; overflow-wrap: anywhere; }
.card-field { display: flex; justify-content: space-between; gap: 8px; font-size: 12px; margin-top: 3px; align-items: center; }
.card-label { color: var(--muted); }
.card-counts { font-size: 12px; color: var(--muted); margin-top: 4px; }
.cal-title { font-weight: 600; min-width: 130px; text-align: center; }
.cal { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.cal-names { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); border-bottom: 1px solid var(--line); }
.cal-names div { padding: 6px 8px; font-size: 11px; font-weight: 600; color: var(--muted); text-transform: uppercase; }
.cal-week { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); min-height: 96px; border-bottom: 1px solid var(--line); row-gap: 2px; }
.cal-week:last-child { border-bottom: 0; }
.cal-day { border-right: 1px solid var(--line); padding: 4px 6px; }
.cal-day:nth-child(7) { border-right: 0; }
.cal-day.wkend { background: #fafbfc; }
.cal-day.other .num { color: #b6bcc6; }
.cal-day .num { font-size: 12px; color: var(--muted); }
.cal-day.today .num { background: var(--accent); color: #fff; border-radius: 10px; padding: 1px 6px; font-weight: 600; }
.cal-item { position: relative; z-index: 1; margin: 0 4px; border: 0; border-radius: 4px; background: var(--accent-soft); color: var(--brand-ink); font: inherit; font-size: 12px; text-align: left; padding: 3px 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: pointer; }
.cal-item:hover { background: #c9ebdf; }
.cal-item.parent { font-weight: 600; background: #e3e7ec; }
.cal-item.before { margin-left: 0; border-top-left-radius: 0; border-bottom-left-radius: 0; }
.cal-item.after { margin-right: 0; border-top-right-radius: 0; border-bottom-right-radius: 0; }
.cal-item .dot { width: 9px; height: 9px; margin-right: 4px; vertical-align: 0; }

/* ---------- conditional formatting ---------- */
dialog:has(.cf-rules) { width: min(820px, 94vw); }
.cf-rule { display: grid; grid-template-columns: 1.1fr 1.3fr 1fr auto auto auto; gap: 6px; align-items: center; margin-bottom: 6px; }
.cf-rule select, .cf-rule input[type=text] { padding: 6px 8px; border: 1px solid var(--line); border-radius: 6px; min-width: 0; }
.cf-rule input[hidden] + .cf-colour { grid-column: 4; }
.cf-colour { display: inline-flex; align-items: center; gap: 4px; }
.cf-row { font-size: 12px; white-space: nowrap; color: var(--muted); }
.cf-rules { margin: 8px 0; }
.cf-swatch { display: inline-block; width: 16px; height: 16px; border-radius: 4px; border: 1px solid var(--line); }
.cf-swatch.cf-red, #grid tr td.cf-red, #grid tr.parent td.cf-red { background: #fde4e4; }
.cf-swatch.cf-yellow, #grid tr td.cf-yellow, #grid tr.parent td.cf-yellow { background: #fff3c4; }
.cf-swatch.cf-green, #grid tr td.cf-green, #grid tr.parent td.cf-green { background: #def4e6; }
.cf-swatch.cf-blue, #grid tr td.cf-blue, #grid tr.parent td.cf-blue { background: #e0ecfc; }
.cf-swatch.cf-purple, #grid tr td.cf-purple, #grid tr.parent td.cf-purple { background: #ece5fb; }
.cf-swatch.cf-grey, #grid tr td.cf-grey, #grid tr.parent td.cf-grey { background: #e9ecf0; }

/* ---------- row history (drawer) ---------- */
.hist-item { padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 13px; }
.hist-item:last-child { border-bottom: none; }

/* ---------- row trash bar ---------- */
.trash-bar { padding: 6px 12px; background: #fff8e1; border-bottom: 1px solid #ffe082; font-size: 13px; color: #7a5c00; }

/* ---------- trash modal ---------- */
.trash-row { display: flex; align-items: center; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.trash-row:last-child { border-bottom: none; }
.trash-info { flex: 1; min-width: 0; }
.trash-acts { display: flex; gap: 6px; flex-shrink: 0; }

/* ---------- workload view ---------- */
.wl-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.wl-table th, .wl-table td { padding: 6px 8px; border: 1px solid var(--line); text-align: center; white-space: nowrap; }
.wl-table th { background: var(--bg2); font-weight: 600; }
.wl-name { text-align: left !important; min-width: 120px; }
.wl-today { background: #e8f4fd !important; }
.wl-cell.wl-low { background: #d1fae5; }
.wl-cell.wl-med { background: #fef3c7; }
.wl-cell.wl-high { background: #fee2e2; }
.wl-legend { display: flex; align-items: center; gap: 8px; margin-top: 12px; font-size: 12px; color: var(--muted); }
.wl-dot { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-left: 8px; }
.wl-dot.wl-low { background: #d1fae5; }
.wl-dot.wl-med { background: #fef3c7; }
.wl-dot.wl-high { background: #fee2e2; }

/* ---------- request-update modal ---------- */
.check-group { max-height: 180px; overflow-y: auto; border: 1px solid var(--line); border-radius: 6px; padding: 6px 10px; }
.check-row { display: flex; align-items: center; gap: 6px; padding: 3px 0; font-size: 13px; cursor: pointer; }
.check-row input[type=checkbox] { flex-shrink: 0; }

/* ---------- mobile nudge ---------- */
.mobile-nudge { display: none; background: #fff3cd; color: #664d03; font-size: 13px; padding: 8px 16px; text-align: center; border-bottom: 1px solid #ffe69c; }
.mobile-nudge button { background: none; border: none; cursor: pointer; margin-left: 8px; font-size: 14px; color: inherit; opacity: .7; vertical-align: middle; }
@media (max-width: 767px) { .mobile-nudge { display: block; } }
