/* ============================================================
   OpsManager â€” design system
   Mobile-first: base styles target small screens; a min-width breakpoint at
   768px promotes the off-canvas nav to a persistent sidebar. Palette/type/
   shadow language takes inspiration from a reference enterprise design system
   the user supplied (indigo primary, DM Sans/Fraunces, layered surfaces) â€”
   adapted, not copied: no build step, no utility-class framework, every
   component here is one this app's templates actually use. No framework â€”
   see memory/DECISIONS.md.
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=DM+Sans:ital,opsz,wght@0,9..40,400;0,9..40,500;0,9..40,600;0,9..40,700;1,9..40,400&family=DM+Mono:wght@400;500&family=Fraunces:opsz,wght@9..144,300;9..144,500;9..144,600&display=swap');

:root {
  --primary: #4F46E5;
  --primary-light: #6366F1;
  --primary-dark: #3730A3;
  --primary-5: rgba(79,70,229,.05);
  --primary-10: rgba(79,70,229,.10);
  --primary-20: rgba(79,70,229,.20);

  --success: #16A34A;
  --success-bg: rgba(34,197,94,.12);
  --warning: #D97706;
  --warning-bg: rgba(245,158,11,.12);
  --danger: #DC2626;
  --danger-bg: rgba(239,68,68,.12);
  --purple: #7C3AED;
  --purple-bg: rgba(124,58,237,.12);

  --bg: #F8FAFC;
  --surface: #FFFFFF;
  --surface-2: #F1F5F9;
  --surface-3: #E2E8F0;
  --border: #E2E8F0;
  --border-light: #F1F5F9;

  --text-primary: #0F172A;
  --text-secondary: #475569;
  --text-tertiary: #94A3B8;
  --text-inverse: #FFFFFF;

  --shadow-xs: 0 1px 2px rgba(15,23,42,.04);
  --shadow-sm: 0 1px 3px rgba(15,23,42,.08), 0 1px 2px rgba(15,23,42,.04);
  --shadow-md: 0 4px 6px rgba(15,23,42,.07), 0 2px 4px rgba(15,23,42,.05);
  --shadow-lg: 0 10px 15px rgba(15,23,42,.08), 0 4px 6px rgba(15,23,42,.04);
  --shadow-xl: 0 20px 25px rgba(15,23,42,.10), 0 8px 10px rgba(15,23,42,.06);

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 18px;
  --radius-full: 9999px;

  --sidebar-w: 240px;
  --topbar-h: 56px;

  --font-sans: 'DM Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-serif: 'Fraunces', Georgia, serif;
  --font-mono: 'DM Mono', "SFMono-Regular", Consolas, monospace;

  --transition-fast: 150ms ease;
  --transition-base: 220ms ease;
  --transition-normal: 260ms ease;
}

/* Dark mode: explicit toggle (data-theme) wins over system preference. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0B0F1A;
    --surface: #111827;
    --surface-2: #1A2233;
    --surface-3: #262F42;
    --border: #232C3F;
    --border-light: #1A2233;
    --text-primary: #F1F5F9;
    --text-secondary: #94A3B8;
    --text-tertiary: #5B6B85;
    --shadow-sm: 0 1px 3px rgba(0,0,0,.35);
    --shadow-md: 0 4px 6px rgba(0,0,0,.3);
    --shadow-lg: 0 10px 15px rgba(0,0,0,.35);
    --shadow-xl: 0 20px 25px rgba(0,0,0,.4);
  }
}
:root[data-theme="dark"] {
  --bg: #0B0F1A;
  --surface: #111827;
  --surface-2: #1A2233;
  --surface-3: #262F42;
  --border: #232C3F;
  --border-light: #1A2233;
  --text-primary: #F1F5F9;
  --text-secondary: #94A3B8;
  --text-tertiary: #5B6B85;
  --shadow-sm: 0 1px 3px rgba(0,0,0,.35);
  --shadow-md: 0 4px 6px rgba(0,0,0,.3);
  --shadow-lg: 0 10px 15px rgba(0,0,0,.35);
  --shadow-xl: 0 20px 25px rgba(0,0,0,.4);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--font-sans);
  color: var(--text-primary);
  background: var(--bg);
  font-size: 16px;
  line-height: 1.55;
  overflow-wrap: anywhere;
}

h1, h2, h3, h4 { margin: 0 0 12px; line-height: 1.25; font-weight: 600; letter-spacing: -0.01em; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.2rem; }
h3 { font-size: 1.02rem; }
p { margin: 0 0 12px; }

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 99px; }

.text-muted { color: var(--text-secondary); }
.text-danger { color: var(--danger); }
.text-right { text-align: right; }
.text-nowrap { white-space: nowrap; }
.mt-4 { margin-top: 16px; }
.mb-0 { margin-bottom: 0; }
/* Wraps a single-button POST form so it sits inline in a row of actions
   instead of taking its own line (a <form> is block-level by default). */
.form-inline { display: inline; }

/* ---------------------------------------------------------------------- */
/* App shell: sidebar (desktop) / off-canvas drawer (mobile)               */
/* ---------------------------------------------------------------------- */

.app-shell { min-height: 100vh; }

.sidebar {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 60;
  transform: translateX(-100%);
  transition: transform var(--transition-base);
}
.sidebar.is-open { transform: translateX(0); box-shadow: var(--shadow-xl); }

.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,.5);
  z-index: 55;
}
.sidebar-backdrop.is-open { display: block; }

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  height: var(--topbar-h);
  padding: 0 18px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.sidebar-brand-mark {
  width: 28px; height: 28px;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, var(--primary), var(--purple));
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-serif);
  font-weight: 600;
  font-size: 15px;
  flex-shrink: 0;
}
.sidebar-brand-text {
  font-family: var(--font-serif);
  font-weight: 600;
  font-size: 17px;
  color: var(--text-primary);
}
.sidebar-brand-logo {
  height: 24px;
  width: auto;
  max-width: 100%;
  flex-shrink: 0;
  display: block;
}
/* The brand logo is a black glyph set — invert it to white in dark mode. */
:root[data-theme="dark"] .sidebar-brand .sidebar-brand-logo,
:root[data-theme="dark"] .auth-logo {
  filter: invert(1);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .sidebar-brand .sidebar-brand-logo,
  :root:not([data-theme="light"]) .auth-logo {
    filter: invert(1);
  }
}
.sidebar-brand:hover { text-decoration: none; }

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
}
.nav-group {
  margin-bottom: 2px;
}
.nav-group-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 38px;
  padding: 0 10px;
  border: 0;
  background: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  font: inherit;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--text-tertiary);
  text-align: left;
  transition: background var(--transition-fast), color var(--transition-fast);
}
.nav-group-toggle:hover {
  background: var(--surface-2);
  color: var(--text-primary);
}
.nav-group-toggle svg { flex-shrink: 0; opacity: .8; }
.nav-group-toggle-label { flex: 1; }
.nav-group-chevron { flex-shrink: 0; display: flex; align-items: center; transition: transform var(--transition-fast); opacity: .7; }
.nav-group.is-open .nav-group-chevron { transform: rotate(180deg); }
.nav-group-items {
  overflow: hidden;
  max-height: 0;
  transition: max-height var(--transition-normal) ease, opacity var(--transition-normal) ease;
  opacity: 0;
}
.nav-group.is-open .nav-group-items {
  max-height: 600px;
  opacity: 1;
  padding-left: 8px;
  margin-top: 2px;
}
.nav-group-items .nav-item-sub { min-height: 38px; font-size: 14px; }
.nav-group-items .nav-item-sub svg { opacity: .55; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 11px;
  min-height: 44px;
  padding: 0 12px;
  border-radius: var(--radius-md);
  font-size: 14.5px;
  font-weight: 500;
  color: var(--text-secondary);
  transition: background var(--transition-fast), color var(--transition-fast);
}
.nav-item:hover { background: var(--surface-2); color: var(--text-primary); text-decoration: none; }
.nav-item.is-active { background: var(--primary-10); color: var(--primary); }
.nav-item svg { flex-shrink: 0; opacity: .8; }
.nav-item.is-active svg { opacity: 1; }

.sidebar-footer {
  border-top: 1px solid var(--border);
  padding: 10px;
  flex-shrink: 0;
}

/* User menu (dropdown) */
.user-menu { position: relative; }
.user-menu-trigger {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 48px;
  padding: 6px 8px;
  border-radius: var(--radius-md);
  cursor: pointer;
  background: none;
  text-align: left;
}
.user-menu-trigger:hover { background: var(--surface-2); }
.user-menu-info { flex: 1; min-width: 0; }
.user-menu-name { font-size: 13.5px; font-weight: 600; color: var(--text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-menu-role { font-size: 11.5px; color: var(--text-tertiary); text-transform: capitalize; }
.user-menu-chevron { color: var(--text-tertiary); flex-shrink: 0; transition: transform var(--transition-fast); }
.user-menu.is-open .user-menu-chevron { transform: rotate(180deg); }

.user-menu-panel {
  display: none;
  position: absolute;
  bottom: calc(100% + 6px);
  left: 0; right: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  padding: 6px;
  z-index: 70;
}
.user-menu.is-open .user-menu-panel { display: block; }
.user-menu-panel a, .user-menu-panel button {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 40px;
  padding: 0 10px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  color: var(--text-primary);
  background: none;
  text-align: left;
}
.user-menu-panel a:hover, .user-menu-panel button:hover { background: var(--surface-2); text-decoration: none; }

.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-full);
  font-weight: 600;
  color: #fff;
  flex-shrink: 0;
  background: linear-gradient(135deg, var(--primary), var(--purple));
  font-family: var(--font-sans);
}
.avatar-sm { width: 28px; height: 28px; font-size: 11px; }
.avatar-md { width: 34px; height: 34px; font-size: 13px; }

/* Main column */
.app-main { min-height: 100vh; display: flex; flex-direction: column; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 12px;
  height: var(--topbar-h);
  padding: 0 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
/* Truncate rather than wrap: .topbar is a fixed var(--topbar-h) tall, so a long
   page title (a client's full company name, an invoice number) used to wrap to
   a second line and break out of the bar, pushing the toggle buttons out of
   alignment. min-width:0 is required for the ellipsis to engage inside flex. */
.topbar-title {
  font-size: 15px;
  font-weight: 600;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.topbar-spacer { flex: 1; }

.nav-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px; height: 40px;
  border-radius: var(--radius-md);
  border: none;
  background: transparent;
  color: var(--text-primary);
  cursor: pointer;
  flex-shrink: 0;
}
.nav-toggle:hover { background: var(--surface-2); }

.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px; height: 36px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-secondary);
  cursor: pointer;
  flex-shrink: 0;
}
.theme-toggle:hover { background: var(--surface-2); color: var(--text-primary); }
.theme-toggle .icon-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-moon { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-sun { display: block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .icon-moon { display: none; }
  :root:not([data-theme="light"]) .theme-toggle .icon-sun { display: block; }
}

.content-area { flex: 1; padding: 20px 16px 40px; }
/* Content fills the full width of the content area â€” no artificial centering
   that leaves empty gutters on both sides of a wide screen. Pages that want a
   readable measure apply it to their own cards (.form-card / .card-narrow). */
.container { width: 100%; max-width: none; }

@media (min-width: 768px) {
  .sidebar { transform: translateX(0); }
  .sidebar-backdrop { display: none !important; }
  .app-main { margin-left: var(--sidebar-w); }
  .nav-toggle { display: none; }
  .content-area { padding: 28px 32px 48px; }
}

/* ---------------------------------------------------------------------- */
/* Page composition primitives                                             */
/*                                                                          */
/* These replace ad-hoc inline `style="display:flex;..."` blocks that were  */
/* hand-written on nearly every page. The same row was authored 40+ times   */
/* with slightly different gaps, and several copies omitted flex-wrap, so   */
/* spacing drifted page to page and some rows could not wrap on narrow      */
/* screens. One class per pattern keeps every page aligned identically.     */
/* ---------------------------------------------------------------------- */

/* Page title on the left, action buttons on the right; stacks when narrow. */
.page-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 20px;
}
.page-head > * { min-width: 0; }
.page-head h1, .page-head h2, .page-head h3 { margin-bottom: 0; }
.page-head .btn-row { margin-top: 0; }

/* Same row, used inside a card to title a section with a trailing action. */
.section-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 12px;
}
.section-head > * { min-width: 0; }
.section-head h1, .section-head h2, .section-head h3, .section-head h4 { margin-bottom: 0; }

/* A short explanatory line directly under a heading. Was written inline as
   `style="margin-top:-8px"` in 20 places â€” a magic number tightening the gap
   left by the heading's own margin-bottom. Named, it stays consistent. */
.card-hint {
  margin-top: -6px;
  margin-bottom: 14px;
  color: var(--text-secondary);
  font-size: 0.88rem;
}

/* Headings/paragraphs never need a top margin as a card's first child. */
.card > :first-child { margin-top: 0; }

/* Read-only label/value pairs (e.g. a "Billing Summary" block). Previously a
   plain flex row, so each item sized to its own content and the values never
   lined up into columns. A grid keeps them on a shared baseline grid. */
.detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 16px 24px;
}
.detail-grid > div { min-width: 0; }
.detail-grid .text-muted { font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.04em; }

/* Horizontal "add a row" forms sitting under a table (add contact, add phone,
   add address). Every field previously carried its own arbitrary inline
   max-width (120/150/160/170/180/200/220/240px), so fields in one row were all
   different widths on desktop AND stacked to different widths on mobile. A
   shared flex-basis makes them size as one set; full width below 640px. */
/* Grid rather than flex, deliberately: with flex, a field's intrinsic content
   (a textarea, a long <option>) still influenced its width, and the items on a
   wrapped last row stretched to fill it â€” so a 4-field row rendered as
   242/242/242/746. Grid tracks are sized by the container alone, so every
   field in the row is exactly the same width and a short last row stays on the
   same column rhythm. minmax(170px, 1fr) (not plain 1fr) keeps intrinsic
   content from blowing a track out. */
.inline-form,
.filter-bar {
  display: grid;
  grid-template-columns: 1fr; /* mobile-first: one control per line */
  gap: 12px;
  align-items: end;
}
.inline-form { margin-top: 16px; }
.filter-bar { margin: 0 0 20px; }

.inline-form > *,
.filter-bar > * { min-width: 0; }
.inline-form .form-group,
.filter-bar .form-group { margin-bottom: 0; max-width: none; }
.inline-form .checkbox-row,
.filter-bar .checkbox-row { margin-bottom: 0; }
.inline-form select, .inline-form input, .inline-form textarea,
.filter-bar select, .filter-bar input { width: 100%; }

@media (min-width: 640px) {
  .inline-form,
  .filter-bar { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
  /* Buttons keep their natural width inside their track instead of being
     stretched to a full column. */
  .inline-form > .btn,
  .filter-bar > .btn { justify-self: start; }
}

@media (max-width: 639px) {
  /* Mobile-first intent: one control per line at full width, so nothing is
     half-width for no reason and every tap target spans the screen. */
  .inline-form > .btn,
  .filter-bar > .btn,
  .page-head > .btn,
  .page-head > .btn-row,
  .page-head > .btn-row > .btn { width: 100%; }
}

/* ---------------------------------------------------------------------- */
/* Alerts / flash messages                                                 */
/* ---------------------------------------------------------------------- */

.alert {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  margin-bottom: 16px;
  font-size: 0.92rem;
  border: 1px solid transparent;
}
.alert-success { background: var(--success-bg); color: var(--success); border-color: rgba(34,197,94,.25); }
.alert-error { background: var(--danger-bg); color: var(--danger); border-color: rgba(239,68,68,.25); }
.alert-warning { background: var(--warning-bg); color: var(--warning); border-color: rgba(245,158,11,.25); }

/* ---------------------------------------------------------------------- */
/* Cards + KPI stat cards                                                  */
/* ---------------------------------------------------------------------- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 20px;
  margin-bottom: 20px;
}
.card-title {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-tertiary);
  margin: 0 0 8px;
  font-weight: 600;
}
.card-value { font-size: 1.75rem; font-weight: 600; font-family: var(--font-serif); }

.stat-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}
@media (min-width: 640px) {
  .stat-grid { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
}

.kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
}
.kpi-card::before {
  content: '';
  position: absolute;
  top: 0; right: 0; bottom: 0; width: 4px;
  background: var(--primary);
}
.kpi-card-success::before { background: var(--success); }
.kpi-card-warning::before { background: var(--warning); }
.kpi-card-danger::before { background: var(--danger); }
.kpi-card-purple::before { background: var(--purple); }

.kpi-icon {
  width: 40px; height: 40px;
  border-radius: var(--radius-md);
  display: flex; align-items: center; justify-content: center;
  background: var(--primary-10);
  color: var(--primary);
  margin-bottom: 14px;
}
.kpi-card-success .kpi-icon { background: var(--success-bg); color: var(--success); }
.kpi-card-warning .kpi-icon { background: var(--warning-bg); color: var(--warning); }
.kpi-card-danger .kpi-icon { background: var(--danger-bg); color: var(--danger); }
.kpi-card-purple .kpi-icon { background: var(--purple-bg); color: var(--purple); }

.kpi-value { font-family: var(--font-serif); font-size: 1.9rem; font-weight: 600; line-height: 1.1; margin-bottom: 4px; }
.kpi-label { font-size: 0.85rem; color: var(--text-secondary); }

/* ---------------------------------------------------------------------- */
/* Buttons                                                                  */
/* ---------------------------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 44px;
  padding: 0 18px;
  border-radius: var(--radius-md);
  border: 1.5px solid var(--border);
  font-size: 0.94rem;
  font-weight: 500;
  cursor: pointer;
  background: var(--surface);
  color: var(--text-primary);
  text-decoration: none;
  transition: background var(--transition-fast), box-shadow var(--transition-fast), border-color var(--transition-fast);
  font-family: inherit;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn:active { transform: scale(.98); }
.btn-primary {
  background: var(--primary); border-color: var(--primary); color: #fff;
  box-shadow: 0 1px 2px rgba(79,70,229,.3);
}
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover { background: #B91C1C; border-color: #B91C1C; }
.btn-sm { min-height: 36px; padding: 0 14px; font-size: 0.85rem; border-radius: var(--radius-sm); }
.btn-block { width: 100%; }

.btn-row { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 20px; }

/* ---------------------------------------------------------------------- */
/* Forms                                                                    */
/* ---------------------------------------------------------------------- */

.form-group { margin-bottom: 18px; }
label { display: block; font-weight: 600; font-size: 0.88rem; margin-bottom: 7px; }
.form-hint { display: block; font-size: 0.8rem; color: var(--text-tertiary); margin-top: 5px; }

input[type="text"], input[type="email"], input[type="password"], input[type="number"],
input[type="search"], input[type="date"], input[type="time"], select, textarea {
  width: 100%;
  min-height: 44px;
  padding: 9px 13px;
  font-size: 16px; /* prevents iOS auto-zoom */
  font-family: inherit;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  color: var(--text-primary);
}
textarea { min-height: 96px; }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-10);
}
input:disabled { background: var(--surface-2); color: var(--text-tertiary); }

.form-card { max-width: 480px; margin: 0 auto; }

/* Readable measure caps for form/detail cards. Pages previously set these
   inline at 480/640/720/860px for the same kind of content â€” including on
   .form-card, which then rendered at three different widths depending on the
   page. Two named sizes keep every form page consistent. Declared after
   .form-card so they win when both are present.
   .card-wide is intentionally NOT capped: it's the "content card" used for
   tables/lists and fills the (now full-width) container. Only .form-card and
   .card-narrow keep a readable measure. */
.card-narrow { max-width: 640px; }
.card-wide { max-width: none; }

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 40px;
  padding: 4px 0;
}
.checkbox-row input[type="checkbox"] {
  width: 20px; height: 20px;
  min-height: 0;
  flex-shrink: 0;
  accent-color: var(--primary);
}
.checkbox-row label { margin: 0; font-weight: 500; font-size: 0.9rem; }

/* ---------------------------------------------------------------------- */
/* Tables â€” collapse to stacked cards on small screens                     */
/* ---------------------------------------------------------------------- */

/* Scrolls the table inside its own box rather than letting it crush. The
   stacked-card transform below only starts at 640px of VIEWPORT, but the
   content area is the viewport minus the 240px sidebar â€” so between roughly
   768px and 940px a wide table had far less room than the breakpoint assumes
   and columns collapsed to one character per line ("PHON E / EMAIL"). */
.table-wrap { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.data-table { width: 100%; border-collapse: collapse; background: var(--surface); border-radius: var(--radius-lg); overflow: hidden; }
@media (min-width: 641px) {
  /* Below 641px the table is already re-laid-out as cards, so this floor must
     not apply there or it would reintroduce a horizontal scroll on mobile. */
  .table-wrap > table.data-table { min-width: 560px; }
}
.data-table th {
  text-align: left; padding: 12px 16px;
  font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.05em;
  color: var(--text-tertiary); background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  white-space: nowrap; /* headers are short labels; never break them mid-word */
}
.data-table td { padding: 13px 16px; border-bottom: 1px solid var(--border-light); overflow-wrap: anywhere; min-width: 0; }
.data-table tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover td { background: var(--surface-2); }

@media (max-width: 640px) {
  .data-table thead { display: none; }
  .data-table, .data-table tbody, .data-table tr, .data-table td { display: block; width: 100%; }
  .data-table {
    background: none;
  }
  .data-table tr {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    margin-bottom: 12px;
    padding: 6px 14px;
    box-shadow: var(--shadow-xs);
  }
  .data-table td {
    border-bottom: none;
    padding: 9px 0;
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 4px 12px;
    text-align: right;
  }
  .data-table td:not(:last-child) { border-bottom: 1px solid var(--border-light); }
  .data-table td::before {
    content: attr(data-label);
    font-weight: 600;
    font-size: 0.8rem;
    color: var(--text-tertiary);
    text-align: left;
    flex-shrink: 0;
  }
}

/* ---------------------------------------------------------------------- */
/* Badges                                                                   */
/* ---------------------------------------------------------------------- */

.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 11px;
  border-radius: var(--radius-full);
  font-size: 0.74rem;
  font-weight: 600;
  /* Short status words; body sets overflow-wrap:anywhere, which otherwise
     breaks them mid-word inside a narrow table cell ("Acti ve"). */
  white-space: nowrap;
}
.badge-active, .badge-success { background: var(--success-bg); color: var(--success); }
.badge-disabled, .badge-inactive, .badge-danger { background: var(--danger-bg); color: var(--danger); }
.badge-role { background: var(--primary-10); color: var(--primary); text-transform: capitalize; }

/* ---------------------------------------------------------------------- */
/* Auth pages (login)                                                      */
/* ---------------------------------------------------------------------- */

.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: radial-gradient(circle at 20% 15%, var(--primary-5), transparent 45%), var(--bg);
}
.auth-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  padding: 36px 32px;
}
.auth-logo {
  height: 34px;
  width: auto;
  max-width: 100%;
  display: block;
  margin: 0 auto 14px;
}
.auth-card h1 {
  text-align: center;
  font-family: var(--font-serif);
  font-weight: 600;
  margin-bottom: 4px;
}
.auth-card .subtitle {
  text-align: center;
  color: var(--text-secondary);
  margin-bottom: 28px;
  font-size: 0.9rem;
}

/* ---------------------------------------------------------------------- */
/* Installer                                                               */
/* ---------------------------------------------------------------------- */

.install-steps { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 22px; font-size: 0.82rem; }
.install-steps span { padding: 4px 12px; border-radius: var(--radius-full); background: var(--surface-2); color: var(--text-tertiary); }
.install-steps span.is-active { background: var(--primary); color: #fff; }
.install-steps span.is-done { background: var(--success-bg); color: var(--success); }

.check-list { list-style: none; margin: 0 0 16px; padding: 0; }
.check-list li { display: flex; justify-content: space-between; padding: 9px 0; border-bottom: 1px solid var(--border-light); font-size: 0.9rem; }
.check-list li:last-child { border-bottom: none; }

/* ---------------------------------------------------------------------- */
/* Utility                                                                  */
/* ---------------------------------------------------------------------- */

.empty-state { text-align: center; padding: 48px 16px; color: var(--text-secondary); }
code {
  font-family: var(--font-mono);
  background: var(--surface-2);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.85em;
}

/* ---------------------------------------------------------------------- */
/* Kanban board (2026-09-02)                                              */
/* Compact, color-coded columns/cards; keeps the horizontal board + drag  */
/* on mobile. Scoped to .kanban-* so no other page is affected.           */
/* ---------------------------------------------------------------------- */

.kanban-board {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  padding-bottom: 10px;
}

.kanban-column {
  flex: 0 0 260px;
  scroll-snap-align: start;
  background: var(--surface-2);
  border-radius: var(--radius-lg);
  padding: 10px;
  min-height: 200px;
  display: flex;
  flex-direction: column;
}
/* Thin status color strip on each column header. */
.kanban-column-head {
  margin: 2px 2px 8px;
  padding-bottom: 6px;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 600;
  color: var(--text-secondary);
  border-bottom: 2px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}
.kanban-column-head .count {
  font-weight: 400;
  color: var(--text-tertiary);
}
.kanban-column[data-status="todo"] .kanban-column-head { border-bottom-color: var(--primary); }
.kanban-column[data-status="in_progress"] .kanban-column-head { border-bottom-color: var(--warning); }
.kanban-column[data-status="done"] .kanban-column-head { border-bottom-color: var(--success); }
.kanban-column[data-status="cancelled"] .kanban-column-head { border-bottom-color: var(--text-tertiary); }

.kanban-dropzone {
  min-height: 120px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.kanban-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-xs);
  padding: 8px 10px;
  cursor: grab;
  overflow-wrap: anywhere;
  transition: box-shadow .15s ease, border-color .15s ease;
  border-left: 4px solid var(--border);
}
.kanban-card:hover { box-shadow: var(--shadow-sm); }
.kanban-card:active { cursor: grabbing; }
/* Priority edge + chip colors. */
.kanban-card.priority-high   { border-left-color: var(--danger); }
.kanban-card.priority-medium { border-left-color: var(--warning); }
.kanban-card.priority-low    { border-left-color: var(--success); }

.kanban-card .k-title {
  font-size: 0.84rem;
  font-weight: 600;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  color: var(--text-primary);
  margin-bottom: 2px;
}
.kanban-card .k-title a { color: inherit; text-decoration: none; }
.kanban-card .k-title a:hover { color: var(--primary); }

.kanban-card .k-project {
  font-size: 0.72rem;
  color: var(--text-tertiary);
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.kanban-card .k-tags {
  margin-top: 3px;
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}
.kanban-card .k-tags .badge {
  padding: 1px 7px;
  font-size: 0.62rem;
  border-radius: var(--radius-full);
}

.kanban-card .k-meta {
  margin-top: 6px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  font-size: 0.7rem;
  color: var(--text-secondary);
}
.kanban-card .k-members {
  display: flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.kanban-card .k-members .k-avatar {
  flex: 0 0 auto;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--primary-10);
  color: var(--primary);
  font-size: 0.6rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.kanban-card .k-due {
  flex: 0 0 auto;
  font-variant-numeric: tabular-nums;
}
.kanban-card .k-due.overdue { color: var(--danger); font-weight: 600; }
.kanban-card .k-chip {
  flex: 0 0 auto;
  font-size: 0.62rem;
  font-weight: 700;
  text-transform: uppercase;
  padding: 1px 6px;
  border-radius: var(--radius-full);
}
.kanban-card .k-chip.p-high { background: var(--danger-bg); color: var(--danger); }
.kanban-card .k-chip.p-medium { background: var(--warning-bg); color: var(--warning); }
.kanban-card .k-chip.p-low { background: var(--success-bg); color: var(--success); }
.kanban-card .k-chip.overdue { background: var(--danger-bg); color: var(--danger); }
.kanban-card .k-chip.done { background: var(--success-bg); color: var(--success); }
.kanban-card .k-chip.cancelled { background: var(--surface-3); color: var(--text-secondary); }

/* Mobile: columns near full-width for readability, still swipeable. */
@media (max-width: 640px) {
  .kanban-column { flex: 0 0 82vw; }
  .kanban-card .k-title { font-size: 0.9rem; }
}
.kanban-card .k-tags.k-assignees { margin-top: 4px; }
.kanban-card .k-assignee {
  color: #fff;
  padding: 1px 8px;
  font-size: 0.66rem;
  font-weight: 600;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.kanban-card .k-assignee-more {
  background: var(--surface-3);
  color: var(--text-secondary);
  padding: 1px 7px;
  font-size: 0.66rem;
  font-weight: 600;
}

