/* ===========================================
   Aurum ERP — Jewelry Design & Manufacturing
   Clean, minimal, jewelry-industry aesthetic
   =========================================== */

:root {
  --color-bg: #f6f7fb;
  --color-surface: #ffffff;
  --color-surface-2: #f9fafc;
  --color-border: #e5e8ef;
  --color-border-strong: #d3d8e2;
  --color-text: #1a1f36;
  --color-text-soft: #5a647a;
  --color-text-muted: #8c95a8;

  --color-primary: #1e2a5e;       /* deep navy */
  --color-primary-soft: #e8ecf7;
  --color-accent: #c9a86c;        /* champagne gold */
  --color-accent-soft: #f5ecd7;
  --color-success: #117a4d;
  --color-success-soft: #e3f5ec;
  --color-warning: #b46b00;
  --color-warning-soft: #fbf0d9;
  --color-danger: #b3261e;
  --color-danger-soft: #fbe4e2;
  --color-info: #1a5fb4;
  --color-info-soft: #e2ecfa;

  --shadow-sm: 0 1px 2px rgba(20, 25, 50, 0.06);
  --shadow-md: 0 4px 14px rgba(20, 25, 50, 0.08);
  --shadow-lg: 0 12px 40px rgba(20, 25, 50, 0.14);

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;

  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;

  --col-new: #6b7280;
  --col-sales: #b46b00;
  --col-prog: #1a5fb4;
  --col-done: #117a4d;
  --col-change: #b3261e;
  --col-conf: #6d28d9;
  --col-ship: #0f766e;

  --sidebar-w: 200px;
  --topbar-h: 60px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  font-family: var(--font);
  background-image: url('../images/jwellery3.jpg');
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  background-attachment: fixed;
  color: var(--color-text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; font-size: 14px; }
a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }

/* ===== Top bar ===== */
.topbar {
  height: var(--topbar-h);
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  display: grid;
  grid-template-columns: 280px 1fr auto;
  align-items: center;
  padding: 0 20px;
  gap: 24px;
  position: sticky;
  top: 0;
  z-index: 50;
}

.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  width: 36px;
  border-radius: 8px;
  background: linear-gradient(135deg, #1e2a5e, #2a3a7a);
  color: var(--color-accent);
  display: grid; place-items: center;
  font-weight: 700; font-size: 18px;
  letter-spacing: 0.5px;
  font-family: Georgia, serif;
}
.brand-name { font-weight: 600; font-size: 15px; }
.brand-sub { font-size: 11px; color: var(--color-text-muted); }

.topbar-search input {
  width: 100%;
  padding: 9px 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
  background: var(--color-surface-2);
  outline: none;
  transition: border-color 0.15s;
}
.topbar-search input:focus { border-color: var(--color-primary); background: #fff; }

.topbar-right { display: flex; align-items: center; gap: 14px; }
.role-switcher {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 10px;
  background: var(--color-primary-soft);
  border-radius: var(--radius-md);
}
.role-label { font-size: 11px; color: var(--color-primary); font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; }
.role-switcher select {
  border: none; background: transparent; font-weight: 600;
  color: var(--color-primary); outline: none; cursor: pointer; padding: 4px 4px;
}

.icon-btn {
  position: relative;
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  border-radius: 50%;
  width: 36px;
  display: grid; place-items: center;
  font-size: 16px;
}
.badge {
  position: absolute; top: -4px; right: -4px;
  background: var(--color-danger); color: white;
  font-size: 10px; font-weight: 700;
  border-radius: 10px; padding: 2px 5px;
  min-width: 18px; text-align: center;
}

.user-chip { display: flex; align-items: center; gap: 10px; cursor: pointer; }
.user-chip .avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--color-accent); color: white;
  display: grid; place-items: center; font-weight: 600; font-size: 12px;
}
.user-name { font-weight: 600; font-size: 13px; }
.user-role { font-size: 11px; color: var(--color-text-muted); }

/* ===== Layout ===== */
.layout {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: calc(100vh - var(--topbar-h));
}

.sidebar {
  background: var(--color-surface);
  border-right: 1px solid var(--color-border);
  padding: 16px 12px;
  display: flex; flex-direction: column; justify-content: space-between;
  position: sticky;
  top: var(--topbar-h);
  height: calc(100vh - var(--topbar-h));
  overflow-y: auto;
}

.nav-section { margin-bottom: 14px; }
.nav-section-title {
  font-size: 10px; font-weight: 700;
  color: var(--color-text-muted);
  text-transform: uppercase; letter-spacing: 1px;
  padding: 0 12px 6px;
}
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius-md);
  color: var(--color-text-soft);
  font-weight: 500;
  cursor: pointer;
  margin: 1px 0;
  font-size: 13.5px;
  transition: background 0.12s;
}
.nav-item:hover { background: var(--color-surface-2); color: var(--color-text); }
.nav-item.active { background: var(--color-primary-soft); color: var(--color-primary); font-weight: 600; }
.nav-icon { width: 18px; text-align: center; opacity: 0.9; }
.nav-count {
  margin-left: auto;
  background: var(--color-border);
  font-size: 10px; font-weight: 700;
  padding: 1px 7px; border-radius: 10px;
  color: var(--color-text-soft);
}
.nav-item.active .nav-count { background: var(--color-primary); color: white; }

.sidebar-footer { padding: 12px 8px; border-top: 1px solid var(--color-border); }
.legend { display: flex; flex-direction: column; gap: 6px; }
.legend-row { display: flex; align-items: center; gap: 8px; font-size: 11.5px; color: var(--color-text-soft); }
/* Status-color legend is internal workflow info (board column colors) —
   not relevant to clients, so hide it only in Client Portal view. Scoped
   via body.client-mode, which AppState.setRole() already sets for the
   client role — the sidebar markup itself is unchanged. */
body.client-mode .sidebar-footer { display: none; }
.dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.dot-new { background: var(--col-new); }
.dot-sales { background: var(--col-sales); }
.dot-prog { background: var(--col-prog); }
.dot-done { background: var(--col-done); }
.dot-change { background: var(--col-change); }
.dot-conf { background: var(--col-conf); }
.dot-ship { background: var(--col-ship); }

/* ===== Content ===== */
.content { padding: 12px 28px; min-width: 0; }

.page-header {
  display: flex; justify-content: space-between; align-items: flex-start;
  margin-bottom: 22px; gap: 16px; flex-wrap: wrap;
}
.page-title { font-size: 22px; font-weight: 700; margin: 0; letter-spacing: -0.2px; }
.page-sub { color: var(--color-text-soft); font-size: 13px; margin-top: 4px; }
.page-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* Buttons */
.btn {
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  color: var(--color-text);
  padding: 8px 14px;
  border-radius: var(--radius-md);
  font-weight: 500;
  font-size: 13px;
  display: inline-flex; align-items: center; gap: 6px;
  transition: all 0.12s;
}
.btn:hover { border-color: var(--color-border-strong); background: var(--color-surface-2); }
.btn-primary { background: var(--color-primary); color: white; border-color: var(--color-primary); }
.btn-primary:hover { background: #2a3a7a; border-color: #2a3a7a; }
.btn-accent { background: var(--color-accent); color: white; border-color: var(--color-accent); }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-danger { background: var(--color-danger); color: white; border-color: var(--color-danger); }
.btn-sm { padding: 5px 10px; font-size: 12px; }

/* Cards / surfaces */
.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 18px;
  box-shadow: var(--shadow-sm);
}
.card-title { font-size: 13px; font-weight: 600; color: var(--color-text-soft); margin-bottom: 8px; }

/* Stats grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 8px;
  margin-bottom: 20px;
}
.stat {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 14px 18px;
  min-height: 140px;
}
.stat-label { font-size: 12px; color: var(--color-text-soft); margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.5px; font-weight: 600; }
.stat-value { font-size: 22px; font-weight: 700; letter-spacing: -0.3px; }
.stat-delta { font-size: 12px; margin-top: 4px; }
.stat-delta.up { color: var(--color-success); }
.stat-delta.down { color: var(--color-danger); }
.stat-icon { float: right; font-size: 20px; opacity: 0.6; }

/* Two-column dashboard rows */
.row-2 { display: grid; grid-template-columns: 2fr 1fr; gap: 18px; margin-bottom: 18px; }
.row-1-1 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; margin-bottom: 20px; margin-top: 20px; }
.row-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; margin-bottom: 18px; }
/* Responsive overrides for these rows live in the dedicated breakpoint sections below */

/* ===== Kanban ===== */
.kanban {
  display: flex;
  gap: 14px;
  overflow-x: auto;
  padding-bottom: 16px;
  align-items: flex-start;
}
.kanban-col {
  background: #fff;
  border: 1px solid #e5e8ef;
  border-radius: 20px;
  min-width: 260px;
  width: 260px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  box-shadow: 0 8px 25px rgba(0,0,0,.08);
  height: calc(100vh - 260px);
  max-height: calc(100vh - 260px);
}

/* Floating zoom button (mobile board view only) — hidden by default;
   made visible inside the mobile @media block below. Desktop/tablet
   already show columns at a comfortable full size, so there's nothing
   for this button to do there. */
.kanban-zoom-btn {
  display: none;
  position: fixed;
  right: 16px;
  bottom: 20px;
  z-index: 30;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: none;
  background: var(--color-primary);
  color: #fff;
  font-size: 16px;
  box-shadow: 0 8px 20px rgba(0,0,0,0.25);
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.kanban-col-header{
    padding:20px;
    background:#fff;
    border-bottom:1px solid #edf0f5;
    border-radius:20px 20px 0 0;
    flex-shrink: 0;
}
.kanban-col-name { font-weight: 600; font-size: 13px; }
.kanban-col-count {
  font-size: 11px; font-weight: 700;
  background: var(--color-border);
  padding: 1px 7px; border-radius: 10px;
  color: var(--color-text-soft);
}
.kanban-col-bar { width: 4px; height: 14px; border-radius: 2px; }
.kanban-col-body{
    padding:18px;
    display:flex;
    flex-direction:column;
    gap:20px;
    flex: 1 1 auto;
    min-height: 0; /* critical: without this, flex items ignore overflow/max-height and grow to fit content instead of scrolling */
    overflow-y: auto;
}
.kanban-col-add {
  text-align: left; padding: 6px 8px;
  border: 1px dashed var(--color-border-strong);
  background: transparent;
  border-radius: var(--radius-sm);
  font-size: 12px; color: var(--color-text-muted);
  margin: 4px 6px 8px;
  flex-shrink: 0;
}
.kcard{
    width:100%;
    max-width:220px;
    min-height:170px;
    border-radius:18px;
    overflow:hidden;
    background:#fff;
    border:1px solid #e8edf5;
    box-shadow:0 6px 18px rgba(0,0,0,.08);
}
.kcard:hover { transform: translateY(-1px); box-shadow: var(--shadow-md); }
.kcard-cover {
  height: 50px;
  background: linear-gradient(135deg, #f5ecd7, #e7d3a5);
  position: relative;
  display: grid; place-items: center;
  font-size: 52px;
}
.kcard-cover.metal-yellow { background: linear-gradient(135deg, #f5e8a8, #d4af37); }
.kcard-cover.metal-rose { background: linear-gradient(135deg, #f3d6c7, #d18b6e); }
.kcard-cover.metal-white { background: linear-gradient(135deg, #eaecef, #b8bdc7); }
.kcard-cover.metal-platinum { background: linear-gradient(135deg, #dde2e8, #93a0b0); }
.kcard-cover.metal-silver { background: linear-gradient(135deg, #ecedef, #c4cad3); }
.kcard-cover-key {
  position: absolute; top: 8px; left: 8px;
  background: rgba(255,255,255,0.85);
  font-size: 10px; font-weight: 700;
  padding: 2px 6px; border-radius: 4px;
  color: var(--color-text);
  letter-spacing: 0.5px;
}
.kcard-cover-prio {
  position: absolute; top: 8px; right: 8px;
  font-size: 10px; font-weight: 700;
  padding: 2px 6px; border-radius: 4px;
  color: white;
}
.prio-low { background: #6b7280; }
.prio-medium { background: #1a5fb4; }
.prio-high { background: #b46b00; }
.prio-urgent { background: #b3261e; }

.kcard-body { padding:12px; }
.kcard-title { font-weight: 600; font-size: 13px; margin-bottom: 4px; line-height: 1.3; }
.kcard-client { font-size: 11.5px; color: var(--color-text-muted); margin-bottom: 8px; }
.kcard-labels { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 8px; }
.label-pill {
  font-size: 10px; font-weight: 600;
  padding: 2px 6px; border-radius: 10px;
  background: var(--color-primary-soft); color: var(--color-primary);
}
.label-pill.bridal { background: #fbe4e2; color: #b3261e; }
.label-pill.ring { background: #e3f5ec; color: #117a4d; }
.label-pill.necklace { background: #fbf0d9; color: #b46b00; }
.label-pill.earring { background: #f4e1f6; color: #6d28d9; }
.label-pill.pendant { background: #e2ecfa; color: #1a5fb4; }
.label-pill.bracelet { background: #f5ecd7; color: #a87a1e; }
.label-pill.custom { background: var(--color-accent-soft); color: var(--color-accent); }

.kcard-meta {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 11px; color: var(--color-text-soft);
}
.kcard-meta-left { display: flex; gap: 10px; align-items: center; }
.kcard-meta-icon { display: inline-flex; align-items: center; gap: 3px; }
.kcard-assignees { display: flex; }
.kcard-avatar {
  width: 22px; border-radius: 50%;
  background: var(--color-primary); color: white;
  display: grid; place-items: center;
  font-size: 10px; font-weight: 600;
  border: 2px solid white;
  margin-left: -6px;
}
.kcard-avatar:first-child { margin-left: 0; }

.kcard-opp {
  background: var(--color-accent-soft); color: #8a6e2e;
  font-size: 10px; font-weight: 700;
  padding: 1px 6px; border-radius: 10px;
  margin-left: 6px;
}

/* Table */
.table {
  width: 100%;
  border-collapse: collapse;
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 1px solid var(--color-border);
  font-size: 13px;
}
.table thead th {
  background: var(--color-surface-2);
  padding: 11px 14px;
  text-align: left;
  font-weight: 600;
  color: var(--color-text-soft);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid var(--color-border);
}
.table tbody td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--color-border);
  vertical-align: middle;
}
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: var(--color-surface-2); }

.table-actions { display: flex; gap: 6px; }
.table-thumb { width: 36px; height: 36px; border-radius: 6px; object-fit: cover; }

.status-pill {
  display: inline-block;
  font-size: 11px; font-weight: 600;
  padding: 3px 9px; border-radius: 10px;
}
.status-paid { background: var(--color-success-soft); color: var(--color-success); }
.status-partial { background: var(--color-warning-soft); color: var(--color-warning); }
.status-unpaid { background: var(--color-info-soft); color: var(--color-info); }
.status-overdue { background: var(--color-danger-soft); color: var(--color-danger); }
.status-hold { background: var(--color-danger-soft); color: var(--color-danger); }
.status-active { background: var(--color-success-soft); color: var(--color-success); }
.status-draft { background: var(--color-border); color: var(--color-text-soft); }

/* Product badges (over the cover) */
.product-badges {
  position: absolute;
  top: 10px; left: 10px;
  display: flex; flex-wrap: wrap; gap: 4px;
  z-index: 1;
}
.product-badge {
  font-size: 9.5px;
  font-weight: 700;
  padding: 3px 7px;
  border-radius: 10px;
  background: rgba(255,255,255,0.92);
  color: var(--color-text);
  letter-spacing: 0.5px;
  text-transform: uppercase;
  backdrop-filter: blur(4px);
}
.product-badge.featured { background: var(--color-accent); color: white; }
.product-badge.shared   { background: var(--color-info-soft); color: var(--color-info); }
.product-badge.hidden   { background: var(--color-text-muted); color: white; }
.product-badge.draft    { background: var(--color-warning-soft); color: var(--color-warning); }
.product-badge.archived { background: var(--color-text-muted); color: white; }

.product-card { position: relative; }

/* Catalog grid */
.catalog-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
}
.product-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: transform 0.1s, box-shadow 0.1s;
}
.product-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.product-cover {
  height: 180px;
  background: linear-gradient(135deg, #f5ecd7, #d4af37);
  display: grid; place-items: center;
  font-size: 48px;
}
.product-info { padding: 12px 14px; }
.product-name { font-weight: 600; font-size: 13.5px; }
.product-sku { font-size: 11px; color: var(--color-text-muted); margin-bottom: 6px; }
.product-price { display: flex; justify-content: space-between; align-items: baseline; margin-top: 6px; }
.price-current { font-weight: 700; font-size: 16px; color: var(--color-primary); }
.price-tier { font-size: 10px; color: var(--color-text-muted); }

/* Filter / toolbar */
.toolbar {
  display: flex; gap: 10px; flex-wrap: wrap; align-items: center;
  margin-bottom: 16px;
}
.toolbar select, .toolbar input {
  padding: 7px 10px;
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  font-size: 13px;
}
.chip {
  font-size: 11.5px; font-weight: 600;
  padding: 4px 10px; border-radius: 20px;
  background: var(--color-primary-soft); color: var(--color-primary);
  cursor: pointer;
  border: 1px solid transparent;
}
.chip.active { background: var(--color-primary); color: white; }
.chip-group { display: flex; gap: 6px; flex-wrap: wrap; }

/* Modal */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(20, 25, 50, 0.55);
  display: grid; place-items: center;
  z-index: 100;
  padding: 30px;
  overflow-y: auto;
}
.modal-backdrop[hidden] { display: none !important; }
.toast[hidden] { display: none !important; }
.modal {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  max-width: 880px; width: 100%;
  max-height: calc(100vh - 60px);
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
}
.modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--color-border);
  display: flex; justify-content: space-between; align-items: flex-start;
  gap: 16px;
  position: sticky; top: 0; background: var(--color-surface); z-index: 2;
}
.modal-title { font-weight: 700; font-size: 17px; margin: 0; }
.modal-subtitle { color: var(--color-text-soft); font-size: 12px; margin-top: 2px; }
.modal-close {
  background: transparent; border: none;
  font-size: 22px; color: var(--color-text-soft);
  cursor: pointer; line-height: 1; padding: 4px 8px;
}
.modal-body { padding: 20px; }
.modal-body-split { display: grid; grid-template-columns: 1.5fr 1fr; gap: 24px; }
@media (max-width: 800px) { .modal-body-split { grid-template-columns: 1fr; } }

/* Card detail blocks */
.detail-section { margin-bottom: 22px; }
.detail-section h4 {
  font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.5px;
  color: var(--color-text-muted); margin: 0 0 8px;
}
.detail-cover {
  width: 100%;
  height: 220px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, #f5ecd7, #d4af37);
  display: grid; place-items: center;
  font-size: 72px;
  margin-bottom: 14px;
}
.detail-cover.metal-yellow { background: linear-gradient(135deg, #f5e8a8, #d4af37); }
.detail-cover.metal-rose { background: linear-gradient(135deg, #f3d6c7, #d18b6e); }
.detail-cover.metal-white { background: linear-gradient(135deg, #eaecef, #b8bdc7); }
.detail-cover.metal-platinum { background: linear-gradient(135deg, #dde2e8, #93a0b0); }
.detail-cover.metal-silver { background: linear-gradient(135deg, #ecedef, #c4cad3); }

.detail-row { display: grid; grid-template-columns: 120px 1fr; gap: 12px; padding: 6px 0; font-size: 13px; }
.detail-row .label { color: var(--color-text-muted); font-size: 12px; }
.detail-row .value { font-weight: 500; }

.timeline { display: flex; flex-direction: column; gap: 12px; }
.timeline-item { display: flex; gap: 10px; font-size: 12.5px; }
.timeline-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--color-primary); margin-top: 4px; flex-shrink: 0; }
.timeline-text { color: var(--color-text-soft); }
.timeline-meta { color: var(--color-text-muted); font-size: 11px; margin-top: 2px; }

.comment-list { display: flex; flex-direction: column; gap: 10px; }
.comment-list::-webkit-scrollbar { width: 6px; }
.comment-list::-webkit-scrollbar-track { background: transparent; }
.comment-list::-webkit-scrollbar-thumb { background: var(--color-border, #d8dce5); border-radius: 999px; }
.comment-list::-webkit-scrollbar-thumb:hover { background: var(--color-text-muted, #9aa1b0); }
.comment {
  background: var(--color-surface-2);
  padding: 10px 12px; border-radius: var(--radius-md);
  font-size: 12.5px;
}
.comment-author { font-weight: 600; }
.comment-time { color: var(--color-text-muted); font-size: 11px; margin-left: 6px; }

.timelog-row {
  display: grid; grid-template-columns: 1fr auto auto auto;
  gap: 10px; padding: 8px 0;
  border-bottom: 1px solid var(--color-border);
  font-size: 13px;
}
.timelog-row:last-child { border-bottom: none; }
.timelog-cost { color: var(--color-accent); font-weight: 600; font-size: 12px; }

/* Owner-only banner */
.owner-only {
  background: var(--color-accent-soft);
  border: 1px solid #e0c890;
  border-left: 3px solid var(--color-accent);
  padding: 12px 14px;
  border-radius: var(--radius-md);
  margin-bottom: 14px;
  margin-top: 20px;
}
.owner-only-label {
  font-size: 10px; font-weight: 700;
  color: #8a6e2e;
  text-transform: uppercase; letter-spacing: 1px;
  margin-bottom: 4px;
}

/* Bars / progress */
.progress {
  height: 8px; background: var(--color-border);
  border-radius: 4px; overflow: hidden;
}
.progress-bar { height: 100%; background: var(--color-primary); border-radius: 4px; }
.progress-bar.warn { background: var(--color-warning); }
.progress-bar.danger { background: var(--color-danger); }
.progress-bar.success { background: var(--color-success); }

/* Bar chart */
.bar-chart { display: flex; flex-direction: column; gap: 10px; }
.bar-row { display: grid; grid-template-columns: 110px 1fr 80px; gap: 12px; align-items: center; font-size: 12.5px; }
.bar-row .bar-name { color: var(--color-text-soft); }
.bar-row .bar-track { background: var(--color-border); border-radius: 4px; height: 10px; }
.bar-row .bar-fill { background: var(--color-primary); height: 100%; border-radius: 4px; }
.bar-row .bar-value { font-weight: 600; text-align: right; }

/* Funnel */
.funnel { display: flex; flex-direction: column; gap: 4px; }
.funnel-row {
  display: grid; grid-template-columns: 1fr auto;
  align-items: center; padding: 10px 14px;
  background: var(--color-primary);
  color: white; border-radius: 6px;
  font-size: 13px;
}

/* Voice order */
.voice-card {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--color-border);
  padding: 32px;
  text-align: center;
}
.mic-button {
  width: 100px; height: 100px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--color-primary), #2a3a7a);
  color: white; border: none;
  font-size: 40px;
  margin: 18px auto;
  cursor: pointer;
  display: grid; place-items: center;
  box-shadow: 0 0 0 0 rgba(30, 42, 94, 0.4);
  animation: pulse 2s infinite;
}
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(201,168,108,0.5); }
  70% { box-shadow: 0 0 0 18px rgba(201,168,108,0); }
  100% { box-shadow: 0 0 0 0 rgba(201,168,108,0); }
}
.mic-button.recording { background: linear-gradient(135deg, var(--color-danger), #d63b32); animation: pulse-red 1s infinite; }
@keyframes pulse-red {
  0% { box-shadow: 0 0 0 0 rgba(179,38,30,0.7); }
  70% { box-shadow: 0 0 0 22px rgba(179,38,30,0); }
  100% { box-shadow: 0 0 0 0 rgba(179,38,30,0); }
}

.transcript-box {
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 14px;
  margin: 14px 0;
  text-align: left;
  font-size: 13px;
  min-height: 60px;
}
.confidence-warn { color: var(--color-warning); font-weight: 600; }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; text-align: left; }
.form-grid .full { grid-column: span 2; }
.form-field label {
  display: block; font-size: 11px; color: var(--color-text-soft);
  font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px;
  margin-bottom: 4px;
}
.form-field input, .form-field select, .form-field textarea {
  width: 100%; padding: 8px 10px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  outline: none;
}
.form-field.low-conf input { border-color: var(--color-warning); background: var(--color-warning-soft); }

/* Toast */
.toast {
  position: fixed; bottom: 24px; right: 24px;
  background: var(--color-primary);
  color: white;
  padding: 12px 18px;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  z-index: 200;
  font-size: 13px;
  font-weight: 500;
  animation: slidein 0.2s;
}
@keyframes slidein { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

/* Client portal mode */
body.client-mode { background: linear-gradient(180deg, #f7f3e8, #f6f7fb); }
.client-hero {
  background: linear-gradient(135deg, #1e2a5e, #2a3a7a);
  color: white;
  border-radius: var(--radius-lg);
  padding: 26px 28px;
  margin-bottom: 20px;
  position: relative;
  overflow: hidden;
}
.client-hero::before {
  content: '';
  position: absolute; top: -40px; right: -40px;
  width: 200px; height: 200px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(201,168,108,0.4), transparent 70%);
}
.client-hero h2 { margin: 0 0 4px; font-size: 22px; font-weight: 600; letter-spacing: -0.3px; }
.client-hero p { margin: 0; opacity: 0.85; font-size: 14px; }
.client-hero-stats { display: flex; gap: 26px; margin-top: 16px; flex-wrap: wrap; }
.client-hero-stat .label { font-size: 11px; opacity: 0.8; text-transform: uppercase; letter-spacing: 0.5px; }
.client-hero-stat .value { font-size: 20px; font-weight: 700; margin-top: 2px; }

/* Hide owner-only when not owner */
body:not(.role-owner) .owner-only { display: none; }
body:not(.role-owner) .owner-only-inline { display: none; }

/* Sales sees opportunity */
body:not(.role-owner):not(.role-sales) .sales-only { display: none; }

/* Empty state */
.empty {
  padding: 40px 20px; text-align: center;
  color: var(--color-text-muted);
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  border: 1px dashed var(--color-border);
}
.empty-icon { font-size: 36px; margin-bottom: 8px; }

/* Notification list */
.notif-list { display: flex; flex-direction: column; gap: 8px; }
.notif {
  display: flex; gap: 10px;
  padding: 10px 12px;
  background: var(--color-surface-2);
  border-radius: var(--radius-md);
  font-size: 13px;
  border-left: 3px solid var(--color-primary);
}
.notif.unread { background: var(--color-primary-soft); }
.notif-time { color: var(--color-text-muted); font-size: 11px; margin-top: 2px; }

/* ===== Boards (Projects landing) ===== */
.boards-section { margin-bottom: 24px; }
.boards-section-title {
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 12px;
  color: var(--color-text-soft);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.boards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 14px;
}
.board-card {
  position: relative;
  border-radius: var(--radius-md);
  min-height: 130px;
  color: white;
  cursor: pointer;
  overflow: hidden;
  transition: transform 0.12s, box-shadow 0.12s;
  display: flex;
  flex-direction: column;
}
.board-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }
.board-card-inner { padding: 16px; flex: 1; }
.board-card-name { font-weight: 700; font-size: 15px; margin-top: 8px; }
.board-card-meta { font-size: 11px; opacity: 0.85; margin-top: 4px; }
.board-card-footer {
  padding: 8px 14px;
  background: rgba(0,0,0,0.18);
  display: flex; justify-content: space-between; align-items: center;
  font-size: 11px;
}
.board-star {
  position: absolute; top: 8px; right: 8px;
  background: rgba(0,0,0,0.2);
  border: none; color: rgba(255,255,255,0.6);
  width: 26px; height: 26px;
  border-radius: 50%;
  font-size: 14px; cursor: pointer;
  display: grid; place-items: center;
  z-index: 2;
}
.board-star:hover, .board-star.starred { color: #fcd34d; }
.board-card-new {
  background: var(--color-surface);
  border: 2px dashed var(--color-border-strong);
  color: var(--color-text-soft);
  display: grid;
  place-items: center;
}
.board-card-new:hover { border-color: var(--color-primary); color: var(--color-primary); }
.board-card-new-inner { text-align: center; padding: 20px; }

/* ===== Board Header (when inside a board) ===== */
.board-header {
  padding: 10px 20px;
  color: white;
  border-radius: var(--radius-md);
  margin-bottom: 0;
  display: flex; justify-content: space-between; align-items: center;
  flex-wrap: wrap; gap: 12px;
}
.board-header-left { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.board-header-title { margin: 0; font-size: 17px; font-weight: 700; letter-spacing: -0.2px; }
.board-header-right { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.board-visibility {
  background: rgba(255,255,255,0.18);
  font-size: 10px; padding: 3px 8px; border-radius: 10px;
  text-transform: uppercase; letter-spacing: 0.5px; font-weight: 600;
}
.board-members { display: flex; }
.board-members .kcard-avatar { border-color: rgba(255,255,255,0.4); }
.btn-ghost { background: transparent; border: none; padding: 6px 10px; cursor: pointer; font-size: 13px; border-radius: 6px; }
.btn-ghost:hover { background: rgba(255,255,255,0.15); }

.board-subnav {
  background: rgba(0,0,0,0.04);
  padding: 6px 14px;
  border-radius: 0 0 var(--radius-md) var(--radius-md);
  display: flex; justify-content: space-between; align-items: center;
  flex-wrap: wrap; gap: 12px;
  margin-bottom: 8px;
  border: 1px solid var(--color-border);
  border-top: none;
}
.board-tabs { display: flex; gap: 4px; }
.board-tab {
  background: transparent; border: none;
  padding: 5px 10px; border-radius: 6px;
  font-size: 12.5px; font-weight: 500; color: var(--color-text-soft);
  cursor: pointer;
}
.board-tab:hover { background: var(--color-surface-2); color: var(--color-text); }
.board-tab.active { background: var(--color-primary); color: white; }
.board-toolbar { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.board-toolbar input, .board-toolbar select {
  padding: 5px 9px; font-size: 12px;
  border-radius: 6px; border: 1px solid var(--color-border);
  background: var(--color-surface);
}

/* Column menu button */
.kanban-col-menu {
  margin-left: auto;
  background: transparent; border: none;
  color: var(--color-text-muted);
  cursor: pointer; padding: 2px 6px;
  border-radius: 4px;
  font-size: 16px;
}
.kanban-col-menu:hover { background: var(--color-border); color: var(--color-text); }

/* WIP limit breach */
.kanban-col-count.wip-breached {
  background: var(--color-danger);
  color: white;
}

/* "Add list" placeholder column */
.kanban-col-new {
  background: rgba(255,255,255,0.6);
  border: 2px dashed var(--color-border-strong);
  border-radius: var(--radius-md);
  min-width: 200px;
  width: 200px;
  height: 90px;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: background 0.12s;
}
.kanban-col-new:hover {
  background: var(--color-primary-soft);
  border-color: var(--color-primary);
}

/* Inline column quick-add composer */
.kanban-col-composer {
  padding: 8px;
  margin: 4px 6px 8px;
  background: var(--color-surface-2);
  border-radius: 8px;
  border: 1px solid var(--color-border);
}
.kanban-col-composer textarea {
  width: 100%;
  border: 1px solid transparent;
  background: white;
  resize: none;
  padding: 8px 10px;
  border-radius: 6px;
  font-family: inherit;
  font-size: 13px;
  line-height: 1.4;
  min-height: 56px;
  outline: none;
  box-shadow: 0 1px 1px rgba(0,0,0,0.08);
  transition: box-shadow 0.12s, border-color 0.12s;
}
.kanban-col-composer textarea:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 2px rgba(30,42,94,0.15);
}
.composer-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 6px;
}
.composer-close, .composer-advanced {
  padding: 4px 8px;
  font-size: 14px;
  color: var(--color-text-muted);
  border-radius: 4px;
}
.composer-close:hover { color: var(--color-danger); background: var(--color-danger-soft); }
.composer-advanced:hover { color: var(--color-primary); background: var(--color-primary-soft); }

/* Drag states */
.kcard.dragging { opacity: 0.4; }
.kanban-col.dragover { background: var(--color-primary-soft); }
.kanban-col[draggable="true"] { cursor: grab; }
.kanban-col[draggable="true"]:active { cursor: grabbing; }

/* ===== Roles & Departments ===== */
.roles-grid, .dept-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
}
.role-card, .dept-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 18px;
  transition: box-shadow 0.12s, transform 0.12s;
}
.role-card:hover, .dept-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}
.role-card-new, .dept-card-new {
  border: 2px dashed var(--color-border-strong);
  background: var(--color-surface-2);
  color: var(--color-text-soft);
  cursor: pointer;
  display: grid;
  place-items: center;
}
.role-card-new:hover, .dept-card-new:hover {
  border-color: var(--color-primary);
  color: var(--color-primary);
  background: var(--color-primary-soft);
}

/* Permission matrix */
.matrix-table th, .matrix-table td {
  vertical-align: middle;
  padding: 8px 12px;
}
.matrix-table tbody tr:hover { background: var(--color-surface-2); }
.matrix-table .matrix-section td { padding: 10px 14px; }
.perm-cell {
  display: inline-grid;
  place-items: center;
  width: 26px; height: 26px;
  border-radius: 6px;
  font-weight: 700;
  color: white;
  font-size: 13px;
  transition: all 0.12s;
}
.perm-cell.off {
  background: transparent;
  border: 1px dashed var(--color-border-strong);
}
.perm-cell.on:hover { opacity: 0.85; }
.matrix-table td[onclick] .perm-cell.off:hover {
  background: var(--color-primary-soft);
  border-color: var(--color-primary);
}

/* ===== Personal To-Do list ===== */
.todo-composer {
  background: var(--color-surface-2);
  padding: 10px;
  border-radius: 8px;
  border: 1px solid var(--color-border);
}
.todo-composer textarea {
  width: 100%;
  border: 1px solid transparent;
  background: white;
  resize: none;
  padding: 8px 10px;
  border-radius: 6px;
  font-family: inherit;
  font-size: 13px;
  min-height: 50px;
  outline: none;
  box-shadow: 0 1px 1px rgba(0,0,0,0.08);
}
.todo-composer textarea:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 2px rgba(30,42,94,0.15);
}
.todo-composer-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
}
.todo-composer-actions select,
.todo-composer-actions input {
  padding: 6px 8px;
  border-radius: 6px;
  border: 1px solid var(--color-border);
  font-size: 12px;
}

.todo-item {
  display: flex;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  margin-bottom: 6px;
  background: var(--color-surface);
  align-items: center;
  transition: background 0.12s;
}
.todo-item:hover { background: var(--color-surface-2); }
.todo-item.done { opacity: 0.6; }
.todo-item.done .todo-text > div:first-child { text-decoration: line-through; }
.todo-item input[type="checkbox"] {
  width: 18px;
  height: 18px;
  cursor: pointer;
}
.todo-text { flex: 1; font-size: 13.5px; }
.todo-meta { display: flex; gap: 8px; margin-top: 4px; font-size: 11px; }
.todo-priority {
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 6px;
  color: white;
}
.todo-due { color: var(--color-text-muted); }
.todo-due.overdue { color: var(--color-danger); font-weight: 600; }
.todo-actions {
  display: flex;
  gap: 2px;
  opacity: 0;
  transition: opacity 0.12s;
}
.todo-item:hover .todo-actions { opacity: 1; }
.todo-actions button {
  padding: 4px 8px;
  font-size: 13px;
  border-radius: 4px;
  color: var(--color-text-muted);
}
.todo-actions button:hover { background: var(--color-border); color: var(--color-text); }

/* ===== @mention autocomplete ===== */
.mention-menu {
  position: absolute;
  left: 0; right: 0;
  bottom: 100%;
  margin-bottom: 4px;
  background: #fff;
  border: 1px solid var(--color-border);
  border-radius: 10px;
  box-shadow: var(--shadow-lg);
  z-index: 20;
  max-height: 240px;
  overflow-y: auto;
  padding: 4px;
}
.mention-item {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 9px;
  border-radius: 7px;
  cursor: pointer;
  font-size: 13px;
}
.mention-item:hover, .mention-item.active { background: var(--color-primary-soft); }
.mention-chip {
  background: var(--color-primary-soft);
  color: var(--color-primary);
  font-weight: 600;
  padding: 0 4px;
  border-radius: 4px;
}

/* ===== Login overlay ===== */
#loginOverlay {
  position: fixed; inset: 0;
  z-index: 1000;
  display: grid; place-items: center;
  background: linear-gradient(135deg, #1e2a5e, #2a3a7a 60%, #6d28d9);
  padding: 20px;
  /* Safety net for short/small screens (or when a mobile keyboard is open
     and eats a big chunk of viewport height): without this, content that
     doesn't fit was just clipped at the viewport edge with no way to
     reach it, since a position:fixed box isn't scrollable by default. */
  overflow-y: auto;
}
.login-card {
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 24px 70px rgba(0,0,0,0.35);
  width: 100%; max-width: 400px;
  padding: 32px 30px;
}
.login-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 24px; }
.login-mark {
  width: 44px; height: 44px; border-radius: 10px;
  background: linear-gradient(135deg, #1e2a5e, #2a3a7a);
  color: var(--color-accent);
  display: grid; place-items: center;
  font-weight: 700; font-size: 22px; font-family: Georgia, serif;
}
.login-name { font-weight: 700; font-size: 16px; }
.login-sub { font-size: 11.5px; color: var(--color-text-muted); }
.login-title { font-size: 20px; font-weight: 700; margin: 0 0 18px; }
.login-label { display: block; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; color: var(--color-text-soft); margin: 12px 0 5px; }
#loginOverlay input {
  width: 100%; padding: 11px 13px;
  border: 1px solid var(--color-border); border-radius: 9px;
  font-size: 14px; outline: none; transition: border-color 0.12s, box-shadow 0.12s;
}
#loginOverlay input:focus { border-color: var(--color-primary); box-shadow: 0 0 0 3px rgba(30,42,94,0.12); }
.login-btn {
  width: 100%; margin-top: 18px; padding: 12px;
  background: var(--color-primary); color: #fff;
  border: none; border-radius: 9px; font-weight: 600; font-size: 14px; cursor: pointer;
}
.login-btn:hover { background: #2a3a7a; }
.login-btn:disabled { opacity: 0.6; cursor: default; }
.login-error { color: var(--color-danger); font-size: 12.5px; min-height: 16px; margin-top: 10px; }
.login-demo {
  width: 100%; margin-top: 10px; padding: 10px;
  background: transparent; color: var(--color-primary);
  border: 1px solid var(--color-border); border-radius: 9px; font-weight: 600; font-size: 13px; cursor: pointer;
}
.login-demo:hover { background: var(--color-surface-2); }
.login-hint {
  margin-top: 20px; padding: 12px 14px;
  background: var(--color-surface-2); border-radius: 9px;
  font-size: 11.5px; color: var(--color-text-soft); line-height: 1.7;
}
.login-hint code { background: #fff; padding: 1px 5px; border-radius: 4px; border: 1px solid var(--color-border); }

/* Tighter spacing on mobile so the whole card — including the Sign in
   button and the test-logins hint — fits on one screen without scrolling
   on most phones, instead of relying on the overflow-y:auto fallback
   above. Values are trimmed, not removed, so it still reads comfortably. */
@media (max-width: 480px) {
  #loginOverlay { padding: 12px; }
  .login-card { padding: 18px 16px; margin-top: 6px; max-width: 340px; }
  .login-mark { width: 34px; height: 34px; font-size: 17px; border-radius: 8px; }
  .login-name { font-size: 14px; }
  .login-sub { font-size: 10.5px; }
  .login-brand { gap: 9px; margin-bottom: 10px; }
  .login-title { font-size: 16px; margin: 0 0 8px; }
  .login-label { font-size: 10px; margin: 6px 0 3px; }
  #loginOverlay input { padding: 7px 10px; font-size: 13px; }
  .login-btn { margin-top: 10px; padding: 9px; font-size: 13px; }
  .login-demo { margin-top: 6px; padding: 7px; font-size: 12px; }
  .login-hint { margin-top: 10px; padding: 7px 9px; font-size: 10px; line-height: 1.4; }
}

/* Scrollbar */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: #c8cdd9; border-radius: 4px; }
::-webkit-scrollbar-track { background: transparent; }

/* =====================================================
   RESPONSIVE — Mobile-first overrides
   Breakpoints:
     - Mobile:  < 640px
     - Tablet:  640px – 1024px
     - Desktop: > 1024px
   ===================================================== */

/* Hamburger button — visible only on mobile */
.menu-toggle {
  display: none;
  width: 40px; height: 40px;
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  border-radius: 8px;
  font-size: 18px;
  cursor: pointer;
  margin-right: 8px;
}
.menu-toggle:hover { background: var(--color-surface-2); }

/* Sidebar backdrop — only visible when sidebar is open on mobile */
.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 49;
}
.sidebar-backdrop.active { display: block; }

/* ===== Tablet & smaller (≤ 1024px) ===== */
@media (max-width: 1024px) {
  :root { --sidebar-w: 220px; }

  .topbar { padding: 0 14px; gap: 12px; }
  .brand-sub { display: none; }
  .topbar-search input { padding: 8px 12px; }
  .topbar-right { gap: 8px; }

  .content { padding: 18px 16px; }

  /* Row layouts stack on tablet */
  .row-2 { grid-template-columns: 1fr; }
  .row-1-1 { grid-template-columns: 1fr; }
  .row-3 { grid-template-columns: 1fr 1fr; }

  /* Modal narrower padding */
  .modal-backdrop { padding: 16px; }
  .modal-body-split { grid-template-columns: 1fr; gap: 16px; }
  .modal-header { padding: 14px 18px; }
  .modal-body { padding: 16px 18px; }

  /* Kanban columns smaller */
  .kanban-col { min-width: 380px; width: 380px; }
}

/* ===== Mobile (≤ 640px) ===== */
@media (max-width: 640px) {
  :root { --topbar-h: 56px; }

  body { font-size: 13.5px; }

  /* Top bar */
  .topbar {
    grid-template-columns: auto 1fr auto;
    padding: 0 12px;
    gap: 8px;
    height: var(--topbar-h);
  }
  .menu-toggle { display: grid; place-items: center; }
  .brand-mark { width: 32px; height: 32px; font-size: 16px; }
  .brand-text { display: none; }
  .topbar-search { display: none; }
  .topbar-right .role-switcher { padding: 4px 6px; }
  .topbar-right .role-label { display: none; }
  .topbar-right .icon-btn { width: 34px; height: 34px; }
  .user-chip { display: none; } /* role-switcher already shows who you are */

  /* Sidebar becomes a drawer */
  .layout { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed;
    top: var(--topbar-h);
    left: 0;
    width: 80%;
    max-width: 300px;
    height: calc(100vh - var(--topbar-h));
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    z-index: 50;
    box-shadow: var(--shadow-lg);
  }
  .sidebar.open { transform: translateX(0); }
  .nav-item { padding: 12px 14px; font-size: 14px; min-height: 44px; }

  /* Content padding */
  .content { padding: 14px 12px; }

  /* Page header */
  .page-header { gap: 10px; margin-bottom: 16px; }
  .page-title { font-size: 18px; }
  .page-sub { font-size: 12.5px; }
  .page-actions { width: 100%; }
  .page-actions .btn { flex: 1 1 auto; justify-content: center; }

  /* Cards */
  .card { padding: 14px; border-radius: 12px; }
  .stat { padding: 12px 14px; }
  .stat-value { font-size: 18px; }
  .stats-grid { grid-template-columns: 1fr 1fr; gap: 10px; }

  /* All multi-col rows stack */
  .row-2, .row-1-1, .row-3 { grid-template-columns: 1fr; gap: 12px; }

  /* =================================================
     MOBILE-FIRST TABLES — Auto-transform table rows
     into cards on small screens. Opt-out with class
     .no-stack (kept as scrollable matrix).
     ================================================= */
  .table:not(.no-stack):not(.matrix-table) {
    border: none;
    background: transparent;
    box-shadow: none;
    border-radius: 0;
    overflow: visible;
  }
  .table:not(.no-stack):not(.matrix-table) thead {
    /* Visually hide but keep for semantics */
    position: absolute;
    width: 1px; height: 1px;
    padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0,0,0,0);
    white-space: nowrap; border: 0;
  }
  .table:not(.no-stack):not(.matrix-table) tbody { display: block; }
  .table:not(.no-stack):not(.matrix-table) tr {
    display: block;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 12px;
    padding: 12px 14px;
    margin-bottom: 10px;
    box-shadow: var(--shadow-sm);
  }
  .table:not(.no-stack):not(.matrix-table) tbody tr:hover { background: var(--color-surface); }
  .table:not(.no-stack):not(.matrix-table) td {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 6px 0;
    border: none;
    border-bottom: 1px solid var(--color-border);
    text-align: right;
  }
  .table:not(.no-stack):not(.matrix-table) td:last-child {
    border-bottom: none;
    padding-bottom: 0;
    padding-top: 8px;
  }
  .table:not(.no-stack):not(.matrix-table) td::before {
    content: attr(data-label);
    font-weight: 600;
    color: var(--color-text-muted);
    font-size: 10.5px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    flex-shrink: 0;
    text-align: left;
  }
  .table:not(.no-stack):not(.matrix-table) td[data-label=""]::before,
  .table:not(.no-stack):not(.matrix-table) td:not([data-label])::before {
    display: none;
  }
  /* First cell = "title/name" — emphasized, full width, no label */
  .table:not(.no-stack):not(.matrix-table) td:first-child {
    flex-direction: column;
    align-items: flex-start;
    gap: 0;
    border-bottom: 1px solid var(--color-border);
    padding-bottom: 10px;
    margin-bottom: 4px;
    text-align: left;
    font-size: 14px;
  }
  .table:not(.no-stack):not(.matrix-table) td:first-child::before { display: none; }
  /* Action cell (last) flows full width if it contains buttons */
  .table:not(.no-stack):not(.matrix-table) td.actions-cell {
    flex-direction: row;
    justify-content: flex-end;
    gap: 6px;
  }
  .table:not(.no-stack):not(.matrix-table) td.actions-cell::before { display: none; }
  .table:not(.no-stack):not(.matrix-table) td.actions-cell .btn { flex: 1; max-width: 140px; }

  /* For tables that need to remain scrollable matrix-style */
  .table.no-stack, .matrix-table {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    white-space: nowrap;
  }

  /* Buttons — touch-friendly */
  .btn { padding: 10px 14px; min-height: 40px; }
  .btn-sm { padding: 7px 10px; min-height: 32px; font-size: 12px; }

  /* Kanban columns */
  .kanban {
    padding: 6px 4px 16px;
    gap: 10px;
    /* Snap-scroll for nicer mobile UX */
    scroll-snap-type: x mandatory;
  }
  .kanban-col {
    /* Was 88vw (one column basically fills the whole screen, next one
       just barely peeking in). Narrower now so ~2 full columns plus a
       partial third are visible at once by default — see .kanban-zoomed-in
       below for the toggle back to the old close-up single-column view. */
    min-width: 42vw;
    width: 42vw;
    max-width: 190px;
    scroll-snap-align: start;
    /* The base rule (line ~291) fixes height at calc(100vh - 260px) so
       every column is always that tall regardless of card count — with
       only a couple cards, that left a large empty white gap below them
       before reaching "+ Add a card". Overriding max-height alone (as
       this rule used to) doesn't help since `height` is a separate,
       higher-priority property that was still forcing the fixed size.
       height: auto lets the column hug its actual content instead. */
    height: auto;
    max-height: calc(100vh - 220px);
  }
  .kanban-col-new { min-width: 42vw; width: 42vw; max-width: 190px; }
  .kcard-cover { height: 110px; }

  /* ===== Zoomed-in mobile board view (BoardView.toggleZoom) =====
   Toggled from the floating 🔍 button in the bottom-right corner of the
   board. The default above (42vw) is "zoomed out" — no override needed
   for that state. This restores the original wide close-up view (one
   column filling almost the whole screen) for anyone who wants to
   actually read a column comfortably instead of the narrower default. */
  .kanban-zoomed-in .kanban-col,
  .kanban-zoomed-in .kanban-col-new {
    min-width: 88vw;
    width: 88vw;
    max-width: 320px;
  }
  .kanban-zoomed-in .kcard-cover { height: 145px; }
  .kanban-zoom-btn { display: flex; }

  /* Boards landing — single column on small phones */
  .boards-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .board-card { min-height: 110px; }
  .board-card-name { font-size: 13px; }
  .roles-grid, .dept-grid, .catalog-grid { grid-template-columns: 1fr; gap: 10px; }

  /* Board header */
  .board-header { padding: 12px 14px; }
  .board-header-title { font-size: 16px; }
  .board-header-right { gap: 6px; }
  .board-header-right .btn-ghost { padding: 6px; font-size: 12px; }
  .board-tabs { overflow-x: auto; }
  .board-tab { padding: 8px 12px; font-size: 12px; min-height: 36px; white-space: nowrap; }
  /* Filter/search toolbar (Filter cards, All priorities, All members, All
     labels) hidden on mobile — on a narrow board view these took up a
     full stacked row each before you even reach the cards. Filtering is
     still available on desktop/tablet where there's room for it. */
  .board-toolbar { display: none; }

  /* Modal — fullscreen on mobile */
  .modal-backdrop { padding: 0; }
  .modal {
    max-width: 100%;
    width: 100%;
    height: 100vh;
    height: 100dvh; /* dynamic vh — handles iOS Safari bar */
    max-height: 100vh;
    max-height: 100dvh;
    border-radius: 0;
  }
  .modal-header {
    padding: 12px 14px;
    align-items: center;
  }
  .modal-title { font-size: 16px; line-height: 1.3; }
  .modal-subtitle { font-size: 11px; }
  .modal-close { padding: 8px 12px; font-size: 26px; }
  .modal-body { padding: 14px; }

  /* Detail cover smaller in modals on mobile */
  .detail-cover { height: 160px !important; font-size: 56px !important; }

  /* Detail rows stack label/value */
  .detail-row {
    grid-template-columns: 110px 1fr;
    padding: 8px 0;
  }

  /* Form action footer sticks to bottom of modal */
  #entityForm > div:last-child {
    position: sticky;
    bottom: 0;
    background: var(--color-surface);
    margin: 0 -14px -14px;
    padding: 12px 14px !important;
    border-top: 1px solid var(--color-border);
    z-index: 5;
  }
  #entityForm > div:last-child button { flex: 1; min-height: 44px; }

  /* Comment / activity sections compact */
  .detail-section h4 { font-size: 11.5px; }
  .timeline-item { font-size: 12px; }
  .comment { padding: 8px 10px; }

  /* Inline timelog rows */
  .timelog-row {
    grid-template-columns: 1fr auto;
    gap: 4px;
    font-size: 12px;
  }

  /* Owner-only / sensitive blocks tighter */
  .owner-only { padding: 10px 12px; }

  /* Form grid stacks */
  .form-grid { grid-template-columns: 1fr; gap: 10px; }
  .form-grid .full { grid-column: span 1; }

  /* Toast */
  .toast {
    bottom: 14px;
    left: 14px;
    right: 14px;
    text-align: center;
  }

  /* Permission matrix — let it horizontally scroll */
  .matrix-table { font-size: 12px; }

  /* Client portal hero compresses */
  .client-hero { padding: 18px 16px; }
  .client-hero h2 { font-size: 18px; }
  .client-hero-stats { gap: 14px; }
  .client-hero-stat .value { font-size: 16px; }

  /* Composer */
  .kanban-col-composer textarea { font-size: 14px; min-height: 60px; }
  .todo-composer-actions { flex-wrap: wrap; }

  /* Catalog */
  .catalog-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .product-cover { height: 130px; font-size: 36px; }
}

/* ===== Very small phones (≤ 380px) ===== */
@media (max-width: 380px) {
  .stats-grid { grid-template-columns: 1fr; }
  .boards-grid, .catalog-grid { grid-template-columns: 1fr; }
  .role-switcher select { font-size: 12px; max-width: 90px; }
}

/* ===== Tablet adjustments (641px – 1024px) ===== */
@media (min-width: 641px) and (max-width: 1024px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .boards-grid { grid-template-columns: repeat(2, 1fr); }
  .roles-grid, .dept-grid { grid-template-columns: repeat(2, 1fr); }
  .catalog-grid { grid-template-columns: repeat(3, 1fr); }
  /* Modal body switches to single column */
  .modal-body-split { grid-template-columns: 1fr; }
}

/* ===== Touch device polish ===== */
@media (hover: none) and (pointer: coarse) {
  /* Bigger tap targets for table rows */
  .table tbody td { padding: 14px 12px; }
  /* Remove hover-shift on cards */
  .product-card:hover, .board-card:hover, .kcard:hover, .role-card:hover, .dept-card:hover {
    transform: none;
  }
  /* Show action buttons always (no hover reveal) */
  .todo-actions { opacity: 1; }
  /* Larger checkbox */
  input[type="checkbox"] { width: 20px; height: 20px; }
}

/* ===== Print-friendly (bonus) ===== */
@media print {
  .topbar, .sidebar, .page-actions, .toast { display: none; }
  .layout { grid-template-columns: 1fr; }
  .content { padding: 0; }
}
.delay-alerts{
  border:1px solid var(--color-border);
  border-radius:16px;
  margin-top:20px;
  background:var(--color-surface);
}
.delay-status {
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 20px;
  display: inline-block;
}

.delay-status.on-track {
  color: #15803d;
  background: #dcfce7;
}

.delay-status.at-risk {
  color: #b45309;
  background: #fef3c7;
}

.delay-status.overdue {
  color: #b91c1c;
  background: #fee2e2;
}

/* ===== Image lightbox (view attachments without repeated downloads) ===== */
.img-lightbox {
  position: fixed;
  inset: 0;
  z-index: 10000;
  background: rgba(15, 23, 42, 0.86);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
}
.img-lightbox[hidden] { display: none; }
.img-lightbox img {
  max-width: 100%;
  max-height: 100%;
  border-radius: 10px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
  object-fit: contain;
}
.img-lightbox-close {
  position: absolute;
  top: 18px;
  right: 24px;
  background: rgba(255,255,255,0.95);
  border: none;
  border-radius: 999px;
  width: 36px;
  height: 36px;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(0,0,0,0.25);
}

/* ===== Attachment "more" menu (6-option list) ===== */
.attachment-menu-item {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  padding: 8px 10px;
  font-size: 13px;
  border-radius: 6px;
  cursor: pointer;
  color: var(--color-text, #0f172a);
  text-decoration: none;
}
.attachment-menu-item:hover { background: var(--color-surface-2, #f1f3f8); }
.attachment-menu-item-danger { color: var(--color-danger, #b91c1c); }

/* NOTE: .client-dash-scroll-list is intentionally NOT defined here.
   client-portal.js ships its own authoritative rule for it in an inline
   <style> block (see ClientPortal's dashboard render) — it used to have a
   conflicting mobile override that cancelled scrolling entirely, which
   has been fixed there directly. A duplicate rule was added here earlier
   while that inline block hadn't been found yet; removed to avoid two
   competing definitions of the same class living in two files. */

/* ===== General-purpose scrollable list box =====
   Same problem as .client-dash-scroll-list above, just showing up in more
   places: Calendar's "Upcoming Deadlines" (can list all 200+ cards with a
   due date), Finance Overview's "Overdue Invoices" widget, and the main
   Invoices page's list — all rendered as a plain unbounded list/table
   inside a .card, so a long list just kept growing the whole page instead
   of scrolling in its own box. Reusable anywhere instead of duplicating
   the same two rules under a new name each time. */
.scroll-list { max-height: 480px; overflow-y: auto; }
@media (max-width: 640px) {
  .scroll-list { max-height: 360px; }
}

/* ===== Attachment row (card detail modal) =====
   Was previously one giant unwrapped inline flex row: thumbnail + filename
   + up to 3 buttons (Play/View/Download, Replace, ⋮ more) all fighting for
   space on one line. Being entirely inline-styled meant no media query
   could ever reach it, so on a narrow phone the filename got squeezed to
   an unreadable sliver while the buttons stayed full-size and cramped.
   Split into two groups (.att-row-main = thumbnail+name, .att-row-actions
   = the buttons) so a mobile breakpoint can drop the actions onto their
   own line instead of endlessly shrinking the filename. */
.att-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding: 8px 10px;
  background: var(--color-surface-2);
  border-radius: 8px;
  margin-bottom: 6px;
  align-items: center;
  position: relative;
}
.att-row-main { display: flex; gap: 10px; align-items: center; flex: 1; min-width: 0; }
.att-row-actions { display: flex; gap: 6px; align-items: center; flex-shrink: 0; }
@media (max-width: 480px) {
  .att-row-actions { flex-basis: 100%; justify-content: flex-end; margin-top: 2px; }
} 