:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #eef2f6;
  --text: #14171f;
  --muted: #6b7280;
  --line: #dde3ea;
  --primary: #0f766e;
  --primary-dark: #115e59;
  --danger: #dc2626;
  --warning: #d97706;
  --success: #15803d;
  --radius: 8px;
  --sidebar: 248px;
}

* { box-sizing: border-box; }
html { min-width: 320px; }
body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  letter-spacing: 0;
}
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; font-size: 16px; }
button { cursor: pointer; }
h1 { margin: 0; font-size: clamp(26px, 4vw, 38px); line-height: 1.04; }
h2 { margin: 26px 0 12px; font-size: 18px; }
small, .muted { color: var(--muted); }

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 60px;
  padding: 0 16px;
  background: rgba(255,255,255,.94);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(14px);
}
.brand, .sidebar-title { font-weight: 800; letter-spacing: .02em; }
.top-actions { display: flex; align-items: center; gap: 8px; }

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 40;
  width: var(--sidebar);
  padding: 24px 14px;
  background: #111827;
  color: #fff;
  transform: translateX(0);
}
.sidebar-title { padding: 0 10px 20px; }
.sidebar a {
  display: block;
  padding: 11px 10px;
  border-radius: var(--radius);
  color: rgba(255,255,255,.82);
}
.sidebar a:hover { background: rgba(255,255,255,.08); color: #fff; }
.scrim { display: none; }
.app-shell {
  width: min(1180px, calc(100% - var(--sidebar) - 40px));
  margin-left: var(--sidebar);
  padding: 28px 20px 86px;
}
.auth-shell { min-height: 100svh; display: grid; place-items: center; padding: 20px; }

.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}
.eyebrow {
  margin: 0 0 6px;
  color: var(--primary);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}
.btn, .icon-btn, .pill {
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: var(--radius);
  min-height: 42px;
  padding: 0 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  white-space: nowrap;
}
.btn.primary, .pill { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-dark); }
.icon-btn { width: 42px; padding: 0; }

.login-panel, .form-panel, .preview-panel {
  width: min(560px, 100%);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px;
}
.stack, .form-panel { display: grid; gap: 14px; }
.field { display: grid; gap: 7px; font-weight: 700; }
.field { position: relative; }
.input {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  color: var(--text);
}
textarea.input { resize: vertical; }
.error { color: var(--danger); }
.search { margin: 0 0 16px; }

.split { display: grid; grid-template-columns: 1.4fr .9fr; gap: 22px; }
.list { display: grid; gap: 8px; }
.row, .note, .task-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.row {
  min-height: 58px;
  padding: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.row span:first-child { min-width: 0; }
.row strong, .row small { display: block; overflow-wrap: anywhere; }
.note { padding: 12px; }
.note p { margin: 6px 0; }
.empty { color: var(--muted); background: var(--surface-2); padding: 14px; border-radius: var(--radius); }
.chip {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 9px;
  border-radius: 999px;
  background: var(--surface-2);
  color: #344054;
  font-size: 13px;
  font-weight: 700;
}
.priority-high, .priority-urgent { background: #fee2e2; color: #991b1b; }
.priority-low { background: #e0f2fe; color: #075985; }

.summary-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin: 14px 0 20px;
}
.summary-grid > div {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
  min-width: 0;
}
.summary-grid span { display: block; color: var(--muted); font-size: 13px; margin-bottom: 6px; }
.summary-grid strong { overflow-wrap: anywhere; }
.detail-text { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }

.stage-tabs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 0 0 10px;
  margin-bottom: 10px;
}
.kanban {
  display: grid;
  grid-template-columns: repeat(4, minmax(240px, 1fr));
  gap: 12px;
  align-items: start;
}
.kanban-column {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  min-height: 280px;
  padding: 10px;
}
.kanban-column header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}
.kanban-column header span {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: var(--status-color);
}
.kanban-list { display: grid; gap: 9px; min-height: 180px; }
.task-card { padding: 12px; background: #fff; }
.task-card a { display: grid; gap: 4px; }
.card-meta { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 10px; color: var(--muted); font-size: 13px; }

.toast-stack { position: fixed; z-index: 70; top: 72px; right: 16px; display: grid; gap: 8px; }
.toast { background: #111827; color: #fff; border-radius: var(--radius); padding: 10px 12px; }
.warning { border-left: 4px solid var(--warning); padding: 8px 12px; background: #fffbeb; margin: 14px 0; }
.suggest-box {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  z-index: 50;
  display: grid;
  gap: 2px;
  margin-top: 4px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: 0 14px 30px rgba(17, 24, 39, .12);
}
.suggest-box:empty { display: none; }
.suggest-box button {
  border: 0;
  background: #fff;
  padding: 10px 12px;
  text-align: left;
}
.suggest-box button:hover { background: var(--surface-2); }
.htmx-indicator { display: none; color: var(--muted); }
.htmx-request .htmx-indicator, .htmx-request.htmx-indicator { display: inline-flex; }
.upload { display: flex; gap: 8px; align-items: center; margin-bottom: 12px; }
.bottom-nav, .mobile-only { display: none; }

@media (max-width: 760px) {
  .mobile-only { display: inline-flex; }
  .sidebar { transform: translateX(-105%); transition: transform .18s ease; }
  body.menu-open .sidebar { transform: translateX(0); }
  body.menu-open .scrim { display: block; position: fixed; inset: 0; z-index: 35; background: rgba(17,24,39,.42); }
  .app-shell { width: 100%; margin-left: 0; padding: 18px 14px 84px; }
  .page-head { align-items: stretch; }
  .page-head .btn { align-self: end; }
  .split, .summary-grid { grid-template-columns: 1fr; }
  .kanban { display: flex; overflow-x: auto; scroll-snap-type: x mandatory; }
  .kanban-column { flex: 0 0 min(88vw, 340px); scroll-snap-align: start; }
  .bottom-nav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 25;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    background: rgba(255,255,255,.96);
    border-top: 1px solid var(--line);
    backdrop-filter: blur(14px);
  }
  .bottom-nav a {
    min-height: 58px;
    display: grid;
    place-items: center;
    font-size: 13px;
    font-weight: 700;
  }
  .topbar { height: 56px; }
  .toast-stack { left: 14px; right: 14px; top: 66px; }
  .upload { display: grid; }
}

@media (max-width: 360px) {
  .app-shell { padding-left: 10px; padding-right: 10px; }
  .row { align-items: flex-start; flex-direction: column; }
  .btn { width: 100%; }
}
