:root {
  --bg: #f4f6fa;
  --bg-2: #ffffff;
  --panel: #ffffff;
  --panel-2: #f0f3f8;
  --line: #e2e7ef;
  --line-soft: #ebeef4;
  --text: #1a2130;
  --muted: #5b6675;
  --dim: #8994a3;
  --accent: #3d63dd;
  --accent-soft: rgba(61, 99, 221, 0.1);
  --todo: #db2777;
  --wip: #b5650a;
  --done: #0f8a58;
  --danger: #c22a4e;
  --urgent: #c22a4e;
  --high: #b5650a;
  --radius: 10px;
  --radius-sm: 7px;
  --shadow: 0 8px 28px rgba(30, 41, 59, 0.1);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, "Cascadia Mono", Consolas, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  color-scheme: light;
  overflow-x: hidden;
}

button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent); text-decoration: none; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #cbd3de; border-radius: 6px; border: 2px solid var(--bg); }
::-webkit-scrollbar-track { background: transparent; }

/* ---------- layout ---------- */

.shell { display: flex; min-height: 100vh; min-width: 0; }

.company-chip {
  margin: 0 8px 10px;
  padding: 4px 8px;
  font-size: 11.5px;
  color: var(--muted);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  gap: 8px;
}
.company-chip-logo {
  width: 20px;
  height: 20px;
  border-radius: 4px;
  object-fit: contain;
  flex-shrink: 0;
  background: var(--panel-2);
}

.topbar-impersonation {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 5px 10px;
  background: #fdf1d6;
  border: 1px solid #f0d78c;
  border-radius: var(--radius-sm);
  color: #7a5b0e;
  font-size: 12.5px;
  white-space: nowrap;
  max-width: 100%;
  min-width: 0;
}
.topbar-impersonation > span {
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}
.topbar-impersonation strong { color: #5c4409; font-weight: 600; }
.topbar-impersonation .btn {
  background: #fff8e8;
  border-color: #ecc76c;
  color: #6b4e0b;
  font-size: 12px;
  flex-shrink: 0;
}
.topbar-impersonation .btn:hover {
  background: #fbe8b8;
  border-color: #d9a93a;
  color: #4a3608;
}

.sidebar {
  width: 232px;
  flex: 0 0 232px;
  background: var(--bg-2);
  border-right: 1px solid var(--line);
  padding: 18px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  z-index: 40;
}

.brand {
  display: flex; align-items: center; gap: 9px;
  padding: 4px 8px 16px;
  font-weight: 650; font-size: 15px; letter-spacing: -0.01em;
  min-width: 0;
}
.brand > div { min-width: 0; overflow: hidden; }
.brand-mark {
  width: 26px; height: 26px; border-radius: 7px;
  background: linear-gradient(135deg, var(--accent), #8f7ae5);
  display: grid; place-items: center; font-size: 14px;
  flex-shrink: 0;
}
.brand-logo {
  width: 28px; height: 28px; border-radius: 7px;
  object-fit: contain; flex-shrink: 0;
  background: var(--panel);
}
.brand-logo-lg {
  width: 40px; height: 40px; border-radius: 10px;
}
.brand small { display: block; font-weight: 400; font-size: 11px; color: var(--dim); letter-spacing: 0; }

.nav-label {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.09em;
  color: var(--dim); padding: 16px 10px 6px; font-weight: 600;
}

.nav-item {
  display: flex; align-items: center; gap: 9px;
  padding: 7px 10px; border-radius: var(--radius-sm);
  color: var(--muted); background: none; border: 0; width: 100%;
  text-align: left; font-size: 13.5px;
  min-width: 0;
}
.nav-item > span:nth-child(2) {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}
.nav-item:hover { background: var(--panel-2); color: var(--text); }
.nav-item.active { background: var(--accent-soft); color: #2447b3; font-weight: 550; }
.nav-item .count { margin-left: auto; font-size: 11px; color: var(--dim); font-variant-numeric: tabular-nums; }
.nav-item.active .count { color: #4f6fd6; }
.nav-item .pill-badge {
  margin-left: auto; background: var(--danger); color: #fff;
  font-size: 10px; font-weight: 700; padding: 1px 6px; border-radius: 9px;
  flex-shrink: 0;
}

.sidebar-foot { margin-top: auto; padding-top: 14px; border-top: 1px solid var(--line); }

.main-wrap {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  width: 100%;
}

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; width: 100%; }

/* Mobile chrome — hidden on desktop */
.mobile-bar { display: none; }
.sidebar-backdrop { display: none; }
.sidebar-close { display: none; }
.menu-toggle {
  display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; padding: 0; flex-shrink: 0;
  background: var(--panel-2); border: 1px solid var(--line);
  border-radius: var(--radius-sm); color: var(--text); font-size: 18px; line-height: 1;
}
.menu-toggle:hover { background: #e6ebf3; border-color: #cdd6e3; }

.topbar {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 14px 24px; border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.85); backdrop-filter: blur(8px);
  position: sticky; top: 0; z-index: 20;
}
.topbar h1 {
  margin: 0; font-size: 17px; font-weight: 600; letter-spacing: -0.01em;
  min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.topbar .sub { color: var(--dim); font-size: 12.5px; flex-shrink: 1; min-width: 0; }
.spacer { flex: 1 1 auto; min-width: 8px; }
.topbar-center-btn {
  /* Stay in normal flow so it never overlaps title/actions on any width */
  flex-shrink: 0;
}
.topbar > .btn { flex-shrink: 0; }

.content { padding: 20px 24px 60px; flex: 1; min-width: 0; }

/* ---------- controls ---------- */

.btn {
  background: var(--panel-2); border: 1px solid var(--line);
  padding: 7px 13px; border-radius: var(--radius-sm); color: var(--text);
  font-size: 13px; transition: background 0.12s, border-color 0.12s;
}
.btn:hover { background: #e6ebf3; border-color: #cdd6e3; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 550; }
.btn-primary:hover { background: #3253c4; border-color: #3253c4; }
.btn-ghost { background: none; border-color: transparent; color: var(--muted); }
.btn-ghost:hover { background: var(--panel); color: var(--text); }
.btn-sm { padding: 4px 9px; font-size: 12px; }
.btn-danger { color: var(--danger); border-color: rgba(194, 42, 78, 0.4); }
.btn-danger:hover { background: rgba(194, 42, 78, 0.1); border-color: var(--danger); color: var(--danger); }
.btn-highlight { background: var(--done); border-color: var(--done); color: #fff; font-weight: 550; }
.btn-highlight:hover { background: #0b6e46; border-color: #0b6e46; }

.input, .select, .textarea {
  background: var(--bg); border: 1px solid var(--line);
  border-radius: var(--radius-sm); padding: 8px 11px; width: 100%;
  transition: border-color 0.12s, box-shadow 0.12s;
}
.input:focus, .select:focus, .textarea:focus {
  outline: 0; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft);
}
.textarea { resize: vertical; min-height: 76px; line-height: 1.55; }
.select { appearance: none; padding-right: 28px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath fill='%235b6675' d='M0 0h10L5 6z'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center; }
label.field { display: block; margin-bottom: 12px; }
label.field > span { display: block; font-size: 11.5px; color: var(--muted); margin-bottom: 5px; font-weight: 550; }

/* Date / datetime inputs — visible picker icon on light theme */
input[type="date"],
input[type="datetime-local"] {
  color-scheme: light;
  padding-right: 38px;
}
input[type="date"]::-webkit-calendar-picker-indicator,
input[type="datetime-local"]::-webkit-calendar-picker-indicator {
  cursor: pointer;
  width: 18px;
  height: 18px;
  margin: 0 2px 0 4px;
  padding: 0;
  opacity: 1;
  /* Custom dark icon — do not invert (color-scheme: light already adjusts native UI) */
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%235b6675' stroke-width='2.1' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3' y='5' width='18' height='16' rx='2'/%3E%3Cpath d='M16 3v4M8 3v4M3 11h18'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: center;
  background-size: 16px 16px;
  /* Hide native glyph; keep the hit target */
  color: transparent;
  filter: none !important;
}
input[type="date"]::-webkit-calendar-picker-indicator:hover,
input[type="datetime-local"]::-webkit-calendar-picker-indicator:hover {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%231a2130' stroke-width='2.1' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3' y='5' width='18' height='16' rx='2'/%3E%3Cpath d='M16 3v4M8 3v4M3 11h18'/%3E%3C/svg%3E");
}

/* ---------- composer ---------- */

.composer { position: relative; margin-bottom: 18px; }
.composer-box {
  display: flex; align-items: flex-start; gap: 10px;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 10px 12px;
  transition: border-color 0.12s, box-shadow 0.12s;
}
.composer-box:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.composer-input {
  flex: 1; background: none; border: 0; outline: 0;
  padding: 6px 0; font-size: 14.5px; resize: none;
  min-height: 32px; max-height: 160px; line-height: 1.5; overflow-y: auto;
}
.composer-hint { font-size: 11.5px; color: var(--dim); margin-top: 7px; padding-left: 2px; }
.composer-hint code {
  font-family: var(--mono); background: var(--panel-2); padding: 1px 5px;
  border-radius: 4px; color: var(--muted); font-size: 11px;
}

.mention-menu {
  position: fixed; z-index: 150; min-width: 250px; max-width: min(360px, calc(100vw - 24px));
  max-height: 264px; overflow-y: auto;
  background: var(--panel-2); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 5px;
}
.mention-item {
  display: flex; align-items: center; gap: 9px; padding: 7px 9px;
  border-radius: var(--radius-sm); cursor: pointer;
}
.mention-item.active { background: var(--accent-soft); }
.mention-item .handle { color: var(--dim); font-size: 12px; margin-left: auto; font-family: var(--mono); }

/* ---------- avatars & chips ---------- */

.avatar {
  width: 26px; height: 26px; flex: 0 0 auto; border-radius: 50%;
  display: grid; place-items: center; font-size: 10.5px; font-weight: 700;
  color: #fff; letter-spacing: 0.02em; user-select: none;
}
.avatar.sm { width: 20px; height: 20px; font-size: 9px; }
.avatar.lg { width: 46px; height: 46px; font-size: 16px; }
.avatar.xl { width: 62px; height: 62px; font-size: 21px; }
.avatar-stack { display: flex; }
.avatar-stack .avatar { margin-left: -6px; border: 2px solid var(--panel); }
.avatar-stack .avatar:first-child { margin-left: 0; }

.chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 8px; border-radius: 20px; font-size: 11.5px;
  background: var(--panel-2); border: 1px solid var(--line); color: var(--muted);
}
.chip.status-todo { color: var(--todo); }
.chip.status-wip { color: var(--wip); border-color: rgba(181, 101, 10, 0.3); background: rgba(181, 101, 10, 0.1); }
.chip.status-done { color: var(--done); border-color: rgba(15, 138, 88, 0.3); background: rgba(15, 138, 88, 0.1); }
.chip.prio-high { color: var(--high); border-color: rgba(181, 101, 10, 0.35); }
.chip.prio-urgent { color: var(--urgent); border-color: rgba(194, 42, 78, 0.4); background: rgba(194, 42, 78, 0.1); font-weight: 600; }
.chip.overdue { color: var(--danger); border-color: rgba(194, 42, 78, 0.4); background: rgba(194, 42, 78, 0.1); }

.mention-tag {
  color: #2447b3; background: var(--accent-soft);
  padding: 0 4px; border-radius: 4px; font-weight: 550;
}

/* ---------- board ---------- */

.board {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  align-items: start;
}

.column {
  background: var(--bg-2); border: 1px solid var(--line);
  border-radius: var(--radius); display: flex; flex-direction: column;
  min-height: 220px; overflow: hidden; transition: border-color 0.15s, background 0.15s;
}
.column.drag-over { border-color: var(--accent); background: rgba(61, 99, 221, 0.06); }
.column-head {
  display: flex; align-items: center; gap: 8px;
  padding: 12px 14px; border-bottom: 1px solid var(--line-soft);
}
.column-head .dot { width: 8px; height: 8px; border-radius: 50%; }
.column-head h2 { margin: 0; font-size: 13px; font-weight: 600; letter-spacing: 0.01em; }
.column[data-col="todo"] .column-head { background: rgba(219, 39, 119, 0.09); }
.column[data-col="todo"] .column-head h2 { color: var(--todo); }
.column[data-col="wip"] .column-head { background: rgba(181, 101, 10, 0.09); }
.column[data-col="wip"] .column-head h2 { color: var(--wip); }
.column[data-col="done"] .column-head { background: rgba(15, 138, 88, 0.09); }
.column[data-col="done"] .column-head h2 { color: var(--done); }
.column-head .n {
  margin-left: auto; font-size: 11.5px; color: var(--dim);
  background: var(--panel); padding: 1px 8px; border-radius: 10px; font-variant-numeric: tabular-nums;
}
.column-body { padding: 10px; display: flex; flex-direction: column; gap: 9px; min-height: 60px; }

.card {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius-sm); padding: 11px 12px;
  cursor: pointer; transition: border-color 0.12s, transform 0.08s, box-shadow 0.12s;
}
.card:hover { border-color: #c3cddb; box-shadow: 0 3px 14px rgba(30, 41, 59, 0.1); }
.card.dragging { opacity: 0.45; transform: rotate(1.5deg); }
.card-title { font-size: 13.5px; line-height: 1.45; margin-bottom: 9px; word-break: break-word; }
.card-meta { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }
.card-meta .when { font-size: 11px; color: var(--dim); margin-left: auto; }
.card-assignee { display: flex; align-items: center; gap: 6px; font-size: 11.5px; color: var(--muted); }
.card-sub { font-size: 11px; color: var(--dim); display: flex; gap: 10px; margin-top: 7px; }

.empty {
  text-align: center; color: var(--dim); font-size: 12.5px;
  padding: 26px 12px; border: 1px dashed var(--line); border-radius: var(--radius-sm);
}

/* ---------- dashboard ---------- */

.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(158px, 1fr)); gap: 12px; margin-bottom: 20px; }
.stat {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 14px 15px;
}
.stat .k { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; font-weight: 600; }
.stat .v { font-size: 27px; font-weight: 650; margin-top: 6px; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.stat .note { font-size: 11.5px; color: var(--dim); margin-top: 2px; }
.stat.accent .v { color: var(--accent); }
.stat.warn .v { color: var(--wip); }
.stat.good .v { color: var(--done); }
.stat.bad .v { color: var(--danger); }

.panel {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); margin-bottom: 16px; overflow: hidden;
}
.panel-head {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 15px; border-bottom: 1px solid var(--line-soft);
}
.panel-head h3 { margin: 0; font-size: 13px; font-weight: 600; }
.panel-head .sub { font-size: 11.5px; color: var(--dim); margin-left: auto; }
.panel-body { padding: 13px 15px; }
/* Wide content (the throughput table) scrolls inside the panel instead of pushing the page sideways. */
.panel-body.flush { padding: 0; overflow-x: auto; }

.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
@media (max-width: 1080px) { .two-col { grid-template-columns: 1fr; } }

.row-list { display: flex; flex-direction: column; }
.row-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 15px; border-bottom: 1px solid var(--line-soft);
  cursor: pointer; font-size: 13px;
}
.row-item:last-child { border-bottom: 0; }
.row-item:hover { background: var(--panel-2); }
.row-item .t { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-item .when { font-size: 11px; color: var(--dim); white-space: nowrap; }

.spark { display: flex; align-items: flex-end; gap: 3px; height: 46px; }
.spark .bar { flex: 1; background: var(--accent); border-radius: 2px 2px 0 0; min-height: 2px; opacity: 0.85; }
.spark .bar.zero { background: var(--line); opacity: 1; }

.workload-row { display: flex; align-items: center; gap: 11px; padding: 9px 15px; border-bottom: 1px solid var(--line-soft); cursor: pointer; min-width: 0; }
.workload-row:last-child { border-bottom: 0; }
.workload-row:hover { background: var(--panel-2); }
.workload-row .who { width: 168px; max-width: 40%; flex-shrink: 0; display: flex; align-items: center; gap: 8px; font-size: 13px; min-width: 0; }
.workload-row .who span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-track { flex: 1; min-width: 48px; display: flex; height: 16px; border-radius: 4px; overflow: hidden; background: var(--bg); }
.bar-seg { transition: width 0.25s; }
.bar-seg.todo { background: var(--todo); }
.bar-seg.wip { background: var(--wip); }
.bar-seg.done { background: var(--done); }
.workload-row .nums { width: 128px; text-align: right; font-size: 11.5px; color: var(--dim); font-variant-numeric: tabular-nums; }

/* ---------- history / activity ---------- */

.feed { display: flex; flex-direction: column; }
.feed-item { display: flex; gap: 10px; padding: 10px 15px; border-bottom: 1px solid var(--line-soft); font-size: 13px; }
.feed-item:last-child { border-bottom: 0; }
.feed-item .body { flex: 1; min-width: 0; }
.feed-item .meta { font-size: 11px; color: var(--dim); margin-top: 2px; }
.feed-item .quote {
  margin-top: 5px; padding: 6px 9px; background: var(--bg);
  border-left: 2px solid var(--line); border-radius: 0 5px 5px 0;
  color: var(--muted); font-size: 12.5px;
}
.feed-item .task-ref { color: var(--muted); cursor: pointer; }
.feed-item .task-ref:hover { color: var(--accent); }

/* ---------- drawer ---------- */

/* ---------- loader ---------- */

.app-loader {
  position: fixed; inset: 0; z-index: 200;
  display: grid; place-items: center;
  background: rgba(244, 246, 250, 0.85);
  backdrop-filter: blur(2px);
}
.app-loader[hidden] { display: none; }
.app-loader-inner {
  display: flex; flex-direction: column; align-items: center; gap: 14px;
  padding: 24px 28px; border-radius: 12px;
  background: var(--panel); border: 1px solid var(--line);
  box-shadow: var(--shadow);
}
.app-loader-text { font-size: 13px; color: var(--muted); font-weight: 500; }
.spinner {
  width: 32px; height: 32px;
  border: 3px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

#overlay:empty { display: none; }
.backdrop {
  position: fixed; inset: 0; background: rgba(17, 24, 39, 0.42);
  z-index: 90;
}
.backdrop.anim-in { animation: fade 0.14s ease; }
@keyframes fade { from { opacity: 0; } }

.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(620px, 100vw);
  background: var(--bg-2); border-left: 1px solid var(--line);
  z-index: 100; display: flex; flex-direction: column;
  box-shadow: -12px 0 40px rgba(30, 41, 59, 0.16);
}
.drawer.anim-in { animation: slide 0.18s cubic-bezier(0.2,0.8,0.3,1); }
@keyframes slide { from { transform: translateX(28px); opacity: 0; } }
.drawer-head { display: flex; align-items: center; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.drawer-body { flex: 1; overflow-y: auto; padding: 18px; }
.drawer-foot { border-top: 1px solid var(--line); padding: 12px 18px; background: var(--panel); }

.modal {
  position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%);
  width: min(560px, calc(100vw - 16px)); max-height: min(88vh, calc(100dvh - 16px));
  background: var(--bg-2); border: 1px solid var(--line);
  border-radius: 12px; z-index: 100; box-shadow: var(--shadow); padding: 0;
  box-sizing: border-box;
  display: flex; flex-direction: column; overflow: hidden;
}
.modal-body {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 22px 22px 12px;
  min-height: 0;
}
.modal-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  flex-wrap: wrap;
  flex-shrink: 0;
  padding: 12px 22px 18px;
  border-top: 1px solid var(--line-soft);
  background: var(--bg-2);
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  min-width: 0;
}
.form-grid > .field,
.form-grid > div { min-width: 0; }
.form-grid > .field { margin-bottom: 0; }
.form-grid.tight { gap: 9px 14px; font-size: 12.5px; }

.attach-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px; flex-wrap: wrap;
  margin-bottom: 8px; font-size: 12.5px; font-weight: 550; color: var(--muted);
}
.attach-actions { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }

.confirm-layer {
  position: fixed; inset: 0; z-index: 110; pointer-events: auto;
}
.confirm-layer .confirm-backdrop { z-index: 0; }
.confirm-layer .confirm-modal {
  z-index: 1;
  /* Confirm dialogs are not wrapped in .modal-body / .modal-actions */
  padding: 22px;
  height: auto;
  max-height: min(88vh, calc(100dvh - 16px));
  overflow-y: auto;
}
.confirm-message {
  color: var(--muted); font-size: 13px; margin: 0 0 20px; line-height: 1.55;
}
.confirm-actions {
  display: flex; gap: 8px; justify-content: flex-end;
}

.detail-title {
  font-size: 19px; font-weight: 600; line-height: 1.35;
  border: 1px solid transparent; border-radius: var(--radius-sm);
  padding: 5px 8px; margin: -5px -8px 12px; width: calc(100% + 16px);
  background: none; letter-spacing: -0.01em;
}
.detail-title:hover { border-color: var(--line); }
.detail-title:focus { border-color: var(--accent); outline: 0; background: var(--bg); }

.meta-grid { display: grid; grid-template-columns: 104px 1fr; gap: 9px 14px; align-items: center; font-size: 13px; margin-bottom: 18px; }
.meta-grid .lbl { color: var(--dim); font-size: 12px; }

/* ---------- attachments ---------- */

.attach-block { margin-bottom: 18px; }
.attach-add { cursor: pointer; margin: 0; }
.attach-hint {
  margin: 8px 0 0; font-size: 11.5px; color: var(--dim); line-height: 1.4;
}
.attach-drop {
  border: 1px dashed var(--line); border-radius: var(--radius);
  background: var(--bg); padding: 10px; min-height: 72px;
  transition: border-color 0.12s ease, background 0.12s ease;
}
.attach-drop.drag { border-color: var(--accent); background: var(--accent-soft); }
.attach-empty {
  color: var(--dim); font-size: 12.5px; text-align: center;
  padding: 18px 10px; line-height: 1.45;
}
.attach-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px;
}
.attach-item {
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--panel); overflow: hidden; display: flex; flex-direction: column;
}
.attach-thumb {
  display: block; aspect-ratio: 4 / 3; background: var(--bg-2); overflow: hidden;
}
.attach-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.attach-file {
  display: flex; flex-direction: column; gap: 8px; align-items: flex-start;
  padding: 12px; min-height: 88px; text-decoration: none; color: var(--text);
}
.attach-file-icon {
  font-size: 10px; font-weight: 700; letter-spacing: 0.04em;
  color: var(--danger); background: rgba(194, 42, 78, 0.12);
  border: 1px solid rgba(194, 42, 78, 0.3); border-radius: 4px; padding: 2px 6px;
}
.attach-file-name {
  font-size: 12.5px; line-height: 1.35; word-break: break-word;
}
.attach-meta {
  display: flex; align-items: center; gap: 6px; padding: 6px 8px;
  border-top: 1px solid var(--line); font-size: 11px; color: var(--muted);
}
.attach-meta > span:first-child {
  flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.attach-meta .dim { color: var(--dim); flex: 0 0 auto; }
.attach-del { padding: 2px 6px !important; color: var(--dim) !important; }
.attach-del:hover { color: var(--danger) !important; }

.status-switch { display: flex; gap: 5px; background: var(--bg); padding: 4px; border-radius: 8px; border: 1px solid var(--line); }
.status-switch button {
  flex: 1; padding: 6px 8px; border: 0; background: none;
  color: var(--muted); border-radius: 6px; font-size: 12.5px; font-weight: 550;
}
.status-switch button:hover { background: var(--panel-2); color: var(--text); }
.status-switch button.on { color: #fff; }
.status-switch button.on[data-s="todo"] { background: var(--todo); }
.status-switch button.on[data-s="wip"] { background: var(--wip); }
.status-switch button.on[data-s="done"] { background: var(--done); }

.tabs { display: flex; gap: 3px; border-bottom: 1px solid var(--line); margin-bottom: 14px; }
.tabs button {
  background: none; border: 0; padding: 8px 12px; color: var(--muted);
  font-size: 13px; border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tabs button:hover { color: var(--text); }
.tabs button.on { color: var(--text); border-bottom-color: var(--accent); font-weight: 550; }

.comment { display: flex; gap: 10px; padding: 11px 0; border-bottom: 1px solid var(--line-soft); }
.comment:last-child { border-bottom: 0; }
.comment .who { font-size: 12.5px; font-weight: 600; }
.comment .when { font-size: 11px; color: var(--dim); font-weight: 400; margin-left: 7px; }
.comment .text { margin-top: 3px; font-size: 13px; white-space: pre-wrap; word-break: break-word; }

/* ---------- login ---------- */

.center-page {
  min-height: 100vh; display: grid; place-items: center; padding: 32px 20px;
  background: radial-gradient(1100px 560px at 50% -10%, #dde6fb 0%, var(--bg) 62%);
}
.card-panel {
  width: min(680px, 100%); background: var(--panel);
  border: 1px solid var(--line); border-radius: 14px; padding: 30px; box-shadow: var(--shadow);
}
.card-panel h1 { margin: 0 0 6px; font-size: 22px; letter-spacing: -0.02em; }
.card-panel .lede { color: var(--muted); margin: 0 0 22px; font-size: 13.5px; line-height: 1.6; }

.login-panel { width: min(420px, 100%); }
.auth-brand {
  display: flex; align-items: center; gap: 10px; margin-bottom: 18px;
  font-weight: 650; letter-spacing: -0.02em;
}
.auth-brand .brand-mark {
  width: 40px; height: 40px; border-radius: 10px; font-size: 18px;
}
.auth-brand small { display: block; font-size: 11px; color: var(--dim); font-weight: 500; letter-spacing: 0; }

.logo-thumb {
  width: 36px; height: 36px; border-radius: 8px;
  object-fit: contain; background: var(--panel-2);
  border: 1px solid var(--line); vertical-align: middle;
}
.logo-thumb-ph {
  width: 36px; height: 36px; border-radius: 8px;
  display: inline-grid; place-items: center;
  background: var(--panel-2); border: 1px solid var(--line);
  color: var(--dim); font-size: 11px;
}
.logo-actions { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.logo-preview {
  width: 64px; height: 64px; border-radius: 10px;
  object-fit: contain; background: var(--panel-2);
  border: 1px solid var(--line);
}
.login-form { display: flex; flex-direction: column; gap: 6px; }
.field-label {
  font-size: 11.5px; font-weight: 600; color: var(--dim);
  text-transform: uppercase; letter-spacing: 0.05em; margin-top: 8px;
}
.btn-block { width: 100%; justify-content: center; margin-top: 14px; }

.people-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(178px, 1fr)); gap: 10px; }
.person-btn {
  display: flex; align-items: center; gap: 10px; padding: 11px 12px;
  background: var(--panel-2); border: 1px solid var(--line);
  border-radius: var(--radius); text-align: left; transition: border-color 0.12s, background 0.12s;
}
.person-btn:hover { border-color: var(--accent); background: #eef2fb; }
.person-btn .nm { font-size: 13px; font-weight: 550; }
.person-btn .hd { font-size: 11px; color: var(--dim); font-family: var(--mono); }

/* ---------- misc ---------- */

.toast {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%);
  background: var(--panel-2); border: 1px solid var(--line);
  padding: 10px 18px; border-radius: 20px; z-index: 200;
  box-shadow: var(--shadow); font-size: 13px; animation: rise 0.18s ease;
}
.toast.err { border-color: var(--danger); color: var(--danger); }
@keyframes rise { from { transform: translate(-50%, 10px); opacity: 0; } }

.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th {
  text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--dim); padding: 9px 15px; border-bottom: 1px solid var(--line); font-weight: 600;
}
.table td { padding: 10px 15px; border-bottom: 1px solid var(--line-soft); }
.table tr:last-child td { border-bottom: 0; }
.table tr:hover td { background: var(--panel-2); }
.num { font-variant-numeric: tabular-nums; }

.filter-bar { display: flex; gap: 8px; align-items: center; margin-bottom: 14px; flex-wrap: wrap; }
.filter-bar .input { width: auto; min-width: 200px; max-width: 100%; }
.filter-bar .select { width: auto; max-width: 100%; }

/* Tablet: keep board columns usable without page-wide overflow */
@media (max-width: 1100px) {
  .board {
    display: flex;
    overflow-x: auto;
    gap: 14px;
    padding-bottom: 6px;
    -webkit-overflow-scrolling: touch;
  }
  .board .column {
    flex: 0 0 min(280px, 78vw);
    max-width: 320px;
  }
}

@media (max-width: 900px) {
  body.sidebar-open { overflow: hidden; }

  .shell { position: relative; }

  .mobile-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    border-bottom: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(8px);
    position: sticky;
    top: 0;
    z-index: 30;
    min-height: 52px;
  }
  .mobile-bar .brand {
    padding: 0;
    flex: 1;
    min-width: 0;
  }
  .mobile-bar .brand small { display: none; }

  .sidebar-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(17, 24, 39, 0.42);
    z-index: 45;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.18s ease, visibility 0.18s ease;
  }
  .shell.sidebar-open .sidebar-backdrop {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
  }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: min(280px, 86vw);
    flex: none;
    height: 100%;
    max-height: 100dvh;
    padding: 14px 12px 18px;
    border-right: 1px solid var(--line);
    box-shadow: 8px 0 28px rgba(30, 41, 59, 0.14);
    transform: translateX(-105%);
    transition: transform 0.2s cubic-bezier(0.2, 0.8, 0.3, 1);
    z-index: 50;
    overscroll-behavior: contain;
  }
  .shell.sidebar-open .sidebar { transform: translateX(0); }

  .sidebar-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    position: absolute;
    top: 12px;
    right: 10px;
    width: 32px;
    height: 32px;
    padding: 0;
    border: 0;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--muted);
    font-size: 20px;
    line-height: 1;
  }
  .sidebar-close:hover { background: var(--panel-2); color: var(--text); }
  .sidebar > .brand { padding-right: 36px; }

  .main { width: 100%; }

  .topbar {
    top: 52px; /* sit under sticky mobile bar */
    padding: 12px 14px;
    gap: 8px 10px;
  }
  .topbar h1 { font-size: 16px; max-width: 100%; order: 1; }
  .topbar > .avatar { order: 1; flex-shrink: 0; }
  .topbar > div:has(h1) { order: 1; flex: 1; min-width: 0; }
  .topbar-center-btn,
  .topbar > .btn { order: 2; margin-left: auto; flex-shrink: 0; }
  .topbar .spacer { display: none; }
  .topbar-impersonation {
    white-space: normal;
    flex-wrap: wrap;
    width: 100%;
    order: 3;
  }
  .topbar .sub,
  .topbar > .sub { min-width: 0; }
  .topbar > .sub { width: 100%; order: 4; flex-basis: 100%; }

  .content { padding: 16px 14px 48px; }

  .board {
    display: grid;
    grid-template-columns: 1fr;
    overflow: visible;
    padding-bottom: 0;
  }
  .board .column {
    flex: none;
    max-width: none;
    width: 100%;
  }

  .filter-bar .input,
  .filter-bar .select {
    width: 100%;
    min-width: 0;
    flex: 1 1 140px;
  }

  .workload-row {
    flex-wrap: wrap;
    align-items: flex-start;
  }
  .workload-row .who {
    width: auto;
    max-width: none;
    flex: 1 1 auto;
  }
  .workload-row .nums {
    width: auto;
    margin-left: auto;
  }

  .stat-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }

  .meta-grid { grid-template-columns: 88px 1fr; gap: 8px 10px; }

  .panel-head { flex-wrap: wrap; }
  .panel-head .sub { margin-left: 0; width: 100%; }

  .table { font-size: 12.5px; }
  .table th, .table td { padding: 8px 10px; }
}

@media (max-width: 560px) {
  .form-grid,
  .form-grid.tight { grid-template-columns: 1fr; }
  .two-col { grid-template-columns: 1fr; }
}

@media (max-width: 520px) {
  .topbar h1 { font-size: 15px; }
  .composer-box { flex-wrap: wrap; }
  .composer-box .btn { width: 100%; }
  .drawer-head { padding: 12px 14px; }
  .drawer-body { padding: 14px; }
  .modal:not(.confirm-modal) {
    width: 100vw;
    max-width: 100vw;
    max-height: 100dvh;
    height: 100dvh;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    transform: none;
    border-radius: 0;
    border: 0;
    padding: 0;
  }
  .modal-body { padding: 16px 14px 12px; }
  .modal-actions { padding: 12px 14px 16px; }
  .modal-actions .btn { flex: 1 1 auto; }
  .confirm-layer .confirm-modal {
    width: min(560px, calc(100vw - 16px));
    max-width: calc(100vw - 16px);
    padding: 18px 16px;
  }
  .confirm-actions { flex-wrap: wrap; }
  .confirm-actions .btn { flex: 1 1 auto; }
  .meta-grid { grid-template-columns: 1fr; gap: 4px 0; }
  .meta-grid .lbl { margin-top: 6px; }
}
