@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

/* ============================================================
   Mithura Design System
   Beaver Hub (Pvt) Ltd
   Brand: #00478f | CTA: #ff5d00 | Neutral: #7b7d87
   ============================================================ */

:root {
  --primary: #00478f;
  --primary-dark: #003370;
  --primary-darker: #002255;
  --primary-light: #e8f0fb;
  --primary-xlight: #f0f5ff;

  --cta: #ff5d00;
  --cta-dark: #e05000;
  --cta-darker: #c24400;
  --cta-light: #fff3ee;
  --cta-border: #ffc4a8;

  --slate: #7b7d87;
  --slate-light: #f4f4f6;
  --slate-border: #e2e3e8;

  --accent: #00478f;
  --accent-hover: #003370;
  --accent-light: #e8f0fb;

  --navy-900: #001e45;
  --navy-800: #002d65;
  --navy-700: #00478f;
  --navy-600: #1258a0;
  --navy-500: #2b6baf;

  --success: #059669;
  --success-light: #ecfdf5;
  --success-border: #6ee7b7;

  --warning: #d97706;
  --warning-light: #fffbeb;
  --warning-border: #fcd34d;

  --danger: #dc2626;
  --danger-light: #fef2f2;
  --danger-border: #fca5a5;

  --gray-50: #f8f9fc;
  --gray-100: #f0f2f7;
  --gray-200: #e2e5ef;
  --gray-300: #c8cdd9;
  --gray-400: #a0a8bb;
  --gray-500: #7b8399;
  --gray-600: #5a6278;
  --gray-700: #3d4459;
  --gray-800: #252b3b;
  --gray-900: #141824;

  --white: #ffffff;
  --text-primary: #141824;
  --text-secondary: #3d4459;
  --text-muted: #7b8399;

  --sidebar-width: 256px;
  --topbar-height: 60px;

  --border-radius: 8px;
  --border-radius-lg: 12px;
  --border-radius-xl: 16px;

  --shadow-xs: 0 1px 2px rgba(0,0,0,0.05);
  --shadow-sm: 0 1px 3px rgba(0,71,143,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow: 0 4px 12px rgba(0,71,143,0.08), 0 2px 4px rgba(0,0,0,0.04);
  --shadow-lg: 0 8px 24px rgba(0,71,143,0.10), 0 4px 8px rgba(0,0,0,0.04);
  --shadow-xl: 0 16px 48px rgba(0,71,143,0.12), 0 8px 16px rgba(0,0,0,0.06);

  --transition: 150ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 300ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-bounce: 200ms cubic-bezier(0.34, 1.56, 0.64, 1);

  --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: "JetBrains Mono", "Fira Code", "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  --font-size-xs: 0.6875rem;
  --font-size-sm: 0.8125rem;
  --font-size-base: 0.9375rem;
  --font-size-lg: 1.0625rem;
  --font-size-xl: 1.25rem;
  --font-size-2xl: 1.5rem;
  --font-size-3xl: 1.875rem;

  --color-info-bg: var(--primary-light);

  --page-bg: #f4f6fb;
  --surface-subtle: #fafbfd;
}

/* ============================================================
   Dark theme — token overrides only. Every component below is
   already built on these custom properties, so redefining the
   tokens here re-themes the whole app without touching component
   rules. Default signal is prefers-color-scheme; the sidebar
   theme toggle (see app.js) stamps data-theme on <html> to
   override it explicitly in either direction.
   ============================================================ */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --primary: #4f8fd6;
    --primary-dark: #7bb0e6;
    --primary-darker: #a3c9ec;
    --primary-light: #16283f;
    --primary-xlight: #131f30;

    --cta: #ff8a4c;
    --cta-dark: #ffa877;
    --cta-darker: #ffc19e;
    --cta-light: #3a2416;
    --cta-border: #7a4321;

    --slate: #9aa3c2;
    --slate-light: #1c2438;
    --slate-border: #2c3650;

    --accent: #4f8fd6;
    --accent-hover: #7bb0e6;
    --accent-light: #16283f;

    --success: #34d399;
    --success-light: #0f2a21;
    --success-border: #1f6e50;

    --warning: #fbbf5e;
    --warning-light: #332309;
    --warning-border: #7a5613;

    --danger: #f87171;
    --danger-light: #331414;
    --danger-border: #7a2e2e;

    --gray-50: #161d2c;
    --gray-100: #1c2438;
    --gray-200: #2c3650;
    --gray-300: #3a4560;
    --gray-400: #56617f;
    --gray-500: #8a94b3;
    --gray-600: #a6afc9;
    --gray-700: #c3cbe0;
    --gray-800: #dfe3f0;
    --gray-900: #f2f4fa;

    --white: #161d2c;
    --text-primary: #f2f4fa;
    --text-secondary: #c3cbe0;
    --text-muted: #8a94b3;

    --page-bg: #0d1420;
    --surface-subtle: #131a29;

    --shadow-xs: 0 1px 2px rgba(0,0,0,0.35);
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.4), 0 1px 2px rgba(0,0,0,0.3);
    --shadow: 0 4px 12px rgba(0,0,0,0.45), 0 2px 4px rgba(0,0,0,0.3);
    --shadow-lg: 0 8px 24px rgba(0,0,0,0.5), 0 4px 8px rgba(0,0,0,0.3);
    --shadow-xl: 0 16px 48px rgba(0,0,0,0.55), 0 8px 16px rgba(0,0,0,0.35);
  }
}
:root[data-theme="dark"] {
  --primary: #4f8fd6;
  --primary-dark: #7bb0e6;
  --primary-darker: #a3c9ec;
  --primary-light: #16283f;
  --primary-xlight: #131f30;

  --cta: #ff8a4c;
  --cta-dark: #ffa877;
  --cta-darker: #ffc19e;
  --cta-light: #3a2416;
  --cta-border: #7a4321;

  --slate: #9aa3c2;
  --slate-light: #1c2438;
  --slate-border: #2c3650;

  --accent: #4f8fd6;
  --accent-hover: #7bb0e6;
  --accent-light: #16283f;

  --success: #34d399;
  --success-light: #0f2a21;
  --success-border: #1f6e50;

  --warning: #fbbf5e;
  --warning-light: #332309;
  --warning-border: #7a5613;

  --danger: #f87171;
  --danger-light: #331414;
  --danger-border: #7a2e2e;

  --gray-50: #161d2c;
  --gray-100: #1c2438;
  --gray-200: #2c3650;
  --gray-300: #3a4560;
  --gray-400: #56617f;
  --gray-500: #8a94b3;
  --gray-600: #a6afc9;
  --gray-700: #c3cbe0;
  --gray-800: #dfe3f0;
  --gray-900: #f2f4fa;

  --white: #161d2c;
  --text-primary: #f2f4fa;
  --text-secondary: #c3cbe0;
  --text-muted: #8a94b3;

  --page-bg: #0d1420;
  --surface-subtle: #131a29;

  --shadow-xs: 0 1px 2px rgba(0,0,0,0.35);
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.4), 0 1px 2px rgba(0,0,0,0.3);
  --shadow: 0 4px 12px rgba(0,0,0,0.45), 0 2px 4px rgba(0,0,0,0.3);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.5), 0 4px 8px rgba(0,0,0,0.3);
  --shadow-xl: 0 16px 48px rgba(0,0,0,0.55), 0 8px 16px rgba(0,0,0,0.35);
}
:root[data-theme="light"] {
  --primary: #00478f;
  --primary-dark: #003370;
  --primary-darker: #002255;
  --primary-light: #e8f0fb;
  --primary-xlight: #f0f5ff;

  --cta: #ff5d00;
  --cta-dark: #e05000;
  --cta-darker: #c24400;
  --cta-light: #fff3ee;
  --cta-border: #ffc4a8;

  --slate: #7b7d87;
  --slate-light: #f4f4f6;
  --slate-border: #e2e3e8;

  --accent: #00478f;
  --accent-hover: #003370;
  --accent-light: #e8f0fb;

  --success: #059669;
  --success-light: #ecfdf5;
  --success-border: #6ee7b7;

  --warning: #d97706;
  --warning-light: #fffbeb;
  --warning-border: #fcd34d;

  --danger: #dc2626;
  --danger-light: #fef2f2;
  --danger-border: #fca5a5;

  --gray-50: #f8f9fc;
  --gray-100: #f0f2f7;
  --gray-200: #e2e5ef;
  --gray-300: #c8cdd9;
  --gray-400: #a0a8bb;
  --gray-500: #7b8399;
  --gray-600: #5a6278;
  --gray-700: #3d4459;
  --gray-800: #252b3b;
  --gray-900: #141824;

  --white: #ffffff;
  --text-primary: #141824;
  --text-secondary: #3d4459;
  --text-muted: #7b8399;

  --page-bg: #f4f6fb;
  --surface-subtle: #fafbfd;

  --shadow-xs: 0 1px 2px rgba(0,0,0,0.05);
  --shadow-sm: 0 1px 3px rgba(0,71,143,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow: 0 4px 12px rgba(0,71,143,0.08), 0 2px 4px rgba(0,0,0,0.04);
  --shadow-lg: 0 8px 24px rgba(0,71,143,0.10), 0 4px 8px rgba(0,0,0,0.04);
  --shadow-xl: 0 16px 48px rgba(0,71,143,0.12), 0 8px 16px rgba(0,0,0,0.06);
}

/* ---- Animations ---- */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes badgePulse {
  0%, 100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(255, 93, 0, 0.4); }
  50%       { transform: scale(1.08); box-shadow: 0 0 0 5px rgba(255, 93, 0, 0); }
}

@keyframes shimmer {
  0%   { background-position: -200% 0; }
  100% { background-position:  200% 0; }
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@keyframes slideDown {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ---- Scrollbars ---- */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--gray-300); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--gray-400); }

/* ---- Reset & Base ---- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-sans);
  font-size: var(--font-size-base);
  color: var(--text-primary);
  background: var(--page-bg);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

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

img { max-width: 100%; }

/* ---- Layout ---- */
.app-layout {
  display: flex;
  min-height: 100vh;
}

/* ---- Sidebar ---- */
.sidebar {
  width: var(--sidebar-width);
  height: 100vh;
  background: linear-gradient(160deg, var(--navy-900) 0%, var(--navy-800) 55%, var(--primary) 100%);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  z-index: 100;
  overflow-y: auto;
  overflow-x: hidden;
  transition: transform var(--transition-slow);
  box-shadow: 2px 0 20px rgba(0, 0, 0, 0.18);
}

.sidebar::-webkit-scrollbar { width: 3px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 2px; }
.sidebar::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.28); }

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 22px 18px 20px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  flex-shrink: 0;
}

.sidebar-logo {
  width: 36px;
  height: 36px;
  object-fit: contain;
  flex-shrink: 0;
}

.sidebar-brand-text { line-height: 1.2; }

.sidebar-brand-name {
  font-size: var(--font-size-sm);
  font-weight: 700;
  color: white;
  letter-spacing: 0.01em;
}

.sidebar-brand-sub {
  font-size: 0.6875rem;
  color: rgba(255,255,255,0.45);
  margin-top: 1px;
}

.sidebar-section { padding: 4px 0; }

.sidebar-section-title {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: rgba(255,255,255,0.32);
  padding: 16px 18px 6px;
}

.sidebar-nav { list-style: none; }

.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 2px 8px;
  padding: 9px 12px;
  color: rgba(255,255,255,0.62);
  font-size: var(--font-size-sm);
  font-weight: 500;
  text-decoration: none;
  border-radius: 8px;
  transition: background var(--transition), color var(--transition), transform var(--transition);
  position: relative;
}

.sidebar-nav a:hover {
  background: rgba(255,255,255,0.1);
  color: rgba(255,255,255,0.96);
  text-decoration: none;
  transform: translateX(2px);
}

.sidebar-nav a.active {
  background: rgba(255,255,255,0.14);
  color: white;
  font-weight: 600;
}

.sidebar-nav a.active::before {
  content: "";
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 65%;
  background: var(--cta);
  border-radius: 0 3px 3px 0;
  box-shadow: 0 0 8px rgba(255,93,0,0.5);
}

.sidebar-nav svg {
  width: 17px;
  height: 17px;
  opacity: 0.7;
  flex-shrink: 0;
  transition: opacity var(--transition);
}

.sidebar-nav a:hover svg,
.sidebar-nav a.active svg {
  opacity: 1;
}

.nav-badge {
  margin-left: auto;
  background: var(--cta);
  color: white;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 7px;
  border-radius: 10px;
  min-width: 19px;
  text-align: center;
  box-shadow: 0 2px 6px rgba(255,93,0,0.4);
  animation: badgePulse 2.5s ease-in-out infinite;
}

.sidebar-footer {
  margin-top: auto;
  border-top: 1px solid rgba(255,255,255,0.09);
  padding: 14px 16px;
  flex-shrink: 0;
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
}

.sidebar-avatar {
  width: 34px;
  height: 34px;
  background: rgba(255,255,255,0.14);
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  color: white;
  flex-shrink: 0;
  transition: background var(--transition);
}

.sidebar-user:hover .sidebar-avatar {
  background: rgba(255,255,255,0.22);
}

.sidebar-user-info {
  flex: 1;
  min-width: 0;
}

.sidebar-username {
  font-size: var(--font-size-sm);
  font-weight: 600;
  color: white;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-logout {
  font-size: var(--font-size-xs);
  color: rgba(255,255,255,0.4);
  transition: color var(--transition);
}

.sidebar-logout:hover {
  color: rgba(255,100,100,0.85);
  text-decoration: none;
}

/* ---- Main Content ---- */
.main-content {
  flex: 1;
  min-width: 0;
  margin-left: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ---- Top Bar ---- */
.topbar {
  height: var(--topbar-height);
  background: var(--white);
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
  padding: 0 28px;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: 0 1px 0 var(--gray-200), 0 2px 8px rgba(0,71,143,0.04);
}

.topbar-title {
  font-size: var(--font-size-lg);
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.01em;
}

.topbar-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ---- Page Content ---- */
.page-content {
  padding: 28px;
  flex: 1;
  animation: fadeInUp 0.22s cubic-bezier(0.4, 0, 0.2, 1);
}

.page-header { margin-bottom: 24px; }

.page-header h1 {
  font-size: 1.625rem;
  font-weight: 800;
  color: var(--text-primary);
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.page-header p {
  color: var(--text-secondary);
  margin-top: 5px;
  font-size: var(--font-size-sm);
}

/* ---- Stat Cards ---- */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--white);
  border-radius: var(--border-radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--gray-200);
  display: flex;
  align-items: flex-start;
  gap: 16px;
  transition: transform var(--transition), box-shadow var(--transition);
  min-width: 120px;
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}

.stat-card-warning {
  border-color: var(--warning-border);
  background: var(--warning-light);
}
.stat-card-warning .stat-value { color: var(--warning); }

.stat-card-success { border-color: var(--success-border); background: var(--success-light); }
.stat-card-success .stat-value { color: var(--success); }

.stat-icon {
  width: 48px;
  height: 48px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.stat-icon svg { width: 24px; height: 24px; }

.stat-icon-blue   { background: var(--primary-light); color: var(--primary); }
.stat-icon-green  { background: var(--success-light); color: var(--success); }
.stat-icon-orange { background: var(--cta-light);     color: var(--cta); }
.stat-icon-red    { background: var(--danger-light);  color: var(--danger); }
.stat-icon-navy   { background: var(--primary-light); color: var(--navy-800); }

.stat-body { flex: 1; min-width: 0; }

.stat-label {
  font-size: var(--font-size-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-muted);
}

.stat-value {
  font-size: 1.875rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
  margin-top: 2px;
  letter-spacing: -0.02em;
}

.stat-sub {
  font-size: var(--font-size-xs);
  color: var(--text-muted);
  margin-top: 3px;
}

.stat-action {
  display: inline-block;
  font-size: var(--font-size-xs);
  color: var(--primary);
  margin-top: 4px;
  font-weight: 600;
  transition: color var(--transition);
}
.stat-action:hover { color: var(--cta); text-decoration: underline; }

/* ---- Cards ---- */
.card {
  background: var(--white);
  border-radius: var(--border-radius-lg);
  border: 1px solid var(--gray-200);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  transition: box-shadow var(--transition);
}

.card-hover {
  transition: transform var(--transition), box-shadow var(--transition);
}
.card-hover:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--gray-100);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--white);
}

.card-title {
  font-size: var(--font-size-base);
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.01em;
}

.card-body { padding: 20px; }

.card-footer {
  padding: 12px 20px;
  border-top: 1px solid var(--gray-100);
  background: var(--gray-50);
}

.card-padded { padding: 1.25rem; }

.card-section-header {
  padding: 10px 20px;
  border-bottom: 1px solid var(--gray-200);
  background: var(--gray-50);
  display: flex;
  align-items: center;
  gap: 8px;
}
.card-section-header strong { font-size: var(--font-size-sm); color: var(--text-primary); }
.card-section-header .muted { font-size: var(--font-size-xs); }

/* ---- Grid ---- */
.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 20px;
}
.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
}
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

/* ---- Tables ---- */
.table-container { overflow-x: auto; }

table,
.table,
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--font-size-sm);
}

thead th,
.table thead th,
.data-table thead th {
  background: var(--gray-50);
  color: var(--text-secondary);
  font-weight: 600;
  font-size: var(--font-size-xs);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  padding: 10px 16px;
  text-align: left;
  border-bottom: 2px solid var(--gray-200);
  white-space: nowrap;
}

tbody tr,
.table tbody tr,
.data-table tbody tr {
  border-bottom: 1px solid var(--gray-100);
  transition: background var(--transition);
}

tbody tr:hover,
.table tbody tr:hover,
.data-table tbody tr:hover {
  background: var(--primary-xlight);
}

tr.clickable-row { cursor: pointer; }

tbody td,
.table tbody td,
.data-table tbody td {
  padding: 12px 16px;
  color: var(--text-primary);
  vertical-align: middle;
}

tbody tr:last-child,
.table tbody tr:last-child,
.data-table tbody tr:last-child {
  border-bottom: none;
}

.td-muted {
  color: var(--text-muted);
  font-size: var(--font-size-xs);
}

/* ---- Badges ---- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: 20px;
  font-size: var(--font-size-xs);
  font-weight: 600;
  white-space: nowrap;
  letter-spacing: 0.01em;
}

.badge-success {
  background: var(--success-light);
  color: var(--success);
  border: 1px solid var(--success-border);
}

.badge-warning {
  background: var(--warning-light);
  color: var(--warning);
  border: 1px solid var(--warning-border);
}

.badge-danger {
  background: var(--danger-light);
  color: var(--danger);
  border: 1px solid var(--danger-border);
}

.badge-blue {
  background: var(--primary-light);
  color: var(--primary);
  border: 1px solid #b3cce8;
}

.badge-info {
  background: var(--primary-light);
  color: var(--primary);
  border: 1px solid #b3cce8;
}

.badge-gray {
  background: var(--gray-100);
  color: var(--slate);
  border: 1px solid var(--gray-300);
}

.badge-navy {
  background: var(--primary-light);
  color: var(--primary);
  border: 1px solid #b3cce8;
}

.badge-secondary { background: var(--gray-100); color: var(--gray-600); border: 1px solid var(--gray-300); }

/* Intent badges */
.badge-intent-order_enquiry   { background: var(--primary-light); color: var(--primary);    border: 1px solid #b3cce8; }
.badge-intent-po_submission   { background: var(--success-light); color: var(--success);    border: 1px solid var(--success-border); }
.badge-intent-delivery_follow_up { background: var(--warning-light); color: var(--warning); border: 1px solid var(--warning-border); }
.badge-intent-complaint       { background: var(--danger-light);  color: var(--danger);     border: 1px solid var(--danger-border); }
.badge-intent-price_request   { background: #f3e5f5; color: #6a1b9a; border: 1px solid #ce93d8; }
.badge-intent-sample_request  { background: #e0f7fa; color: #006064; border: 1px solid #80deea; }
.badge-intent-general         { background: var(--gray-100); color: var(--slate); border: 1px solid var(--gray-300); }
.badge-intent-spam            { background: var(--gray-50);  color: var(--gray-500); border: 1px solid var(--gray-200); }

/* ---- Buttons ---- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--border-radius);
  font-size: var(--font-size-sm);
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  text-decoration: none;
  line-height: 1.4;
  transition: all var(--transition);
  white-space: nowrap;
  letter-spacing: 0.01em;
  font-family: var(--font-sans);
}

.btn:hover {
  text-decoration: none;
  transform: translateY(-1px);
}

.btn:active { transform: translateY(0); }

.btn svg {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
}

.btn-primary {
  background: var(--cta);
  color: white;
  border-color: var(--cta);
  box-shadow: 0 1px 3px rgba(255, 93, 0, 0.28);
}
.btn-primary:hover {
  background: var(--cta-dark);
  color: white;
  box-shadow: 0 4px 14px rgba(255, 93, 0, 0.38);
}

.btn-success {
  background: var(--success);
  color: white;
  border-color: var(--success);
  box-shadow: 0 1px 3px rgba(5,150,105,0.25);
}
.btn-success:hover { background: #047857; color: white; box-shadow: 0 4px 12px rgba(5,150,105,0.3); }

.btn-danger {
  background: var(--danger);
  color: white;
  border-color: var(--danger);
  box-shadow: 0 1px 3px rgba(220,38,38,0.25);
}
.btn-danger:hover { background: #b91c1c; color: white; box-shadow: 0 4px 12px rgba(220,38,38,0.3); }

.btn-warning {
  background: var(--warning);
  color: white;
  border-color: var(--warning);
  box-shadow: 0 1px 3px rgba(217,119,6,0.25);
}
.btn-warning:hover { background: #b45309; color: white; }

.btn-blue {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
  box-shadow: 0 1px 3px rgba(0,71,143,0.25);
}
.btn-blue:hover { background: var(--primary-dark); color: white; box-shadow: 0 4px 12px rgba(0,71,143,0.3); }

.btn-outline {
  background: var(--white);
  color: var(--text-secondary);
  border-color: var(--gray-300);
}
.btn-outline:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-light);
}

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border-color: transparent;
}
.btn-ghost:hover {
  background: var(--gray-100);
  color: var(--text-primary);
}

.btn-secondary {
  background: var(--white);
  color: var(--text-secondary);
  border-color: var(--gray-300);
}
.btn-secondary:hover {
  background: var(--gray-50);
  color: var(--text-primary);
  border-color: var(--gray-400);
}

.btn-sm  { padding: 5px 12px; font-size: var(--font-size-xs); }
.btn-lg  { padding: 12px 24px; font-size: var(--font-size-base); }
.btn-xs  { font-size: 0.6875rem; padding: 3px 8px; border-radius: 5px; }
.btn-full { width: 100%; justify-content: center; }

/* ---- Forms ---- */
.form-group {
  margin-bottom: 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.form-label {
  display: block;
  font-size: var(--font-size-sm);
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 5px;
}

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1.5px solid var(--gray-300);
  border-radius: var(--border-radius);
  font-size: var(--font-size-sm);
  font-family: var(--font-sans);
  color: var(--text-primary);
  background: var(--white);
  transition: border-color var(--transition), box-shadow var(--transition), background var(--transition);
  line-height: 1.5;
}

.form-input:hover,
.form-select:hover,
.form-textarea:hover {
  border-color: var(--gray-400);
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(0, 71, 143, 0.12);
  background: var(--white);
}

.form-textarea { min-height: 100px; resize: vertical; }

.form-hint {
  font-size: var(--font-size-xs);
  color: var(--text-muted);
  margin-top: 4px;
}

.form-inline {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  flex-wrap: wrap;
}

.form-inline .form-group {
  margin-bottom: 0;
  flex: 1;
  min-width: 150px;
}

.form-input-sm { padding: 5px 9px; font-size: var(--font-size-xs); }

select.form-input,
select.form-select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%237b8399' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 11px center;
  padding-right: 30px;
  cursor: pointer;
}

textarea.form-input { resize: vertical; min-height: 60px; }

.required { color: var(--danger); }

.search-input {
  height: 37px;
  padding: 0 12px;
  border: 1.5px solid var(--gray-300);
  border-radius: var(--border-radius);
  font-size: var(--font-size-sm);
  font-family: var(--font-sans);
  color: var(--text-primary);
  background: var(--white);
  transition: border-color var(--transition), box-shadow var(--transition);
}
.search-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(0, 71, 143, 0.12);
}

.select-input {
  height: 37px;
  padding: 0 30px 0 12px;
  border: 1.5px solid var(--gray-300);
  border-radius: var(--border-radius);
  font-size: var(--font-size-sm);
  font-family: var(--font-sans);
  color: var(--text-primary);
  background: var(--white) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%237b8399' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E") no-repeat right 10px center;
  appearance: none;
  transition: border-color var(--transition);
  cursor: pointer;
}
.select-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(0, 71, 143, 0.12);
}

.inline-form { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* ---- Alerts ---- */
.alert {
  padding: 12px 16px;
  border-radius: var(--border-radius);
  font-size: var(--font-size-sm);
  margin-bottom: 16px;
  border: 1px solid transparent;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  animation: slideDown 0.2s ease-out;
}

.alert svg { width: 17px; height: 17px; flex-shrink: 0; margin-top: 1px; }

.alert-success  { background: var(--success-light); color: var(--success);  border-color: var(--success-border); }
.alert-warning  { background: var(--warning-light); color: var(--warning);  border-color: var(--warning-border); }
.alert-danger   { background: var(--danger-light);  color: var(--danger);   border-color: var(--danger-border); }
.alert-error    { background: var(--danger-light);  color: var(--danger);   border-color: var(--danger-border); }
.alert-info     { background: var(--primary-light); color: var(--navy-800); border-color: #b3cce8; }

/* ---- Confidence Bar ---- */
.confidence-bar-wrapper {
  display: flex;
  align-items: center;
  gap: 8px;
}

.confidence-bar {
  flex: 1;
  height: 6px;
  background: var(--gray-200);
  border-radius: 3px;
  overflow: hidden;
}

.confidence-bar-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.confidence-bar-fill.high   { background: var(--success); }
.confidence-bar-fill.medium { background: var(--warning); }
.confidence-bar-fill.low    { background: var(--danger); }

.confidence-value {
  font-size: var(--font-size-xs);
  font-weight: 600;
  color: var(--text-secondary);
  min-width: 38px;
  text-align: right;
}

/* ---- Pagination ---- */
.pagination {
  display: flex;
  align-items: center;
  gap: 4px;
  justify-content: center;
  padding: 16px;
}

.pagination a,
.pagination span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: var(--border-radius);
  font-size: var(--font-size-sm);
  font-weight: 500;
  text-decoration: none;
  transition: all var(--transition);
}

.pagination a {
  color: var(--primary);
  border: 1px solid var(--gray-200);
}

.pagination a:hover {
  background: var(--primary-light);
  border-color: var(--primary);
  text-decoration: none;
}

.pagination .current {
  background: var(--primary);
  color: white;
  border: 1px solid var(--primary);
  font-weight: 700;
}

.pagination .disabled { color: var(--gray-400); cursor: default; }

/* ---- Charts ---- */
.chart-container { position: relative; width: 100%; }
.charts-row { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-bottom: 20px; }

/* ---- Empty State ---- */
.empty-state {
  text-align: center;
  padding: 52px 24px;
  color: var(--text-muted);
}

.empty-state svg {
  width: 48px;
  height: 48px;
  opacity: 0.25;
  margin-bottom: 14px;
}

.empty-state h3 {
  font-size: var(--font-size-lg);
  font-weight: 700;
  color: var(--gray-500);
  margin-bottom: 6px;
}

.empty-state p { font-size: var(--font-size-sm); }

/* ---- Filter Bar ---- */
.filter-bar {
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--border-radius-lg);
  padding: 16px 20px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-xs);
}

.filter-bar form {
  display: flex;
  gap: 12px;
  align-items: flex-end;
  flex-wrap: wrap;
}

.filter-bar .form-group {
  margin: 0;
  min-width: 150px;
}

/* ---- Email Body Preview ---- */
.email-body-preview {
  background: var(--gray-50);
  border: 1px solid var(--gray-200);
  border-radius: var(--border-radius);
  padding: 16px;
  font-size: var(--font-size-sm);
  line-height: 1.75;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 300px;
  overflow-y: auto;
  font-family: var(--font-sans);
}

.draft-textarea {
  width: 100%;
  min-height: 200px;
  padding: 16px;
  border: 1.5px solid var(--gray-200);
  border-radius: var(--border-radius);
  font-size: var(--font-size-sm);
  font-family: var(--font-sans);
  line-height: 1.75;
  resize: vertical;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.draft-textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(0, 71, 143, 0.12);
}

/* ---- Meta Info ---- */
.meta-list {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 6px 16px;
  font-size: var(--font-size-sm);
}

.meta-list dt { font-weight: 600; color: var(--text-secondary); white-space: nowrap; }
.meta-list dd { color: var(--text-primary); }

.info-table { width: 100%; font-size: var(--font-size-sm); border-collapse: collapse; }
.info-table th { width: 42%; color: var(--text-muted); font-weight: 500; padding: 3px 0; vertical-align: top; }
.info-table td { padding: 3px 0 3px 8px; color: var(--text-primary); }

/* ---- PO Lines ---- */
.po-lines-table th { white-space: nowrap; }

/* ---- Upload Drop Zone ---- */
.upload-zone {
  border: 2px dashed var(--gray-300);
  border-radius: var(--border-radius-lg);
  padding: 36px;
  text-align: center;
  cursor: pointer;
  transition: border-color var(--transition-slow), background var(--transition-slow);
}

.upload-zone:hover,
.upload-zone.drag-over {
  border-color: var(--primary);
  background: var(--primary-light);
}

.upload-zone svg { width: 40px; height: 40px; color: var(--gray-400); margin-bottom: 10px; }

/* ---- Login Page ---- */
.login-body {
  background: linear-gradient(135deg, var(--navy-900) 0%, var(--primary) 60%, #1258a0 100%);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-wrapper { width: 100%; max-width: 400px; padding: 24px; }

.login-card {
  background: #ffffff;
  border-radius: 20px;
  padding: 44px 40px;
  box-shadow: var(--shadow-xl);
}

.login-card .form-group { margin-bottom: 18px; }

.login-card .form-label {
  color: #0d1f3c;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 7px;
}

.login-card .form-input {
  color: #0d1f3c;
  background: #f8f9fc;
  border: 1.5px solid #e2e5ee;
  border-radius: 10px;
  padding: 11px 14px;
  font-size: 0.9375rem;
  transition: border-color var(--transition), background var(--transition), box-shadow var(--transition);
}

.login-card .form-input::placeholder { color: #9aa3b8; }

.login-card .form-input:hover { border-color: #c7cde0; }

.login-card .form-input:focus {
  background: #ffffff;
  border-color: #00478f;
  box-shadow: 0 0 0 3px rgba(0, 71, 143, 0.14);
}

.login-card .btn-primary {
  background: #ff6b35;
  border-color: #ff6b35;
  box-shadow: 0 2px 10px rgba(255, 107, 53, 0.3);
}

.login-card .btn-primary:hover {
  background: #e4531f;
  border-color: #e4531f;
  box-shadow: 0 4px 16px rgba(228, 83, 31, 0.4);
}

.login-card .alert-danger {
  background: #fef2f2;
  color: #dc2626;
  border-color: #fca5a5;
}

.login-brand { text-align: center; margin-bottom: 32px; }

.login-logo-full {
  display: inline-block;
  width: 100%;
  max-width: 240px;
  height: auto;
  object-fit: contain;
  margin-bottom: 8px;
}

.login-title {
  font-size: var(--font-size-2xl);
  font-weight: 800;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}

.login-subtitle { font-size: var(--font-size-sm); color: var(--text-muted); margin-top: 3px; }

.login-form .btn-primary { margin-top: 8px; }

/* ---- Activity Feed ---- */
.activity-item {
  display: flex;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--gray-100);
}
.activity-item:last-child { border-bottom: none; }

.activity-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--primary);
  margin-top: 6px;
  flex-shrink: 0;
}

.activity-text {
  font-size: var(--font-size-sm);
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.activity-time { font-size: var(--font-size-xs); color: var(--text-muted); }

/* ---- Breadcrumbs ---- */
.breadcrumb {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: var(--font-size-sm);
  color: var(--text-muted);
  margin-bottom: 16px;
}
.breadcrumb a { color: var(--primary); }
.breadcrumb span { color: var(--gray-300); }

/* ---- Utilities ---- */
.text-muted    { color: var(--text-muted); }
.muted         { color: var(--text-muted); }
small.muted    { font-size: var(--font-size-xs); }
.text-success  { color: var(--success); }
.text-danger   { color: var(--danger); }
.text-warning  { color: var(--warning); }
.text-accent   { color: var(--primary); }
.font-mono     { font-family: var(--font-mono); }
.text-sm       { font-size: var(--font-size-sm); }
.text-xs       { font-size: var(--font-size-xs); }
.fw-600        { font-weight: 600; }
.fw-700        { font-weight: 700; }
.mb-0  { margin-bottom: 0 !important; }
.mb-8  { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.mb-24 { margin-bottom: 24px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.flex           { display: flex; }
.flex-gap-8     { gap: 8px; }
.flex-gap-12    { gap: 12px; }
.items-center   { align-items: center; }
.justify-between{ justify-content: space-between; }
.wrap           { flex-wrap: wrap; }
.subtitle       { color: var(--text-secondary); font-size: var(--font-size-sm); margin-top: 3px; }

/* Animation utilities */
.skeleton {
  background: linear-gradient(90deg, var(--gray-100) 25%, var(--gray-50) 50%, var(--gray-100) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--border-radius);
}
.spin { animation: spin 0.8s linear infinite; }

/* ---- Small inline confidence bar (canvas/tables) ---- */
.conf-bar-wrap {
  display: inline-block;
  width: 60px;
  height: 5px;
  background: var(--gray-200);
  border-radius: 3px;
  overflow: hidden;
  vertical-align: middle;
}
.conf-bar {
  display: block;
  height: 5px;
  background: var(--primary);
  border-radius: 3px;
  transition: width 0.4s ease;
}

/* ---- Progress bars ---- */
.progress-bar-outer { height: 8px; background: var(--gray-100); border-radius: 4px; overflow: hidden; }
.progress-bar-inner { height: 100%; background: var(--primary); border-radius: 4px; transition: width 0.4s ease; }

/* ---- Tag pills ---- */
.tag {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  background: var(--gray-100);
  border: 1px solid var(--gray-200);
  border-radius: 5px;
  font-size: var(--font-size-xs);
  color: var(--text-secondary);
  white-space: nowrap;
  font-weight: 500;
}
.tag-blue   { background: var(--primary-light); border-color: #b3cce8; color: var(--primary); }
.tag-green  { background: var(--success-light); border-color: var(--success-border); color: var(--success); }
.tag-orange { background: var(--cta-light);     border-color: var(--cta-border);     color: var(--cta); }
.tag-red    { background: var(--danger-light);  border-color: var(--danger-border);  color: var(--danger); }

/* ---- Status Chips ---- */
.status-chips { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 16px; }

.stat-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 12px;
  background: var(--white);
  border: 1.5px solid var(--gray-200);
  border-radius: 20px;
  font-size: var(--font-size-xs);
  color: var(--text-secondary);
  text-decoration: none;
  font-weight: 500;
  transition: all var(--transition);
  cursor: pointer;
}
.stat-chip:hover { border-color: var(--primary); color: var(--primary); text-decoration: none; }
.stat-chip.active { background: var(--primary); color: white; border-color: var(--primary); }

.chip-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  background: rgba(0,0,0,0.12);
  border-radius: 9px;
  font-size: 10px;
  font-weight: 700;
}
.stat-chip.active .chip-count { background: rgba(255,255,255,0.28); }

/* ---- Critical Path ---- */
.cp-task         { padding: 12px 20px; border-bottom: 1px solid var(--gray-100); transition: background var(--transition); }
.cp-task:last-child { border-bottom: none; }
.cp-task-overdue { background: #fffbeb; border-left: 3px solid var(--warning); }
.cp-task-done    { background: #f0fdf4; opacity: 0.88; }
.cp-task-active  { background: var(--primary-xlight); }
.cp-task-blocked { background: var(--danger-light); border-left: 3px solid var(--danger); }
.cp-task-header  { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.cp-task-left    { display: flex; gap: 10px; align-items: flex-start; flex: 1; }
.cp-task-right   { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; flex-shrink: 0; }
.cp-task-title   { font-weight: 600; font-size: var(--font-size-sm); }
.cp-task-desc    { font-size: 0.8rem; color: var(--text-muted); margin-top: 2px; }
.cp-status-icon  { font-size: 1rem; flex-shrink: 0; margin-top: 1px; }
.cp-meta         { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; }
.cp-responsible  { font-size: 0.7rem; padding: 2px 8px; border-radius: 12px; background: var(--gray-100); color: var(--text-secondary); }
.cp-responsible-clara        { background: #dbeafe; color: #1d4ed8; }
.cp-responsible-merchandiser { background: #fef3c7; color: #92400e; }
.cp-responsible-buyer        { background: #fce7f3; color: #9d174d; }
.cp-responsible-production   { background: #d1fae5; color: #065f46; }
.cp-responsible-supplier     { background: #f3e8ff; color: #6b21a8; }
.cp-responsible-qa           { background: #e0f2fe; color: #0369a1; }
.cp-responsible-logistics    { background: #fff7ed; color: #9a3412; }
.cp-date         { font-size: 0.75rem; color: var(--text-muted); }
.cp-date-overdue { color: var(--danger); font-weight: 600; }
.cp-completion-note { font-size: 0.75rem; color: var(--text-muted); text-align: right; }
.cp-subtasks     { margin: 8px 0 0 28px; padding: 8px 12px; background: var(--gray-50); border-radius: 6px; }
.cp-subtask      { display: flex; align-items: center; gap: 6px; padding: 3px 0; font-size: 0.8rem; }
.subtask-toggle  { background: none; border: none; cursor: pointer; font-size: 1rem; padding: 0; line-height: 1; }
.subtask-done    { color: var(--success); }
.subtask-text-done { text-decoration: line-through; color: var(--text-muted); }

/* ---- Costing row highlights ---- */
.row-danger td  { background: var(--danger-light) !important; }
.row-warning td { background: var(--warning-light) !important; }
.row-success td { background: var(--success-light) !important; }

/* ---- Production stage bars ---- */
.prod-row         { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.prod-stage-label { width: 72px; color: var(--text-secondary); font-size: var(--font-size-xs); flex-shrink: 0; }
.prod-bar-wrap    { flex: 1; background: var(--gray-100); border-radius: 3px; height: 8px; overflow: hidden; }
.prod-bar         { height: 100%; background: var(--primary); border-radius: 3px; transition: width 0.4s ease; }
.prod-qty         { width: 60px; text-align: right; color: var(--text-muted); font-size: var(--font-size-xs); }

/* ---- Responsive ---- */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; }
  .stat-grid { grid-template-columns: 1fr 1fr; }
  .grid-2, .grid-3, .charts-row { grid-template-columns: 1fr; }
  .page-content { padding: 16px; }
  .filter-bar form { flex-direction: column; }
  .topbar-title { font-size: var(--font-size-base); }
  .topbar { padding: 0 16px; }
}

@media (max-width: 480px) {
  .stat-grid { grid-template-columns: 1fr; }
  .topbar { flex-wrap: wrap; height: auto; min-height: var(--topbar-height); padding: 10px 16px; row-gap: 6px; }
  .topbar-title { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
  .topbar-actions { margin-left: 0; flex-wrap: wrap; }
}

@media (max-width: 800px) {
  .grid-2, .form-grid { grid-template-columns: 1fr; }
}

@media print {
  .sidebar, .topbar { display: none; }
  .main-content { margin-left: 0; }
}

/* ============================================================
   Canvas & extra utilities
   ============================================================ */

.stat-card-warning { border-color: var(--warning-border); background: var(--warning-light); }
.stat-card-warning .stat-value { color: var(--warning); }

/* ============================================================
   Agent Skills Editor
   ============================================================ */

.skill-editor-layout {
  display: grid;
  grid-template-columns: 340px 1fr;
  gap: 20px;
  align-items: start;
}

.skill-meta-panel { display: flex; flex-direction: column; gap: 16px; }

.skill-content-panel .card {
  display: flex;
  flex-direction: column;
  min-height: 560px;
}

.skill-content-editor {
  width: 100%;
  min-height: 460px;
  padding: 20px;
  border: none;
  border-radius: 0;
  font-size: var(--font-size-sm);
  font-family: var(--font-mono);
  color: var(--text-primary);
  background: var(--surface-subtle);
  resize: vertical;
  line-height: 1.75;
  outline: none;
  flex: 1;
  transition: background var(--transition);
}

.skill-content-editor:focus {
  background: var(--white);
  box-shadow: inset 0 0 0 2px var(--primary);
}

.skill-preview-pane {
  font-size: var(--font-size-sm);
  line-height: 1.8;
  color: var(--text-primary);
}

.skill-preview-pane h1, .skill-preview-pane h2, .skill-preview-pane h3 {
  margin-top: 20px; margin-bottom: 8px; color: var(--text-primary);
}
.skill-preview-pane h1 { font-size: var(--font-size-xl); }
.skill-preview-pane h2 { font-size: var(--font-size-lg); }
.skill-preview-pane h3 { font-size: var(--font-size-base); }
.skill-preview-pane p  { margin-bottom: 12px; }
.skill-preview-pane ul, .skill-preview-pane ol { margin-left: 20px; margin-bottom: 12px; }
.skill-preview-pane li { margin-bottom: 4px; }
.skill-preview-pane code {
  background: var(--gray-100); padding: 1px 5px; border-radius: 3px;
  font-family: var(--font-mono); font-size: 0.9em;
}
.skill-preview-pane pre {
  background: var(--gray-100); border: 1px solid var(--gray-200);
  border-radius: var(--border-radius); padding: 14px;
  overflow-x: auto; margin-bottom: 12px;
}
.skill-preview-pane blockquote {
  border-left: 3px solid var(--primary); padding-left: 12px;
  color: var(--text-secondary); margin: 0 0 12px 0;
}
.skill-preview-pane hr { border: none; border-top: 1px solid var(--gray-200); margin: 16px 0; }

.editor-tab-btn {
  background: none;
  border: none;
  padding: 5px 14px;
  border-radius: 6px;
  font-size: var(--font-size-xs);
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition);
  font-family: var(--font-sans);
}
.editor-tab-btn.active {
  background: var(--white);
  color: var(--text-primary);
  box-shadow: var(--shadow-sm);
}
.editor-tab-btn:hover:not(.active) { color: var(--text-secondary); }

@media (max-width: 960px) {
  .skill-editor-layout { grid-template-columns: 1fr; }
}

/* ============================================================
   System Settings
   ============================================================ */

.settings-layout {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 20px;
  align-items: start;
}

.settings-nav-panel {
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--border-radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  padding: 8px 0;
}

.settings-nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  color: var(--text-secondary);
  font-size: var(--font-size-sm);
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  border-left: 3px solid transparent;
  transition: all var(--transition);
}
.settings-nav-item:hover {
  background: var(--gray-50);
  color: var(--text-primary);
  text-decoration: none;
}
.settings-nav-item.active {
  background: var(--primary-light);
  color: var(--primary);
  border-left-color: var(--cta);
  font-weight: 600;
}

.settings-nav-icon {
  width: 32px; height: 32px;
  border-radius: var(--border-radius);
  background: var(--gray-100);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: all var(--transition);
}
.settings-nav-item.active .settings-nav-icon {
  background: var(--primary-light);
  color: var(--primary);
}
.settings-nav-icon svg { width: 16px; height: 16px; }

.settings-field {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  align-items: start;
  padding: 20px 0;
  border-bottom: 1px solid var(--gray-100);
}
.settings-field:last-child { border-bottom: none; }

.settings-field-label {
  display: block;
  font-size: var(--font-size-sm);
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 4px;
}
.settings-field-desc {
  font-size: var(--font-size-xs);
  color: var(--text-muted);
  line-height: 1.55;
  margin-bottom: 4px;
}
.settings-field-key { font-size: var(--font-size-xs); color: var(--text-muted); }
.settings-field-key code {
  background: var(--gray-100); padding: 1px 4px; border-radius: 3px;
  font-family: var(--font-mono); font-size: 0.9em; color: var(--navy-700);
}

.settings-readonly {
  background: var(--gray-50) !important;
  color: var(--text-muted) !important;
  cursor: not-allowed;
}

/* Toggle Switch */
.toggle-switch {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  user-select: none;
}
.toggle-switch input[type=checkbox] {
  position: absolute; opacity: 0; width: 0; height: 0;
}
.toggle-track {
  width: 44px; height: 24px;
  background: var(--gray-300);
  border-radius: 12px;
  position: relative;
  transition: background 0.22s;
  flex-shrink: 0;
}
.toggle-switch input:checked + .toggle-track { background: var(--primary); }
.toggle-thumb {
  position: absolute; top: 3px; left: 3px;
  width: 18px; height: 18px;
  background: var(--white);
  border-radius: 50%;
  box-shadow: 0 1px 4px rgba(0,0,0,0.2);
  transition: transform 0.22s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.toggle-switch input:checked + .toggle-track .toggle-thumb { transform: translateX(20px); }
.toggle-label { font-size: var(--font-size-sm); font-weight: 600; color: var(--text-secondary); min-width: 60px; }

@media (max-width: 800px) {
  .settings-layout { grid-template-columns: 1fr; }
  .settings-field { grid-template-columns: 1fr; gap: 10px; }
  .settings-nav-panel { display: flex; flex-wrap: wrap; padding: 8px; gap: 4px; }
  .settings-nav-item { border-left: none; border-radius: var(--border-radius); border-bottom: 2px solid transparent; }
  .settings-nav-item.active { border-bottom-color: var(--cta); border-left-color: transparent; }
}

/* ============================================================
   Dashboard — Welcome Banner
   ============================================================ */

.welcome-banner { padding: 4px 0 28px 0; }

.welcome-greeting {
  font-size: 1.625rem;
  font-weight: 800;
  color: var(--text-primary);
  line-height: 1.2;
  letter-spacing: -0.02em;
}

.welcome-sub {
  font-size: var(--font-size-sm);
  color: var(--text-muted);
  margin-top: 5px;
}

/* ============================================================
   Dashboard — Action Required
   ============================================================ */

.action-required {
  background: linear-gradient(135deg, var(--white) 0%, var(--cta-light) 100%);
  border: 1px solid var(--cta-border);
  border-left: 4px solid var(--cta);
  border-radius: var(--border-radius-lg);
  padding: 18px 20px;
  margin-bottom: 24px;
  animation: slideDown 0.25s ease-out;
}

.action-required-title {
  font-size: var(--font-size-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.9px;
  color: var(--cta);
}

.action-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
  margin-top: 14px;
}

.action-card {
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--border-radius-lg);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  box-shadow: var(--shadow-xs);
  transition: transform var(--transition), box-shadow var(--transition);
}
.action-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}

.action-card-count {
  font-size: 2.25rem;
  font-weight: 800;
  line-height: 1;
  letter-spacing: -0.03em;
}

.action-card-label {
  font-size: var(--font-size-xs);
  color: var(--text-secondary);
  font-weight: 500;
}

.action-card-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

/* ============================================================
   Dashboard — KPI Cards
   ============================================================ */

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

.kpi-grid-5 { grid-template-columns: repeat(5, 1fr); }

.kpi-card {
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--border-radius-lg);
  padding: 20px 20px 20px 24px;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition: transform var(--transition), box-shadow var(--transition);
}

.kpi-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}

.kpi-card::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  border-radius: 0 2px 2px 0;
}

.kpi-card-blue::before    { background: var(--primary); }
.kpi-card-green::before   { background: var(--success); }
.kpi-card-orange::before  { background: var(--cta); }
.kpi-card-navy::before    { background: var(--navy-900); }
.kpi-card-warning::before { background: var(--warning); }

.kpi-value {
  font-size: 2.1rem;
  font-weight: 800;
  color: var(--text-primary);
  line-height: 1.1;
  margin-bottom: 2px;
  letter-spacing: -0.03em;
}

.kpi-label {
  font-size: 0.6875rem;
  text-transform: uppercase;
  letter-spacing: 0.9px;
  color: var(--text-muted);
  font-weight: 600;
  margin-bottom: 6px;
}

.kpi-sub { font-size: 0.75rem; color: var(--text-muted); margin-top: 4px; }

@media (max-width: 1100px) {
  .kpi-grid-5 { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 900px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 540px) {
  .kpi-grid { grid-template-columns: 1fr; }
  .action-cards { grid-template-columns: 1fr; }
}

/* ── Role Badges ─────────────────────────────────────────────────────────── */
.role-badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: var(--font-size-xs);
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  white-space: nowrap;
  border: 1px solid transparent;
}
.role-admin       { background: var(--cta-light);     color: var(--cta-dark);    border-color: var(--cta-border); }
.role-manager     { background: var(--primary-light);  color: var(--primary);     border-color: #b3cce8; }
.role-merchandiser{ background: var(--success-light);  color: var(--success);     border-color: var(--success-border); }
.role-finance     { background: #f3e5f5;               color: #7b1fa2;            border-color: #d7b3e8; }
.role-viewer      { background: var(--gray-100);       color: var(--slate);       border-color: var(--gray-300); }

/* ── Role Permission Matrix ──────────────────────────────────────────────── */
.matrix-table th,
.matrix-table td {
  padding: 11px 16px;
  border-bottom: 1px solid var(--gray-100);
  vertical-align: middle;
}
.matrix-table thead th {
  background: var(--gray-50);
  font-weight: 600;
  font-size: var(--font-size-xs);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  padding: 12px 16px;
}
.matrix-table tbody tr:hover { background: var(--primary-xlight); }

.matrix-cell {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 7px;
}
.matrix-cell-full {
  background: var(--success-light);
  color: var(--success);
  border: 1px solid var(--success-border);
}
.matrix-cell-view {
  background: var(--primary-light);
  color: var(--primary);
  border: 1px solid #b3cce8;
}
.matrix-cell-none {
  background: var(--gray-100);
  color: var(--gray-400);
  border: 1px solid var(--gray-200);
}

/* ── Access Control Sidebar Section ─────────────────────────────────────── */
.sidebar-access-divider {
  height: 1px;
  background: rgba(255,255,255,0.08);
  margin: 8px 16px;
}

/* ── Email Review Layout ─────────────────────────────────────────────────── */
.email-review-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  align-items: start;
}
.email-review-left,
.email-review-right {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Email meta block */
.email-meta-block {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 16px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--gray-100);
}
.email-subject {
  font-size: var(--font-size-lg);
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.35;
}
.email-from {
  font-size: var(--font-size-sm);
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.email-attachments {
  font-size: var(--font-size-xs);
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 4px;
}

/* AI summary callout */
.email-ai-summary {
  background: var(--primary-xlight);
  border: 1px solid rgba(0,71,143,0.12);
  border-left: 3px solid var(--primary);
  border-radius: 0 var(--border-radius) var(--border-radius) 0;
  padding: 12px 14px;
  margin-bottom: 16px;
}
.email-ai-summary-label {
  font-size: var(--font-size-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--primary);
  display: flex;
  align-items: center;
  gap: 5px;
  margin-bottom: 5px;
}
.email-ai-summary-text {
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
  line-height: 1.5;
}

/* Email body */
.email-body-text {
  font-size: var(--font-size-sm);
  line-height: 1.65;
  color: var(--text-primary);
  white-space: pre-wrap;
  max-height: 340px;
  overflow-y: auto;
  padding-right: 4px;
}
.email-body-text::-webkit-scrollbar { width: 4px; }
.email-body-text::-webkit-scrollbar-thumb { background: var(--gray-300); border-radius: 2px; }

/* Thread history items */
.thread-item {
  padding: 10px 12px;
  border-left: 3px solid var(--gray-300);
  border-radius: 0 var(--border-radius) var(--border-radius) 0;
  background: var(--gray-50);
  margin-bottom: 10px;
}
.thread-item-sent {
  border-left-color: var(--success);
  background: var(--success-light);
}
.thread-item-received {
  border-left-color: var(--primary);
  background: var(--primary-xlight);
}
.thread-item-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 5px;
  flex-wrap: wrap;
}
.thread-item-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}
.thread-item-subject {
  font-weight: 600;
  font-size: var(--font-size-xs);
  color: var(--text-primary);
  flex: 1;
}
.thread-item-body {
  font-size: var(--font-size-xs);
  color: var(--text-secondary);
  line-height: 1.5;
}
.thread-item-reply {
  margin-top: 6px;
  font-size: var(--font-size-xs);
  color: var(--success);
  font-style: italic;
}

/* Coordination items */
.coordination-item {
  padding: 12px;
  border: 1px solid var(--gray-200);
  border-radius: var(--border-radius);
  margin-bottom: 10px;
  background: var(--gray-50);
}
.coordination-item:last-child { margin-bottom: 0; }

/* Action bar at bottom of draft form */
.email-action-bar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--gray-100);
}

/* Entity grid */
.entity-grid {
  display: grid;
  grid-template-columns: 1fr 2fr;
  gap: 8px 16px;
  font-size: var(--font-size-sm);
}
.entity-grid dt {
  color: var(--text-muted);
  font-weight: 500;
}
.entity-grid dd {
  margin: 0;
  color: var(--text-primary);
  font-weight: 500;
}

/* Star rating */
.star-rating-row {
  display: flex;
  align-items: center;
  gap: 10px;
}
.star-picker {
  display: flex;
  gap: 4px;
}
.star-btn {
  font-size: 1.4rem;
  cursor: pointer;
  color: var(--warning);
  line-height: 1;
  transition: transform var(--transition-bounce);
  user-select: none;
}
.star-btn:hover { transform: scale(1.2); }

@media (max-width: 900px) {
  .email-review-grid {
    grid-template-columns: 1fr;
  }
}

/* ============================================================
   BUSINESS RULES
   ============================================================ */

.rules-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 18px;
}

.rule-card {
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--border-radius-lg);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  transition: box-shadow var(--transition-fast), border-color var(--transition-fast);
}
.rule-card:hover {
  box-shadow: var(--shadow-md);
  border-color: rgba(0,71,143,0.15);
}

.rule-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.rule-card-title {
  font-weight: 700;
  font-size: var(--font-size-base);
  color: var(--text-primary);
}

.rule-card-desc {
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
  line-height: 1.6;
  flex: 1;
}

.rule-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 12px;
  border-top: 1px solid var(--gray-100);
  margin-top: auto;
}

.rule-card-meta {
  font-size: var(--font-size-xs);
  color: var(--text-muted);
}

/* Rule editor two-column layout */
.rule-editor-layout {
  display: grid;
  grid-template-columns: 340px 1fr;
  gap: 20px;
  align-items: start;
}

.rule-structured-form {
  padding: 14px;
  background: var(--gray-50);
  border-radius: var(--border-radius);
  margin-bottom: 14px;
}

.rule-structured-label {
  font-weight: 600;
  font-size: var(--font-size-sm);
  color: var(--primary);
  margin-bottom: 10px;
}

.rule-summary-box {
  background: var(--primary-xlight);
  border: 1px solid rgba(0,71,143,0.12);
  border-radius: var(--border-radius);
  padding: 12px 14px;
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
  line-height: 1.7;
  margin-top: 12px;
}

@media (max-width: 900px) {
  .rule-editor-layout { grid-template-columns: 1fr; }
}

/* ============================================================
   IMPORT WIZARD
   ============================================================ */

.wizard-steps {
  display: flex;
  gap: 0;
  position: relative;
}

.wizard-steps::before {
  content: '';
  position: absolute;
  top: 20px;
  left: 40px;
  right: 40px;
  height: 2px;
  background: var(--gray-200);
  z-index: 0;
}

.wizard-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  flex: 1;
  position: relative;
  z-index: 1;
}

.wizard-step-num {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--white);
  border: 2px solid var(--gray-200);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: var(--font-size-sm);
  color: var(--text-muted);
  transition: all 0.2s;
}

.wizard-step.active .wizard-step-num {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
  box-shadow: 0 0 0 4px rgba(0,71,143,0.15);
}

.wizard-step.done .wizard-step-num {
  background: var(--success);
  border-color: var(--success);
  color: white;
}

.wizard-step-label {
  font-size: var(--font-size-xs);
  font-weight: 600;
  color: var(--text-muted);
  text-align: center;
}

.wizard-step.active .wizard-step-label { color: var(--primary); }
.wizard-step.done  .wizard-step-label  { color: var(--success); }

/* Import mapping table */
.import-mapping-table table { width: 100%; border-collapse: collapse; }
.import-mapping-table th {
  background: var(--gray-50);
  padding: 8px 12px;
  font-size: var(--font-size-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--gray-200);
  text-align: left;
}
.import-mapping-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--gray-100);
  vertical-align: middle;
}

.form-select-sm {
  font-size: var(--font-size-sm);
  padding: 6px 10px;
  height: 34px;
}

/* Validation row colouring */
.validation-row-valid  { background: #f0fdf4; }
.validation-row-warning { background: #fffbeb; }
.validation-row-error   { background: #fff5f5; }

.validation-icon-valid   { color: var(--success); font-weight: 700; }
.validation-icon-warning { color: var(--warning); font-weight: 700; }
.validation-icon-error   { color: var(--danger);  font-weight: 700; }

/* Validation summary chips */
.validation-summary {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.validation-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: 999px;
  font-size: var(--font-size-sm);
  font-weight: 600;
  border: 1px solid transparent;
}

.validation-chip span {
  font-size: var(--font-size-lg);
  font-weight: 800;
}

.validation-chip-valid   { background: #f0fdf4; color: var(--success); border-color: #bbf7d0; }
.validation-chip-warning { background: #fffbeb; color: var(--warning); border-color: #fde68a; }
.validation-chip-error   { background: #fff5f5; color: var(--danger);  border-color: #fecaca; }

/* Import result banner */
.import-result-banner {
  background: linear-gradient(135deg, var(--primary), #0066cc);
  color: white;
  border-radius: var(--border-radius-lg);
  padding: 36px 30px;
  text-align: center;
}

.import-result-number {
  font-size: 56px;
  font-weight: 900;
  line-height: 1;
  margin-bottom: 6px;
}

.import-result-label {
  font-size: var(--font-size-xl);
  opacity: 0.9;
}

/* Upload zone input hidden inside label */
.upload-zone-input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  overflow: hidden;
  clip: rect(0,0,0,0);
}

/* ============================================================
   MAILBOX FORMS
   ============================================================ */

.mailbox-test-result {
  display: none;
  padding: 10px 14px;
  border-radius: var(--border-radius);
  font-size: var(--font-size-sm);
  font-weight: 500;
  border: 1px solid transparent;
}

.mailbox-test-result.loading {
  display: block;
  background: var(--gray-50);
  border-color: var(--gray-200);
  color: var(--text-muted);
}

.mailbox-test-result.success {
  display: block;
  background: #f0fdf4;
  border-color: #bbf7d0;
  color: var(--success);
}

.mailbox-test-result.error {
  display: block;
  background: #fff5f5;
  border-color: #fecaca;
  color: var(--danger);
}

/* ═══════════════════════════════════════════════════════════════════════════
   Smart Search Bar (Odoo-style)
   ─────────────────────────────────────────────────────────────────────────── */

.ssb-wrapper {
  position: relative;
  width: 100%;
  margin-bottom: 20px;
}

/* ── Bar ─────────────────────────────────────────────────────────────────── */
.ssb-bar {
  display: flex;
  align-items: center;
  gap: 4px;
  background: var(--white);
  border: 1.5px solid var(--gray-200);
  border-radius: var(--border-radius-lg);
  padding: 6px 10px 6px 14px;
  min-height: 46px;
  box-shadow: var(--shadow-sm);
  transition: border-color var(--transition), box-shadow var(--transition);
  flex-wrap: wrap;
  cursor: text;
}
.ssb-bar:hover { border-color: var(--gray-300); }
.ssb-bar-focused,
.ssb-bar:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(0,71,143,0.10), var(--shadow-sm);
}

/* ── Search icon ──────────────────────────────────────────────────────────── */
.ssb-icon {
  flex-shrink: 0;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  margin-right: 2px;
}
.ssb-icon svg { width: 16px; height: 16px; }

/* ── Chips ────────────────────────────────────────────────────────────────── */
.ssb-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  flex-shrink: 0;
}

.ssb-chip {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  background: var(--primary-xlight);
  border: 1px solid rgba(0,71,143,0.20);
  border-radius: 5px;
  padding: 2px 4px 2px 8px;
  font-size: var(--font-size-xs);
  line-height: 1.4;
  white-space: nowrap;
  animation: fadeInUp 0.12s ease;
}
.ssb-chip-label { color: var(--primary); font-weight: 700; }
.ssb-chip-value { color: var(--text-primary); font-weight: 500; }
.ssb-chip-remove {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px; height: 16px;
  border: none; background: none;
  cursor: pointer; padding: 0;
  color: var(--text-muted);
  font-size: 15px; line-height: 1;
  border-radius: 3px;
  transition: background var(--transition), color var(--transition);
  margin-left: 1px;
}
.ssb-chip-remove:hover { background: rgba(0,71,143,0.12); color: var(--primary); }

/* ── Text input ───────────────────────────────────────────────────────────── */
.ssb-input {
  flex: 1;
  min-width: 120px;
  border: none; outline: none; background: transparent;
  font-family: var(--font-sans);
  font-size: var(--font-size-sm);
  color: var(--text-primary);
  padding: 2px 0;
}
.ssb-input::placeholder { color: var(--text-muted); }

/* ── Keyboard hint ────────────────────────────────────────────────────────── */
.ssb-kbd-hint {
  font-size: 10px; font-family: var(--font-mono);
  color: var(--text-muted); opacity: 0.6;
  background: var(--gray-100);
  border: 1px solid var(--gray-200);
  border-radius: 4px;
  padding: 1px 5px;
  flex-shrink: 0;
  pointer-events: none;
}
.ssb-bar-focused .ssb-kbd-hint,
.ssb-bar:focus-within .ssb-kbd-hint { opacity: 0; }

/* ── Right controls ───────────────────────────────────────────────────────── */
.ssb-controls {
  display: flex; align-items: center; gap: 6px;
  flex-shrink: 0; margin-left: auto;
}
.ssb-divider { width: 1px; height: 18px; background: var(--gray-200); }

.ssb-clear-btn {
  display: flex; align-items: center; justify-content: center;
  width: 22px; height: 22px;
  border: none; background: none; cursor: pointer;
  color: var(--text-muted); border-radius: 50%;
  transition: background var(--transition), color var(--transition);
}
.ssb-clear-btn:hover { background: var(--danger-light); color: var(--danger); }

.ssb-filter-btn {
  display: inline-flex; align-items: center; gap: 5px;
  border: 1px solid var(--gray-200); background: var(--white);
  border-radius: 6px; padding: 4px 10px;
  font-size: var(--font-size-xs); font-weight: 600;
  color: var(--text-secondary); cursor: pointer;
  transition: all var(--transition); white-space: nowrap;
  font-family: var(--font-sans);
}
.ssb-filter-btn:hover,
.ssb-filter-btn-active {
  border-color: var(--primary); color: var(--primary); background: var(--primary-xlight);
}
.ssb-filter-count {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 17px; height: 17px; padding: 0 4px;
  background: var(--cta); color: white;
  border-radius: 9px; font-size: 10px; font-weight: 700; line-height: 1;
}

/* ── Dropdown ─────────────────────────────────────────────────────────────── */
.ssb-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  left: 0; right: 0;
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--border-radius-lg);
  box-shadow: var(--shadow-lg);
  z-index: 300;
  padding: 8px;
  animation: slideDown 0.15s ease;
}
.ssb-dropdown[style*="display: block"],
.ssb-dropdown[style*="display:block"] {
  display: grid !important;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 0 20px;
}

/* ── Sections ─────────────────────────────────────────────────────────────── */
.ssb-section { padding: 4px 0 8px; min-width: 0; }
.ssb-section + .ssb-section {
  border-top: 1px solid var(--gray-100);
  padding-top: 8px;
  margin-top: 0;
}
.ssb-section-title {
  font-size: 10px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--text-muted); padding: 4px 10px 6px;
}

/* ── Options ──────────────────────────────────────────────────────────────── */
.ssb-option {
  display: flex; align-items: center; gap: 8px;
  width: 100%; padding: 6px 10px;
  border: none; background: none; cursor: pointer;
  font-family: var(--font-sans); font-size: var(--font-size-sm);
  color: var(--text-secondary); text-align: left;
  border-radius: 6px; transition: background var(--transition), color var(--transition);
  white-space: nowrap;
}
.ssb-option:hover { background: var(--gray-50); color: var(--text-primary); }
.ssb-option-active { color: var(--primary); font-weight: 600; }
.ssb-option-active:hover { background: var(--primary-xlight); }

.ssb-option-check {
  width: 14px; height: 14px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  color: transparent;
}
.ssb-option-active .ssb-option-check { color: var(--primary); }

.ssb-option-recent { color: var(--text-muted); }
.ssb-option-recent:hover { color: var(--text-secondary); }

/* ── Column span for sections in wider viewports ───────────────────────────── */
@media (min-width: 700px) {
  .ssb-section { grid-column: span 1; }
}
@media (max-width: 600px) {
  .ssb-dropdown[style*="display: block"],
  .ssb-dropdown[style*="display:block"] {
    grid-template-columns: 1fr !important;
  }
}

/* ═══════════════════════════════════════════════════════════════════════
   Task Manager
   ═══════════════════════════════════════════════════════════════════════ */

.priority-critical { background: var(--danger-light); color: var(--danger); border: 1px solid var(--danger-border); }
.priority-high     { background: var(--warning-light); color: var(--warning); border: 1px solid var(--warning-border); }
.priority-medium   { background: var(--accent-light); color: var(--accent); border: 1px solid var(--accent); }
.priority-low      { background: var(--gray-100); color: var(--gray-600); border: 1px solid var(--gray-300); }

/* Toolbar shared across board/list/table/reports */
.tm-toolbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 0.75rem; flex-wrap: wrap; margin-bottom: 1.25rem;
}
.tm-view-tabs { display: flex; gap: 0.25rem; background: var(--gray-100); padding: 3px; border-radius: var(--border-radius); }
.tm-view-tab {
  padding: 6px 14px; border-radius: 6px; font-size: var(--font-size-sm); font-weight: 600;
  color: var(--text-muted); text-decoration: none; transition: var(--transition);
}
.tm-view-tab:hover { color: var(--text-primary); }
.tm-view-tab.active { background: var(--white); color: var(--primary); box-shadow: 0 1px 3px rgba(0,0,0,0.08); }

.tm-stat-chips { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.tm-stat-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px; border-radius: 20px; font-size: var(--font-size-xs); font-weight: 600;
  background: var(--gray-100); color: var(--text-primary); text-decoration: none;
  border: 1px solid var(--gray-200); transition: var(--transition);
}
.tm-stat-chip:hover { transform: translateY(-1px); box-shadow: 0 2px 6px rgba(0,0,0,0.08); }
.tm-stat-chip strong { font-size: var(--font-size-sm); }
.tm-stat-chip.overdue   { background: var(--danger-light); color: var(--danger); border-color: var(--danger-border); }
.tm-stat-chip.escalated { background: var(--warning-light); color: var(--warning); border-color: var(--warning-border); }
.tm-stat-chip.blocked   { background: var(--gray-100); color: var(--gray-600); }
.tm-stat-chip.high_priority { background: var(--accent-light); color: var(--accent); }

/* Board */
.tm-board { display: flex; gap: 1rem; overflow-x: auto; padding-bottom: 1rem; align-items: flex-start; }
.tm-column {
  flex: 0 0 300px; background: var(--gray-50); border-radius: var(--border-radius-lg); border: 1px solid var(--gray-200);
  display: flex; flex-direction: column; max-height: calc(100vh - 260px); transition: flex-basis 0.15s ease;
  overflow: hidden;
}
.tm-column.collapsed {
  flex: 0 0 44px; width: 44px; max-height: calc(100vh - 260px); height: calc(100vh - 260px); cursor: pointer;
}
.tm-column.collapsed .tm-column-body { display: none; }
.tm-column.collapsed .tm-column-header {
  flex-direction: column; height: 100%; justify-content: flex-start; padding: 0.875rem 0;
  border-bottom: none;
}
.tm-column.collapsed .tm-column-label {
  writing-mode: vertical-rl; transform: rotate(180deg); white-space: nowrap;
  margin-top: 8px; letter-spacing: 0.02em;
}
.tm-column.collapsed .tm-column-count { margin-top: auto; margin-bottom: 8px; }
.tm-column-toggle {
  background: none; border: none; padding: 2px; color: var(--text-muted); cursor: pointer;
  display: flex; align-items: center; justify-content: center; border-radius: 4px; flex-shrink: 0;
  transition: var(--transition);
}
.tm-column-toggle:hover { background: var(--gray-200); color: var(--text-primary); }
.tm-column.collapsed .tm-column-toggle svg { transform: rotate(180deg); }
.tm-column-label { flex: 1; }
.tm-column-header {
  display: flex; align-items: center; justify-content: space-between; gap: 6px;
  padding: 0.75rem 0.875rem; border-bottom: 1px solid var(--gray-200); font-weight: 600; font-size: var(--font-size-sm);
}
.tm-column-count { font-size: var(--font-size-xs); color: var(--text-muted); font-weight: 500; }

/* Column header accent — driven by Task Stage Settings (color per status), or
   priority/badge tokens for other groupings. */
.tm-column-header { border-top: 3px solid transparent; }
.tm-column-accent-gray      { border-top-color: var(--gray-300); }
.tm-column-accent-blue      { border-top-color: var(--primary); }
.tm-column-accent-info      { border-top-color: #0891b2; }
.tm-column-accent-success   { border-top-color: var(--success); }
.tm-column-accent-warning   { border-top-color: var(--warning); }
.tm-column-accent-danger    { border-top-color: var(--danger); }
.tm-column-accent-navy      { border-top-color: var(--navy-800); }
.tm-column-accent-secondary { border-top-color: var(--gray-500); }
.tm-column-accent-critical  { border-top-color: var(--danger); }
.tm-column-accent-high      { border-top-color: var(--warning); }
.tm-column-accent-medium    { border-top-color: var(--accent); }
.tm-column-accent-low       { border-top-color: var(--gray-300); }
.tm-column-body { padding: 0.625rem; overflow-y: auto; flex: 1; display: flex; flex-direction: column; gap: 0.625rem; min-height: 40px; }
.tm-column-body.drag-over { background: var(--primary-xlight); border-radius: var(--border-radius); }

.tm-card {
  background: var(--white); border-radius: var(--border-radius); border: 1px solid var(--gray-200);
  padding: 0.75rem; box-shadow: 0 1px 2px rgba(0,0,0,0.04); cursor: grab; text-decoration: none; display: block; color: inherit;
}
.tm-card:hover { border-color: var(--primary); box-shadow: 0 2px 8px rgba(0,71,143,0.1); }
.tm-card.dragging { opacity: 0.4; }
.tm-card-title { font-size: var(--font-size-sm); font-weight: 600; color: var(--text-primary); margin-bottom: 0.5rem; line-height: 1.35; }
.tm-card-meta { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.tm-card-footer { display: flex; align-items: center; justify-content: space-between; margin-top: 0.625rem; gap: 6px; }
.tm-card-due { font-size: var(--font-size-xs); color: var(--text-muted); }
.tm-card-due.overdue { color: var(--danger); font-weight: 600; }
.tm-card-flag { color: var(--warning); }

.tm-avatar {
  width: 24px; height: 24px; border-radius: 50%; background: var(--primary-light); color: var(--primary);
  display: inline-flex; align-items: center; justify-content: center; font-size: 0.6875rem; font-weight: 700;
  flex-shrink: 0;
}
.tm-avatar.agent { background: var(--accent); color: var(--white); }
.tm-avatar.team { background: var(--gray-200); color: var(--gray-600); }
.tm-avatar.unassigned { background: var(--gray-100); color: var(--gray-500); border: 1px dashed var(--gray-300); }

.tm-tag { display: inline-flex; align-items: center; padding: 2px 8px; border-radius: 20px; font-size: 0.6875rem; font-weight: 600; background: var(--gray-100); color: var(--gray-600); }

/* Detail drawer / page */
.tm-drawer-overlay {
  position: fixed; inset: 0; background: rgba(20,24,36,0.35); z-index: 90; display: none;
}
.tm-drawer-overlay.open { display: block; }
.tm-drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(560px, 100vw); background: var(--white);
  box-shadow: -8px 0 32px rgba(0,0,0,0.15); z-index: 91; overflow-y: auto;
  transform: translateX(100%); transition: transform 0.25s ease;
}
.tm-drawer.open { transform: translateX(0); }
.tm-drawer-close { position: absolute; top: 1rem; right: 1rem; }

.tm-section-title { font-size: var(--font-size-xs); text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-muted); font-weight: 700; margin: 1.25rem 0 0.625rem; }
.tm-blocked-banner {
  background: var(--danger-light); border: 1px solid var(--danger-border); color: var(--danger);
  border-radius: var(--border-radius); padding: 0.625rem 0.875rem; font-size: var(--font-size-sm); margin-bottom: 1rem;
}

.tm-activity-item { display: flex; gap: 0.625rem; padding: 0.5rem 0; border-bottom: 1px solid var(--gray-100); font-size: var(--font-size-sm); }
.tm-activity-item:last-child { border-bottom: none; }
.tm-comment { padding: 0.75rem; background: var(--gray-50); border-radius: var(--border-radius); margin-bottom: 0.625rem; }
.tm-comment-header { display: flex; justify-content: space-between; font-size: var(--font-size-xs); color: var(--text-muted); margin-bottom: 0.375rem; }

/* Notification bell */
.tm-notif-bell { position: relative; display: inline-flex; align-items: center; }
.tm-notif-dot {
  position: absolute; top: -2px; right: -2px; min-width: 16px; height: 16px; padding: 0 3px; border-radius: 8px;
  background: var(--danger); color: white; font-size: 0.625rem; font-weight: 700; display: flex; align-items: center; justify-content: center;
}
.tm-notif-dropdown {
  position: absolute; top: calc(100% + 8px); right: 0; width: 340px; max-height: 420px; overflow-y: auto;
  background: var(--white); border-radius: var(--border-radius-lg); box-shadow: 0 12px 32px rgba(0,0,0,0.15);
  border: 1px solid var(--gray-200); z-index: 100; display: none;
}
.tm-notif-dropdown.open { display: block; }
.tm-notif-item { display: block; padding: 0.75rem 1rem; border-bottom: 1px solid var(--gray-100); text-decoration: none; color: inherit; font-size: var(--font-size-sm); }
.tm-notif-item:hover { background: var(--gray-50); }
.tm-notif-item.unread { background: var(--primary-xlight); }
.tm-notif-empty { padding: 2rem 1rem; text-align: center; color: var(--text-muted); font-size: var(--font-size-sm); }

/* ============================================================
   Command palette + keyboard shortcut help (Ctrl+K / ?)
   ============================================================ */
.cmdk-overlay {
  position: fixed; inset: 0; background: rgba(10, 14, 24, 0.45);
  backdrop-filter: blur(2px); z-index: 2000;
  display: none; justify-content: center; align-items: flex-start;
  padding-top: 14vh;
}
.cmdk-overlay.open { display: flex; animation: cmdkFade .12s ease; }
@keyframes cmdkFade { from { opacity: 0; } to { opacity: 1; } }

.cmdk {
  width: 560px; max-width: 92vw;
  background: var(--white); border: 1px solid var(--gray-200);
  border-radius: 14px; overflow: hidden;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.25);
  animation: cmdkPop .14s ease;
}
[data-theme="dark"] .cmdk { background: var(--gray-50); }
@keyframes cmdkPop { from { transform: translateY(-8px) scale(.985); opacity:.6; } to { transform:none; opacity:1; } }

.cmdk-input {
  width: 100%; border: none; outline: none; background: transparent;
  padding: 16px 18px; font-size: 0.95rem; color: var(--text-primary);
  border-bottom: 1px solid var(--gray-200);
}
.cmdk-input::placeholder { color: var(--gray-400); }
.cmdk-list { max-height: 46vh; overflow-y: auto; padding: 6px; }
.cmdk-item {
  display: flex; justify-content: space-between; align-items: center;
  gap: 12px; padding: 9px 12px; border-radius: 8px; cursor: pointer;
  font-size: 0.86rem; color: var(--text-primary);
}
.cmdk-item.active { background: var(--primary-light); }
[data-theme="dark"] .cmdk-item.active { background: var(--gray-100); }
.cmdk-item-meta { font-size: 0.7rem; color: var(--gray-500); white-space: nowrap; }
.cmdk-empty { padding: 20px; text-align: center; color: var(--gray-500); font-size: 0.85rem; }
.cmdk-foot {
  display: flex; gap: 16px; padding: 8px 14px; font-size: 0.7rem;
  color: var(--gray-500); border-top: 1px solid var(--gray-200);
}
.cmdk kbd {
  background: var(--gray-100); border: 1px solid var(--gray-200);
  border-radius: 4px; padding: 0 5px; font-size: 0.68rem; font-family: inherit;
}
.cmdk-help { padding: 18px 22px; }
.cmdk-help h3 { margin: 0 0 14px; font-size: 1rem; color: var(--text-primary); }
.cmdk-help-grid {
  display: grid; grid-template-columns: auto 1fr; gap: 8px 18px;
  font-size: 0.82rem; color: var(--text-primary);
}

/* ============================================================
   Global interaction polish
   ============================================================ */
:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
  border-radius: 4px;
}
.btn:focus-visible { outline-offset: 1px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

.cmdk-hint {
  display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid var(--gray-200); background: transparent;
  color: var(--gray-500); border-radius: 8px; padding: 4px 10px;
  font-size: 0.72rem; cursor: pointer; margin-right: 8px;
  transition: all .12s;
}
.cmdk-hint:hover { border-color: var(--gray-300); color: var(--text-primary); }
.cmdk-hint kbd {
  background: var(--gray-100); border: 1px solid var(--gray-200);
  border-radius: 4px; padding: 0 5px; font-size: 0.66rem; font-family: inherit;
}
@media (max-width: 760px) { .cmdk-hint kbd { display: none; } }
