/* =========================================================================
   ACCOUNTING OPERATIONS WORK OS — Styles.html (PHASE 1)
   Design tokens, light/dark themes, and full component styling.
   ========================================================================= */

/* ----------------------------------------------------------------- TOKENS */
:root {
  --bg:            #f5f6fb;
  --surface:       #ffffff;
  --surface-2:     #f1f3f9;
  --surface-3:     #eaedf6;
  --border:        #e4e7f1;
  --border-strong: #d3d8e6;
  --text:          #1c1f3a;
  --text-2:        #5b6178;
  --text-3:        #8b90a8;

  --accent:        #6161ff;
  --accent-hover:  #4f4fe6;
  --accent-soft:   rgba(97,97,255,.10);
  --accent-ring:   rgba(97,97,255,.30);

  --danger:        #e2445c;
  --danger-soft:   rgba(226,68,92,.12);
  --success:       #00c875;
  --warn:          #fdab3d;

  --shadow-sm: 0 1px 2px rgba(20,23,55,.06), 0 1px 3px rgba(20,23,55,.05);
  --shadow-md: 0 4px 16px rgba(20,23,55,.10);
  --shadow-lg: 0 20px 50px rgba(20,23,55,.18);

  --r-sm: 7px;
  --r-md: 10px;
  --r-lg: 14px;
  --r-pill: 999px;

  --sidebar-w: 250px;
  --sidebar-w-collapsed: 66px;
  --drawer-w: 560px;

  --ff: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
        Helvetica, Arial, sans-serif;
  --transition: 160ms cubic-bezier(.4,0,.2,1);
}

[data-theme="dark"] {
  --bg:            #101227;
  --surface:       #1b1e3a;
  --surface-2:     #23264a;
  --surface-3:     #2a2e54;
  --border:        #2d3159;
  --border-strong: #3a3f6b;
  --text:          #e8eaf6;
  --text-2:        #aab0d0;
  --text-3:        #7b81a8;

  --accent:        #7b7bff;
  --accent-hover:  #6e6efc;
  --accent-soft:   rgba(123,123,255,.16);
  --accent-ring:   rgba(123,123,255,.40);

  --danger-soft:   rgba(226,68,92,.18);

  --shadow-sm: 0 1px 2px rgba(0,0,0,.35);
  --shadow-md: 0 6px 20px rgba(0,0,0,.40);
  --shadow-lg: 0 24px 60px rgba(0,0,0,.55);
}

/* ----------------------------------------------------------------- RESET */
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--ff);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
h1,h2,h3,h4 { margin: 0; font-weight: 700; }
p { margin: 0; }
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, textarea, select { font-family: inherit; font-size: 14px; }
a { color: var(--accent); text-decoration: none; }
.hidden { display: none !important; }
.muted { color: var(--text-3); font-size: 12.5px; }

::selection { background: var(--accent-ring); }

/* Scrollbars */
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 999px; border: 2px solid transparent; background-clip: padding-box; }
*::-webkit-scrollbar-thumb:hover { background: var(--text-3); background-clip: padding-box; }
*::-webkit-scrollbar-track { background: transparent; }

/* Icons */
.ic { width: 18px; height: 18px; flex: 0 0 auto; display: inline-block; }
.ic-xl { width: 46px; height: 46px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

/* ----------------------------------------------------------------- LOADER */
.app-loading {
  position: fixed; inset: 0; display: flex; align-items: center; justify-content: center;
  background: var(--bg); z-index: 4000;
}
.loader-card { display: flex; flex-direction: column; align-items: center; gap: 16px; }
.loader-text { color: var(--text-2); font-size: 13.5px; }
.spinner {
  width: 38px; height: 38px; border-radius: 50%;
  border: 3px solid var(--border); border-top-color: var(--accent);
  animation: spin .8s linear infinite;
}
.spinner.small { width: 18px; height: 18px; border-width: 2px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ----------------------------------------------------------------- ERROR */
.app-error { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; background: var(--bg); z-index: 4000; padding: 20px; }
.error-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); padding: 36px; max-width: 420px; text-align: center; box-shadow: var(--shadow-lg); }
.error-icon { font-size: 38px; }
.error-card h1 { font-size: 19px; margin: 12px 0 6px; }
.error-card p { color: var(--text-2); margin-bottom: 18px; }

/* ----------------------------------------------------------------- LAYOUT */
.app-root { display: flex; height: 100vh; overflow: hidden; }

/* ----------------------------------------------------------------- SIDEBAR */
.sidebar {
  width: var(--sidebar-w); flex: 0 0 var(--sidebar-w);
  background: var(--surface); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; padding: 14px 12px;
  transition: width var(--transition), flex-basis var(--transition);
}
.sidebar-brand { display: flex; align-items: center; gap: 10px; padding: 4px 6px 12px; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 9px; flex: 0 0 auto;
  background: linear-gradient(135deg, var(--accent), #a25ddc);
  color: #fff; display: flex; align-items: center; justify-content: center;
}
.brand-text { flex: 1; min-width: 0; overflow: hidden; }
.brand-title { font-size: 14.5px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-sub { font-size: 11px; color: var(--text-3); letter-spacing: .04em; text-transform: uppercase; }
.sidebar-collapse { transform: rotate(180deg); }

.sidebar-section { margin-top: 8px; }
.sidebar-section-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 8px 6px; font-size: 11px; font-weight: 700; letter-spacing: .05em;
  text-transform: uppercase; color: var(--text-3);
}

.board-list { display: flex; flex-direction: column; gap: 2px; max-height: 34vh; overflow-y: auto; }
.b-item {
  display: flex; align-items: center; gap: 9px; width: 100%; text-align: left;
  padding: 8px 10px; border-radius: var(--r-sm); color: var(--text-2);
  font-size: 13.5px; font-weight: 500; transition: background var(--transition), color var(--transition);
}
.b-item:hover { background: var(--surface-2); color: var(--text); }
.b-item.is-active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.b-item .b-dot { width: 8px; height: 8px; border-radius: 50%; flex: 0 0 auto; background: var(--accent); }
.b-item .b-name { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.nav-views { display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left;
  padding: 8px 10px; border-radius: var(--r-sm); color: var(--text-2);
  font-size: 13.5px; font-weight: 500; transition: background var(--transition), color var(--transition);
}
.nav-item:hover:not(.is-disabled) { background: var(--surface-2); color: var(--text); }
.nav-item.is-active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.nav-item.is-active .ic { color: var(--accent); }
.nav-item .ic { color: var(--text-3); }
.nav-item span { flex: 1; }
.nav-item.is-disabled { opacity: .55; cursor: not-allowed; }
.soon { font-size: 9.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em;
  background: var(--surface-3); color: var(--text-3); padding: 2px 6px; border-radius: var(--r-pill); }

.sidebar-spacer { flex: 1; }
.sidebar-footer { border-top: 1px solid var(--border); padding-top: 10px; }
.footer-actions { display: flex; gap: 6px; margin-bottom: 10px; padding: 0 4px; }

.icon-btn {
  width: 32px; height: 32px; border-radius: var(--r-sm); display: inline-flex;
  align-items: center; justify-content: center; color: var(--text-2);
  transition: background var(--transition), color var(--transition);
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn.is-disabled { opacity: .45; cursor: not-allowed; }
.icon-btn .ic-moon { display: none; }
[data-theme="dark"] .icon-btn .ic-sun { display: none; }
[data-theme="dark"] .icon-btn .ic-moon { display: inline-block; }

.user-chip { display: flex; align-items: center; gap: 10px; padding: 6px 6px; border-radius: var(--r-sm); }
.avatar {
  width: 32px; height: 32px; border-radius: 50%; flex: 0 0 auto;
  display: inline-flex; align-items: center; justify-content: center;
  color: #fff; font-size: 12px; font-weight: 700; background: var(--accent);
}
.avatar.sm { width: 24px; height: 24px; font-size: 10px; }
.user-chip-text { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.user-name { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.role-pill {
  align-self: flex-start; font-size: 10px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .03em; padding: 1px 7px; border-radius: var(--r-pill);
  background: var(--accent-soft); color: var(--accent);
}

/* Collapsed sidebar */
.app-root.is-collapsed .sidebar { width: var(--sidebar-w-collapsed); flex-basis: var(--sidebar-w-collapsed); }
.app-root.is-collapsed .brand-text,
.app-root.is-collapsed .sidebar-section-head span,
.app-root.is-collapsed .b-name,
.app-root.is-collapsed .b-dept-head,
.app-root.is-collapsed .nav-item span,
.app-root.is-collapsed .soon,
.app-root.is-collapsed .user-chip-text,
.app-root.is-collapsed .sidebar-section-head #btn-new-board { display: none; }
.app-root.is-collapsed .nav-item,
.app-root.is-collapsed .b-item { justify-content: center; }
.app-root.is-collapsed .sidebar-collapse { transform: rotate(0deg); }
.app-root.is-collapsed .footer-actions { flex-direction: column; align-items: center; }

/* ----------------------------------------------------------------- MAIN */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; overflow: hidden; }

.board-header {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 16px;
  padding: 20px 26px 14px; border-bottom: 1px solid var(--border); background: var(--surface);
}
.board-header-left { min-width: 0; }
.board-title-row { display: flex; align-items: center; gap: 10px; }
.board-title { font-size: 21px; letter-spacing: -.01em; }
.board-vis-pill {
  font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em;
  padding: 2px 8px; border-radius: var(--r-pill); background: var(--surface-2); color: var(--text-2);
}
.board-desc { color: var(--text-2); font-size: 13px; margin-top: 4px; max-width: 640px; }
.board-header-right { display: flex; align-items: center; gap: 14px; }
.board-meta { display: flex; gap: 16px; }
.meta-stat { text-align: center; }
.meta-stat .num { font-size: 17px; font-weight: 700; line-height: 1; }
.meta-stat .lbl { font-size: 10.5px; color: var(--text-3); text-transform: uppercase; letter-spacing: .04em; }
.meta-stat.danger .num { color: var(--danger); }
.meta-stat.warn .num { color: var(--warn); }
.meta-stat.success .num { color: var(--success); }

.board-menu-wrap { position: relative; }
.dropdown {
  position: absolute; top: 38px; right: 0; min-width: 184px; z-index: 60;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md);
  box-shadow: var(--shadow-lg); padding: 6px; animation: pop .12s ease;
}
@keyframes pop { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
.dropdown-item {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left;
  padding: 8px 10px; border-radius: var(--r-sm); font-size: 13px; color: var(--text);
}
.dropdown-item:hover { background: var(--surface-2); }
.dropdown-item.danger { color: var(--danger); }
.dropdown-item.danger:hover { background: var(--danger-soft); }
.dropdown-item .ic { color: var(--text-3); }
.dropdown-item.danger .ic { color: var(--danger); }

/* Toolbar */
.board-toolbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 26px; background: var(--surface); border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.toolbar-left, .toolbar-right { display: flex; align-items: center; gap: 8px; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; gap: 7px; padding: 8px 14px;
  border-radius: var(--r-sm); font-size: 13px; font-weight: 600; white-space: nowrap;
  transition: background var(--transition), color var(--transition), box-shadow var(--transition), transform var(--transition);
}
.btn:active { transform: translateY(1px); }
.btn .ic { width: 16px; height: 16px; }
.btn-primary { background: var(--accent); color: #fff; box-shadow: var(--shadow-sm); }
.btn-primary:hover { background: var(--accent-hover); }
.btn-ghost { background: var(--surface-2); color: var(--text); }
.btn-ghost:hover { background: var(--surface-3); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { filter: brightness(.93); }
.btn-danger-ghost { background: transparent; color: var(--danger); }
.btn-danger-ghost:hover { background: var(--danger-soft); }
.btn:disabled { opacity: .55; cursor: not-allowed; }

.search-box {
  display: flex; align-items: center; gap: 7px; padding: 0 10px;
  background: var(--surface-2); border: 1px solid transparent; border-radius: var(--r-sm); height: 34px;
}
.search-box:focus-within { border-color: var(--accent); background: var(--surface); }
.search-box .ic { color: var(--text-3); width: 16px; height: 16px; }
.search-box input { border: none; background: transparent; outline: none; color: var(--text); width: 180px; }
.filter-select {
  height: 34px; padding: 0 28px 0 10px; border-radius: var(--r-sm);
  background: var(--surface-2); border: 1px solid transparent; color: var(--text); cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24'><path fill='%238b90a8' d='m7 10 5 5 5-5z'/></svg>");
  background-repeat: no-repeat; background-position: right 8px center;
}
.filter-select:focus { border-color: var(--accent); outline: none; }

/* Board content */
.board-scroll { flex: 1; overflow: auto; padding: 18px 26px 60px; }
.board-inline-loading { display: flex; align-items: center; gap: 10px; color: var(--text-2); padding: 30px; justify-content: center; }
.board-container { display: flex; flex-direction: column; gap: 22px; }

/* ----------------------------------------------------------------- GROUPS */
.group { border-radius: var(--r-md); }
.group-header {
  display: flex; align-items: center; gap: 10px; padding: 6px 4px 8px;
  position: sticky; top: -18px; background: var(--bg); z-index: 5;
}
.group-collapse { width: 22px; height: 22px; display: inline-flex; align-items: center; justify-content: center; color: var(--text-3); border-radius: 5px; }
.group-collapse:hover { background: var(--surface-2); }
.group-collapse .ic { width: 16px; height: 16px; transition: transform var(--transition); }
.group.is-collapsed .group-collapse .ic { transform: rotate(-90deg); }
.group-name {
  font-size: 14.5px; font-weight: 700; padding: 2px 4px; border-radius: 5px;
  border-left: 4px solid var(--accent); padding-left: 10px;
}
.group-count { font-size: 12px; color: var(--text-3); font-weight: 600; }
.group-summary { display: flex; align-items: center; gap: 10px; margin-left: auto; }
.summary-bar { width: 120px; height: 7px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.summary-bar > span { display: block; height: 100%; background: var(--success); border-radius: 999px; transition: width var(--transition); }
.summary-text { font-size: 11.5px; color: var(--text-2); font-weight: 600; min-width: 84px; text-align: right; }

.group-body { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md); overflow: hidden; box-shadow: var(--shadow-sm); }
.group.is-collapsed .group-body { display: none; }

/* ----------------------------------------------------------------- ITEM TABLE */
.item-table { display: flex; flex-direction: column; }
.row {
  display: grid;
  grid-template-columns: 30px minmax(220px, 2.4fr) 130px 150px 110px 130px 70px;
  align-items: center; gap: 0;
  border-bottom: 1px solid var(--border);
}
.row:last-child { border-bottom: none; }
.row.head {
  background: var(--surface-2); font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .04em; color: var(--text-3); position: sticky; top: 0;
}
.row.head .cell { padding: 9px 12px; }
.row.item { transition: background var(--transition); cursor: pointer; }
.row.item:hover { background: var(--surface-2); }
.row.item .cell { padding: 10px 12px; min-width: 0; }
.cell { display: flex; align-items: center; min-width: 0; }
.cell-handle { justify-content: center; cursor: grab; color: var(--text-3); }
.cell-handle:active { cursor: grabbing; }
.cell-handle .ic { width: 16px; height: 16px; opacity: 0; transition: opacity var(--transition); }
.row.item:hover .cell-handle .ic { opacity: 1; }

.item-name { font-weight: 600; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item-name .item-sub { display: block; font-weight: 400; font-size: 11.5px; color: var(--text-3); }

/* Pills */
.pill {
  display: inline-flex; align-items: center; gap: 5px; padding: 4px 11px;
  border-radius: var(--r-pill); font-size: 11.5px; font-weight: 700; color: #fff;
  white-space: nowrap; max-width: 100%; overflow: hidden; text-overflow: ellipsis;
  line-height: 1.3; background: var(--text-3);
}
.pill.status { min-width: 96px; justify-content: center; }
.pill.priority { min-width: 70px; justify-content: center; }
.pill.empty { background: var(--surface-3); color: var(--text-3); font-weight: 600; }

/* Owner chip */
.owner-chip { display: inline-flex; align-items: center; gap: 7px; min-width: 0; }
.owner-chip .name { font-size: 12.5px; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.owner-empty { color: var(--text-3); font-size: 12.5px; font-style: italic; }
.avatar-stack { display: inline-flex; }
.avatar-stack .avatar.sm { margin-left: -6px; border: 2px solid var(--surface); }
.avatar-stack .avatar.sm:first-child { margin-left: 0; }

/* Due-date pill */
.due-pill {
  display: inline-flex; align-items: center; gap: 5px; padding: 4px 9px; border-radius: var(--r-sm);
  font-size: 11.5px; font-weight: 600; background: var(--surface-2); color: var(--text-2); white-space: nowrap;
}
.due-pill.overdue { background: var(--danger-soft); color: var(--danger); }
.due-pill.today { background: rgba(253,171,61,.16); color: #c77b12; }
.due-pill.soon { background: var(--accent-soft); color: var(--accent); }
.due-pill.none { color: var(--text-3); background: transparent; font-style: italic; font-weight: 500; }
[data-theme="dark"] .due-pill.today { color: var(--warn); }

/* Add-item row inside a group */
.row.add-row { grid-template-columns: 1fr; }
.add-item-btn {
  display: flex; align-items: center; gap: 8px; width: 100%; text-align: left;
  padding: 10px 16px; color: var(--text-3); font-size: 13px; font-weight: 500;
}
.add-item-btn:hover { color: var(--accent); background: var(--surface-2); }
.add-item-btn .ic { width: 16px; height: 16px; }

/* Drag states */
.row.item.dragging { opacity: .45; }
.group-body.drag-over { outline: 2px dashed var(--accent); outline-offset: -2px; background: var(--accent-soft); }
.group.drag-over .group-name { color: var(--accent); }

/* ----------------------------------------------------------------- EMPTY */
.empty-state { text-align: center; padding: 70px 20px; max-width: 440px; margin: 0 auto; }
.empty-illustration {
  width: 88px; height: 88px; border-radius: 22px; margin: 0 auto 18px;
  display: flex; align-items: center; justify-content: center;
  background: var(--accent-soft); color: var(--accent);
}
.empty-state h2 { font-size: 18px; margin-bottom: 6px; }
.empty-state p { color: var(--text-2); margin-bottom: 16px; }

/* ----------------------------------------------------------------- DRAWER */
.overlay { position: fixed; inset: 0; background: rgba(20,23,55,.42); z-index: 1000; opacity: 0; animation: fade .15s ease forwards; }
[data-theme="dark"] .overlay { background: rgba(0,0,0,.55); }
@keyframes fade { to { opacity: 1; } }

.drawer {
  position: fixed; top: 0; right: 0; height: 100vh; width: var(--drawer-w); max-width: 94vw;
  background: var(--surface); border-left: 1px solid var(--border); z-index: 1001;
  display: flex; flex-direction: column; transform: translateX(100%);
  transition: transform .22s cubic-bezier(.4,0,.2,1); box-shadow: var(--shadow-lg);
}
.drawer.open { transform: translateX(0); }
.drawer-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 18px 22px 14px; border-bottom: 1px solid var(--border); }
.drawer-head-text { min-width: 0; }
.drawer-id { font-size: 11px; font-weight: 700; color: var(--text-3); letter-spacing: .04em; }
.drawer-title { font-size: 17px; margin-top: 2px; word-break: break-word; }
.drawer-body { flex: 1; overflow-y: auto; padding: 18px 22px; display: flex; flex-direction: column; gap: 14px; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field-label { font-size: 12px; font-weight: 600; color: var(--text-2); }
.field-label .req { color: var(--danger); }
.field-label .hint { color: var(--text-3); font-weight: 400; font-style: italic; }
.field-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.input {
  width: 100%; padding: 9px 11px; border: 1px solid var(--border-strong); border-radius: var(--r-sm);
  background: var(--surface); color: var(--text); transition: border var(--transition), box-shadow var(--transition);
}
.input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-ring); }
.textarea { resize: vertical; min-height: 38px; }
.select { cursor: pointer; appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24'><path fill='%238b90a8' d='m7 10 5 5 5-5z'/></svg>");
  background-repeat: no-repeat; background-position: right 10px center; padding-right: 30px; }
.checkbox-row { display: flex; align-items: center; gap: 9px; font-size: 13.5px; color: var(--text); cursor: pointer; }
.checkbox-row input { width: 16px; height: 16px; accent-color: var(--accent); }

.drawer-meta { margin-top: 4px; padding-top: 14px; border-top: 1px solid var(--border); font-size: 12px; color: var(--text-3); display: flex; flex-direction: column; gap: 4px; }

.drawer-foot { display: flex; align-items: center; justify-content: space-between; padding: 14px 22px; border-top: 1px solid var(--border); background: var(--surface); }
.drawer-foot-right { display: flex; gap: 8px; margin-left: auto; }

/* ----------------------------------------------------------------- MODALS */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(20,23,55,.42); z-index: 2000;
  display: flex; align-items: center; justify-content: center; padding: 20px; animation: fade .15s ease forwards;
}
[data-theme="dark"] .modal-overlay { background: rgba(0,0,0,.6); }
.modal {
  width: 100%; max-width: 480px; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg); box-shadow: var(--shadow-lg); display: flex; flex-direction: column;
  animation: modalIn .18s cubic-bezier(.4,0,.2,1);
}
.modal.modal-sm { max-width: 400px; }
@keyframes modalIn { from { opacity: 0; transform: translateY(10px) scale(.98); } to { opacity: 1; transform: none; } }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 20px 6px; }
.modal-head h3 { font-size: 16px; }
.modal-body { padding: 12px 20px; display: flex; flex-direction: column; gap: 14px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 20px 18px; }
.confirm-message { color: var(--text-2); }

.swatch-row { display: flex; flex-wrap: wrap; gap: 8px; }
.swatch { width: 26px; height: 26px; border-radius: 7px; cursor: pointer; border: 2px solid transparent; transition: transform var(--transition); }
.swatch:hover { transform: scale(1.1); }
.swatch.is-selected { border-color: var(--text); box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--text); }

/* ----------------------------------------------------------------- TOASTS */
.toast-host { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); z-index: 5000; display: flex; flex-direction: column; gap: 10px; align-items: center; pointer-events: none; }
.toast {
  pointer-events: auto; display: flex; align-items: center; gap: 10px; min-width: 240px; max-width: 460px;
  padding: 11px 16px; border-radius: var(--r-md); background: var(--surface); color: var(--text);
  border: 1px solid var(--border); box-shadow: var(--shadow-lg); font-size: 13.5px; font-weight: 500;
  animation: toastIn .22s cubic-bezier(.4,0,.2,1);
}
.toast.leaving { animation: toastOut .2s ease forwards; }
.toast .toast-dot { width: 9px; height: 9px; border-radius: 50%; flex: 0 0 auto; }
.toast.success .toast-dot { background: var(--success); }
.toast.error   .toast-dot { background: var(--danger); }
.toast.info    .toast-dot { background: var(--accent); }
.toast.error { border-color: var(--danger); }
@keyframes toastIn { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
@keyframes toastOut { to { opacity: 0; transform: translateY(14px); } }

/* ----------------------------------------------------------------- RESPONSIVE */
@media (max-width: 1080px) {
  .row { grid-template-columns: 28px minmax(160px,2fr) 120px 120px 100px 90px; }
  .row .cell-recurring { display: none; }
}
@media (max-width: 840px) {
  .sidebar { position: fixed; z-index: 1500; height: 100vh; box-shadow: var(--shadow-lg);
    transform: translateX(-100%); transition: transform var(--transition); }
  .app-root.sidebar-open .sidebar { transform: translateX(0); }
  .main { width: 100%; }
  .board-header { flex-direction: column; gap: 10px; }
  .board-header-right { width: 100%; justify-content: space-between; }
  .row { grid-template-columns: 26px minmax(140px,2fr) 110px 96px; }
  .row .cell-priority, .row .cell-recurring { display: none; }
  .row.head .cell-priority, .row.head .cell-recurring { display: none; }
  .drawer { width: 100vw; max-width: 100vw; }
  .field-grid { grid-template-columns: 1fr; }
  .toolbar-right .filter-select { display: none; }
}
/* =========================================================================
   PHASE 2 COMPONENTS
   ========================================================================= */

/* ----- Sidebar count badges ----- */
.count-badge {
  margin-left: auto; min-width: 20px; text-align: center; font-size: 11px; font-weight: 700;
  padding: 1px 7px; border-radius: var(--r-pill); background: var(--surface-3); color: var(--text-2);
}
.count-badge:empty { display: none; }
.count-badge.danger { background: var(--danger-soft); color: var(--danger); }
.nav-item.is-active .count-badge { background: rgba(255,255,255,.25); color: inherit; }
[data-theme="dark"] .nav-item.is-active .count-badge { background: rgba(255,255,255,.18); }

/* ----- Segmented Table/Kanban toggle ----- */
.seg-toggle { display: inline-flex; background: var(--surface-2); border-radius: var(--r-sm); padding: 3px; gap: 2px; margin-left: 4px; }
.seg-btn {
  display: inline-flex; align-items: center; gap: 6px; padding: 5px 11px; border-radius: 6px;
  font-size: 12.5px; font-weight: 600; color: var(--text-2); transition: background var(--transition), color var(--transition);
}
.seg-btn .ic { width: 15px; height: 15px; }
.seg-btn:hover { color: var(--text); }
.seg-btn.is-active { background: var(--surface); color: var(--accent); box-shadow: var(--shadow-sm); }
[data-theme="dark"] .seg-btn.is-active { background: var(--surface-3); }

/* ----- Panels ----- */
.panel { flex: 1; min-height: 0; display: flex; flex-direction: column; }
#panel-board.hidden, #panel-view.hidden { display: none !important; }

/* ----- View panel header ----- */
.view-header {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 16px;
  padding: 20px 26px 16px; border-bottom: 1px solid var(--border); background: var(--surface);
}
.view-header-left { min-width: 0; }
.view-title-row { display: flex; align-items: center; gap: 10px; }
.view-icon { width: 22px; height: 22px; color: var(--accent); }
.view-header-right { display: flex; align-items: center; gap: 10px; }
.view-content { display: flex; flex-direction: column; gap: 24px; }

/* ----- My Work stat cards ----- */
.mywork-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; margin-bottom: 8px; }
.mw-stat {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md);
  padding: 14px 16px; cursor: pointer; transition: border var(--transition), transform var(--transition), box-shadow var(--transition);
  text-align: left;
}
.mw-stat:hover { border-color: var(--accent); transform: translateY(-1px); box-shadow: var(--shadow-md); }
.mw-stat .num { font-size: 24px; font-weight: 800; line-height: 1; }
.mw-stat .lbl { font-size: 12px; color: var(--text-3); margin-top: 6px; }
.mw-stat.danger .num { color: var(--danger); }
.mw-stat.warn .num { color: var(--warn); }
.mw-stat.accent .num { color: var(--accent); }

/* ----- View sections + context rows ----- */
.view-section { }
.view-section-head { display: flex; align-items: center; gap: 10px; padding: 0 2px 10px; }
.vs-bar { width: 4px; height: 18px; border-radius: 2px; background: var(--accent); }
.vs-title { font-size: 14.5px; font-weight: 700; }
.vs-count { font-size: 12px; color: var(--text-3); font-weight: 600; }

.ctx-list { border: 1px solid var(--border); border-radius: var(--r-md); overflow: hidden; background: var(--surface); box-shadow: var(--shadow-sm); }
.ctx-row {
  display: flex; align-items: center; gap: 14px; padding: 11px 16px;
  border-bottom: 1px solid var(--border); cursor: pointer; transition: background var(--transition);
}
.ctx-row:last-child { border-bottom: none; }
.ctx-row:hover { background: var(--surface-2); }
.ctx-main { flex: 1; min-width: 0; }
.ctx-name { font-weight: 600; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ctx-breadcrumb { font-size: 11.5px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }
.ctx-breadcrumb .crumb-sep { opacity: .5; margin: 0 4px; }
.ctx-meta { display: flex; align-items: center; gap: 10px; flex: 0 0 auto; }

/* ----- Kanban ----- */
.kanban-container { padding-top: 4px; }
.kanban-board { display: flex; gap: 14px; align-items: flex-start; overflow-x: auto; padding-bottom: 12px; min-height: 200px; }
.kanban-col {
  width: 290px; flex: 0 0 290px; background: var(--surface-2); border-radius: var(--r-md);
  display: flex; flex-direction: column; max-height: calc(100vh - 250px);
}
.kanban-col-head {
  display: flex; align-items: center; gap: 8px; padding: 12px 14px 10px; position: sticky; top: 0;
  background: var(--surface-2); border-radius: var(--r-md) var(--r-md) 0 0; z-index: 2;
  border-top: 3px solid var(--accent);
}
.kanban-col-dot { width: 10px; height: 10px; border-radius: 50%; flex: 0 0 auto; }
.kanban-col-name { font-weight: 700; font-size: 13px; }
.kanban-col-count { margin-left: auto; font-size: 12px; color: var(--text-3); font-weight: 600; background: var(--surface); padding: 1px 8px; border-radius: var(--r-pill); }
.kanban-col-body { padding: 10px; display: flex; flex-direction: column; gap: 10px; overflow-y: auto; min-height: 60px; }
.kanban-col.drag-over .kanban-col-body { outline: 2px dashed var(--accent); outline-offset: -4px; border-radius: var(--r-sm); background: var(--accent-soft); }

.kanban-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-sm);
  padding: 11px 12px; box-shadow: var(--shadow-sm); cursor: pointer; transition: box-shadow var(--transition), transform var(--transition);
}
.kanban-card:hover { box-shadow: var(--shadow-md); }
.kanban-card.dragging { opacity: .45; }
.kanban-card-title { font-weight: 600; font-size: 13px; margin-bottom: 8px; line-height: 1.35; }
.kanban-card-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.kanban-card-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 9px; }
.kanban-card-tags { display: flex; gap: 4px; flex-wrap: wrap; }
.tag-chip { font-size: 10.5px; font-weight: 600; padding: 1px 7px; border-radius: var(--r-pill); background: var(--surface-3); color: var(--text-2); }
.kanban-empty { color: var(--text-3); font-size: 12.5px; text-align: center; padding: 14px 6px; font-style: italic; }

/* ----- Drawer collaboration ----- */
.drawer-collab { margin-top: 6px; padding-top: 16px; border-top: 1px solid var(--border); display: flex; flex-direction: column; gap: 20px; }
.collab-block { }
.collab-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.collab-title { display: flex; align-items: center; gap: 7px; font-weight: 700; font-size: 13px; }
.collab-title .ic { width: 16px; height: 16px; color: var(--text-3); }
.collab-count, #update-count { font-size: 12px; color: var(--text-3); font-weight: 600; }
.btn-xs { padding: 4px 11px; font-size: 12px; }

.watcher-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.watcher-empty { font-size: 12.5px; color: var(--text-3); font-style: italic; }
.watcher-chip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 8px 3px 4px; background: var(--surface-2); border-radius: var(--r-pill); font-size: 12px; }
.watcher-chip .name { color: var(--text); max-width: 140px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wc-remove { width: 16px; height: 16px; display: inline-flex; align-items: center; justify-content: center; border-radius: 50%; color: var(--text-3); font-size: 14px; line-height: 1; }
.wc-remove:hover { background: var(--danger-soft); color: var(--danger); }
.watcher-add-row { display: flex; gap: 8px; margin-top: 8px; }
.watcher-add-row .select { flex: 1; }

.composer { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r-md); padding: 8px; }
.composer-wrap { position: relative; }
.composer .textarea { background: var(--surface); }
.mention-suggest {
  position: absolute; z-index: 50; left: 8px; bottom: calc(100% + 4px); min-width: 220px; max-height: 220px; overflow-y: auto;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-sm); box-shadow: var(--shadow-lg); padding: 4px;
}
.mention-option { display: flex; align-items: center; gap: 8px; padding: 7px 9px; border-radius: 6px; cursor: pointer; font-size: 13px; }
.mention-option:hover, .mention-option.is-active { background: var(--accent-soft); }
.mention-option .mo-email { color: var(--text-3); font-size: 11.5px; }
.composer-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 8px; }
.composer-hint { font-size: 11px; color: var(--text-3); }

.updates-list { display: flex; flex-direction: column; gap: 14px; margin-top: 14px; }
.update-item { display: flex; gap: 10px; }
.update-content { flex: 1; min-width: 0; }
.update-meta { font-size: 11.5px; color: var(--text-3); }
.update-author { font-weight: 700; color: var(--text); }
.update-body { margin-top: 4px; font-size: 13px; line-height: 1.5; white-space: pre-wrap; word-break: break-word; background: var(--surface-2); padding: 9px 11px; border-radius: var(--r-sm); }
.update-body .mention { color: var(--accent); font-weight: 600; background: var(--accent-soft); padding: 0 4px; border-radius: 4px; }
.updates-empty { color: var(--text-3); font-size: 13px; text-align: center; padding: 18px 6px; font-style: italic; }

/* ----- Phase 2 responsive ----- */
@media (max-width: 840px) {
  .kanban-col { width: 250px; flex-basis: 250px; }
  .view-header { flex-direction: column; gap: 10px; }
  .view-header-right { width: 100%; }
  .ctx-meta .cell-priority, .ctx-meta .owner-chip .name { display: none; }
}
/* =========================================================================
   PHASE 3 COMPONENTS — command centers & settings
   ========================================================================= */

/* ----- Command center cards & grid ----- */
.cc-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.cc-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md);
  padding: 16px 18px; box-shadow: var(--shadow-sm);
}
.cc-card-title { font-size: 13.5px; font-weight: 700; margin-bottom: 12px; color: var(--text); }

/* ----- Chips used in command tables ----- */
.cc-chip {
  display: inline-flex; align-items: center; font-size: 11px; font-weight: 700;
  padding: 2px 9px; border-radius: var(--r-pill); background: var(--surface-2); color: var(--text-2);
}
.cc-chip.danger { background: var(--danger-soft); color: var(--danger); }

/* ----- Bar charts ----- */
.cc-bars { display: flex; flex-direction: column; gap: 9px; }
.cc-bar-row { display: grid; grid-template-columns: 120px 1fr 34px; align-items: center; gap: 10px; }
.cc-bar-label { font-size: 12px; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cc-bar-track { height: 10px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.cc-bar-track > span { display: block; height: 100%; border-radius: 999px; transition: width var(--transition); }
.cc-bar-count { font-size: 12px; font-weight: 700; text-align: right; color: var(--text); }

/* ----- Progress bar ----- */
.cc-progress { }
.cc-progress-head { display: flex; justify-content: space-between; font-size: 12px; color: var(--text-2); font-weight: 600; margin-bottom: 6px; }
.cc-progress-track { height: 12px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.cc-progress-track > span { display: block; height: 100%; border-radius: 999px; transition: width var(--transition); }

/* ----- Settings ----- */
.settings-card { margin-bottom: 4px; }
.settings-help { font-size: 12.5px; color: var(--text-2); margin-bottom: 12px; line-height: 1.5; }
.settings-warn {
  font-size: 12px; color: #9a6a12; background: rgba(253,171,61,.14);
  border-radius: var(--r-sm); padding: 8px 10px; margin-bottom: 12px;
}
[data-theme="dark"] .settings-warn { color: var(--warn); }
.settings-form { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 12px; }
.settings-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }

.settings-list-block { padding: 12px 0; border-top: 1px solid var(--border); }
.settings-list-block:first-of-type { border-top: none; }
.settings-list-name { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--text-3); margin-bottom: 8px; }
.settings-chip-row { display: flex; flex-wrap: wrap; gap: 7px; margin-bottom: 8px; }
.settings-value-chip {
  display: inline-flex; align-items: center; gap: 7px; padding: 4px 6px 4px 9px;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r-pill); font-size: 12.5px;
}
.settings-value-chip.is-off { opacity: .5; text-decoration: line-through; }
.svc-dot { width: 9px; height: 9px; border-radius: 50%; flex: 0 0 auto; }
.svc-text { color: var(--text); }
.svc-toggle {
  width: 18px; height: 18px; display: inline-flex; align-items: center; justify-content: center;
  border-radius: 50%; color: var(--text-3); font-size: 14px; line-height: 1;
}
.svc-toggle:hover { background: var(--surface-3); color: var(--text); }
.settings-value-chip.is-off .svc-toggle:hover { background: var(--accent-soft); color: var(--accent); }
.settings-add-row { display: flex; gap: 8px; align-items: center; }
.settings-add-row .input { flex: 1; }
.settings-color { width: 44px; padding: 2px; cursor: pointer; flex: 0 0 auto; }

/* ----- Phase 3 responsive ----- */
@media (max-width: 840px) {
  .cc-grid { grid-template-columns: 1fr; }
  .settings-form { grid-template-columns: 1fr; }
  .cc-bar-row { grid-template-columns: 96px 1fr 30px; }
}
/* =========================================================================
   GAP-FILL — notifications feed & settings extras
   ========================================================================= */

/* ----- Bell + unread badge ----- */
.notif-btn { position: relative; }
.notif-badge {
  position: absolute; top: 1px; right: 1px; min-width: 16px; height: 16px; padding: 0 4px;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--danger); color: #fff; font-size: 10px; font-weight: 800;
  border-radius: 999px; border: 2px solid var(--surface); line-height: 1;
}

/* ----- Notifications panel (fixed dropdown) ----- */
.notif-panel {
  position: fixed; z-index: 1600; width: 340px; max-width: 92vw; max-height: 64vh;
  display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md);
  box-shadow: var(--shadow-lg); overflow: hidden; animation: pop .12s ease;
}
.notif-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 14px; border-bottom: 1px solid var(--border);
}
.notif-title { font-size: 13.5px; font-weight: 700; }
.notif-list { overflow-y: auto; flex: 1; }
.notif-empty { padding: 26px 16px; text-align: center; color: var(--text-3); font-size: 13px; font-style: italic; }

.notif-item {
  display: flex; align-items: flex-start; gap: 9px; padding: 11px 14px;
  border-bottom: 1px solid var(--border); cursor: pointer; transition: background var(--transition);
}
.notif-item:last-child { border-bottom: none; }
.notif-item:hover { background: var(--surface-2); }
.notif-item.is-unread { background: var(--accent-soft); }
.notif-item.is-unread:hover { background: var(--accent-soft); filter: brightness(.98); }
.notif-dot { width: 8px; height: 8px; border-radius: 50%; background: transparent; flex: 0 0 auto; margin-top: 6px; }
.notif-item.is-unread .notif-dot { background: var(--accent); }
.notif-ic { width: 18px; height: 18px; color: var(--text-3); flex: 0 0 auto; margin-top: 2px; }
.notif-body { min-width: 0; flex: 1; }
.notif-subject {
  font-size: 13px; font-weight: 600; color: var(--text); line-height: 1.35;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.notif-meta { font-size: 11.5px; color: var(--text-3); margin-top: 2px; }

/* ----- Settings extras ----- */
.settings-card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; }
.settings-checks { display: flex; flex-wrap: wrap; gap: 18px; margin: 4px 0 14px; }

@media (max-width: 840px) {
  .notif-panel { left: 8px !important; right: 8px; width: auto; }
}

/* ---------------------------------------------------------------------
   Quick Create modal — read-only board chip + collapsible extras
   --------------------------------------------------------------------- */
.qc-board {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 8px 11px; border: 1px solid var(--border); border-radius: var(--r-sm);
  background: var(--surface-2); color: var(--text-2); font-size: 13px; font-weight: 600;
}
.qc-board::before {
  content: ""; width: 8px; height: 8px; border-radius: 50%;
  background: var(--accent); flex: 0 0 auto;
}
.qc-more { margin-top: 2px; border-top: 1px solid var(--border); padding-top: 10px; }
.qc-more > summary {
  cursor: pointer; list-style: none; font-size: 12.5px; font-weight: 600;
  color: var(--accent); user-select: none; padding: 2px 0;
}
.qc-more > summary::-webkit-details-marker { display: none; }
.qc-more > summary::before { content: "+ "; font-weight: 700; }
.qc-more[open] > summary::before { content: "– "; }
.qc-more[open] > summary { margin-bottom: 8px; }
.qc-more .field + .field { margin-top: 10px; }

/* ---------------------------------------------------------------------
   Drawer accordion sections (collapsible Overview / People / … )
   --------------------------------------------------------------------- */
.acc { border-bottom: 1px solid var(--border); }
.acc:first-of-type { border-top: 1px solid var(--border); }
.acc-head {
  cursor: pointer; list-style: none; user-select: none;
  display: flex; align-items: center; gap: 8px;
  padding: 13px 2px; font-size: 13px; font-weight: 700; color: var(--text);
  transition: color var(--transition);
}
.acc-head::-webkit-details-marker { display: none; }
.acc-head::before {
  content: ""; width: 7px; height: 7px; flex: 0 0 auto;
  border-right: 2px solid var(--text-3); border-bottom: 2px solid var(--text-3);
  transform: rotate(-45deg); margin-left: 2px;
  transition: transform var(--transition), border-color var(--transition);
}
.acc[open] > .acc-head::before { transform: rotate(45deg); }
.acc-head:hover { color: var(--accent); }
.acc-head:hover::before { border-color: var(--accent); }
.acc-body { padding: 2px 2px 16px; display: grid; gap: 12px; }
.acc-body .field-grid { margin: 0; }

/* ---------------------------------------------------------------------
   Sidebar department group headers
   --------------------------------------------------------------------- */
.b-dept-head {
  padding: 10px 10px 4px; font-size: 10.5px; font-weight: 700;
  letter-spacing: .06em; text-transform: uppercase; color: var(--text-3);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.b-dept-head:first-child { padding-top: 2px; }

/* ---------------------------------------------------------------------
   Recurring template editor — grouped sections
   --------------------------------------------------------------------- */
.tpl-form { display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px; }
.tpl-section { padding: 12px 0; border-bottom: 1px dashed var(--border); }
.tpl-section:first-child { padding-top: 0; }
.tpl-section:last-child { border-bottom: none; }
.tpl-section-label {
  font-size: 11px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase;
  color: var(--text-3); margin-bottom: 10px;
}
.tpl-form .settings-form { margin-bottom: 0; }
.field-label .hint { font-weight: 500; color: var(--text-3); text-transform: none; letter-spacing: 0; }

/* ---------------------------------------------------------------------
   Audit Log — filter bar + event table
   --------------------------------------------------------------------- */
.audit-filters {
  display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; margin-bottom: 14px;
}
.audit-filters .field { margin: 0; min-width: 150px; }
.audit-filters .input { padding: 7px 9px; }
.audit-filters .audit-filter-actions { display: flex; gap: 8px; margin-left: auto; }

.audit-table { border: 1px solid var(--border); border-radius: var(--r-md); overflow: hidden; background: var(--surface); }
.audit-head, .audit-row {
  display: grid;
  grid-template-columns: 150px 150px 130px 1fr;
  gap: 12px; padding: 9px 14px; align-items: center;
}
.audit-head {
  background: var(--surface-2); font-size: 11px; font-weight: 700;
  letter-spacing: .04em; text-transform: uppercase; color: var(--text-3);
  position: sticky; top: 0; z-index: 1;
}
.audit-row { border-top: 1px solid var(--border); font-size: 13px; }
.audit-row:hover { background: var(--surface-2); }
.audit-time { color: var(--text-3); font-size: 12px; white-space: nowrap; }
.audit-actor { font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.audit-detail { color: var(--text-2); min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.audit-action-chip {
  display: inline-block; padding: 2px 9px; border-radius: var(--r-pill);
  font-size: 11px; font-weight: 600; background: var(--accent-soft); color: var(--accent);
  white-space: nowrap;
}
.audit-action-chip.is-archive, .audit-action-chip.is-remove { background: var(--danger-soft); color: var(--danger); }
.audit-action-chip.is-create { background: rgba(0,200,117,.14); color: var(--success); }
.audit-ent { color: var(--text-3); font-size: 11px; text-transform: uppercase; letter-spacing: .03em; }
.audit-empty { padding: 26px; text-align: center; color: var(--text-3); }
@media (max-width: 720px) {
  .audit-head { display: none; }
  .audit-row { grid-template-columns: 1fr; gap: 4px; }
}

/* ---------------------------------------------------------------------
   Sidebar scroll — keep brand pinned top, footer pinned bottom,
   let the nav sections scroll when they exceed the viewport height.
   --------------------------------------------------------------------- */
.sidebar { overflow-y: auto; overflow-x: hidden; }
.sidebar-brand {
  position: sticky; top: 0; z-index: 3;
  background: var(--surface); margin: -14px -12px 0; padding: 18px 18px 12px;
}
.sidebar-footer {
  position: sticky; bottom: 0; z-index: 3;
  background: var(--surface); margin: 0 -12px -14px; padding: 10px 12px 14px;
}
/* The board list no longer needs its own tall scroll once the whole rail scrolls. */
.board-list { max-height: none; }

/* ---------------------------------------------------------------------
   Dashboard — department rollup table
   --------------------------------------------------------------------- */
.dept-table { display: flex; flex-direction: column; }
.dept-row {
  display: grid; grid-template-columns: 1fr 70px 80px 80px; gap: 10px;
  align-items: center; padding: 9px 4px; border-top: 1px solid var(--border); font-size: 13px;
}
.dept-row:first-child { border-top: none; }
.dept-head {
  font-size: 11px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase;
  color: var(--text-3); border-top: none;
}
.dept-name { font-weight: 600; color: var(--text); }
.dept-bad { color: var(--danger); font-weight: 700; }
.dept-empty { padding: 16px 4px; color: var(--text-3); }

/* ---------------------------------------------------------------------
   Drawer custom fields
   --------------------------------------------------------------------- */
.cf-field { gap: 6px; }
.cf-label-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.cf-del {
  border: none; background: transparent; color: var(--text-3); cursor: pointer;
  font-size: 16px; line-height: 1; padding: 0 4px; border-radius: 6px;
}
.cf-del:hover { color: var(--danger); background: var(--danger-soft); }
.cf-add {
  display: flex; gap: 8px; align-items: center; margin-top: 12px;
  padding-top: 12px; border-top: 1px dashed var(--border);
}
.cf-add .input { flex: 1; min-width: 0; }
.cf-add select.input { flex: 0 0 120px; }