*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: var(--fs-md);
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  letter-spacing: -0.005em;
}
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
a { color: inherit; text-decoration: none; }
svg.i { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.mono { font-family: var(--mono); }

/* ---------- App shell ---------- */
.app { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr) 0px; height: 100vh; transition: grid-template-columns .18s ease; }
body.collapsed .app { grid-template-columns: var(--sidebar-w-collapsed) minmax(0, 1fr) 0px; }
body.has-panel:not(.panel-closed) .app { grid-template-columns: var(--sidebar-w) minmax(0, 1fr) var(--panel-w); }
body.has-panel:not(.panel-closed).collapsed .app { grid-template-columns: var(--sidebar-w-collapsed) minmax(0, 1fr) var(--panel-w); }
.panel { overflow: hidden; border-left: 1px solid var(--line); display: none; }
body.has-panel:not(.panel-closed) .panel { display: block; }
body.public-mode .app { display: none; }
#public { display: none; }
body.public-mode #public { display: block; }

.sidebar {
  background: var(--bg-sidebar);
  border-right: 1px solid var(--line);
  display: flex; flex-direction: column;
  padding: 0 8px 8px;
  overflow: hidden;
}
.sb-top { height: var(--header-h); display: flex; align-items: center; justify-content: space-between; padding: 0 4px 0 8px; flex: none; }
.logo { display: flex; align-items: center; gap: 6px; font-size: 14px; letter-spacing: -0.02em; white-space: nowrap; }
.logo b { font-weight: 700; }
.logo span { font-weight: 300; }
.logo svg { width: 15px; height: 15px; }
.icon-btn { width: 28px; height: 28px; display: grid; place-items: center; border-radius: var(--r-sm); color: var(--text-2); }
.icon-btn:hover { background: var(--surface-hover); color: var(--text); }

.ws-switch {
  display: flex; align-items: center; gap: 10px; width: 100%;
  margin-top: 6px; padding: 8px; border-radius: var(--r-md); text-align: left;
}
.ws-switch:hover { background: var(--surface-hover); }
.ws-lock { width: 24px; height: 24px; display: grid; place-items: center; color: var(--text-2); flex: none; }
.ws-text { flex: 1; min-width: 0; line-height: 1.2; }
.ws-text .n { font-size: 13px; }
.ws-text .s { font-size: 10px; letter-spacing: .06em; color: var(--text-3); text-transform: uppercase; }
.ws-switch > svg { color: var(--text-3); }

.find {
  display: flex; align-items: center; gap: 8px; width: 100%;
  margin: 8px 0 10px; padding: 0 8px; height: 32px;
  border: 1px solid var(--line-strong); border-radius: var(--r-md);
  color: var(--text-3); font-size: 13px; text-align: left;
}
.find:hover { border-color: #3a3a3a; color: var(--text-2); }
.find span { flex: 1; }
.kbd {
  font-family: var(--font); font-size: 10px; color: var(--text-3);
  background: var(--surface); border-radius: 4px; padding: 1px 5px;
}

.nav { display: flex; flex-direction: column; gap: 1px; }
.nav-item {
  display: flex; align-items: center; gap: 10px; height: 29px; padding: 0 8px;
  border-radius: var(--r-md); color: var(--text-2); font-size: 13px; white-space: nowrap;
}
.nav-item:hover { background: var(--surface-hover); color: var(--text); }
.nav-item.active { background: var(--surface-active); color: var(--text); }
.nav-item .grow { flex: 1; }
.nav-item .chev { color: var(--text-3); }
.nav-sep { height: 1px; background: var(--line); margin: 9px 0; flex: none; }

.group { margin-top: 2px; }
.group-head {
  display: flex; align-items: center; gap: 4px; height: 28px; padding: 0 8px; width: 100%;
  color: var(--text-2); font-size: 12px;
}
.group-head .count { margin-left: auto; font-family: var(--mono); font-size: 11px; color: var(--text-3); }
.group-head svg { width: 12px; height: 12px; }
.group-item {
  display: block; padding: 6px 8px 6px 8px; font-size: 12.5px; color: var(--text-2);
  border-radius: var(--r-md); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.group-item:hover { background: var(--surface-hover); color: var(--text); }
.group-item.active { background: var(--surface-active); color: var(--text); }
.group-new { display: flex; align-items: center; gap: 10px; height: 29px; padding: 0 8px; color: var(--text-2); font-size: 13px; width: 100%; border-radius: var(--r-md); }
.group-new:hover { background: var(--surface-hover); color: var(--text); }
.sb-spacer { flex: 1; }

/* collapsed sidebar */
body.collapsed .sidebar { padding: 0 8px 8px; }
body.collapsed .logo, body.collapsed .ws-text, body.collapsed .ws-switch > svg,
body.collapsed .find span, body.collapsed .find .kbd,
body.collapsed .nav-item .label, body.collapsed .nav-item .chev,
body.collapsed .group-head, body.collapsed .group-item,
body.collapsed .group-new .label { display: none; }
body.collapsed .sb-top { justify-content: center; padding: 0; }
body.collapsed .ws-switch { justify-content: center; padding: 8px 0; }
body.collapsed .find { justify-content: center; padding: 0; }
body.collapsed .nav-item, body.collapsed .group-new { justify-content: center; padding: 0; }

/* ---------- Main ---------- */
.main { display: flex; flex-direction: column; min-width: 0; height: 100vh; }
.topbar {
  height: var(--header-h); flex: none; display: flex; align-items: center; justify-content: flex-end; gap: 10px;
  padding: 0 14px; border-bottom: 1px solid var(--line);
}
.btn-new {
  display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 12px;
  border: 1px solid var(--line-strong); border-radius: var(--r-pill); font-size: 13px;
}
.btn-new:hover { background: var(--surface-hover); }
.avatar {
  border: 0; padding: 0; cursor: pointer;
  width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center;
  font-size: 10px; font-weight: 600; color: #fff;
  background: radial-gradient(circle at 30% 25%, #e8d9c4 0%, #6d7f9c 45%, #1c2230 100%);
}
.scroll { flex: 1; overflow-y: auto; }
.page { max-width: var(--content-w); margin: 0 auto; padding: 36px 32px 80px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 32px; padding: 0 12px; border-radius: var(--r-md); font-size: 13px; font-weight: 500;
  border: 1px solid var(--line-strong);
}
.btn:hover { background: var(--surface-hover); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.primary:hover { background: #e6e6e6; }
.btn.lg { height: 34px; padding: 0 14px; }

/* ---------- Page header ---------- */
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.page-title { margin: 0; font-size: var(--fs-title); font-weight: 600; letter-spacing: -0.02em; line-height: 1.25; }
.page-sub { margin-top: 6px; color: var(--text-2); font-size: 13px; }
.page-sub b { color: var(--text); font-weight: 500; }

/* ---------- Sections ---------- */
.section { margin-top: 26px; }
.section-head {
  display: flex; align-items: baseline; justify-content: space-between;
  padding-bottom: 10px; border-bottom: 1px solid var(--line);
}
.section-head h2 { margin: 0; font-size: 13px; font-weight: 500; }
.section-head .aside { font-size: 12px; color: var(--text-2); }
.section-head a.aside:hover { color: var(--text); }
.section-body { padding-top: 16px; color: var(--text-2); }
.muted { color: var(--text-2); }
.faint { color: var(--text-3); }

.cols3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 32px; }
.stat-l { font-size: 12px; color: var(--text-2); margin-bottom: 10px; }
.stat-v { font-size: 13px; color: var(--text-3); }
.stat-v.has { color: var(--text); }

/* ---------- Timeline ---------- */
.tl { display: flex; margin-top: 18px; --days: 30; --row: 36px; }
.tl-label-col { width: 231px; flex: none; padding-top: 38px; }
.tl-label { height: var(--row); display: flex; align-items: center; padding-left: 4px; color: var(--text); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tl-label:hover { text-decoration: underline; text-underline-offset: 3px; }
.tl-grid { flex: 1; position: relative; }
.tl-head { display: flex; height: 38px; }
.tl-day { flex: 1; position: relative; display: flex; align-items: flex-end; justify-content: center; padding-bottom: 5px; font-family: var(--mono); font-size: 10.5px; color: var(--text-2); }
.tl-day .top { position: absolute; top: 2px; left: 0; font-family: var(--font); font-size: 10px; color: var(--text-2); white-space: nowrap; }
.tl-day.wk { color: var(--text-4); }
.tl-day.today { color: var(--text); font-weight: 600; }
.tl-day.today .top { color: var(--text); font-weight: 500; }
.tl-day.past { color: var(--text-4); }
.tl-body { position: relative; }
.tl-wk { position: absolute; top: 0; bottom: 0; background: #0f0f0f; }
.tl-today-line { position: absolute; top: -8px; bottom: 0; width: 1px; background: var(--text); opacity: .85; }
.tl-row { position: relative; height: var(--row); }
.tl-ms { position: absolute; top: 50%; width: 9px; height: 9px; transform: translate(-50%, -50%) rotate(45deg); border: 1px solid var(--text); background: var(--bg); }
.tl-ms.done { background: var(--text); }
.tl-shoot { position: absolute; top: 50%; height: 10px; transform: translateY(-50%); border-radius: 3px; background: var(--text); }
.tl-deliv { position: absolute; top: 6px; bottom: 6px; width: 2px; background: var(--text); }
.tl-del-col { width: 84px; flex: none; padding-top: 38px; text-align: right; position: relative; }
.tl-del-col .hd { position: absolute; top: 8px; right: 0; font-size: 12px; color: var(--text-2); }
.tl-del { height: var(--row); display: flex; align-items: center; justify-content: flex-end; font-family: var(--mono); font-size: 11px; color: var(--text-2); }

.legend { display: flex; align-items: center; gap: 16px; margin: 12px 0 0 231px; font-size: 12px; color: var(--text-2); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.lg-bar { width: 14px; height: 8px; border-radius: 2px; background: var(--text); }
.lg-dia { width: 8px; height: 8px; border: 1px solid var(--text); transform: rotate(45deg); }
.lg-line { width: 2px; height: 12px; background: var(--text); }

/* ---------- Placeholder pages ---------- */
.stub { padding-top: 6px; }
.empty-box { margin-top: 28px; }
.empty-box h3 { margin: 0 0 6px; font-size: 14px; font-weight: 500; }
.empty-box p { margin: 0 0 14px; color: var(--text-2); max-width: 460px; }

/* ---------- Command palette ---------- */
.overlay { position: fixed; inset: 0; background: rgba(0,0,0,.55); display: none; align-items: flex-start; justify-content: center; padding-top: 14vh; z-index: 50; }
.overlay.open { display: flex; }
.palette { width: 580px; max-width: calc(100vw - 32px); background: #0f0f0f; border: 1px solid var(--line-strong); border-radius: 14px; overflow: hidden; box-shadow: 0 20px 60px rgba(0,0,0,.6); }
.pal-input { display: flex; align-items: center; gap: 10px; padding: 0 16px; height: 52px; border-bottom: 1px solid var(--line); color: var(--text-3); }
.pal-input input { flex: 1; background: none; border: 0; outline: 0; color: var(--text); font: inherit; font-size: 14px; }
.pal-list { max-height: 340px; overflow-y: auto; padding: 8px; }
.pal-group { font-size: 11px; color: var(--text-3); padding: 8px 10px 6px; }
.pal-item { display: flex; align-items: center; gap: 12px; width: 100%; padding: 0 10px; height: 36px; border-radius: var(--r-md); text-align: left; font-size: 13.5px; }
.pal-item.sel { background: var(--surface-active); }
.pal-foot { display: flex; gap: 16px; padding: 10px 16px; border-top: 1px solid var(--line); font-size: 11px; color: var(--text-3); }

/* ---------- Toast ---------- */
.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(20px); opacity: 0; background: #1a1a1a; border: 1px solid var(--line-strong); border-radius: var(--r-md); padding: 9px 14px; font-size: 12.5px; transition: .2s; pointer-events: none; z-index: 60; }
.toast.show { opacity: 1; transform: translateX(-50%); }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #1f1f1f; border-radius: 10px; border: 2px solid var(--bg); }
