/* ═══════════════════════════════════════════
   ATLAS HQ — NEXUS DESIGN SYSTEM
   Hydra Teal Theme · Forked from Atlas V2
   ═══════════════════════════════════════════ */

/* ─── BASE & DESIGN TOKENS ─── */
:root, [data-theme="light"] {
  --text-xs:   clamp(0.75rem,  0.7rem  + 0.25vw, 0.875rem);
  --text-sm:   clamp(0.875rem, 0.8rem  + 0.35vw, 1rem);
  --text-base: clamp(1rem,     0.9rem  + 0.5vw,  1.125rem);
  --text-lg:   clamp(1.125rem, 0.95rem + 0.85vw, 1.5rem);
  --text-xl:   clamp(1.5rem,   1rem    + 1.5vw,  2.25rem);
  --radius-sm: 0.375rem;
  --radius-md: 0.5rem;
  --radius-lg: 0.75rem;
  --radius-xl: 1rem;
  --radius-full: 9999px;
  --transition-interactive: 180ms cubic-bezier(0.16, 1, 0.3, 1);
  --shadow-sm: 0 1px 2px oklch(0.2 0.01 80 / 0.06);
  --shadow-md: 0 4px 12px oklch(0.2 0.01 80 / 0.08);
  --shadow-lg: 0 12px 32px oklch(0.2 0.01 80 / 0.12);

  /* Surfaces */
  --color-bg: #f7f6f2;
  --color-surface: #f9f8f5;
  --color-surface-2: #fbfbf9;
  --color-surface-offset: #f3f0ec;
  --color-surface-offset-2: #edeae5;
  --color-surface-dynamic: #e6e4df;
  --color-divider: #dcd9d5;
  --color-border: #d4d1ca;

  /* Text */
  --color-tx: #28251d;
  --color-tx-muted: #7a7974;
  --color-tx-faint: #bab9b4;
  --color-tx-inverse: #f9f8f4;

  /* Primary (Hydra Teal) */
  --color-primary: #01696f;
  --color-primary-hover: #0c4e54;
  --color-primary-active: #0f3638;
  --color-primary-hl: #cedcd8;

  /* Semantic */
  --color-error: #a12c7b;
  --color-error-hl: #e0ced7;
  --color-success: #437a22;
  --color-success-hl: #d4dfcc;
  --color-warning: #964219;
  --color-warning-hl: #ddcfc6;
  --color-blue: #006494;
  --color-blue-hl: #c6d8e4;
  --color-orange: #da7101;
  --color-orange-hl: #e7d7c4;
}

[data-theme="dark"] {
  --color-bg: #171614;
  --color-surface: #1c1b19;
  --color-surface-2: #201f1d;
  --color-surface-offset: #1d1c1a;
  --color-surface-offset-2: #22211f;
  --color-surface-dynamic: #2d2c2a;
  --color-divider: #262523;
  --color-border: #393836;
  --color-tx: #cdccca;
  --color-tx-muted: #797876;
  --color-tx-faint: #5a5957;
  --color-tx-inverse: #2b2a28;
  --color-primary: #4f98a3;
  --color-primary-hover: #227f8b;
  --color-primary-active: #1a626b;
  --color-primary-hl: #313b3b;
  --color-error: #c4528f;
  --color-error-hl: #3b2d35;
  --color-success: #6aad44;
  --color-success-hl: #2d3a27;
  --color-warning: #c46a30;
  --color-warning-hl: #3b3027;
  --color-blue: #3d9cc9;
  --color-blue-hl: #273540;
  --color-orange: #e89030;
  --color-orange-hl: #3b3027;
  --shadow-sm: 0 1px 2px oklch(0 0 0 / 0.2);
  --shadow-md: 0 4px 12px oklch(0 0 0 / 0.3);
  --shadow-lg: 0 12px 32px oklch(0 0 0 / 0.4);
}

/* ─── RESET ─── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; }
body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  font-size: var(--text-base);
  color: var(--color-tx);
  background: var(--color-bg);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow: hidden;
  height: 100dvh;
}
a { color: var(--color-primary); text-decoration: none; }
a:hover { text-decoration: underline; }
img, svg { display: block; max-width: 100%; }
button { cursor: pointer; font-family: inherit; }
input, select, textarea { font-family: inherit; }

/* ─── FONT FACES ─── */
@font-face { font-family: 'Inter'; src: url('./fonts/inter-400.woff2') format('woff2'); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: 'Inter'; src: url('./fonts/inter-500.woff2') format('woff2'); font-weight: 500; font-style: normal; font-display: swap; }
@font-face { font-family: 'Inter'; src: url('./fonts/inter-600.woff2') format('woff2'); font-weight: 600; font-style: normal; font-display: swap; }
@font-face { font-family: 'Inter'; src: url('./fonts/inter-700.woff2') format('woff2'); font-weight: 700; font-style: normal; font-display: swap; }

/* ─── LOGIN PAGE ─── */
#login-page {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--color-bg);
  padding: 1rem;
}
.login-container {
  width: 100%;
  max-width: 380px;
  text-align: center;
}
.login-logo {
  width: 56px;
  height: 56px;
  margin: 0 auto 1rem;
}
.login-title {
  font-size: var(--text-lg);
  font-weight: 700;
  margin-bottom: 0.25rem;
}
.login-subtitle {
  font-size: var(--text-sm);
  color: var(--color-tx-muted);
  margin-bottom: 1.5rem;
}
.login-card {
  background: var(--color-surface);
  border: 1px solid var(--color-divider);
  border-radius: var(--radius-xl);
  padding: 1.5rem;
  text-align: left;
}
.login-card .field-label { margin-bottom: 0.25rem; }
.login-card .input-field { margin-bottom: 1rem; }
.login-error {
  color: var(--color-error);
  font-size: var(--text-xs);
  margin-bottom: 0.75rem;
  display: none;
}
.login-toggle {
  margin-top: 1rem;
  font-size: var(--text-xs);
  color: var(--color-tx-muted);
  text-align: center;
}
.login-toggle a { cursor: pointer; }

/* ─── APP SHELL GRID ─── */
#app-shell {
  display: none;
  height: 100dvh;
  grid-template-columns: 240px 1fr;
  grid-template-rows: 56px 1fr;
  grid-template-areas:
    "sidebar header"
    "sidebar main";
  overflow: hidden;
}
#app-shell.active { display: grid; }

/* ─── SIDEBAR ─── */
#sidebar {
  grid-area: sidebar;
  background: var(--color-surface);
  border-right: 1px solid var(--color-divider);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  z-index: 20;
}
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0 1rem;
  height: 56px;
  border-bottom: 1px solid var(--color-divider);
  flex-shrink: 0;
}
.sidebar-brand svg {
  width: 28px;
  height: 28px;
  flex-shrink: 0;
}
.sidebar-brand-text {
  font-size: var(--text-sm);
  font-weight: 700;
  color: var(--color-tx);
  white-space: nowrap;
}
#sidebar nav {
  flex: 1;
  padding: 0.75rem 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
#sidebar nav a, .nav-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 1rem;
  min-height: 44px;
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--color-tx-muted);
  border-radius: var(--radius-md);
  transition: all var(--transition-interactive);
  text-decoration: none;
  cursor: pointer;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
}
#sidebar nav a:hover, .nav-item:hover {
  color: var(--color-tx);
  background: var(--color-surface-offset);
  text-decoration: none;
}
#sidebar nav a.active, .nav-item.active {
  color: var(--color-primary);
  background: var(--color-primary-hl);
  font-weight: 600;
}
#sidebar nav a svg, .nav-item svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  opacity: 0.7;
}
#sidebar nav a.active svg, .nav-item.active svg { opacity: 1; }
.nav-label { white-space: nowrap; }
.sidebar-footer {
  padding: 0.75rem;
  border-top: 1px solid var(--color-divider);
  flex-shrink: 0;
}
.sidebar-user {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem;
  border-radius: var(--radius-md);
}
.sidebar-avatar {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  background: var(--color-primary-hl);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--color-primary);
  flex-shrink: 0;
}

/* ─── TOP HEADER ─── */
#top-header {
  grid-area: header;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-divider);
  display: flex;
  align-items: center;
  padding: 0 1.5rem;
  gap: 0.75rem;
  z-index: 15;
}
.header-search {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.375rem 0.75rem;
  background: var(--color-surface-offset);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  cursor: pointer;
  max-width: 400px;
  flex: 1;
  min-height: 36px;
  transition: border-color var(--transition-interactive);
}
.header-search:hover { border-color: var(--color-primary); }
.header-search svg { width: 16px; height: 16px; color: var(--color-tx-faint); flex-shrink: 0; }
.header-search-text {
  font-size: var(--text-xs);
  color: var(--color-tx-faint);
  flex: 1;
}
.header-search-kbd {
  font-size: 0.625rem;
  font-weight: 600;
  padding: 0.125rem 0.375rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  color: var(--color-tx-faint);
  white-space: nowrap;
}
.header-spacer { flex: 1; }
.header-btn {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: none;
  border-radius: var(--radius-md);
  color: var(--color-tx-muted);
  transition: all var(--transition-interactive);
  position: relative;
}
.header-btn:hover {
  background: var(--color-surface-offset);
  color: var(--color-tx);
}
.header-btn svg { width: 18px; height: 18px; }
.notif-badge {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 8px;
  height: 8px;
  border-radius: var(--radius-full);
  background: var(--color-error);
}
.header-user {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.25rem 0.5rem;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background var(--transition-interactive);
}
.header-user:hover { background: var(--color-surface-offset); }
.header-user-name {
  font-size: var(--text-xs);
  font-weight: 500;
  color: var(--color-tx);
}

/* ─── MAIN CONTENT ─── */
#main-content {
  grid-area: main;
  overflow-y: auto;
  padding: 1.5rem;
  background: var(--color-bg);
}

/* ─── VIEWS ─── */
.view { display: none; }
.view.active {
  display: block;
  animation: fadeIn 200ms cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.view-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
  gap: 0.75rem;
}
.view-title {
  font-size: var(--text-lg);
  font-weight: 700;
  color: var(--color-tx);
}
.view-subtitle {
  font-size: var(--text-xs);
  color: var(--color-tx-muted);
  margin-top: 0.125rem;
}

/* ─── BUTTONS ─── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.375rem;
  padding: 0.5rem 1rem;
  min-height: 44px;
  font-size: var(--text-sm);
  font-weight: 500;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  transition: all var(--transition-interactive);
  white-space: nowrap;
  cursor: pointer;
  text-decoration: none;
}
.btn svg { width: 16px; height: 16px; flex-shrink: 0; }
.btn-primary {
  background: var(--color-primary);
  color: var(--color-tx-inverse);
}
.btn-primary:hover { background: var(--color-primary-hover); }
.btn-primary:active { background: var(--color-primary-active); }
.btn-secondary {
  background: var(--color-surface-offset);
  color: var(--color-tx);
  border-color: var(--color-border);
}
.btn-secondary:hover { background: var(--color-surface-dynamic); }
.btn-ghost {
  background: transparent;
  color: var(--color-tx-muted);
}
.btn-ghost:hover {
  background: var(--color-surface-offset);
  color: var(--color-tx);
}
.btn-danger {
  background: var(--color-error);
  color: var(--color-tx-inverse);
}
.btn-danger:hover { opacity: 0.9; }
.btn-danger-ghost {
  background: transparent;
  color: var(--color-tx-faint);
  border: none;
}
.btn-danger-ghost:hover {
  background: var(--color-error-hl);
  color: var(--color-error);
}
.btn-sm {
  padding: 0.25rem 0.625rem;
  min-height: 32px;
  font-size: var(--text-xs);
}
.btn-outline {
  background: transparent;
  color: var(--color-primary);
  border-color: var(--color-primary);
}
.btn-outline:hover {
  background: var(--color-primary-hl);
}

/* ─── FORM FIELDS ─── */
.field-label {
  display: block;
  font-size: var(--text-xs);
  font-weight: 500;
  color: var(--color-tx-muted);
  margin-bottom: 0.375rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.input-field {
  width: 100%;
  padding: 0.5rem 0.75rem;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  color: var(--color-tx);
  min-height: 44px;
  transition: border-color var(--transition-interactive), box-shadow var(--transition-interactive);
}
.input-field:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-primary-hl);
}
.input-field::placeholder { color: var(--color-tx-faint); }
.select-field {
  appearance: none;
  width: 100%;
  padding: 0.5rem 2rem 0.5rem 0.75rem;
  background: var(--color-surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='none' stroke='%237a7974' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M2 4l4 4 4-4'/%3E%3C/svg%3E") no-repeat right 0.75rem center;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  color: var(--color-tx);
  min-height: 44px;
  cursor: pointer;
  transition: border-color var(--transition-interactive), box-shadow var(--transition-interactive);
}
.select-field:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-primary-hl);
}
textarea.input-field {
  min-height: 80px;
  resize: vertical;
}
.form-row {
  margin-bottom: 1rem;
}
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

/* ─── DATA TABLES ─── */
.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--color-divider);
  border-radius: var(--radius-lg);
  background: var(--color-surface);
}
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
}
.data-table thead {
  position: sticky;
  top: 0;
  z-index: 1;
}
.data-table thead th {
  background: var(--color-surface-offset);
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--color-tx-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0.625rem 0.75rem;
  text-align: left;
  border-bottom: 1px solid var(--color-divider);
  white-space: nowrap;
}
.data-table tbody tr {
  transition: background var(--transition-interactive);
}
.data-table tbody tr:hover {
  background: var(--color-surface-offset);
}
.data-table tbody td {
  padding: 0.625rem 0.75rem;
  border-bottom: 1px solid var(--color-divider);
  vertical-align: middle;
}
.data-table tbody tr:last-child td { border-bottom: none; }

/* ─── KPI CARDS ─── */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.kpi-card {
  background: var(--color-surface);
  border: 1px solid var(--color-divider);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  transition: box-shadow var(--transition-interactive);
}
.kpi-card:hover { box-shadow: var(--shadow-md); }
.kpi-label {
  font-size: var(--text-xs);
  font-weight: 500;
  color: var(--color-tx-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 0.5rem;
}
.kpi-value {
  font-size: var(--text-xl);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--color-tx);
}
.kpi-delta {
  font-size: var(--text-xs);
  margin-top: 0.375rem;
}
.kpi-delta.up { color: var(--color-success); }
.kpi-delta.down { color: var(--color-error); }
.kpi-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 0.75rem;
}
.kpi-icon svg { width: 20px; height: 20px; }
.kpi-icon.teal { background: var(--color-primary-hl); color: var(--color-primary); }
.kpi-icon.green { background: var(--color-success-hl); color: var(--color-success); }
.kpi-icon.orange { background: var(--color-warning-hl); color: var(--color-warning); }
.kpi-icon.blue { background: var(--color-blue-hl); color: var(--color-blue); }
.kpi-icon.red { background: var(--color-error-hl); color: var(--color-error); }

/* ─── BADGES ─── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.125rem 0.5rem;
  font-size: var(--text-xs);
  font-weight: 500;
  border-radius: var(--radius-full);
  white-space: nowrap;
}
.badge-success, .badge-active, .badge-compliant {
  background: var(--color-success-hl);
  color: var(--color-success);
}
.badge-warning, .badge-due-soon {
  background: var(--color-warning-hl);
  color: var(--color-warning);
}
.badge-error, .badge-overdue, .badge-expired {
  background: var(--color-error-hl);
  color: var(--color-error);
}
.badge-blue, .badge-in-progress {
  background: var(--color-blue-hl);
  color: var(--color-blue);
}
.badge-orange {
  background: var(--color-orange-hl);
  color: var(--color-orange);
}
.badge-muted, .badge-pending {
  background: var(--color-surface-dynamic);
  color: var(--color-tx-muted);
}
.badge-primary {
  background: var(--color-primary-hl);
  color: var(--color-primary);
}

/* ─── TABS ─── */
.tab-list {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--color-divider);
  margin-bottom: 1.5rem;
  overflow-x: auto;
}
.tab-btn {
  padding: 0.75rem 1rem;
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--color-tx-muted);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  min-height: 44px;
  cursor: pointer;
  white-space: nowrap;
  transition: all var(--transition-interactive);
}
.tab-btn:hover { color: var(--color-tx); }
.tab-btn.active {
  color: var(--color-primary);
  border-bottom-color: var(--color-primary);
}

/* ─── CARDS ─── */
.card {
  background: var(--color-surface);
  border: 1px solid var(--color-divider);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  transition: box-shadow var(--transition-interactive);
}
.card:hover { box-shadow: var(--shadow-md); }
.card-title {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--color-tx);
  margin-bottom: 0.5rem;
}
.card-meta {
  font-size: var(--text-xs);
  color: var(--color-tx-muted);
}
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1rem;
}

/* ─── MODALS ─── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: oklch(0 0 0 / 0.4);
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-interactive);
  padding: 1rem;
}
.modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}
.modal-panel {
  background: var(--color-surface);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 560px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: scale(0.95) translateY(8px);
  transition: transform var(--transition-interactive);
}
.modal-overlay.active .modal-panel {
  transform: scale(1) translateY(0);
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--color-divider);
  flex-shrink: 0;
}
.modal-title {
  font-size: var(--text-base);
  font-weight: 600;
}
.modal-close {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: none;
  border-radius: var(--radius-md);
  color: var(--color-tx-muted);
  cursor: pointer;
  transition: background var(--transition-interactive);
}
.modal-close:hover { background: var(--color-surface-offset); }
.modal-body {
  padding: 1.5rem;
  overflow-y: auto;
  flex: 1 1 auto;
}
.modal-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--color-divider);
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  flex-shrink: 0;
}
.modal-wide .modal-panel { max-width: 720px; }

/* ─── TOASTS ─── */
#toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.toast {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0.75rem 1rem;
  background: var(--color-surface);
  border: 1px solid var(--color-divider);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  min-width: 280px;
  max-width: 420px;
  font-size: var(--text-sm);
  animation: toastIn 300ms ease-out;
}
.toast-success { border-left: 3px solid var(--color-success); }
.toast-error { border-left: 3px solid var(--color-error); }
.toast-info { border-left: 3px solid var(--color-blue); }
.toast-warning { border-left: 3px solid var(--color-warning); }
.toast-removing { animation: toastOut 200ms ease-in forwards; }
@keyframes toastIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@keyframes toastOut { from { opacity: 1; } to { opacity: 0; transform: translateY(8px); } }

/* ─── SEARCH OVERLAY ─── */
#ai-search-overlay {
  position: fixed;
  inset: 0;
  background: oklch(0 0 0 / 0.5);
  z-index: 60;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 15vh;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-interactive);
}
#ai-search-overlay.active {
  opacity: 1;
  pointer-events: auto;
}
.search-panel {
  background: var(--color-surface);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 640px;
  max-height: 70vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: scale(0.95) translateY(-16px);
  transition: transform var(--transition-interactive);
}
#ai-search-overlay.active .search-panel {
  transform: scale(1) translateY(0);
}
.search-input-wrap {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--color-divider);
}
.search-input-wrap svg {
  width: 20px;
  height: 20px;
  color: var(--color-primary);
  flex-shrink: 0;
}
.search-input {
  flex: 1;
  border: none;
  background: none;
  font-size: var(--text-base);
  color: var(--color-tx);
  outline: none;
}
.search-input::placeholder { color: var(--color-tx-faint); }
.search-results {
  overflow-y: auto;
  padding: 0.75rem;
  flex: 1;
}
.search-result-item {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.75rem;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background var(--transition-interactive);
}
.search-result-item:hover { background: var(--color-surface-offset); }
.search-result-icon {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: var(--text-xs);
  font-weight: 600;
}
.search-result-title {
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--color-tx);
}
.search-result-meta {
  font-size: var(--text-xs);
  color: var(--color-tx-muted);
  margin-top: 0.125rem;
}
.search-hint {
  text-align: center;
  padding: 2rem;
  color: var(--color-tx-faint);
  font-size: var(--text-sm);
}
.search-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 2rem;
  color: var(--color-tx-muted);
  font-size: var(--text-sm);
}

/* ─── KANBAN BOARD ─── */
.kanban-board {
  display: flex;
  gap: 1rem;
  overflow-x: auto;
  padding-bottom: 1rem;
  min-height: 400px;
}
.kanban-column {
  min-width: 280px;
  max-width: 320px;
  flex-shrink: 0;
  background: var(--color-surface-offset);
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 200px);
}
.kanban-column-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--color-tx-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-bottom: 1px solid var(--color-divider);
  flex-shrink: 0;
}
.kanban-column-count {
  background: var(--color-surface-dynamic);
  padding: 0.125rem 0.375rem;
  border-radius: var(--radius-full);
  font-size: 0.625rem;
}
.kanban-column-body {
  flex: 1;
  overflow-y: auto;
  padding: 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.kanban-card {
  background: var(--color-surface);
  border: 1px solid var(--color-divider);
  border-radius: var(--radius-md);
  padding: 0.75rem;
  cursor: grab;
  transition: box-shadow var(--transition-interactive), transform var(--transition-interactive);
}
.kanban-card:hover { box-shadow: var(--shadow-md); }
.kanban-card.dragging { opacity: 0.5; transform: scale(0.97); }
.kanban-card-title {
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--color-tx);
  margin-bottom: 0.375rem;
}
.kanban-card-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: var(--text-xs);
  color: var(--color-tx-muted);
}
.kanban-card-assignee {
  display: flex;
  align-items: center;
  gap: 0.375rem;
}
.kanban-card-avatar {
  width: 20px;
  height: 20px;
  border-radius: var(--radius-full);
  background: var(--color-primary-hl);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.5rem;
  font-weight: 600;
  color: var(--color-primary);
}
.kanban-drop-indicator {
  border: 2px dashed var(--color-primary);
  border-radius: var(--radius-md);
  background: var(--color-primary-hl);
  min-height: 60px;
  opacity: 0.5;
}
.kanban-column.drag-over { background: var(--color-surface-offset-2); }

/* ─── LICENSE CARDS ─── */
.license-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1rem;
}
.license-card {
  background: var(--color-surface);
  border: 1px solid var(--color-divider);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  position: relative;
  transition: box-shadow var(--transition-interactive);
}
.license-card:hover { box-shadow: var(--shadow-md); }
.license-card-status {
  position: absolute;
  top: 1.25rem;
  right: 1.25rem;
}
.license-card-type {
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--color-tx-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 0.375rem;
}
.license-card-number {
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--color-tx);
  margin-bottom: 0.75rem;
}
.license-card-detail {
  display: flex;
  justify-content: space-between;
  font-size: var(--text-xs);
  color: var(--color-tx-muted);
  padding: 0.25rem 0;
}
.license-card-detail span:last-child { color: var(--color-tx); font-weight: 500; }

/* ─── COMPLIANCE CARDS ─── */
.compliance-item {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem;
  background: var(--color-surface);
  border: 1px solid var(--color-divider);
  border-radius: var(--radius-lg);
  transition: box-shadow var(--transition-interactive);
  cursor: pointer;
}
.compliance-item:hover { box-shadow: var(--shadow-sm); }
.compliance-dot {
  width: 10px;
  height: 10px;
  border-radius: var(--radius-full);
  flex-shrink: 0;
}
.compliance-dot.green { background: var(--color-success); }
.compliance-dot.amber { background: var(--color-warning); }
.compliance-dot.red { background: var(--color-error); }
.compliance-dot.blue { background: var(--color-blue); }
.compliance-dot.gray { background: var(--color-tx-faint); }
.compliance-info { flex: 1; min-width: 0; }
.compliance-title {
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--color-tx);
}
.compliance-due {
  font-size: var(--text-xs);
  color: var(--color-tx-muted);
  margin-top: 0.125rem;
}

/* ─── DOCUMENT BROWSER ─── */
.doc-browser {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 1rem;
  min-height: 400px;
}
.doc-tree {
  background: var(--color-surface);
  border: 1px solid var(--color-divider);
  border-radius: var(--radius-lg);
  padding: 0.75rem;
  overflow-y: auto;
}
.doc-tree-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.375rem 0.5rem;
  border-radius: var(--radius-sm);
  font-size: var(--text-xs);
  color: var(--color-tx-muted);
  cursor: pointer;
  transition: all var(--transition-interactive);
}
.doc-tree-item:hover { background: var(--color-surface-offset); color: var(--color-tx); }
.doc-tree-item.active { background: var(--color-primary-hl); color: var(--color-primary); font-weight: 500; }
.doc-tree-item svg { width: 14px; height: 14px; flex-shrink: 0; }
.doc-main {
  background: var(--color-surface);
  border: 1px solid var(--color-divider);
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
}
.doc-breadcrumb {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--color-divider);
  font-size: var(--text-xs);
  color: var(--color-tx-muted);
}
.doc-breadcrumb a { color: var(--color-primary); cursor: pointer; }
.doc-file-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 0.75rem;
  padding: 1rem;
  flex: 1;
}
.doc-file-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  padding: 1rem;
  border: 1px solid var(--color-divider);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-interactive);
  text-align: center;
}
.doc-file-card:hover { background: var(--color-surface-offset); box-shadow: var(--shadow-sm); }
.doc-file-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-xs);
  font-weight: 700;
}
.doc-file-icon.pdf { background: #fee2e2; color: #dc2626; }
.doc-file-icon.doc { background: #dbeafe; color: #2563eb; }
.doc-file-icon.sheet { background: #dcfce7; color: #16a34a; }
.doc-file-icon.img { background: #fef3c7; color: #d97706; }
.doc-file-icon.other { background: var(--color-surface-dynamic); color: var(--color-tx-muted); }
.doc-file-name {
  font-size: var(--text-xs);
  font-weight: 500;
  color: var(--color-tx);
  word-break: break-word;
}
.doc-file-meta {
  font-size: 0.625rem;
  color: var(--color-tx-faint);
}
.doc-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 3rem;
  color: var(--color-tx-faint);
  text-align: center;
  flex: 1;
}
.doc-empty svg { width: 48px; height: 48px; margin-bottom: 1rem; opacity: 0.5; }

/* ─── ACTIVITY FEED ─── */
.activity-feed {
  display: flex;
  flex-direction: column;
  gap: 0;
}
.activity-item {
  display: flex;
  gap: 0.75rem;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--color-divider);
}
.activity-item:last-child { border-bottom: none; }
.activity-dot {
  width: 8px;
  height: 8px;
  border-radius: var(--radius-full);
  margin-top: 6px;
  flex-shrink: 0;
}
.activity-text {
  font-size: var(--text-sm);
  color: var(--color-tx);
}
.activity-time {
  font-size: var(--text-xs);
  color: var(--color-tx-faint);
  margin-top: 0.125rem;
}

/* ─── PRIORITY INDICATORS ─── */
.priority-dot {
  width: 8px;
  height: 8px;
  border-radius: var(--radius-full);
  display: inline-block;
}
.priority-low { background: var(--color-tx-faint); }
.priority-medium { background: var(--color-blue); }
.priority-high { background: var(--color-orange); }
.priority-urgent { background: var(--color-error); }

/* ─── TOGGLE SWITCH ─── */
.toggle-switch { position: relative; width: 44px; height: 24px; display: inline-block; }
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute;
  inset: 0;
  background: var(--color-surface-dynamic);
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: background var(--transition-interactive);
}
.toggle-slider::before {
  content: '';
  position: absolute;
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background: white;
  border-radius: 50%;
  transition: transform var(--transition-interactive);
}
.toggle-switch input:checked + .toggle-slider { background: var(--color-primary); }
.toggle-switch input:checked + .toggle-slider::before { transform: translateX(20px); }

/* ─── EMPTY STATES ─── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 3rem;
  text-align: center;
  color: var(--color-tx-faint);
}
.empty-state svg { width: 48px; height: 48px; margin-bottom: 1rem; opacity: 0.4; }
.empty-state-title {
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--color-tx-muted);
  margin-bottom: 0.375rem;
}
.empty-state-text {
  font-size: var(--text-xs);
  margin-bottom: 1rem;
}

/* ─── SKELETON LOADING ─── */
.skeleton {
  background: linear-gradient(90deg, var(--color-surface-offset) 25%, var(--color-surface-dynamic) 50%, var(--color-surface-offset) 75%);
  background-size: 200% 100%;
  animation: skeletonShimmer 1.5s ease-in-out infinite;
  border-radius: var(--radius-md);
}
@keyframes skeletonShimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* ─── FILTER BAR ─── */
.filter-bar {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
  align-items: center;
}
.filter-bar .select-field,
.filter-bar .input-field {
  width: auto;
  min-width: 160px;
  flex: 0 1 auto;
}

/* ─── STATE GROUPING ─── */
.state-group {
  margin-bottom: 1.5rem;
}
.state-group-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--color-divider);
}
.state-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.25rem 0.625rem;
  font-size: var(--text-xs);
  font-weight: 700;
  border-radius: var(--radius-sm);
  background: var(--color-primary-hl);
  color: var(--color-primary);
}
.state-group-title {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--color-tx);
}

/* ─── CUSTOM CONFIRM ─── */
#custom-confirm-overlay {
  position: fixed;
  inset: 0;
  background: oklch(0 0 0 / 0.4);
  z-index: 70;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
#custom-confirm-box {
  background: var(--color-surface);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  padding: 1.5rem;
  max-width: 400px;
  width: 100%;
  text-align: center;
}
#custom-confirm-msg {
  font-size: var(--text-sm);
  color: var(--color-tx);
  margin-bottom: 1.25rem;
  line-height: 1.5;
}
#custom-confirm-actions {
  display: flex;
  gap: 0.75rem;
  justify-content: center;
}

/* ─── MOBILE MENU BUTTON ─── */
.mobile-menu-btn {
  display: none;
  width: 44px;
  height: 44px;
  align-items: center;
  justify-content: center;
  border: none;
  background: none;
  color: var(--color-tx);
  cursor: pointer;
}
.mobile-menu-btn svg { width: 20px; height: 20px; }

/* ─── MONDAY-STYLE BOARD ─── */
.board-selector {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}
.board-wrapper {
  overflow-x: auto;
  overflow-y: visible;
  border-radius: var(--radius-lg);
  position: relative;
}
.board-header-row {
  display: grid;
  position: sticky;
  top: 0;
  z-index: 5;
  background: var(--color-surface-offset);
  border-bottom: 1px solid var(--color-divider);
  min-height: 36px;
}
.board-col-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.375rem 0.625rem;
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--color-tx-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
  position: relative;
  user-select: none;
  border-right: 1px solid var(--color-divider);
}
.board-col-header:first-child { border-left: none; }
.board-col-resize {
  position: absolute;
  right: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  cursor: col-resize;
  background: transparent;
  z-index: 2;
}
.board-col-resize:hover, .board-col-resize.active { background: var(--color-primary); }
.board-add-col-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 40px;
  font-size: var(--text-sm);
  color: var(--color-tx-faint);
  cursor: pointer;
  transition: all var(--transition-interactive);
  border-left: 1px solid var(--color-divider);
}
.board-add-col-btn:hover { color: var(--color-primary); background: var(--color-primary-hl); }

/* Board Group */
.board-group { margin-bottom: 0.5rem; }
.board-group-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius-md);
  cursor: pointer;
  user-select: none;
  min-height: 36px;
  transition: background var(--transition-interactive);
}
.board-group-header:hover { filter: brightness(0.95); }
.board-group-toggle {
  display: flex;
  align-items: center;
  transition: transform var(--transition-interactive);
  color: inherit;
}
.board-group-toggle.collapsed { transform: rotate(-90deg); }
.board-group-name {
  font-size: var(--text-sm);
  font-weight: 600;
  color: inherit;
  outline: none;
  min-width: 40px;
}
.board-group-name[contenteditable="true"] {
  background: rgba(255,255,255,0.3);
  border-radius: var(--radius-sm);
  padding: 0 0.25rem;
}
.board-group-count {
  font-size: var(--text-xs);
  font-weight: 500;
  opacity: 0.7;
  margin-left: auto;
}
.board-group-menu {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: none;
  border-radius: var(--radius-sm);
  color: inherit;
  opacity: 0;
  cursor: pointer;
  font-size: var(--text-sm);
  transition: opacity var(--transition-interactive);
}
.board-group-header:hover .board-group-menu { opacity: 0.7; }
.board-group-menu:hover { opacity: 1 !important; background: rgba(255,255,255,0.2); }
.board-group-body {
  overflow: hidden;
  transition: max-height 200ms ease;
}
.board-group-body.collapsed { max-height: 0 !important; overflow: hidden; }

/* Board Rows */
.board-row {
  display: grid;
  min-height: 40px;
  border-bottom: 1px solid var(--color-divider);
  background: var(--color-surface);
  transition: background var(--transition-interactive);
  align-items: center;
}
.board-row:hover { background: var(--color-surface-offset); }
.board-row.selected { background: var(--color-primary-hl); }
.board-row.dragging { opacity: 0.4; }
.board-row.drop-target { border-top: 2px solid var(--color-primary); }

/* Board Cells */
.board-cell {
  padding: 0.25rem 0.625rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: var(--text-sm);
  color: var(--color-tx);
  border-right: 1px solid var(--color-divider);
  display: flex;
  align-items: center;
  min-height: 40px;
  cursor: default;
}
.board-cell-name {
  font-weight: 500;
  cursor: text;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
}
.board-cell-checkbox {
  width: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-right: 1px solid var(--color-divider);
}
.board-cell-checkbox input { width: 16px; height: 16px; cursor: pointer; }
.board-cell-edit {
  width: 100%;
  border: none;
  background: none;
  font-size: var(--text-sm);
  font-family: inherit;
  color: var(--color-tx);
  padding: 0;
  outline: none;
}
.board-cell-edit:focus { outline: 2px solid var(--color-primary); outline-offset: -2px; border-radius: 2px; }

/* Status Pill */
.board-status-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.125rem 0.75rem;
  border-radius: var(--radius-sm);
  font-size: var(--text-xs);
  font-weight: 600;
  color: white;
  cursor: pointer;
  min-width: 80px;
  text-align: center;
  transition: filter var(--transition-interactive);
  white-space: nowrap;
}
.board-status-pill:hover { filter: brightness(0.9); }
.board-status-empty {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 28px;
  border-radius: var(--radius-sm);
  background: var(--color-surface-dynamic);
  cursor: pointer;
  transition: background var(--transition-interactive);
}
.board-status-empty:hover { background: var(--color-surface-offset-2); }

/* Person Avatar */
.board-person-avatar {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.5625rem;
  font-weight: 600;
  color: white;
  cursor: pointer;
  flex-shrink: 0;
}
.board-person-empty {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-full);
  border: 2px dashed var(--color-border);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.board-person-empty:hover { border-color: var(--color-primary); }

/* Priority Label */
.board-priority-label {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.125rem 0.625rem;
  border-radius: var(--radius-sm);
  font-size: var(--text-xs);
  font-weight: 600;
  color: white;
  cursor: pointer;
  min-width: 70px;
  text-align: center;
  white-space: nowrap;
}
.board-priority-label:hover { filter: brightness(0.9); }

/* Date Cell */
.board-date-display {
  font-size: var(--text-xs);
  color: var(--color-tx-muted);
  cursor: pointer;
  padding: 0.125rem 0.25rem;
  border-radius: var(--radius-sm);
  transition: background var(--transition-interactive);
}
.board-date-display:hover { background: var(--color-surface-offset); }
.board-date-input {
  border: none;
  background: none;
  font-size: var(--text-xs);
  font-family: inherit;
  color: var(--color-tx);
  width: 100%;
  outline: none;
  cursor: pointer;
}

/* Timeline Bar */
.board-timeline-bar {
  height: 6px;
  border-radius: 3px;
  min-width: 20px;
}
.board-timeline-label {
  font-size: 0.5625rem;
  color: var(--color-tx-faint);
  margin-top: 2px;
  white-space: nowrap;
}

/* Picker Dropdowns */
.board-picker {
  position: fixed;
  z-index: 30;
  background: var(--color-surface);
  border: 1px solid var(--color-divider);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  min-width: 160px;
  max-width: 260px;
  padding: 0.375rem;
  animation: pickerIn 150ms cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes pickerIn { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: translateY(0); } }
.board-picker-search {
  width: 100%;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 0.375rem 0.5rem;
  font-size: var(--text-xs);
  margin-bottom: 0.375rem;
  outline: none;
  background: var(--color-surface);
  color: var(--color-tx);
}
.board-picker-search:focus { border-color: var(--color-primary); }
.board-picker-option {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.375rem 0.5rem;
  border-radius: var(--radius-sm);
  font-size: var(--text-xs);
  font-weight: 500;
  color: var(--color-tx);
  cursor: pointer;
  transition: background var(--transition-interactive);
}
.board-picker-option:hover { background: var(--color-surface-offset); }
.board-picker-option.active { background: var(--color-primary-hl); color: var(--color-primary); }
.board-picker-dot {
  width: 12px;
  height: 12px;
  border-radius: var(--radius-full);
  flex-shrink: 0;
}

/* Add Item Row */
.board-add-item {
  display: grid;
  min-height: 36px;
  align-items: center;
  border-bottom: 1px solid var(--color-divider);
  background: var(--color-surface);
}
.board-add-item-input {
  border: none;
  background: none;
  font-size: var(--text-sm);
  font-family: inherit;
  color: var(--color-tx);
  padding: 0.25rem 0.625rem;
  outline: none;
  width: 100%;
}
.board-add-item-input::placeholder { color: var(--color-tx-faint); }

/* Add Group Button */
.board-add-group {
  margin-top: 0.75rem;
}

/* Group Context Menu */
.board-context-menu {
  position: fixed;
  z-index: 35;
  background: var(--color-surface);
  border: 1px solid var(--color-divider);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 0.375rem;
  min-width: 180px;
  animation: pickerIn 150ms cubic-bezier(0.16, 1, 0.3, 1);
}
.board-context-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
  color: var(--color-tx);
  cursor: pointer;
  transition: background var(--transition-interactive);
}
.board-context-item:hover { background: var(--color-surface-offset); }
.board-context-item.danger { color: var(--color-error); }
.board-context-item.danger:hover { background: var(--color-error-hl); }
.board-context-divider {
  height: 1px;
  background: var(--color-divider);
  margin: 0.25rem 0;
}
.board-color-dots {
  display: flex;
  gap: 0.375rem;
  padding: 0.375rem 0.5rem;
  flex-wrap: wrap;
}
.board-color-dot {
  width: 20px;
  height: 20px;
  border-radius: var(--radius-full);
  cursor: pointer;
  border: 2px solid transparent;
  transition: border-color var(--transition-interactive);
}
.board-color-dot:hover, .board-color-dot.active { border-color: var(--color-tx); }

/* Column Type Picker */
.board-col-type-picker {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.25rem;
  padding: 0.375rem;
}
.board-col-type-option {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.5rem;
  border-radius: var(--radius-sm);
  font-size: var(--text-xs);
  font-weight: 500;
  color: var(--color-tx-muted);
  cursor: pointer;
  transition: all var(--transition-interactive);
}
.board-col-type-option:hover { background: var(--color-surface-offset); color: var(--color-tx); }
.board-col-type-icon {
  width: 20px;
  height: 20px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.5625rem;
  font-weight: 700;
}

/* ─── BOARD INTERACTIVITY ENHANCEMENTS ─── */

/* Search & Filter Bar */
.board-toolbar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
  flex-wrap: wrap;
}
.board-search {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.375rem 0.75rem;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  min-width: 220px;
  transition: border-color var(--transition-interactive);
}
.board-search:focus-within { border-color: var(--color-primary); }
.board-search svg { width: 14px; height: 14px; color: var(--color-tx-faint); flex-shrink: 0; }
.board-search-input {
  border: none;
  background: none;
  font-size: var(--text-xs);
  color: var(--color-tx);
  outline: none;
  width: 100%;
  font-family: inherit;
}
.board-search-input::placeholder { color: var(--color-tx-faint); }
.board-filter-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.375rem 0.625rem;
  font-size: var(--text-xs);
  font-weight: 500;
  color: var(--color-tx-muted);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-interactive);
  white-space: nowrap;
}
.board-filter-btn:hover { border-color: var(--color-primary); color: var(--color-primary); }
.board-filter-btn.active { background: var(--color-primary-hl); border-color: var(--color-primary); color: var(--color-primary); }
.board-item-count {
  font-size: var(--text-xs);
  color: var(--color-tx-faint);
  margin-left: auto;
}

/* Bulk Actions Toolbar */
.board-bulk-bar {
  display: none;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 1rem;
  background: var(--color-primary);
  color: white;
  border-radius: var(--radius-md);
  margin-bottom: 0.75rem;
  animation: slideDown 200ms ease;
}
.board-bulk-bar.active { display: flex; }
.board-bulk-count { font-size: var(--text-sm); font-weight: 600; }
.board-bulk-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.25rem 0.5rem;
  font-size: var(--text-xs);
  font-weight: 500;
  color: white;
  background: rgba(255,255,255,0.15);
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--transition-interactive);
}
.board-bulk-btn:hover { background: rgba(255,255,255,0.3); }
.board-bulk-btn.danger:hover { background: rgba(255,80,80,0.5); }
.board-bulk-close {
  margin-left: auto;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: rgba(255,255,255,0.15);
  border-radius: var(--radius-sm);
  color: white;
  cursor: pointer;
  font-size: var(--text-xs);
}
@keyframes slideDown { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: translateY(0); } }

/* Row Hover Actions */
.board-row-actions {
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  display: none;
  align-items: center;
  gap: 2px;
  z-index: 3;
}
.board-row:hover .board-row-actions { display: flex; }
.board-row-action-btn {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: var(--color-surface-offset);
  border-radius: var(--radius-sm);
  color: var(--color-tx-muted);
  cursor: pointer;
  font-size: 0.625rem;
  transition: all var(--transition-interactive);
}
.board-row-action-btn:hover { background: var(--color-surface-dynamic); color: var(--color-tx); }
.board-row-action-btn.danger:hover { background: var(--color-error-hl); color: var(--color-error); }
.board-row { position: relative; }

/* Auto-Save Indicator */
.board-save-indicator {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.625rem;
  color: var(--color-tx-faint);
  padding: 0.125rem 0.375rem;
  border-radius: var(--radius-sm);
  transition: all var(--transition-interactive);
}
.board-save-indicator.saving { color: var(--color-orange); }
.board-save-indicator.saved { color: var(--color-success); }
.board-save-dot {
  width: 6px;
  height: 6px;
  border-radius: var(--radius-full);
  background: currentColor;
}
.board-save-indicator.saving .board-save-dot { animation: pulse 1s ease infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.3; } }

/* Item Detail Side Panel */
.board-detail-panel {
  position: fixed;
  top: 0;
  right: 0;
  width: 480px;
  max-width: 90vw;
  height: 100vh;
  background: var(--color-surface);
  border-left: 1px solid var(--color-divider);
  box-shadow: var(--shadow-lg);
  z-index: 40;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 250ms cubic-bezier(0.16, 1, 0.3, 1);
}
.board-detail-panel.open { transform: translateX(0); }
.board-detail-overlay {
  position: fixed;
  inset: 0;
  background: oklch(0 0 0 / 0.2);
  z-index: 39;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-interactive);
}
.board-detail-overlay.open { opacity: 1; pointer-events: auto; }
.board-detail-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--color-divider);
  flex-shrink: 0;
}
.board-detail-title {
  font-size: var(--text-base);
  font-weight: 600;
  color: var(--color-tx);
  outline: none;
  flex: 1;
  min-width: 0;
}
.board-detail-close {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: none;
  border-radius: var(--radius-md);
  color: var(--color-tx-muted);
  cursor: pointer;
  flex-shrink: 0;
  margin-left: 0.75rem;
}
.board-detail-close:hover { background: var(--color-surface-offset); }
.board-detail-body {
  flex: 1;
  overflow-y: auto;
  padding: 1.5rem;
}
.board-detail-field {
  margin-bottom: 1.25rem;
}
.board-detail-label {
  font-size: var(--text-xs);
  font-weight: 500;
  color: var(--color-tx-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 0.375rem;
}
.board-detail-value {
  font-size: var(--text-sm);
  color: var(--color-tx);
  min-height: 28px;
  display: flex;
  align-items: center;
}
.board-detail-section {
  border-top: 1px solid var(--color-divider);
  padding-top: 1.25rem;
  margin-top: 1.25rem;
}
.board-detail-section-title {
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--color-tx-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 0.75rem;
}
.board-detail-updates {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.board-detail-update-input {
  width: 100%;
  min-height: 60px;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-family: inherit;
  color: var(--color-tx);
  background: var(--color-surface);
  resize: vertical;
  outline: none;
}
.board-detail-update-input:focus { border-color: var(--color-primary); }
.board-detail-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--color-divider);
  display: flex;
  justify-content: space-between;
  flex-shrink: 0;
}

/* Summary Row */
.board-summary-row {
  display: grid;
  min-height: 32px;
  align-items: center;
  background: var(--color-surface-offset);
  border-bottom: 1px solid var(--color-divider);
  font-size: var(--text-xs);
  color: var(--color-tx-muted);
  font-weight: 500;
}
.board-summary-cell {
  padding: 0.25rem 0.625rem;
  border-right: 1px solid var(--color-divider);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Sort Indicator */
.board-sort-icon {
  margin-left: 0.25rem;
  opacity: 0;
  transition: opacity var(--transition-interactive);
  font-size: 0.5rem;
}
.board-col-header:hover .board-sort-icon { opacity: 0.5; }
.board-col-header.sorted .board-sort-icon { opacity: 1; }
.board-col-header.sorted { color: var(--color-primary); }

/* Row enter/exit animations */
.board-row-new {
  animation: rowEnter 300ms cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes rowEnter {
  from { opacity: 0; transform: translateY(-8px); background: var(--color-primary-hl); }
  to { opacity: 1; transform: translateY(0); }
}
.board-row-removing {
  animation: rowExit 200ms ease forwards;
}
@keyframes rowExit {
  to { opacity: 0; transform: translateX(20px); height: 0; min-height: 0; padding: 0; overflow: hidden; }
}

/* Highlighted row (just edited) */
.board-row-highlight {
  background: var(--color-primary-hl) !important;
  transition: background 1s ease;
}

/* ─── RESPONSIVE ─── */
@media (max-width: 768px) {
  #app-shell {
    grid-template-columns: 1fr;
    grid-template-rows: 56px 1fr 56px;
    grid-template-areas:
      "header"
      "main"
      "sidebar";
  }
  #sidebar {
    border-right: none;
    border-top: 1px solid var(--color-divider);
    flex-direction: row;
    overflow-x: auto;
    overflow-y: hidden;
  }
  .sidebar-brand { display: none; }
  #sidebar nav {
    flex-direction: row;
    padding: 0 0.5rem;
    gap: 0;
    width: 100%;
    justify-content: space-around;
  }
  #sidebar nav a, .nav-item {
    flex-direction: column;
    gap: 0.25rem;
    padding: 0.375rem;
    min-height: auto;
    font-size: 0.625rem;
    text-align: center;
    min-width: 0;
    flex: 1;
  }
  .nav-label { font-size: 0.5625rem; }
  .sidebar-footer { display: none; }
  #main-content { padding: 1rem; }
  .mobile-menu-btn { display: flex; }
  .form-grid { grid-template-columns: 1fr; }
  .doc-browser { grid-template-columns: 1fr; }
  .doc-tree { display: none; }
  .kanban-board { padding-bottom: 0.5rem; }
  .kanban-column { min-width: 260px; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .view-header { flex-direction: column; align-items: flex-start; }
}

@media (max-width: 480px) {
  .kpi-grid { grid-template-columns: 1fr; }
  .license-grid { grid-template-columns: 1fr; }
  .card-grid { grid-template-columns: 1fr; }
}

/* ─── PRINT ─── */
@media print {
  #sidebar, #top-header, .sidebar-footer, .mobile-menu-btn { display: none !important; }
  #app-shell { display: block !important; }
  #main-content { padding: 0; overflow: visible; }
  .view { display: block !important; }
}
