/* ===========================================================
   BPMS Core — global stylesheet (RTL / modern enterprise)
   =========================================================== */

/* ---------- Design tokens ---------- */
:root {
  --font-sans: 'Vazirmatn', 'IRANSans', 'Tahoma', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, Menlo, Consolas, monospace;

  --c-primary: #4f46e5;
  --c-primary-hover: #4338ca;
  --c-primary-soft: #eef2ff;
  --c-accent: #06b6d4;
  --c-accent-2: #8b5cf6;
  --c-success: #10b981;
  --c-success-soft: #d1fae5;
  --c-warning: #f59e0b;
  --c-warning-soft: #fef3c7;
  --c-danger:  #ef4444;
  --c-danger-soft: #fee2e2;
  --c-info: #0ea5e9;

  --c-bg:        #f6f7fb;
  --c-surface:   #ffffff;
  --c-surface-2: #f8fafc;
  --c-border:    #eef0f5;
  --c-border-strong: #dde2ec;
  --c-text:      #1e293b;
  --c-text-muted:#64748b;
  --c-text-inverse:#ffffff;

  --c-sidebar-bg: linear-gradient(180deg, #0f172a 0%, #1e1b4b 55%, #312e81 100%);
  --c-sidebar-surface: rgba(255,255,255,.06);
  --c-sidebar-hover: rgba(255,255,255,.09);
  --c-sidebar-text: #cbd5e1;
  --c-sidebar-active: linear-gradient(135deg, #6366f1, #8b5cf6);
  --c-topbar-bg: rgba(255,255,255,.82);

  --c-chart-1: #6366f1;
  --c-chart-2: #06b6d4;
  --c-chart-3: #10b981;
  --c-chart-4: #f59e0b;
  --c-chart-5: #ec4899;
  --c-chart-6: #ef4444;

  --radius-sm: 8px;
  --radius:    12px;
  --radius-lg: 18px;
  --radius-xl: 24px;

  --shadow-xs: 0 1px 2px rgba(15, 23, 42, .04);
  --shadow-sm: 0 2px 8px rgba(15, 23, 42, .06);
  --shadow:    0 8px 24px rgba(15, 23, 42, .08);
  --shadow-lg: 0 24px 56px rgba(15, 23, 42, .14);
  --shadow-glow: 0 8px 28px rgba(99, 102, 241, .28);

  --sidebar-w: 272px;
  --sidebar-w-compact: 72px;
  --topbar-h: 68px;

  --transition: 200ms cubic-bezier(.4,0,.2,1);
}

[data-theme="dark"] {
  --c-bg:        #0a0e1a;
  --c-surface:   #111827;
  --c-surface-2: #0f172a;
  --c-border:    #1f2a3d;
  --c-border-strong: #2d3a52;
  --c-text:      #e2e8f0;
  --c-text-muted:#94a3b8;
  --c-text-inverse:#0f172a;
  --c-primary-soft: #1e1b4b;
  --c-sidebar-bg: linear-gradient(180deg, #020617 0%, #0f172a 100%);
  --c-sidebar-surface: rgba(255,255,255,.04);
  --c-sidebar-hover: rgba(255,255,255,.07);
  --c-success-soft:#052e22;
  --c-warning-soft:#3a2a07;
  --c-danger-soft: #3b0d0d;
  --c-topbar-bg: rgba(17, 24, 39, .8);
  --shadow-xs: 0 1px 2px rgba(0,0,0,.4);
  --shadow-sm: 0 2px 8px rgba(0,0,0,.3);
  --shadow:    0 8px 24px rgba(0,0,0,.35);
  --shadow-lg: 0 24px 56px rgba(0,0,0,.5);
  --shadow-glow: 0 8px 28px rgba(99, 102, 241, .4);
}

/* ---- Font classes ---- */
.font-vazirmatn { --font-sans: 'Vazirmatn', 'Tahoma', sans-serif; }
.font-sahel     { --font-sans: 'Sahel', 'Tahoma', sans-serif; }
.font-samim     { --font-sans: 'Samim', 'Tahoma', sans-serif; }
.font-shabnam   { --font-sans: 'Shabnam', 'Tahoma', sans-serif; }
.font-iransans  { --font-sans: 'IRANSans', 'Tahoma', sans-serif; }
.font-tahoma    { --font-sans: 'Tahoma', 'Segoe UI', sans-serif; }

/* ---- Reset ---- */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.7;
  color: var(--c-text);
  background:
    radial-gradient(1100px 600px at 90% -10%, rgba(99,102,241,.08), transparent 60%),
    radial-gradient(900px 500px at -10% 110%, rgba(6,182,212,.07), transparent 60%),
    var(--c-bg);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  direction: rtl;
}
a { color: var(--c-primary); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--c-primary-hover); }
h1,h2,h3,h4,h5 { margin: 0 0 .5em; font-weight: 700; line-height: 1.35; letter-spacing: -.01em; }
h1 { font-size: 1.7rem; } h2 { font-size: 1.35rem; } h3 { font-size: 1.12rem; }
p { margin: 0 0 1em; }
img { max-width: 100%; }
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; font-size: inherit; }
hr { border: 0; border-top: 1px solid var(--c-border); margin: 16px 0; }
::selection { background: var(--c-primary); color: #fff; }

/* Scrollbars */
* { scrollbar-width: thin; scrollbar-color: var(--c-border-strong) transparent; }
*::-webkit-scrollbar { width: 9px; height: 9px; }
*::-webkit-scrollbar-thumb { background: var(--c-border-strong); border-radius: 99px; }
*::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* ---- App shell ---- */
.app-shell { display: flex; min-height: 100vh; }

/* Sidebar (RTL: fixed on the RIGHT) */
.sidebar {
  width: var(--sidebar-w);
  background: var(--c-sidebar-bg);
  color: var(--c-sidebar-text);
  display: flex;
  flex-direction: column;
  position: fixed;
  inset: 0 0 0 auto;           /* right edge for RTL */
  z-index: 50;
  box-shadow: var(--shadow-lg);
  transition: transform var(--transition);
}
.sidebar::before {
  content: ""; position: absolute; inset: 0;
  background: radial-gradient(400px 220px at 100% 0%, rgba(139,92,246,.22), transparent 70%);
  pointer-events: none;
}
.sidebar-brand {
  display: flex; align-items: center; gap: 13px;
  padding: 22px 22px;
  position: relative;
}
.brand-mark {
  width: 44px; height: 44px; border-radius: 13px;
  background: linear-gradient(135deg, var(--c-primary), var(--c-accent-2));
  color: white; display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 21px;
  box-shadow: var(--shadow-glow);
}
.brand-text { display: flex; flex-direction: column; line-height: 1.25; }
.brand-text strong { color: #fff; font-size: 17px; letter-spacing: .2px; }
.brand-text small { color: #94a3b8; font-size: 11px; }
.sidebar-toggle { margin-inline-start: auto; background: transparent; border: 0; color: #fff; font-size: 26px; line-height: 1; }

.sidebar-nav {
  flex: 1; padding: 12px 14px 20px; overflow-y: auto;
  position: relative;
}
.sidebar-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,.1); }

.nav-section-label {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: .12em;
  color: rgba(255,255,255,.4); padding: 14px 14px 6px; font-weight: 700;
}
.nav-item, .nav-group > summary {
  display: flex; align-items: center; gap: 13px;
  padding: 11px 14px; border-radius: 12px;
  color: var(--c-sidebar-text);
  font-weight: 500; cursor: pointer; list-style: none;
  transition: background var(--transition), color var(--transition), transform var(--transition);
  margin-bottom: 3px; position: relative;
}
.nav-item:hover, .nav-group > summary:hover {
  background: var(--c-sidebar-hover); color: #fff;
}
.nav-item.active {
  background: var(--c-sidebar-active);
  color: #fff;
  box-shadow: 0 10px 24px rgba(99,102,241,.42);
}
.nav-item.active::before {
  content: ""; position: absolute; inset-inline-end: -14px; top: 50%;
  transform: translateY(-50%);
  width: 4px; height: 60%; border-radius: 4px 0 0 4px; background: #fff;
}
.nav-icon {
  width: 24px; height: 24px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 17px; flex-shrink: 0;
  background: var(--c-sidebar-surface); border-radius: 9px;
  transition: background var(--transition);
}
.nav-item.active .nav-icon { background: rgba(255,255,255,.18); }
.nav-label { flex: 1; font-size: 13.5px; }
.nav-caret { font-size: 9px; opacity: .55; transition: transform var(--transition); }
.nav-group[open] > summary .nav-caret { transform: rotate(180deg); }
.nav-children {
  padding: 4px 8px 8px; display: flex; flex-direction: column; gap: 2px;
  margin-inline-end: 8px;
  border-inline-end: 1px dashed rgba(255,255,255,.12);
  margin-inline-start: 8px;
}
.nav-sub {
  padding: 8px 14px 8px 10px; border-radius: 9px;
  color: var(--c-sidebar-text); font-size: 12.5px;
  display: flex; gap: 8px; align-items: center;
  transition: background var(--transition);
}
.nav-sub:hover { background: var(--c-sidebar-hover); color: #fff; }
.nav-sub.active { background: rgba(99,102,241,.22); color: #fff; }
.sidebar-foot { padding: 14px; border-top: 1px solid rgba(255,255,255,.08); position: relative; }
.sidebar-foot .text-muted { color: rgba(255,255,255,.6) !important; }

.badge {
  background: linear-gradient(135deg, #f43f5e, #ef4444);
  color: #fff; font-size: 10px; font-weight: 700;
  padding: 2px 8px; border-radius: 999px; margin-inline-start: auto;
  box-shadow: 0 4px 10px rgba(239,68,68,.4);
}

/* ---- Main area ---- */
.main-area {
  flex: 1; margin-inline-start: var(--sidebar-w);
  display: flex; flex-direction: column; min-width: 0;
}
.topbar {
  height: var(--topbar-h);
  background: var(--c-topbar-bg);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--c-border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 28px; position: sticky; top: 0; z-index: 40;
}
.topbar-left, .topbar-right { display: flex; align-items: center; gap: 14px; }
.crumb { font-weight: 700; font-size: 15px; color: var(--c-text); }
.crumb small { display: block; font-weight: 400; font-size: 11.5px; color: var(--c-text-muted); margin-top: 2px; }

.icon-btn {
  width: 42px; height: 42px; border-radius: 12px;
  background: transparent; border: 1px solid transparent;
  color: var(--c-text); font-size: 18px;
  display: inline-flex; align-items: center; justify-content: center;
  transition: all var(--transition);
}
.icon-btn:hover { background: var(--c-surface-2); border-color: var(--c-border); transform: translateY(-1px); }
[data-theme="light"] .theme-icon-dark { display: none; }
[data-theme="dark"]  .theme-icon-light { display: none; }

.icon-notif { position: relative; }
.icon-notif .dot {
  position: absolute; top: 7px; inset-inline-end: 9px;
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--c-danger); border: 2px solid var(--c-surface);
}

.user-menu { position: relative; }
.user-trigger {
  display: flex; align-items: center; gap: 11px;
  background: var(--c-surface); border: 1px solid var(--c-border);
  border-radius: 14px; padding: 6px 8px 6px 14px;
  color: var(--c-text); transition: all var(--transition);
}
.user-trigger:hover { border-color: var(--c-primary); box-shadow: var(--shadow-sm); }
.avatar {
  width: 36px; height: 36px; border-radius: 11px;
  background: linear-gradient(135deg, var(--c-primary), var(--c-accent-2));
  color: #fff; font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 10px rgba(99,102,241,.3);
}
.avatar.sm { width: 30px; height: 30px; border-radius: 9px; font-size: 12px; }
.user-name { font-weight: 600; font-size: 13px; }
.user-name small { display: block; font-weight: 400; font-size: 10.5px; color: var(--c-text-muted); }
.caret { font-size: 9px; color: var(--c-text-muted); }
.user-dropdown {
  position: absolute; top: calc(100% + 10px); inset-inline-end: 0;
  background: var(--c-surface); border: 1px solid var(--c-border);
  border-radius: 16px; min-width: 256px; padding: 8px;
  box-shadow: var(--shadow-lg); display: none; z-index: 60;
}
.user-menu.open .user-dropdown { display: block; animation: dropIn .18s ease; }
@keyframes dropIn { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }
.user-dropdown-head {
  padding: 12px 14px; border-bottom: 1px solid var(--c-border);
  display: flex; flex-direction: column; gap: 3px; margin-bottom: 6px;
}
.user-dropdown-head small { color: var(--c-text-muted); font-size: 11px; }
.user-dropdown a, .dropdown-link {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: right;
  padding: 10px 13px; border-radius: 10px; color: var(--c-text);
  background: transparent; border: 0; text-decoration: none; font-size: 13.5px;
}
.user-dropdown a:hover, .dropdown-link:hover { background: var(--c-surface-2); color: var(--c-primary); }

.content {
  padding: 28px 32px 40px; flex: 1;
  animation: fadeUp .35s ease both;
}
@keyframes fadeUp { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.app-foot {
  padding: 16px 32px; border-top: 1px solid var(--c-border);
  color: var(--c-text-muted); font-size: 12px;
  display: flex; justify-content: space-between; align-items: center;
  background: var(--c-surface);
}
.sidebar-backdrop { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 45; backdrop-filter: blur(2px); }

/* ---------- Page heading ---------- */
.page-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 16px; margin-bottom: 24px; flex-wrap: wrap;
}
.page-head h1 { margin: 0 0 4px; }
.page-head .sub { color: var(--c-text-muted); font-size: 13px; margin: 0; }

/* ---- Cards ---- */
.card {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xs);
  overflow: hidden;
  transition: box-shadow var(--transition), transform var(--transition);
}
.card.hover:hover { box-shadow: var(--shadow); transform: translateY(-2px); }
.card-header {
  padding: 18px 22px; border-bottom: 1px solid var(--c-border);
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.card-title { margin: 0; font-size: 15px; font-weight: 700; display: flex; align-items: center; gap: 9px; }
.card-title .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--c-primary); }
.card-subtitle { color: var(--c-text-muted); font-size: 12px; margin-top: 3px; }
.card-body { padding: 22px; }
.card-foot {
  padding: 14px 22px; border-top: 1px solid var(--c-border);
  background: var(--c-surface-2); display: flex; gap: 8px;
}

.grid { display: grid; gap: 20px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 1200px) { .grid-4 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 900px)  { .grid-3, .grid-4 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 640px)  { .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; } }

/* ---- KPI cards ---- */
.kpi {
  position: relative;
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-lg);
  padding: 22px;
  display: flex; flex-direction: column; gap: 12px;
  overflow: hidden;
  box-shadow: var(--shadow-xs);
  transition: transform var(--transition), box-shadow var(--transition);
}
.kpi::after {
  content: ""; position: absolute; inset-inline-end: -30px; top: -30px;
  width: 120px; height: 120px; border-radius: 50%;
  background: radial-gradient(circle, rgba(99,102,241,.10), transparent 70%);
}
.kpi:hover { transform: translateY(-3px); box-shadow: var(--shadow); }
.kpi-top { display: flex; align-items: center; justify-content: space-between; position: relative; z-index: 1; }
.kpi-icon {
  width: 52px; height: 52px; border-radius: 15px;
  background: linear-gradient(135deg, var(--c-primary-soft), #fff);
  color: var(--c-primary);
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; box-shadow: var(--shadow-sm);
}
[data-theme="dark"] .kpi-icon { background: rgba(99,102,241,.16); }
.kpi.green .kpi-icon { background: linear-gradient(135deg, var(--c-success-soft), #fff); color: var(--c-success); }
.kpi.amber .kpi-icon { background: linear-gradient(135deg, var(--c-warning-soft), #fff); color: var(--c-warning); }
.kpi.red   .kpi-icon { background: linear-gradient(135deg, var(--c-danger-soft), #fff); color: var(--c-danger); }
[data-theme="dark"] .kpi.green .kpi-icon { background: rgba(16,185,129,.18); }
[data-theme="dark"] .kpi.amber .kpi-icon { background: rgba(245,158,11,.18); }
[data-theme="dark"] .kpi.red   .kpi-icon { background: rgba(239,68,68,.18); }
.kpi-label { color: var(--c-text-muted); font-size: 12.5px; font-weight: 500; }
.kpi-value { font-size: 28px; font-weight: 800; letter-spacing: -.5px; position: relative; z-index: 1; }
.kpi-trend { font-size: 12px; font-weight: 600; padding: 3px 9px; border-radius: 99px; }
.kpi-trend.up { color: var(--c-success); background: var(--c-success-soft); }
.kpi-trend.down { color: var(--c-danger); background: var(--c-danger-soft); }
.kpi-spark { position: relative; z-index: 1; height: 34px; margin-top: 4px; }

/* ---- Buttons ---- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 18px; border-radius: 11px;
  border: 1px solid transparent; background: var(--c-surface-2);
  color: var(--c-text); font-weight: 600; font-size: 13px;
  transition: all var(--transition); white-space: nowrap;
  text-decoration: none; cursor: pointer;
}
.btn:hover { transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.btn:active { transform: translateY(0); }
.btn-primary {
  background: linear-gradient(135deg, var(--c-primary), var(--c-accent-2));
  color: #fff; box-shadow: 0 6px 16px rgba(99,102,241,.32);
}
.btn-primary:hover { color: #fff; box-shadow: var(--shadow-glow); }
.btn-success { background: linear-gradient(135deg, #10b981, #059669); color: #fff; box-shadow: 0 6px 16px rgba(16,185,129,.3); }
.btn-danger  { background: linear-gradient(135deg, #ef4444, #dc2626); color: #fff; box-shadow: 0 6px 16px rgba(239,68,68,.3); }
.btn-warning { background: linear-gradient(135deg, #f59e0b, #d97706); color: #fff; }
.btn-ghost { background: transparent; border-color: var(--c-border-strong); }
.btn-ghost:hover { background: var(--c-surface-2); }
.btn-soft { background: var(--c-primary-soft); color: var(--c-primary); }
.btn-soft:hover { background: #e0e7ff; }
.btn-sm { padding: 7px 13px; font-size: 12px; border-radius: 9px; }
.btn-lg { padding: 13px 24px; font-size: 15px; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .55; cursor: not-allowed; transform: none; box-shadow: none; }
.btn-group { display: inline-flex; gap: 8px; flex-wrap: wrap; }

/* ---- Forms ---- */
.form-group { margin-bottom: 18px; }
.form-label { display: block; margin-bottom: 7px; font-weight: 600; font-size: 13px; color: var(--c-text); }
.form-control, input[type=text], input[type=email], input[type=password],
input[type=number], input[type=date], input[type=tel], input[type=search],
select, textarea {
  width: 100%; padding: 11px 15px;
  background: var(--c-surface);
  border: 1.5px solid var(--c-border-strong);
  border-radius: 11px; color: var(--c-text);
  transition: border-color var(--transition), box-shadow var(--transition), background var(--transition);
  outline: none;
}
.form-control:focus, input:focus, select:focus, textarea:focus {
  border-color: var(--c-primary);
  box-shadow: 0 0 0 4px rgba(99,102,241,.14);
  background: var(--c-surface);
}
textarea { min-height: 96px; resize: vertical; line-height: 1.7; }
.form-help { font-size: 12px; color: var(--c-text-muted); margin-top: 5px; }
.form-row { display: grid; grid-template-columns: repeat(2, 1fr); gap: 15px; }
.form-row-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 15px; }
@media (max-width: 700px) { .form-row, .form-row-3 { grid-template-columns: 1fr; } }
.input-icon { position: relative; }
.input-icon > input { padding-inline-start: 42px; }
.input-icon > .ic { position: absolute; inset-inline-start: 14px; top: 50%; transform: translateY(-50%); color: var(--c-text-muted); }

/* ---- Tables ---- */
.table-wrap { overflow-x: auto; border-radius: var(--radius); }
table.table { width: 100%; border-collapse: collapse; font-size: 13px; }
table.table th, table.table td {
  padding: 13px 18px; text-align: right; vertical-align: middle;
  border-bottom: 1px solid var(--c-border);
}
table.table th {
  background: var(--c-surface-2);
  font-weight: 700; color: var(--c-text-muted);
  font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em;
  white-space: nowrap;
}
table.table tbody tr { transition: background var(--transition); }
table.table tbody tr:hover { background: var(--c-surface-2); }
table.table tbody tr:last-child td { border-bottom: 0; }

/* ---- Tags / badges ---- */
.tag {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 11px; border-radius: 999px; font-size: 11px; font-weight: 600;
  background: var(--c-surface-2); color: var(--c-text-muted);
  border: 1px solid var(--c-border);
}
.tag-primary { background: var(--c-primary-soft); color: var(--c-primary); border-color: transparent; }
.tag-success { background: var(--c-success-soft); color: var(--c-success); border-color: transparent; }
.tag-warning { background: var(--c-warning-soft); color: var(--c-warning); border-color: transparent; }
.tag-danger  { background: var(--c-danger-soft); color: var(--c-danger); border-color: transparent; }

.dot-status { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-inline-end: 6px; }
.dot-status.green { background: var(--c-success); box-shadow: 0 0 0 3px var(--c-success-soft); }
.dot-status.amber { background: var(--c-warning); box-shadow: 0 0 0 3px var(--c-warning-soft); }
.dot-status.red   { background: var(--c-danger); box-shadow: 0 0 0 3px var(--c-danger-soft); }
.dot-status.gray  { background: #94a3b8; }
.dot-status.cyan  { background: var(--c-accent); box-shadow: 0 0 0 3px rgba(6,182,212,.18); }
.dot-status.indigo{ background: var(--c-primary); box-shadow: 0 0 0 3px rgba(99,102,241,.18); }

/* ---- Alerts ---- */
.alert {
  display: flex; align-items: flex-start; gap: 13px;
  padding: 15px 18px; border-radius: var(--radius);
  margin-bottom: 18px; border: 1px solid transparent;
  animation: slideDown .3s ease;
}
@keyframes slideDown { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }
.alert-success { background: var(--c-success-soft); color: var(--c-success); }
.alert-danger  { background: var(--c-danger-soft); color: var(--c-danger); }
.alert-warning { background: var(--c-warning-soft); color: var(--c-warning); }
.alert > span:first-child {
  font-weight: 800; font-size: 18px; line-height: 1;
  width: 28px; height: 28px; border-radius: 50%;
  background: rgba(255,255,255,.4); display: inline-flex;
  align-items: center; justify-content: center; flex-shrink: 0;
}
.alert > div { flex: 1; color: var(--c-text); }
.alert-close { background: transparent; border: 0; color: inherit; font-size: 20px; cursor: pointer; opacity: .6; }
.alert-close:hover { opacity: 1; }

/* ---- Login page ---- */
.auth-shell {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  padding: 24px;
  background:
    radial-gradient(900px 500px at 85% 0%, rgba(99,102,241,.18), transparent 55%),
    radial-gradient(800px 500px at 10% 100%, rgba(6,182,212,.16), transparent 55%),
    var(--c-bg);
}
.auth-card {
  width: 100%; max-width: 440px;
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: 24px; padding: 40px;
  box-shadow: var(--shadow-lg);
  animation: fadeUp .4s ease both;
}
.auth-brand { text-align: center; margin-bottom: 28px; }
.auth-brand .brand-mark { margin: 0 auto 16px; width: 64px; height: 64px; font-size: 30px; border-radius: 18px; }
.auth-brand h1 { margin: 0 0 6px; font-size: 22px; }
.auth-brand p { color: var(--c-text-muted); margin: 0; font-size: 13px; }

/* ---- Kanban ---- */
.kanban {
  display: grid; grid-auto-flow: column;
  grid-auto-columns: 308px; gap: 18px;
  overflow-x: auto; padding-bottom: 14px;
}
.kanban-col {
  background: var(--c-surface-2);
  border: 1px solid var(--c-border);
  border-radius: 18px; padding: 16px;
  min-height: 200px; display: flex; flex-direction: column; gap: 12px;
}
.kanban-col.drag-over { border-color: var(--c-primary); background: var(--c-primary-soft); }
.kanban-col-head {
  display: flex; align-items: center; justify-content: space-between;
  font-weight: 700; font-size: 13px; padding-bottom: 12px;
  border-bottom: 1px solid var(--c-border);
}
.kanban-col-head .count {
  background: var(--c-surface); border: 1px solid var(--c-border);
  color: var(--c-text-muted); border-radius: 999px;
  padding: 3px 10px; font-size: 11px; font-weight: 700;
}
.kanban-card {
  background: var(--c-surface); border: 1px solid var(--c-border);
  border-radius: 14px; padding: 14px;
  cursor: grab; box-shadow: var(--shadow-xs);
  transition: transform var(--transition), box-shadow var(--transition), border-color var(--transition);
  display: block; color: var(--c-text);
}
.kanban-card:hover { transform: translateY(-3px); box-shadow: var(--shadow); border-color: var(--c-primary); color: var(--c-text); }
.kanban-card.dragging { opacity: .45; }
.kanban-card-title { font-weight: 700; font-size: 13.5px; margin-bottom: 6px; }
.kanban-card-meta { font-size: 11.5px; color: var(--c-text-muted); display: flex; justify-content: space-between; align-items: center; }
.kanban-card .avatar.sm { font-size: 11px; }

/* ---- Funnel ---- */
.funnel { display: flex; flex-direction: column; gap: 8px; }
.funnel-stage {
  display: grid; grid-template-columns: 170px 1fr 120px; gap: 14px;
  align-items: center; padding: 12px 16px;
  background: var(--c-surface-2); border-radius: 12px;
}
.funnel-bar {
  height: 30px; background: linear-gradient(90deg, var(--c-primary), var(--c-accent-2));
  border-radius: 8px; display: flex; align-items: center; justify-content: flex-start;
  padding: 0 12px; color: #fff; font-size: 11px; font-weight: 700; min-width: 36px;
}

/* ---- Charts ---- */
.chart-box { position: relative; height: 290px; }

/* ---- Tabs ---- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--c-border); margin-bottom: 22px; overflow-x: auto; }
.tab {
  padding: 12px 18px; color: var(--c-text-muted);
  font-weight: 600; cursor: pointer; border-bottom: 2px solid transparent;
  white-space: nowrap; transition: all var(--transition);
}
.tab:hover { color: var(--c-text); }
.tab.active { color: var(--c-primary); border-bottom-color: var(--c-primary); }

/* ---- Modal ---- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(15,23,42,.55);
  backdrop-filter: blur(4px);
  display: none; align-items: center; justify-content: center;
  z-index: 100; padding: 24px; animation: fadeIn .2s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal-backdrop.open { display: flex; }
.modal {
  background: var(--c-surface); border-radius: 20px;
  width: 100%; max-width: 580px; max-height: 90vh; overflow: auto;
  box-shadow: var(--shadow-lg); animation: modalIn .25s cubic-bezier(.4,0,.2,1);
}
@keyframes modalIn { from { opacity: 0; transform: scale(.95) translateY(10px); } to { opacity: 1; transform: none; } }
.modal-header { padding: 20px 24px; border-bottom: 1px solid var(--c-border); display: flex; align-items: center; justify-content: space-between; }
.modal-body { padding: 24px; }
.modal-foot { padding: 16px 24px; border-top: 1px solid var(--c-border); display: flex; justify-content: flex-end; gap: 10px; background: var(--c-surface-2); }

/* ---- Timeline ---- */
.timeline { position: relative; padding-inline-start: 28px; }
.timeline::before {
  content: ""; position: absolute; inset-inline-start: 8px; top: 6px; bottom: 6px;
  width: 2px; background: linear-gradient(var(--c-primary), var(--c-accent-2));
  opacity: .3;
}
.timeline-item { position: relative; padding-bottom: 20px; }
.timeline-item::before {
  content: ""; position: absolute; inset-inline-start: -27px; top: 4px;
  width: 18px; height: 18px; border-radius: 50%;
  background: var(--c-primary); border: 3px solid var(--c-surface);
  box-shadow: 0 0 0 2px var(--c-primary);
}
.timeline-time { font-size: 11px; color: var(--c-text-muted); }
.timeline-title { font-weight: 700; font-size: 13.5px; }

/* ---- Utility ---- */
.d-none { display: none !important; }
.d-block { display: block; }
.d-flex { display: flex; }
.inline-flex { display: inline-flex; }
.flex-wrap { flex-wrap: wrap; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }
.gap-2 { gap: 8px; } .gap-3 { gap: 12px; } .gap-4 { gap: 16px; }
.mt-2 { margin-top: 8px; } .mt-3 { margin-top: 12px; } .mt-4 { margin-top: 18px; }
.mb-2 { margin-bottom: 8px; } .mb-3 { margin-bottom: 12px; } .mb-4 { margin-bottom: 18px; }
.p-2 { padding: 8px; } .p-3 { padding: 12px; } .p-4 { padding: 18px; }
.text-right { text-align: right; } .text-center { text-align: center; } .text-left { text-align: left; }
.text-sm { font-size: 12px; } .text-lg { font-size: 16px; } .text-xl { font-size: 22px; font-weight: 800; }
.text-bold { font-weight: 700; }
.text-success { color: var(--c-success); } .text-danger { color: var(--c-danger); }
.text-warning { color: var(--c-warning); } .text-muted { color: var(--c-text-muted); }
.flex-1 { flex: 1; min-width: 0; }
.w-full { width: 100%; }
.rounded { border-radius: var(--radius); }
.space-y-3 > * + * { margin-top: 12px; }
.relative { position: relative; }
.overflow-hidden { overflow: hidden; }

/* ---- Empty state ---- */
.empty-state { text-align: center; padding: 56px 24px; color: var(--c-text-muted); }
.empty-state .icon {
  width: 80px; height: 80px; margin: 0 auto 16px;
  border-radius: 50%; background: var(--c-surface-2);
  display: flex; align-items: center; justify-content: center;
  font-size: 34px;
}
.empty-state h3 { color: var(--c-text); margin-bottom: 6px; }

/* ---- Steps ---- */
.steps { display: flex; gap: 0; align-items: center; flex-wrap: wrap; }
.step { display: flex; align-items: center; gap: 9px; padding: 8px 12px; font-size: 12.5px; color: var(--c-text-muted); }
.step .dot {
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--c-surface-2); border: 2px solid var(--c-border);
  display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 12px;
}
.step.active { color: var(--c-primary); font-weight: 700; }
.step.active .dot { background: var(--c-primary); border-color: var(--c-primary); color: #fff; box-shadow: 0 0 0 4px var(--c-primary-soft); }
.step.done { color: var(--c-success); }
.step.done .dot { background: var(--c-success); border-color: var(--c-success); color: #fff; }
.step-line { flex: 1; height: 2px; background: var(--c-border); min-width: 24px; }
.step-line.done { background: var(--c-success); }

/* ---- AI box ---- */
.ai-box {
  position: relative;
  background:
    linear-gradient(135deg, rgba(139,92,246,.1), rgba(6,182,212,.08));
  border: 1px solid rgba(139,92,246,.3);
  border-radius: 18px; padding: 20px; overflow: hidden;
}
.ai-box::before {
  content: ""; position: absolute; inset: 0;
  background: radial-gradient(400px 120px at 100% 0%, rgba(139,92,246,.18), transparent);
  pointer-events: none;
}
.ai-badge {
  display: inline-flex; align-items: center; gap: 6px;
  background: linear-gradient(135deg, #8b5cf6, #06b6d4);
  color: white; padding: 4px 12px; border-radius: 999px;
  font-size: 10.5px; font-weight: 700; letter-spacing: .4px;
  box-shadow: 0 6px 16px rgba(139,92,246,.35);
}

/* ---- Progress bar ---- */
.progress {
  height: 10px; background: var(--c-surface-2); border-radius: 99px;
  overflow: hidden; border: 1px solid var(--c-border);
}
.progress > span {
  display: block; height: 100%;
  background: linear-gradient(90deg, var(--c-primary), var(--c-accent-2));
  border-radius: 99px; transition: width .5s ease;
}
.progress.success > span { background: linear-gradient(90deg, #10b981, #059669); }
.progress.warning > span { background: linear-gradient(90deg, #f59e0b, #d97706); }

/* ---- Responsive ---- */
.d-md-none { display: none; }
@media (max-width: 900px) {
  .sidebar { transform: translateX(100%); }
  html[dir="ltr"] .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .sidebar.open ~ .sidebar-backdrop, .sidebar-backdrop.show { display: block; }
  .main-area { margin-inline-start: 0; }
  .d-md-none { display: inline-flex; }
  .d-sm-block { display: none; }
  .content { padding: 20px 18px 30px; }
  .app-foot { padding: 14px 18px; }
  .topbar { padding: 0 16px; }
}
.d-sm-block { display: initial; }
