/* Control Panel styles — earthy sage on warm paper */
:root {
  --bg: #F7F5F0; --side: #FFFDF8; --panel: #FFFFFF; --sunk: #EFECE4; --tint: #FBF9F4;
  --line: #E7E2D6; --line2: #F1EEE7; --field: #D6D3D1;
  --text: #1C1917; --text2: #44403C; --muted: #57534E; --faint: #A8A29E;
  --accent: #5F7A61; --accent-dark: #3F5A43; --accent-mid: #4A6650; --accent-soft: #E3EBDF; --accent-tint: #F6F8F3;
  --red: #B91C1C; --red-dark: #991B1B; --red-soft: #FEF2F2; --red-line: #FECACA;
  --amber-bg: #FEF3C7; --amber: #92400E;
  --r: 12px; --side-w: 236px; --panel-w: 460px;
  font-family: Inter, system-ui, -apple-system, Segoe UI, sans-serif;
  color: var(--text); background: var(--bg);
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); font-size: 14px; line-height: 1.4; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent-dark); }
h1, h2 { margin: 0; }
h1 { font-family: 'Space Grotesk', Inter, sans-serif; font-size: 28px; font-weight: 700; color: var(--accent-dark); line-height: 1.15; }
h2 { font-size: 15px; font-weight: 600; color: var(--accent-mid); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.muted { color: var(--muted); } .small { font-size: 12px; } .grow { flex: 1; } .min0 { min-width: 0; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.empty { color: var(--muted); font-size: 13px; margin: 4px 0; }
.late-text { color: var(--red); font-weight: 600; }
.loading { padding: 40px; color: var(--muted); }

/* ---------- buttons & fields ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 38px; padding: 0 14px; border-radius: 8px;
  border: 1px solid var(--field); background: #fff; color: var(--text2); font-size: 13px; cursor: pointer; white-space: nowrap; text-decoration: none; }
.btn:hover { border-color: var(--accent); color: var(--accent-dark); }
.btn.sm { height: 32px; padding: 0 10px; font-size: 12px; }
.btn.icon { width: 38px; padding: 0; } .btn.icon.sm { width: 32px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.btn.primary:hover { background: var(--accent-dark); color: #fff; }
.btn.ghost { border-style: dashed; }
.btn.danger { color: var(--red); } .btn.danger:hover { border-color: var(--red); color: var(--red-dark); }
.btn.big { height: 48px; font-size: 15px; padding: 0 24px; }
.link { background: none; border: 0; padding: 0; color: var(--text); cursor: pointer; text-align: left; font-size: inherit; }
.link:hover { color: var(--accent-dark); text-decoration: underline; }
.link.strong { font-weight: 600; } .link.left { text-align: left; }
.mini { background: none; border: 0; color: var(--accent-dark); font-size: 12px; cursor: pointer; padding: 4px 2px; font-weight: 600; }
.input { height: 40px; border: 1px solid var(--field); border-radius: 8px; padding: 0 10px; background: #fff; font-size: 14px; width: 100%; }
.input.sm { height: 30px; font-size: 13px; width: 110px; }
textarea.input { height: auto; padding: 10px; resize: vertical; }
.lbl { display: block; font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 4px; }
.row-btns { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.seg { display: inline-flex; gap: 4px; }
.seg button { height: 38px; padding: 0 12px; border-radius: 8px; border: 1px solid var(--field); background: #fff; color: var(--text2); font-size: 13px; cursor: pointer; }
.seg button.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.pill { font-size: 12px; padding: 3px 8px; border-radius: 6px; white-space: nowrap; }
.st-todo { background: #F5F5F4; color: var(--text2); } .st-doing { background: var(--accent-soft); color: var(--accent-dark); }
.st-waiting { background: var(--amber-bg); color: var(--amber); } .st-done { background: #E7E5E4; color: var(--muted); }
.bar { height: 8px; border-radius: 4px; background: #EDE9E0; overflow: hidden; }
.bar > div { height: 100%; background: var(--accent); border-radius: 4px; }

/* ---------- shell ---------- */
.shell { display: flex; min-height: 100vh; }
.topbar { display: none; }
.side { width: var(--side-w); flex: none; background: var(--side); border-right: 1px solid var(--line); padding: 18px 12px; display: flex; flex-direction: column; gap: 2px;
  position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.brand { font-family: 'Space Grotesk', Inter, sans-serif; font-weight: 700; font-size: 18px; padding: 4px 10px 16px; color: var(--accent-dark); }
.nav-link { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 8px; color: var(--text2); text-decoration: none; font-size: 14px; }
.nav-link:hover { background: var(--accent-tint); color: var(--accent-dark); }
.nav-link.on { background: var(--accent); color: #fff; font-weight: 600; }
.nav-link.sub { padding-left: 22px; font-size: 13px; }
.count { font-size: 12px; color: var(--muted); } .nav-link.on .count { color: #fff; } .count.late { color: var(--red); font-weight: 600; }
.nav-link.on .count.late { color: #fff; }
.side-head { display: flex; justify-content: space-between; align-items: center; font-size: 11px; font-weight: 600; color: var(--accent-mid);
  text-transform: uppercase; letter-spacing: .06em; padding: 18px 10px 4px; }
.side-actions { display: flex; gap: 6px; text-transform: none; letter-spacing: 0; }
.pad { padding: 0 10px; }
.side-foot { margin-top: auto; padding: 18px 10px 4px; display: flex; flex-direction: column; gap: 4px; }
.demo-note { margin: 0 0 6px; font-size: 12px; padding: 8px; border-radius: 8px; background: var(--amber-bg); color: var(--amber); }
.main { flex: 1; min-width: 0; }
.page { padding: 22px 28px 48px; display: flex; flex-direction: column; gap: 16px; max-width: 1400px; }
.page.narrow { max-width: 980px; }
.page-head { display: flex; flex-wrap: wrap; gap: 16px; align-items: flex-end; justify-content: space-between; }
.page-head .sub { font-size: 13px; color: var(--muted); margin-top: 2px; }
.head-qa { flex: 1 1 380px; max-width: 560px; }
.scrim { display: none; }

/* ---------- panels & rows ---------- */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 16px 18px; display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding-bottom: 4px; flex-wrap: wrap; }
.grid3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; align-items: start; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.row { display: flex; align-items: center; gap: 10px; padding: 6px 0; border-bottom: 1px solid var(--line2); min-width: 0; flex-wrap: wrap; }
.row:last-child { border-bottom: 0; }
.row-main { flex: 1 1 200px; min-width: 0; display: flex; flex-direction: column; align-items: flex-start; background: none; border: 0; padding: 2px 0; cursor: pointer; text-align: left; }
.row-title { font-size: 14px; color: var(--text); }
.row-main:hover .row-title { color: var(--accent-dark); text-decoration: underline; }
.row-meta { font-size: 12px; color: var(--muted); display: inline-flex; align-items: center; gap: 4px; }
.rep { display: inline-flex; color: var(--accent-mid); }
.is-done .row-title, .is-done > .link, .is-done .card-title, .trow.is-done .link { color: var(--muted); text-decoration: line-through; }
.is-late .row-meta { color: var(--red-dark); }
.indent { padding-left: 30px; }
.group-lbl { font-size: 12px; font-weight: 600; color: var(--accent-mid); text-transform: uppercase; letter-spacing: .05em; padding: 12px 0 2px; }
.check { width: 20px; height: 20px; border-radius: 6px; border: 2px solid var(--faint); background: #fff; padding: 0; flex: none; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; color: #fff; }
.check:hover { border-color: var(--accent); }
.check.sm { width: 17px; height: 17px; border-radius: 5px; }
.check.done { background: var(--accent); border-color: var(--accent); }
.check.late { border-color: #DC2626; }
.clip { display: inline-flex; align-items: center; gap: 3px; font-size: 12px; color: var(--muted); }
.tags { display: inline-flex; gap: 4px; flex-wrap: wrap; }
.tag { font-size: 12px; padding: 2px 8px; border-radius: 999px; background: var(--accent-soft); color: var(--accent-dark); border: 0; cursor: pointer; display: inline-flex; align-items: center; gap: 4px; }
.tag button { background: none; border: 0; padding: 0; color: inherit; cursor: pointer; display: inline-flex; }
.ag-row { display: flex; align-items: center; gap: 10px; font-size: 14px; padding: 5px 0; flex-wrap: wrap; }
.ag-row.meeting { color: var(--text2); }
.ag-time { width: 70px; flex: none; font-size: 13px; color: var(--muted); }
.ag-time.accent { color: var(--accent-dark); font-weight: 600; }
.ag-row.task .link { font-weight: 600; }
.late-box { margin-top: 8px; padding: 6px 12px; border-radius: 10px; background: var(--red-soft); border: 1px solid var(--red-line); }
.late-box .row { border-color: #F9DADA; }
.late-head { font-size: 12px; font-weight: 700; color: var(--red-dark); text-transform: uppercase; letter-spacing: .05em; padding-top: 4px; }
.late-panel { border-color: var(--red-line); }

/* ---------- quick add ---------- */
.qa { display: flex; flex-direction: column; gap: 2px; }
.qa-input { height: 44px; font-size: 15px; }
.qa.compact .qa-input { height: 34px; font-size: 13px; }
.qa-hint { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: 12px; color: var(--muted); min-height: 0; padding-top: 4px; }
.qa-hint:empty { padding: 0; }
.chip { padding: 2px 8px; border-radius: 6px; background: #F3F1EC; color: var(--text2); }
.chip.tagchip { background: var(--accent-soft); color: var(--accent-dark); }

/* ---------- projects table ---------- */
.ptable { display: flex; flex-direction: column; gap: 12px; }
.prow { display: grid; grid-template-columns: minmax(180px, 1.6fr) minmax(100px, 1fr) repeat(4, minmax(50px, 70px)); gap: 12px; align-items: center; }
.pcount { text-align: center; display: flex; flex-direction: column; } .pcount span { font-size: 11px; color: var(--muted); }

/* ---------- master list ---------- */
.filters { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; background: var(--side); border: 1px solid var(--line); border-radius: var(--r); padding: 12px 14px; }
.field.grow { flex: 1 1 220px; }
.table-wrap { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; overflow-x: auto; }
.table { min-width: 760px; }
.trow { display: grid; grid-template-columns: minmax(300px, 3fr) 180px 100px 150px; gap: 12px; align-items: center; padding: 8px 18px; border-bottom: 1px solid var(--line2); }
.thead { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; border-bottom-color: var(--line); }
.tgroup { padding: 12px 18px 6px; background: var(--tint); border-bottom: 1px solid var(--line2); font-size: 13px; font-weight: 600; color: var(--accent-dark); }
.tcell-task { display: flex; align-items: center; gap: 10px; min-width: 0; flex-wrap: wrap; }
.tcell-task.sub { padding-left: 30px; }

/* ---------- week ---------- */
.week { min-width: 840px; }
.wk-row { display: grid; grid-template-columns: 56px repeat(7, minmax(0, 1fr)); }
.wk-head { border-bottom: 1px solid var(--line); }
.wk-day { padding: 10px 6px; text-align: center; font-size: 13px; font-weight: 500; color: var(--text2); border-left: 1px solid var(--line2); }
.wk-day.today { color: var(--accent-dark); font-weight: 700; }
.wk-any { border-bottom: 1px solid var(--line); min-height: 64px; }
.wk-lbl { font-size: 11px; color: var(--muted); padding: 8px 6px; }
.wk-cell { border-left: 1px solid var(--line2); padding: 6px; display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.today { background: var(--accent-tint); }
.wk-chip { font-size: 12px; padding: 4px 6px; border-radius: 5px; background: #F3F1EC; color: var(--text); border: 0; text-align: left; cursor: pointer; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wk-chip.meeting { background: #E7E5E4; cursor: default; }
.wk-hours { position: relative; }
.wk-hours span { position: absolute; left: 6px; font-size: 11px; color: var(--muted); transform: translateY(2px); }
.wk-col { position: relative; border-left: 1px solid var(--line2); }
.wk-line { position: absolute; left: 0; right: 0; border-top: 1px solid var(--line2); }
.wk-block { position: absolute; border-radius: 5px; padding: 3px 6px; font-size: 12px; overflow: hidden; text-align: left; border: 0; line-height: 1.25; }
.wk-block.meeting { background: #E7E5E4; color: #292524; }
.wk-block.task { background: var(--accent); color: #fff; cursor: pointer; }
.legend { display: flex; gap: 16px; font-size: 12px; color: var(--muted); }
.legend span { display: inline-flex; gap: 6px; align-items: center; }
.sw { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.sw.task { background: var(--accent); } .sw.meeting { background: #E7E5E4; }

/* ---------- board ---------- */
.board { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 14px; align-items: start; }
.col { background: var(--sunk); border-radius: 14px; padding: 12px; display: flex; flex-direction: column; gap: 10px; min-height: 120px; border: 2px solid transparent; }
.col.over { border-color: var(--accent); background: var(--accent-tint); }
.col-head { display: flex; justify-content: space-between; font-size: 14px; color: var(--accent-dark); padding: 2px 4px; }
.card { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 12px; display: flex; flex-direction: column; gap: 8px; cursor: grab; }
.card:active { cursor: grabbing; }
.card-top { display: flex; gap: 10px; align-items: flex-start; }
.card-title { font-weight: 500; }
.card-meta { display: flex; flex-wrap: wrap; gap: 8px; font-size: 12px; color: var(--muted); align-items: center; }
.menu { position: relative; }
.menu summary { list-style: none; } .menu summary::-webkit-details-marker { display: none; }
.menu-pop { position: absolute; right: 0; top: 44px; z-index: 30; background: #fff; border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 8px 24px rgba(28,25,23,.12);
  padding: 6px; display: flex; flex-direction: column; min-width: 200px; }
.menu-pop button { background: none; border: 0; text-align: left; padding: 9px 10px; border-radius: 6px; cursor: pointer; font-size: 13px; }
.menu-pop button:hover { background: var(--accent-tint); }
.menu-pop .danger { color: var(--red); }
.menu-field { display: flex; flex-direction: column; gap: 4px; padding: 6px 10px; font-size: 12px; color: var(--muted); }
.menu-field select { height: 32px; border: 1px solid var(--field); border-radius: 6px; }
.datebtn { position: relative; display: inline-flex; }
.datebtn-input { position: absolute; left: 0; bottom: 0; width: 1px; height: 1px; opacity: 0; pointer-events: none; }

/* ---------- task panel ---------- */
.tpanel { position: fixed; top: 0; right: 0; bottom: 0; width: var(--panel-w); max-width: 100vw; background: #fff; border-left: 1px solid var(--line);
  box-shadow: -12px 0 32px rgba(28,25,23,.08); overflow-y: auto; padding: 20px 24px 28px; display: flex; flex-direction: column; gap: 18px; z-index: 40; outline: none; }
.panel-scrim { display: block; position: fixed; inset: 0; z-index: 35; background: transparent; }
.tp-top { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.crumb { font-size: 12px; color: var(--muted); }
.crumb .link { color: var(--muted); }
.tp-title { display: flex; gap: 12px; align-items: flex-start; }
.tp-title .check { margin-top: 8px; }
.title-input { flex: 1; border: 1px solid transparent; border-radius: 8px; padding: 4px 6px; font-family: 'Space Grotesk', Inter, sans-serif; font-size: 22px; font-weight: 700;
  resize: none; overflow: hidden; line-height: 1.25; color: var(--accent-dark); background: transparent; }
.title-input:hover, .title-input:focus { border-color: var(--field); background: #fff; }
.tp-fields { display: grid; grid-template-columns: 90px minmax(0, 1fr); gap: 10px; align-items: center; }
.tp-fields > * { min-width: 0; }
.tp-fields > label, .tp-lbl { color: var(--muted); font-size: 13px; }
.tp-inline { display: flex; gap: 8px; align-items: center; min-width: 0; }
.tp-inline .input { min-width: 0; flex: 1 1 auto; }
.tp-inline .input.time { width: 130px; flex: 0 0 130px; }
.tp-tags { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.tag.on { cursor: default; }
.tp-sec { display: flex; flex-direction: column; gap: 8px; }
.sec-head { display: flex; justify-content: space-between; align-items: center; }
.sec-lbl { font-size: 12px; font-weight: 600; color: var(--accent-mid); text-transform: uppercase; letter-spacing: .05em; }
.notes { min-height: 80px; }
.sub-row { display: flex; gap: 10px; align-items: center; padding: 6px 0; border-bottom: 1px solid var(--line2); }
.drop { border: 1.5px dashed var(--faint); border-radius: 10px; padding: 12px 14px; display: flex; align-items: center; gap: 12px; background: var(--tint); color: var(--text2); font-size: 13px; }
.drop.over { border-color: var(--accent); background: var(--accent-tint); }
.file-row { display: flex; gap: 12px; align-items: center; padding: 6px 0; border-bottom: 1px solid var(--line2); }
.fkind { width: 40px; height: 40px; border-radius: 8px; font-size: 11px; font-weight: 700; display: flex; align-items: center; justify-content: center; flex: none; }
.k-pdf { background: #FEE2E2; color: #991B1B; } .k-doc { background: #DBEAFE; color: #1E3A8A; } .k-xls { background: #DCFCE7; color: #166534; }
.k-ppt { background: #FFEDD5; color: #9A3412; } .k-eml { background: var(--amber-bg); color: var(--amber); } .k-img { background: var(--accent-soft); color: var(--accent-dark); }
.k-file { background: #F5F5F4; color: var(--text2); }
.fname { font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tp-foot { margin-top: auto; display: flex; justify-content: space-between; align-items: center; padding-top: 8px; }

/* ---------- login & toast ---------- */
.login { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.login-card { background: #fff; border: 1px solid var(--line); border-radius: 18px; padding: 40px 36px; max-width: 420px; width: 100%; display: flex; flex-direction: column; gap: 14px; text-align: center; }
.login-card p { margin: 0; }
.toast-area { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); z-index: 60; }
.toast { padding: 12px 16px; border-radius: 10px; background: #292524; color: #fff; font-size: 13px; box-shadow: 0 8px 24px rgba(0,0,0,.2); max-width: 90vw; }
.toast.error { background: var(--red-dark); }

/* ---------- phones & small screens ---------- */
@media (max-width: 860px) {
  .shell { flex-direction: column; }
  .topbar { display: flex; align-items: center; gap: 10px; padding: 10px 14px; background: var(--side); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; }
  .topbar .brand { padding: 0; }
  .side { position: fixed; left: 0; top: 0; bottom: 0; z-index: 50; transform: translateX(-100%); transition: transform .2s; box-shadow: 8px 0 24px rgba(0,0,0,.1); }
  .side.open { transform: none; }
  .scrim { display: block; position: fixed; inset: 0; background: rgba(28,25,23,.35); z-index: 45; }
  .panel-scrim { background: rgba(28,25,23,.35); }
  .page { padding: 16px 14px 40px; }
  h1 { font-size: 24px; }
  .tpanel { width: 100vw; padding: 16px; }
  .prow { grid-template-columns: 1fr 1fr; }
  .prow .pcount { display: none; }
  .tp-fields { grid-template-columns: 80px minmax(0, 1fr); }
}
