/* ============================================================
   CRM Enterprise System - Main Stylesheet
   RTL | Vazirmatn Font | Professional Design
   ============================================================ */

/* ── Font Face ─────────────────────────────────────────────── */
@font-face {
  font-family: 'Vazirmatn';
  src: url('../fonts/vazirmatn/Vazirmatn-Thin.woff2') format('woff2');
  font-weight: 100; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'Vazirmatn';
  src: url('../fonts/vazirmatn/Vazirmatn-ExtraLight.woff2') format('woff2');
  font-weight: 200; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'Vazirmatn';
  src: url('../fonts/vazirmatn/Vazirmatn-Light.woff2') format('woff2');
  font-weight: 300; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'Vazirmatn';
  src: url('../fonts/vazirmatn/Vazirmatn-Regular.woff2') format('woff2');
  font-weight: 400; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'Vazirmatn';
  src: url('../fonts/vazirmatn/Vazirmatn-Medium.woff2') format('woff2');
  font-weight: 500; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'Vazirmatn';
  src: url('../fonts/vazirmatn/Vazirmatn-SemiBold.woff2') format('woff2');
  font-weight: 600; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'Vazirmatn';
  src: url('../fonts/vazirmatn/Vazirmatn-Bold.woff2') format('woff2');
  font-weight: 700; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'Vazirmatn';
  src: url('../fonts/vazirmatn/Vazirmatn-ExtraBold.woff2') format('woff2');
  font-weight: 800; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'Vazirmatn';
  src: url('../fonts/vazirmatn/Vazirmatn-Black.woff2') format('woff2');
  font-weight: 900; font-style: normal; font-display: swap;
}

/* ── CSS Variables ──────────────────────────────────────────── */
:root {
  /* Brand Colors */
  --primary:       #2563eb;
  --primary-dark:  #1d4ed8;
  --primary-light: #dbeafe;
  --secondary:     #64748b;
  --success:       #16a34a;
  --success-light: #dcfce7;
  --warning:       #d97706;
  --warning-light: #fef3c7;
  --danger:        #dc2626;
  --danger-light:  #fee2e2;
  --info:          #0891b2;
  --info-light:    #cffafe;
  --dark:          #1e293b;
  --light:         #f8fafc;

  /* Sidebar */
  --sidebar-bg:       #0f172a;
  --sidebar-text:     #cbd5e1;
  --sidebar-hover:    #1e3a5f;
  --sidebar-active:   #2563eb;
  --sidebar-width:    260px;
  --sidebar-collapsed: 70px;

  /* Layout */
  --header-height:    64px;
  --border-radius:    8px;
  --border-radius-lg: 12px;
  --shadow-sm:        0 1px 3px rgba(0,0,0,.08);
  --shadow-md:        0 4px 12px rgba(0,0,0,.12);
  --shadow-lg:        0 10px 30px rgba(0,0,0,.15);

  /* Typography */
  --font-size-xs:   .75rem;
  --font-size-sm:   .875rem;
  --font-size-base: 1rem;
  --font-size-lg:   1.125rem;
  --font-size-xl:   1.25rem;
  --font-size-2xl:  1.5rem;

  /* Colors */
  --text-primary:   #1e293b;
  --text-secondary: #475569;
  --text-muted:     #94a3b8;
  --border-color:   #e2e8f0;
  --bg-body:        #f1f5f9;
  --bg-card:        #ffffff;
  --bg-hover:       #f8fafc;
}

/* ── Dark theme ─────────────────────────────────────────────── */
[data-theme="dark"] {
  /* Tinted "light" badge backgrounds become subtle translucent fills */
  --primary-light: rgba(59,130,246,.20);
  --success-light: rgba(34,197,94,.18);
  --warning-light: rgba(217,119,6,.22);
  --danger-light:  rgba(239,68,68,.20);
  --info-light:    rgba(34,211,238,.18);

  --text-primary:   #e6eaf2;
  --text-secondary: #b4bdcc;
  --text-muted:     #7e8aa0;
  --border-color:   #2a3446;
  --bg-body:        #0b1120;
  --bg-card:        #151d2e;
  --bg-hover:       #1e2840;

  --shadow-sm: 0 1px 3px rgba(0,0,0,.45);
  --shadow-md: 0 4px 12px rgba(0,0,0,.55);
  --shadow-lg: 0 10px 30px rgba(0,0,0,.65);

  --bg-secondary: #1a2236;

  /* Links: lighter blues so they stay visible (and don't turn navy on hover) */
  --link:       #93c5fd;
  --link-hover: #bfdbfe;

  color-scheme: dark;
}
/* Patch hardcoded light surfaces so they adapt in dark mode */
[data-theme="dark"] .form-control,
[data-theme="dark"] .page-link,
[data-theme="dark"] .task-check { background: var(--bg-hover); }
[data-theme="dark"] .form-control:disabled { background: var(--bg-body); }
[data-theme="dark"] .table th,
[data-theme="dark"] .data-table th { background: var(--bg-hover); }
[data-theme="dark"] .table tbody tr:hover,
[data-theme="dark"] .data-table tbody tr:hover,
[data-theme="dark"] .table-striped tbody tr:nth-child(even):hover { background: var(--bg-hover); }
[data-theme="dark"] .table-striped tbody tr:nth-child(even) { background: rgba(255,255,255,.03); }
[data-theme="dark"] .badge-secondary { background: var(--bg-hover); color: var(--text-secondary); }
[data-theme="dark"] .roles-list-item:hover { background: var(--bg-hover); }
[data-theme="dark"] .roles-edit-toolbar { background: var(--bg-hover); }
[data-theme="dark"] ::-webkit-scrollbar-track { background: var(--bg-body); }

/* Keep alert text readable on the darker translucent backgrounds */
[data-theme="dark"] .alert-success { color: #86efac; }
[data-theme="dark"] .alert-danger  { color: #fca5a5; }
[data-theme="dark"] .alert-warning { color: #fcd34d; }
[data-theme="dark"] .alert-info    { color: #67e8f9; }
[data-theme="dark"] .badge-purple  { background: rgba(124,58,237,.22); color: #c4b5fd; }
[data-theme="dark"] .badge-dark    { background: var(--bg-hover); }

/* Colored text utilities: use lighter shades so they stay legible on dark surfaces
   (e.g. the "حذف تسک" / delete buttons that rely on .text-danger). */
[data-theme="dark"] .text-danger,
[data-theme="dark"] .dropdown-item.danger { color: #f87171; }
[data-theme="dark"] .text-success    { color: #4ade80; }
[data-theme="dark"] .text-warning    { color: #fbbf24; }
[data-theme="dark"] .text-info       { color: #38bdf8; }
[data-theme="dark"] .text-primary-color { color: #93c5fd; }
[data-theme="dark"] .btn-ghost.text-danger { color: #f87171; }

/* Theme toggle icon swap */
.theme-icon-light { display: none; }
[data-theme="dark"] .theme-icon-light { display: block; }
[data-theme="dark"] .theme-icon-dark  { display: none; }

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

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

body {
  font-family: 'Vazirmatn', 'Tahoma', sans-serif;
  font-weight: 400;
  color: var(--text-primary);
  background-color: var(--bg-body);
  line-height: 1.7;
  min-height: 100vh;
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  max-width: 100vw;
}

a { color: var(--link, var(--primary)); text-decoration: none; }
a:hover:not(.btn) { color: var(--link-hover, var(--primary-dark)); }
img { max-width: 100%; }
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; }
p { margin-bottom: .75rem; }
p:last-child { margin-bottom: 0; }

/* ── Scrollbar ──────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: #f1f5f9; }
::-webkit-scrollbar-thumb { background: #94a3b8; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #64748b; }

/* ── Layout ─────────────────────────────────────────────────── */
.app-wrapper {
  display: flex;
  min-height: 100vh;
  min-height: 100dvh;
  width: 100%;
  max-width: 100%;
  overflow-x: clip;
}

/* ── Sidebar ────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; right: 0; bottom: 0;
  z-index: 1000;
  transition: width .25s cubic-bezier(.4,0,.2,1);
  overflow: hidden;
}
.sidebar.collapsed { width: var(--sidebar-collapsed); }
.sidebar.collapsed .nav-label,
.sidebar.collapsed .sidebar-section-title,
.sidebar.collapsed .brand-name { display: none; }
.sidebar.collapsed .sidebar-brand { justify-content: center; }
.sidebar.collapsed .nav-link { justify-content: center; padding: .625rem; }
.sidebar.collapsed .nav-arrow { display: none; }

.sidebar-brand {
  height: var(--header-height);
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: 0 1.25rem;
  border-bottom: 1px solid rgba(255,255,255,.06);
  flex-shrink: 0;
}
.brand-icon {
  width: 36px; height: 36px;
  background: linear-gradient(135deg, var(--primary), #6366f1);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.brand-icon svg { width: 20px; height: 20px; fill: white; }
.brand-name { color: #fff; font-weight: 700; font-size: 1rem; white-space: nowrap; }
.brand-sub { color: var(--sidebar-text); font-size: .7rem; }

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: .75rem 0;
}
.sidebar-section-title {
  padding: .875rem 1.25rem .375rem;
  font-size: .65rem;
  font-weight: 700;
  color: #475569;
  letter-spacing: .08em;
  text-transform: uppercase;
  white-space: nowrap;
}
.nav-item { position: relative; }
.nav-link {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .625rem 1.25rem;
  color: var(--sidebar-text);
  font-size: .875rem;
  font-weight: 500;
  transition: all .18s;
  cursor: pointer;
  border: none;
  background: none;
  width: 100%;
  white-space: nowrap;
  position: relative;
}
.nav-link:hover {
  background: rgba(255,255,255,.06);
  color: #fff;
}
.nav-link.active {
  background: linear-gradient(90deg, rgba(37,99,235,.25), rgba(37,99,235,.05));
  color: #fff;
  border-right: 3px solid var(--primary);
}
.nav-link .nav-icon {
  width: 18px; height: 18px;
  opacity: .7;
  flex-shrink: 0;
  transition: opacity .18s;
}
.nav-link:hover .nav-icon,
.nav-link.active .nav-icon { opacity: 1; }
.nav-label { flex: 1; }
.nav-arrow {
  width: 14px; height: 14px;
  opacity: .5;
  transition: transform .2s;
}
.nav-item.open > .nav-link .nav-arrow { transform: rotate(90deg); }

/* Sub-nav */
.sub-nav {
  overflow: hidden;
  max-height: 0;
  transition: max-height .25s ease;
}
.nav-item.open .sub-nav { max-height: 400px; }
.sub-nav-link {
  display: flex; align-items: center; gap: .5rem;
  padding: .45rem 1.25rem .45rem 2.5rem;
  color: #64748b;
  font-size: .825rem;
  transition: all .18s;
}
.sub-nav-link:hover { color: #fff; background: rgba(255,255,255,.04); }
.sub-nav-link.active { color: #93c5fd; font-weight: 600; }
.sub-nav-link::before {
  content: ''; width: 5px; height: 5px;
  border-radius: 50%; background: currentColor; opacity: .5; flex-shrink: 0;
}

/* Notification badge on nav */
.nav-badge {
  background: var(--danger);
  color: #fff;
  font-size: .65rem;
  font-weight: 700;
  padding: .1rem .4rem;
  border-radius: 10px;
  min-width: 18px;
  text-align: center;
}

.sidebar-footer {
  padding: 1rem 1.25rem;
  border-top: 1px solid rgba(255,255,255,.06);
  display: flex; align-items: center; gap: .75rem;
}
.sidebar-avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), #6366f1);
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 700; font-size: .85rem;
  flex-shrink: 0;
}
.sidebar-user-name { color: #fff; font-size: .825rem; font-weight: 600; white-space: nowrap; }
.sidebar-user-role { color: #64748b; font-size: .725rem; white-space: nowrap; }
.sidebar-user-info { flex: 1; overflow: hidden; }

/* ── Main Content ────────────────────────────────────────────── */
.main-content {
  flex: 1;
  margin-right: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
  min-width: 0;
  width: 100%;
  max-width: 100%;
  transition: margin-right .25s cubic-bezier(.4,0,.2,1);
}
.main-content.sidebar-collapsed { margin-right: var(--sidebar-collapsed); }

/* ── Top Header ─────────────────────────────────────────────── */
.top-header {
  height: var(--header-height);
  background: var(--bg-card);
  border-bottom: 1px solid var(--border-color);
  display: flex; align-items: center;
  padding: 0 1.5rem;
  gap: 1rem;
  position: sticky; top: 0; z-index: 100;
  box-shadow: var(--shadow-sm);
}
.header-toggle-btn {
  width: 36px; height: 36px;
  border: none; background: none;
  color: var(--text-secondary);
  display: flex; align-items: center; justify-content: center;
  border-radius: 6px;
  transition: all .18s;
}
.header-toggle-btn:hover { background: var(--bg-hover); color: var(--text-primary); }
.header-toggle-btn svg { width: 20px; height: 20px; }

.header-breadcrumb {
  flex: 1;
  display: flex; align-items: center; gap: .5rem;
  font-size: .825rem; color: var(--text-secondary);
}
.header-breadcrumb a { color: var(--text-secondary); }
.header-breadcrumb a:hover { color: var(--primary); }
.breadcrumb-sep { opacity: .4; }

.header-actions { display: flex; align-items: center; gap: .5rem; }
.header-btn {
  width: 36px; height: 36px;
  border: none; background: none;
  color: var(--text-secondary);
  display: flex; align-items: center; justify-content: center;
  border-radius: 6px; position: relative;
  transition: all .18s;
}
.header-btn:hover { background: var(--bg-hover); color: var(--text-primary); }
.header-btn svg { width: 20px; height: 20px; }
.notif-badge {
  position: absolute; top: 2px; right: 2px;
  min-width: 18px; height: 18px; padding: 0 5px;
  background: var(--danger); color: #fff;
  border-radius: 999px; border: 2px solid var(--bg-card);
  font-size: .65rem; font-weight: 700; line-height: 14px;
  text-align: center;
}
.header-user {
  display: flex; align-items: center; gap: .625rem;
  padding: .375rem .75rem;
  border-radius: 8px;
  cursor: pointer; transition: all .18s;
  border: none; background: none;
  font-family: inherit; color: inherit;
  max-width: 100%;
}
.header-user:hover { background: var(--bg-hover); }
.header-user-text { min-width: 0; text-align: right; }
.header-user-chevron { flex-shrink: 0; opacity: .5; margin-right: .15rem; }
.header-avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), #6366f1);
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 700; font-size: .825rem;
}
.header-username { font-size: .825rem; font-weight: 600; color: var(--text-primary); }
.header-role { font-size: .7rem; color: var(--text-muted); }

/* ── Page Content ────────────────────────────────────────────── */
.page-content {
  flex: 1;
  padding: 1.5rem;
  max-width: 1600px;
  width: 100%;
}
.page-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 1.5rem; gap: 1rem; flex-wrap: wrap;
}
.page-title {
  font-size: 1.375rem; font-weight: 700;
  color: var(--text-primary); line-height: 1.3;
}
.page-subtitle { font-size: .875rem; color: var(--text-secondary); margin-top: .25rem; }
.page-actions { display: flex; gap: .5rem; flex-wrap: wrap; }

/* ── Cards ───────────────────────────────────────────────────── */
.card {
  background: var(--bg-card);
  border-radius: var(--border-radius-lg);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.card-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border-color);
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; flex-wrap: wrap;
}
.card-title {
  font-size: 1rem; font-weight: 700;
  color: var(--text-primary);
  display: flex; align-items: center; gap: .5rem;
}
.card-title-icon {
  width: 20px; height: 20px; color: var(--primary);
}
.card-actions { display: flex; gap: .5rem; flex-wrap: wrap; }
.card-body { padding: 1.25rem; }
.card-footer {
  padding: .875rem 1.25rem;
  border-top: 1px solid var(--border-color);
  background: #fafbfc;
}

/* Stats Cards */
.stat-card {
  background: var(--bg-card);
  border-radius: var(--border-radius-lg);
  border: 1px solid var(--border-color);
  padding: 1.25rem;
  display: flex; align-items: center; gap: 1rem;
  box-shadow: var(--shadow-sm);
  transition: all .2s;
}
.stat-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.stat-icon {
  width: 52px; height: 52px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.stat-icon svg { width: 26px; height: 26px; }
.stat-icon.blue   { background: var(--primary-light); color: var(--primary); }
.stat-icon.green  { background: var(--success-light); color: var(--success); }
.stat-icon.yellow { background: var(--warning-light); color: var(--warning); }
.stat-icon.red    { background: var(--danger-light);  color: var(--danger); }
.stat-icon.cyan   { background: var(--info-light);    color: var(--info); }
.stat-icon.purple { background: #ede9fe; color: #7c3aed; }
.stat-content { flex: 1; }
.stat-value { font-size: 1.625rem; font-weight: 800; color: var(--text-primary); line-height: 1; }
.stat-label { font-size: .8rem; color: var(--text-secondary); margin-top: .25rem; }
.stat-change {
  font-size: .75rem; font-weight: 600; display: flex; align-items: center; gap: .2rem;
  margin-top: .25rem;
}
.stat-change.up   { color: var(--success); }
.stat-change.down { color: var(--danger); }

/* ── Buttons ─────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: .4rem;
  padding: .5rem 1rem;
  font-size: .875rem; font-weight: 600; font-family: inherit;
  border-radius: var(--border-radius);
  border: 1px solid transparent;
  cursor: pointer; transition: all .18s;
  white-space: nowrap; line-height: 1.5;
  text-decoration: none;
}
.btn:disabled { opacity: .6; cursor: not-allowed; }
.btn svg { width: 16px; height: 16px; flex-shrink: 0; }
.btn-sm { padding: .3rem .75rem; font-size: .8rem; }
.btn-lg { padding: .7rem 1.5rem; font-size: 1rem; }
.btn-icon { padding: .5rem; aspect-ratio: 1; }

.btn-primary {
  background: var(--primary); color: #fff; border-color: var(--primary);
}
.btn-primary:hover,
.btn-primary:focus,
.btn-primary:active {
  background: var(--primary-dark);
  border-color: var(--primary-dark);
  color: #fff;
}

.btn-secondary {
  background: var(--secondary); color: #fff; border-color: var(--secondary);
}
.btn-secondary:hover { background: #4b5563; }

.btn-success {
  background: var(--success); color: #fff; border-color: var(--success);
}
.btn-success:hover { background: #15803d; }

.btn-danger {
  background: var(--danger); color: #fff; border-color: var(--danger);
}
.btn-danger:hover { background: #b91c1c; }

.btn-warning {
  background: var(--warning); color: #fff; border-color: var(--warning);
}
.btn-warning:hover { background: #b45309; }

.btn-outline {
  background: transparent; color: var(--primary); border-color: var(--primary);
}
.btn-outline:hover { background: var(--primary-light); }

.btn-outline-secondary {
  background: transparent;
  color: var(--text-secondary);
  border-color: var(--border-color);
}
.btn-outline-secondary:hover,
.btn-outline-secondary:focus,
.btn-outline-secondary:active {
  background: var(--bg-hover);
  color: var(--text-primary);
  border-color: var(--text-muted);
}

.btn-ghost {
  background: transparent; color: var(--text-secondary); border-color: transparent;
}
.btn-ghost:hover { background: var(--bg-hover); color: var(--text-primary); }

/* ── Forms ───────────────────────────────────────────────────── */
.form-group { margin-bottom: 1.125rem; }
.form-label {
  display: block; margin-bottom: .4rem;
  font-size: .85rem; font-weight: 600; color: var(--text-primary);
}
.form-label .required { color: var(--danger); margin-right: .2rem; }
.form-control {
  display: block; width: 100%;
  padding: .55rem .875rem;
  font-size: .875rem; font-family: inherit; color: var(--text-primary);
  background: #fff;
  border: 1.5px solid var(--border-color); border-radius: var(--border-radius);
  transition: border-color .18s, box-shadow .18s;
  line-height: 1.5;
}
.form-control:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,.12);
}
.form-control::placeholder { color: var(--text-muted); }
.form-control:disabled { background: #f1f5f9; color: var(--text-muted); cursor: not-allowed; }
.form-control.is-invalid { border-color: var(--danger); }
.form-control.is-valid   { border-color: var(--success); }
textarea.form-control { resize: vertical; min-height: 90px; }
select.form-control { cursor: pointer; }

.form-text { font-size: .775rem; color: var(--text-muted); margin-top: .3rem; }
.invalid-feedback { font-size: .775rem; color: var(--danger); margin-top: .3rem; }
.valid-feedback   { font-size: .775rem; color: var(--success); margin-top: .3rem; }

.input-group { display: flex; }
.input-group .form-control { border-radius: 0; flex: 1; }
.input-group .form-control:last-child { border-radius: 0 var(--border-radius) var(--border-radius) 0; }
.input-group .form-control:first-child { border-radius: var(--border-radius) 0 0 var(--border-radius); }
.input-group-text {
  display: flex; align-items: center;
  padding: .55rem .875rem;
  background: var(--bg-hover);
  border: 1.5px solid var(--border-color);
  font-size: .875rem; color: var(--text-secondary);
  border-right: none;
}

.form-check { display: flex; align-items: center; gap: .5rem; cursor: pointer; }
.form-check-input {
  width: 16px; height: 16px;
  border: 2px solid var(--border-color);
  border-radius: 4px;
  cursor: pointer; flex-shrink: 0;
}
.form-switch .form-check-input {
  width: 40px; height: 20px; border-radius: 10px;
  appearance: none; background: var(--border-color);
  position: relative; transition: background .18s;
}
.form-switch .form-check-input:checked { background: var(--primary); border-color: var(--primary); }
.form-switch .form-check-input::after {
  content: ''; position: absolute; top: 2px; right: 2px;
  width: 14px; height: 14px; border-radius: 50%; background: #fff;
  transition: transform .18s;
}
.form-switch .form-check-input:checked::after { transform: translateX(-18px); }
.form-check-label { font-size: .875rem; color: var(--text-primary); cursor: pointer; }

/* Row/Col grid */
.row {
  display: flex; flex-wrap: wrap;
  margin: 0 -.5rem;
}
[class*="col-"] { padding: 0 .5rem; }
.col { flex: 1 0 0%; padding: 0 .5rem; min-width: 0; }
.col-auto { flex: 0 0 auto; width: auto; padding: 0 .5rem; }
.col-12 { width: 100%; }
.col-11 { width: 91.66%; }
.col-10 { width: 83.33%; }
.col-9  { width: 75%; }
.col-8  { width: 66.66%; }
.col-7  { width: 58.33%; }
.col-6  { width: 50%; }
.col-5  { width: 41.66%; }
.col-4  { width: 33.33%; }
.col-3  { width: 25%; }
.col-2  { width: 16.66%; }
.col-1  { width: 8.33%; }
@media (max-width: 768px) {
  [class*="col-"] { width: 100%; }
}
/* Responsive grid (Bootstrap-compatible col-sm / col-md / col-lg) */
@media (min-width: 577px) {
  .col-sm-1{width:8.33%}.col-sm-2{width:16.66%}.col-sm-3{width:25%}
  .col-sm-4{width:33.33%}.col-sm-5{width:41.66%}.col-sm-6{width:50%}
  .col-sm-7{width:58.33%}.col-sm-8{width:66.66%}.col-sm-9{width:75%}
  .col-sm-10{width:83.33%}.col-sm-11{width:91.66%}.col-sm-12{width:100%}
}
@media (min-width: 769px) {
  .col-md-1{width:8.33%}.col-md-2{width:16.66%}.col-md-3{width:25%}
  .col-md-4{width:33.33%}.col-md-5{width:41.66%}.col-md-6{width:50%}
  .col-md-7{width:58.33%}.col-md-8{width:66.66%}.col-md-9{width:75%}
  .col-md-10{width:83.33%}.col-md-11{width:91.66%}.col-md-12{width:100%}
}
@media (min-width: 1025px) {
  .col-lg-1{width:8.33%}.col-lg-2{width:16.66%}.col-lg-3{width:25%}
  .col-lg-4{width:33.33%}.col-lg-5{width:41.66%}.col-lg-6{width:50%}
  .col-lg-7{width:58.33%}.col-lg-8{width:66.66%}.col-lg-9{width:75%}
  .col-lg-10{width:83.33%}.col-lg-11{width:91.66%}.col-lg-12{width:100%}
}
/* Row gutter utilities (spacing provided by .row negative margin; keep vertical rhythm) */
.row[class*="g-"] > [class*="col-"] { margin-bottom: 0; }
.row.g-1 { row-gap: .25rem; }
.row.g-2 { row-gap: .5rem; }
.row.g-3 { row-gap: 1rem; }
.row.g-4 { row-gap: 1.5rem; }

/* ── Tables ──────────────────────────────────────────────────── */
/* .table-container / .data-table are legacy aliases kept in sync with .table-wrapper / .table */
.table-wrapper,
.table-container {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  max-width: 100%;
}
.table-wrapper::after {
  content: '';
  display: block;
  height: 1px;
}
.table,
.data-table {
  width: 100%; border-collapse: collapse;
  font-size: .875rem;
}
.table th,
.data-table th {
  padding: .75rem 1rem;
  background: #f8fafc;
  color: var(--text-secondary); font-weight: 700;
  font-size: .775rem; text-transform: uppercase; letter-spacing: .04em;
  border-bottom: 2px solid var(--border-color);
  white-space: nowrap;
  text-align: right;
}
.table td,
.data-table td {
  padding: .75rem 1rem;
  border-bottom: 1px solid var(--border-color);
  color: var(--text-primary);
  vertical-align: middle;
}
.table tbody tr:hover,
.data-table tbody tr:hover { background: #fafbfc; }
.table tbody tr:last-child td,
.data-table tbody tr:last-child td { border-bottom: none; }
.table .actions { white-space: nowrap; }
.table-striped tbody tr:nth-child(even) { background: #fafbfc; }
.table-striped tbody tr:nth-child(even):hover { background: #f1f5f9; }

/* ── Badges ──────────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; gap: .25rem;
  padding: .25rem .625rem;
  font-size: .7rem; font-weight: 700; letter-spacing: .02em;
  border-radius: 20px; white-space: nowrap;
}
.badge-primary   { background: var(--primary-light);  color: var(--primary); }
.badge-success   { background: var(--success-light);  color: var(--success); }
.badge-warning   { background: var(--warning-light);  color: var(--warning); }
.badge-danger    { background: var(--danger-light);   color: var(--danger); }
.badge-info      { background: var(--info-light);     color: var(--info); }
.badge-secondary { background: #f1f5f9;               color: var(--secondary); }
.badge-dark      { background: #1e293b;               color: #fff; }
.badge-purple    { background: #ede9fe;               color: #7c3aed; }

/* ── Alerts ──────────────────────────────────────────────────── */
.alert {
  padding: .875rem 1rem;
  border-radius: var(--border-radius);
  border: 1px solid transparent;
  display: flex; align-items: flex-start; gap: .75rem;
  font-size: .875rem; margin-bottom: 1rem;
}
.alert-icon { width: 20px; height: 20px; flex-shrink: 0; margin-top: .1rem; }
.alert-content { flex: 1; }
.alert-close {
  background: none; border: none; cursor: pointer;
  opacity: .6; padding: .1rem; color: inherit;
}
.alert-close:hover { opacity: 1; }
.alert-success  { background: var(--success-light);  border-color: #86efac;  color: #166534; }
.alert-danger   { background: var(--danger-light);   border-color: #fca5a5;  color: #991b1b; }
.alert-warning  { background: var(--warning-light);  border-color: #fcd34d;  color: #92400e; }
.alert-info     { background: var(--info-light);     border-color: #67e8f9;  color: #155e75; }

/* ── Modals ──────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 2000;
  display: flex; align-items: center; justify-content: center;
  padding: 1rem;
  opacity: 0; visibility: hidden;
  transition: all .25s;
}
.modal-overlay.open { opacity: 1; visibility: visible; }
.modal {
  background: var(--bg-card);
  border-radius: var(--border-radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%; max-width: 560px;
  max-height: 90vh;
  max-height: 90dvh;
  display: flex; flex-direction: column;
  overflow: hidden;
  min-height: 0;
  transform: scale(.95) translateY(10px);
  transition: transform .25s;
}
/* Form inside modal: scroll body only, keep footer pinned */
.modal > form {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
}
.modal-overlay.open .modal { transform: scale(1) translateY(0); }
.modal-lg { max-width: 800px; }
.modal-xl { max-width: 1100px; }

/* Legacy modal system (toggleModal) — container holds .modal-overlay + .modal-content */
.modal:has(> .modal-content) {
  position: fixed; inset: 0; z-index: 2000;
  display: none; align-items: center; justify-content: center;
  padding: 1rem;
  /* neutralize base .modal (dialog) styles that would otherwise pollute the full-screen container */
  background: transparent; box-shadow: none; border-radius: 0;
  transform: none; width: auto; max-width: none; max-height: none;
}
.modal.open:has(> .modal-content) { display: flex; }
.modal > .modal-overlay {
  position: absolute; inset: 0;
  background: rgba(0,0,0,.5);
  opacity: 1; visibility: visible;
  z-index: 0; /* must sit BELOW .modal-content so the form stays interactive */
}
.modal > .modal-content {
  position: relative; z-index: 1;
  background: var(--bg-card);
  border-radius: var(--border-radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%; max-width: 600px;
  max-height: 90vh; overflow-y: auto;
  display: flex; flex-direction: column;
}
/* Normalize legacy <h5> headings inside modal/card headers for consistent look */
.modal-header h5,
.card-header h5 {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary);
}
.modal-header {
  padding: 1.125rem 1.25rem;
  border-bottom: 1px solid var(--border-color);
  display: flex; align-items: center; justify-content: space-between;
  flex-shrink: 0;
}
.modal-title { font-size: 1rem; font-weight: 700; color: var(--text-primary); }
.modal-close {
  width: 32px; height: 32px;
  border: none; background: none;
  color: var(--text-muted); border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; transition: all .18s;
}
.modal-close:hover { background: var(--danger-light); color: var(--danger); }
.modal-body {
  padding: 1.25rem;
  overflow-y: auto;
  flex: 1 1 auto;
  min-height: 0;
  -webkit-overflow-scrolling: touch;
}
.modal-footer {
  padding: 1rem 1.25rem;
  padding-bottom: calc(1rem + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--border-color);
  display: flex; justify-content: flex-end; align-items: center;
  gap: .5rem;
  flex-shrink: 0;
  background: var(--bg-card);
  position: relative;
  z-index: 1;
}
.modal-footer .btn {
  flex-shrink: 0;
}

/* ── Dropdown ─────────────────────────────────────────────────── */
.dropdown { position: relative; display: inline-block; }
.dropdown-menu {
  position: absolute; top: calc(100% + 4px); left: 0;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  box-shadow: var(--shadow-md);
  min-width: 180px; z-index: 500;
  overflow: hidden;
  opacity: 0; visibility: hidden; transform: translateY(-4px);
  transition: opacity .18s, transform .18s, visibility .18s;
}
.dropdown-menu.open { opacity: 1; visibility: visible; transform: translateY(0); }
.dropdown-menu--fixed {
  position: fixed;
  z-index: 3500;
  transform: none;
}
.dropdown-menu--fixed.open { transform: none; }
.dropdown-trigger {
  width: 34px; height: 34px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
}
.dropdown-item {
  display: flex; align-items: center; gap: .625rem;
  padding: .625rem 1rem;
  font-size: .85rem; color: var(--text-primary);
  cursor: pointer; transition: background .15s;
  border: none; background: none; width: 100%;
}
.dropdown-item:hover { background: var(--bg-hover); }
.dropdown-item.danger { color: var(--danger); }
.dropdown-item svg { width: 16px; height: 16px; opacity: .7; }
.dropdown-divider { height: 1px; background: var(--border-color); margin: .25rem 0; }

/* ── Tabs ────────────────────────────────────────────────────── */
.tabs {
  display: flex; gap: .25rem;
  border-bottom: 2px solid var(--border-color);
  margin-bottom: 1.5rem; overflow-x: auto;
  scrollbar-width: thin;
}
.tab-btn {
  position: relative;
  padding: .65rem 1.15rem;
  font-size: .875rem; font-weight: 600; font-family: inherit;
  color: var(--text-secondary); border: none; background: none;
  cursor: pointer; white-space: nowrap;
  border-radius: 8px 8px 0 0;
  border-bottom: 3px solid transparent; margin-bottom: -2px;
  transition: color .18s, background .18s; display: flex; align-items: center; gap: .4rem;
}
.tab-btn:hover { color: var(--primary); background: var(--bg-hover); }
.tab-btn.active {
  color: var(--primary);
  background: rgba(37, 99, 235, .09);
  font-weight: 700;
}
.tab-btn.active::after {
  content: '';
  position: absolute;
  left: .65rem; right: .65rem; bottom: -2px;
  height: 3px; border-radius: 3px 3px 0 0;
  background: var(--primary);
}
.tab-btn .badge { transition: all .18s; }
.tab-btn.active .badge {
  background: var(--primary);
  color: #fff;
}
.tab-pane { display: none; }
.tab-pane.active { display: block; }

/* ── Progress ────────────────────────────────────────────────── */
.progress {
  height: 8px; background: var(--border-color);
  border-radius: 4px; overflow: hidden;
}
.progress-bar {
  height: 100%; background: var(--primary);
  border-radius: 4px; transition: width .4s ease;
}
.progress-bar.success { background: var(--success); }
.progress-bar.warning { background: var(--warning); }
.progress-bar.danger  { background: var(--danger); }

/* ── Timeline ────────────────────────────────────────────────── */
.timeline { position: relative; padding-right: 1.5rem; }
.timeline::before {
  content: ''; position: absolute;
  right: .65rem; top: 0; bottom: 0; width: 2px;
  background: var(--border-color);
}
.timeline-item {
  position: relative; padding-bottom: 1.5rem;
  padding-right: 1.5rem;
}
.timeline-item:last-child { padding-bottom: 0; }
.timeline-dot {
  position: absolute; right: -1.5rem;
  width: 12px; height: 12px; border-radius: 50%;
  border: 2px solid var(--bg-card);
  top: .3rem; background: var(--primary);
}
.timeline-dot.success { background: var(--success); }
.timeline-dot.warning { background: var(--warning); }
.timeline-dot.danger  { background: var(--danger); }
.timeline-content { background: var(--bg-hover); border-radius: var(--border-radius); padding: .75rem 1rem; }
.timeline-title { font-weight: 600; font-size: .875rem; margin-bottom: .25rem; }
.timeline-time { font-size: .75rem; color: var(--text-muted); }

/* ── Status Steps ────────────────────────────────────────────── */
.status-steps { display: flex; align-items: center; gap: 0; flex-wrap: nowrap; overflow-x: auto; }
.status-step {
  display: flex; align-items: center; flex: 1; min-width: 80px;
}
.step-bubble {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--border-color); color: var(--text-muted);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: .75rem; flex-shrink: 0; z-index: 1;
}
.status-step.done .step-bubble  { background: var(--success); color: #fff; }
.status-step.active .step-bubble { background: var(--primary); color: #fff; box-shadow: 0 0 0 4px var(--primary-light); }
.step-line { flex: 1; height: 2px; background: var(--border-color); }
.status-step.done .step-line { background: var(--success); }
.step-label {
  display: none;
  font-size: .65rem; color: var(--text-muted);
  margin-top: .25rem; text-align: center; white-space: nowrap;
}

/* ── Notifications Panel ──────────────────────────────────────── */
.notif-panel {
  position: fixed; top: var(--header-height); left: 0;
  width: 360px; max-height: 500px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 0 0 var(--border-radius-lg) var(--border-radius-lg);
  box-shadow: var(--shadow-lg); z-index: 900;
  overflow: hidden;
  transform: translateY(-10px); opacity: 0; visibility: hidden;
  transition: all .25s;
}
.notif-panel.open { transform: translateY(0); opacity: 1; visibility: visible; }
.notif-panel-header {
  padding: .875rem 1rem;
  border-bottom: 1px solid var(--border-color);
  display: flex; align-items: center; justify-content: space-between;
}
.notif-panel-title { font-weight: 700; font-size: .925rem; display: block; }
.notif-panel-sub {
  display: block; font-size: .72rem; color: var(--text-muted); margin-top: .15rem;
}
.notif-panel-actions {
  display: flex; align-items: center; gap: .5rem; flex-shrink: 0;
}
.notif-panel-link {
  font-size: .8rem; color: var(--primary); white-space: nowrap;
}
.notif-panel-link:hover { text-decoration: underline; }
.notif-list { overflow-y: auto; max-height: 380px; min-height: 120px; }
.notif-panel-placeholder,
.notif-panel-error {
  padding: 2rem 1rem; text-align: center; color: var(--text-muted);
  display: flex; flex-direction: column; align-items: center; gap: .75rem;
  font-size: .85rem;
}
.notif-panel-error p { margin: 0; color: var(--danger); }
.notif-item {
  display: flex; gap: .75rem;
  padding: .875rem 1rem;
  border-bottom: 1px solid var(--border-color);
  transition: background .15s; cursor: pointer;
}
.notif-item-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: .5rem; margin-bottom: .2rem;
}
.notif-type-badge {
  font-size: .65rem; font-weight: 600; color: var(--text-muted);
}
.notif-item-actions {
  display: flex; gap: .5rem; margin-top: .5rem;
}
.notif-item:hover { background: var(--bg-hover); }
.notif-item.unread { background: var(--primary-light); }
.notif-item.unread:hover { background: #dbeafe; }
.notif-icon {
  width: 36px; height: 36px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.notif-icon svg { width: 18px; height: 18px; }
.notif-icon.warning { background: var(--warning-light); color: var(--warning); }
.notif-icon.danger  { background: var(--danger-light);  color: var(--danger); }
.notif-icon.success { background: var(--success-light); color: var(--success); }
.notif-icon.info    { background: var(--info-light);    color: var(--info); }
.notif-body { flex: 1; }
.notif-title { font-size: .825rem; font-weight: 600; color: var(--text-primary); }
.notif-text  { font-size: .775rem; color: var(--text-secondary); margin-top: .125rem; }
.notif-time  { font-size: .7rem; color: var(--text-muted); }

/* Notifications full page */
.notif-page-tabs {
  display: flex; gap: .5rem; margin-bottom: 1rem;
}
.notif-page-tab {
  display: inline-flex; align-items: center; gap: .35rem;
  padding: .5rem 1rem; border-radius: 999px;
  background: var(--bg-card); border: 1px solid var(--border-color);
  color: var(--text-secondary); font-size: .85rem; font-weight: 600;
  transition: all .15s;
}
.notif-page-tab:hover { border-color: var(--primary); color: var(--primary); }
.notif-page-tab.active {
  background: var(--primary-light); border-color: var(--primary); color: var(--primary);
}
.notif-page-card { overflow: hidden; }
.notif-page-list .notif-item { cursor: default; }
.notif-page-list .notif-item:last-child { border-bottom: none; }
.notif-page-list .notif-title {
  margin: 0; font-size: .9rem; font-weight: 700;
}
.notif-page-list .notif-text { margin: .35rem 0 0; }
.notif-empty-state {
  padding: 3rem 2rem; text-align: center; color: var(--text-muted);
}
.notif-empty-state--panel { padding: 2rem 1rem; }
.notif-empty-state h3,
.notif-empty-state p { margin: 0; }
.notif-empty-state h3 {
  font-size: 1rem; color: var(--text-primary); margin-bottom: .35rem;
}
.notif-empty-icon { font-size: 2.5rem; margin-bottom: .75rem; opacity: .85; }

/* ── Dashboard Widgets ────────────────────────────────────────── */
.widget-chart { min-height: 200px; }
.mini-chart-bar {
  display: flex; align-items: flex-end; gap: 4px;
  height: 50px;
}
.mini-bar {
  flex: 1; background: var(--primary-light); border-radius: 3px 3px 0 0;
  transition: height .3s;
}
.mini-bar.active { background: var(--primary); }

/* PI Gauge */
.pi-gauge {
  text-align: center;
}
.pi-circle {
  width: 120px; height: 120px; border-radius: 50%;
  background: conic-gradient(var(--primary) 0deg, var(--border-color) 0deg);
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 1rem;
  position: relative;
}
.pi-circle::before {
  content: ''; position: absolute; inset: 10px;
  background: var(--bg-card); border-radius: 50%;
}
.pi-value {
  position: relative; z-index: 1;
  font-size: 1.375rem; font-weight: 800;
}

/* ── Info Grid ───────────────────────────────────────────────── */
.info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1rem;
}
.info-item label { font-size: .775rem; color: var(--text-muted); font-weight: 600; display: block; margin-bottom: .25rem; }
.info-item span  { font-size: .9rem; color: var(--text-primary); font-weight: 500; }

/* ── Empty State ─────────────────────────────────────────────── */
.empty-state {
  text-align: center; padding: 4rem 1rem; color: var(--text-muted);
}
.empty-state svg { width: 64px; height: 64px; margin-bottom: 1rem; opacity: .3; }
.empty-state h3 { font-size: 1.125rem; color: var(--text-secondary); margin-bottom: .5rem; }
.empty-state p  { font-size: .875rem; }

/* ── Loading ─────────────────────────────────────────────────── */
.spinner {
  width: 20px; height: 20px;
  border: 2.5px solid var(--border-color);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .8s linear infinite;
  display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }
.page-loader {
  position: fixed; inset: 0;
  background: rgba(255,255,255,.85);
  z-index: 9999;
  display: flex; align-items: center; justify-content: center;
}

/* ── Filter Bar ──────────────────────────────────────────────── */
.filter-bar {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-lg);
  padding: 1rem 1.25rem;
  margin-bottom: 1rem;
  display: flex; gap: .75rem; flex-wrap: wrap; align-items: flex-end;
}
.filter-bar .form-group { margin-bottom: 0; flex: 1; min-width: 160px; }

/* ── Search ──────────────────────────────────────────────────── */
.search-box {
  position: relative;
}
.search-box .form-control { padding-right: 2.5rem; }
.task-check {
  width: 22px; height: 22px;
  border: 2px solid var(--border-color);
  border-radius: 50%;
  background: #fff;
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer; color: #fff;
  transition: all .15s;
}
.task-check:hover { border-color: var(--primary); }
.task-check.checked {
  background: var(--success, #16a34a);
  border-color: var(--success, #16a34a);
}

.page-content.is-filtering {
  opacity: 0.55;
  pointer-events: none;
  transition: opacity 0.12s ease;
}

.search-box .search-icon {
  position: absolute; right: .75rem; top: 50%; transform: translateY(-50%);
  color: var(--text-muted); pointer-events: none;
  width: 16px; height: 16px;
}

/* ── Misc Utilities ──────────────────────────────────────────── */
.d-flex   { display: flex; }
.d-grid   { display: grid; }
.d-block  { display: block; }
.d-none   { display: none; }
.d-inline { display: inline; }
.align-center   { align-items: center; }
.justify-between { justify-content: space-between; }
.justify-center  { justify-content: center; }
.justify-end     { justify-content: flex-end; }
.flex-1          { flex: 1; }
.gap-1 { gap: .25rem; }
.gap-2 { gap: .5rem; }
.gap-3 { gap: .75rem; }
.gap-4 { gap: 1rem; }
.gap-6 { gap: 1.5rem; }
.flex-wrap { flex-wrap: wrap; }
.mt-1 { margin-top: .25rem; }
.mt-2 { margin-top: .5rem; }
.mt-3 { margin-top: .75rem; }
.mt-4 { margin-top: 1rem; }
.mt-6 { margin-top: 1.5rem; }
.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: .25rem; }
.mb-2 { margin-bottom: .5rem; }
.mb-3 { margin-bottom: .75rem; }
.mb-4 { margin-bottom: 1rem; }
.mb-6 { margin-bottom: 1.5rem; }
.p-0  { padding: 0; }
.p-1  { padding: .25rem; }
.p-2  { padding: .5rem; }
.p-3  { padding: .75rem; }
.p-4  { padding: 1rem; }
.text-right   { text-align: right; }
.text-center  { text-align: center; }
.text-left    { text-align: left; }
.text-small   { font-size: .8rem; }
.text-muted   { color: var(--text-muted); }
.text-primary-color { color: var(--primary); }
.text-success { color: var(--success); }
.text-danger  { color: var(--danger); }
.text-warning { color: var(--warning); }
.text-info    { color: var(--info); }
.font-bold    { font-weight: 700; }
.font-semibold{ font-weight: 600; }
.font-medium  { font-weight: 500; }
.w-100 { width: 100%; }

/* Filter forms: action buttons should hug their content, not stretch full-width.
   Their wrapper column should also shrink instead of taking a fixed grid width. */
.live-filter-form .btn { width: auto; }
.live-filter-form > [class*="col-"]:has(> .btn:only-child) { width: auto; flex: 0 0 auto; }
.h-100 { height: 100%; }
.rounded      { border-radius: var(--border-radius); }
.rounded-full { border-radius: 50%; }
.overflow-hidden { overflow: hidden; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ── Divider ─────────────────────────────────────────────────── */
.divider {
  height: 1px; background: var(--border-color);
  margin: 1rem 0; border: none;
}

/* ── Tooltip ─────────────────────────────────────────────────── */
[data-tooltip] { position: relative; cursor: help; }
[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute; bottom: 100%; right: 50%; transform: translateX(50%);
  background: var(--dark); color: #fff;
  padding: .35rem .625rem; border-radius: 5px;
  font-size: .75rem; white-space: nowrap;
  opacity: 0; pointer-events: none;
  transition: opacity .18s; margin-bottom: 4px; z-index: 1000;
}
[data-tooltip]:hover::after { opacity: 1; }

/* ── Login Page ──────────────────────────────────────────────── */
.login-page {
  min-height: 100vh;
  background: linear-gradient(135deg, #0f172a 0%, #1e3a5f 50%, #0f172a 100%);
  display: flex; align-items: center; justify-content: center;
  padding: 1.5rem;
  position: relative; overflow: hidden;
}
.login-page::before {
  content: '';
  position: absolute; inset: 0;
  background-image: radial-gradient(circle at 20% 80%, rgba(37,99,235,.2) 0%, transparent 50%),
                    radial-gradient(circle at 80% 20%, rgba(99,102,241,.2) 0%, transparent 50%);
}
.login-card {
  width: 100%; max-width: 420px;
  background: rgba(255,255,255,.97);
  border-radius: 16px;
  padding: 2.5rem;
  box-shadow: 0 25px 60px rgba(0,0,0,.4);
  position: relative; z-index: 1;
}
.login-logo {
  text-align: center; margin-bottom: 2rem;
}
.login-logo-icon {
  width: 56px; height: 56px; border-radius: 14px;
  background: linear-gradient(135deg, var(--primary), #6366f1);
  display: inline-flex; align-items: center; justify-content: center;
  margin-bottom: .75rem;
}
.login-logo-icon svg { width: 30px; height: 30px; fill: white; }
.login-title { font-size: 1.5rem; font-weight: 800; color: var(--text-primary); }
.login-subtitle { font-size: .875rem; color: var(--text-secondary); margin-top: .25rem; }

/* ── Charts (CSS-based) ──────────────────────────────────────── */
.bar-chart-container { display: flex; align-items: flex-end; gap: 4px; height: 120px; }
.bar-chart-bar {
  flex: 1; border-radius: 4px 4px 0 0;
  background: var(--primary);
  transition: height .4s ease;
  min-height: 4px;
  position: relative; cursor: pointer;
}
.bar-chart-bar:hover { filter: brightness(1.1); }
.bar-chart-bar::after {
  content: attr(data-value);
  position: absolute; bottom: calc(100% + 4px); right: 50%; transform: translateX(50%);
  font-size: .7rem; color: var(--text-secondary); white-space: nowrap;
}
.bar-chart-labels {
  display: flex; gap: 4px;
  font-size: .7rem; color: var(--text-muted);
}
.bar-chart-labels span { flex: 1; text-align: center; }

/* ── Pagination ──────────────────────────────────────────────── */
.pagination-nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
}
.pagination {
  display: flex;
  flex-wrap: wrap;
  gap: .35rem;
  list-style: none;
  margin: 0;
  padding: 0;
}
.page-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 36px;
  min-height: 36px;
  padding: .35rem .65rem;
  border-radius: 8px;
  border: 1px solid var(--border-color);
  background: #fff;
  color: var(--text-secondary);
  font-size: .82rem;
  font-weight: 600;
}
.page-link:hover { border-color: var(--primary); color: var(--primary); }
.page-link.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}
.pagination-info {
  font-size: .8rem;
  color: var(--text-muted);
}

/* ── Responsive ──────────────────────────────────────────────── */
body.sidebar-mobile-open { overflow: hidden; }

@media (max-width: 992px) {
  :root { --header-height: 56px; }

  .sidebar {
    width: min(300px, 88vw);
    transform: translateX(100%);
    transition: transform .28s cubic-bezier(.4,0,.2,1), box-shadow .28s;
    box-shadow: none;
  }
  .sidebar.mobile-open {
    transform: translateX(0);
    box-shadow: -8px 0 32px rgba(0,0,0,.35);
  }
  .sidebar.collapsed { width: min(300px, 88vw); }

  .main-content,
  .main-content.sidebar-collapsed {
    margin-right: 0;
    width: 100%;
  }

  .mobile-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, .55);
    z-index: 999;
    backdrop-filter: blur(2px);
  }
  .mobile-overlay.show { display: block; }

  .top-header {
    padding: 0 .75rem;
    gap: .5rem;
  }
  .header-toggle-btn { flex-shrink: 0; }
  .header-actions { flex-shrink: 0; }
  .header-breadcrumb {
    font-size: .8rem;
    min-width: 0;
    flex: 1;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
  }
  /* On mobile keep only the current page so it is always visible */
  .header-breadcrumb > *:not(:last-child) { display: none; }
  .header-breadcrumb > *:last-child {
    color: var(--text-primary);
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .header-user-text { display: none; }
  .header-user-chevron { display: none; }
  .header-user { padding: .25rem; }

  .page-content { padding: 1rem; }
  .page-title { font-size: 1.2rem; }
  .page-header { gap: .75rem; }
  .page-actions { width: 100%; }
  .page-actions .btn { flex: 1; justify-content: center; }

  .col-4 { width: 50%; }
  .col-3 { width: 50%; }

  .notif-panel {
    width: auto;
    left: .75rem;
    right: .75rem;
    max-width: none;
    border-radius: var(--border-radius-lg);
  }

  .roles-layout { grid-template-columns: 1fr; }
  .modal-lg, .modal-xl { max-width: 100%; }
}

@media (max-width: 768px) {
  [class*="col-"] { width: 100%; }

  .filter-bar,
  .users-filter-form {
    flex-direction: column;
    align-items: stretch;
  }
  .filter-bar .form-group,
  .users-filter-search { min-width: 0; width: 100%; }
  .filter-bar .btn,
  .users-filter-actions { width: 100%; }
  .users-filter-actions { display: flex; gap: .5rem; }

  .table th,
  .table td {
    padding: .6rem .65rem;
    font-size: .8rem;
  }
  .table th { font-size: .7rem; }

  .card-header,
  .card-footer { padding: .875rem 1rem; }
  .card-body { padding: 1rem; }

  .btn { min-height: 40px; }
  .btn-sm { min-height: 34px; }

  .stat-card {
    padding: 1rem;
    gap: .75rem;
    margin: 0 0 .75rem !important;
  }
  .stat-icon { width: 44px; height: 44px; }
  .stat-icon svg { width: 22px; height: 22px; }
  .stat-value { font-size: 1.35rem; }

  .tabs { gap: 0; }
  .tab-btn { font-size: .8rem; padding: .5rem .75rem; }

  .status-steps { padding-bottom: .25rem; }

  .pagination-nav {
    flex-direction: column;
    align-items: stretch;
  }
  .pagination { justify-content: center; }
  .pagination-info { text-align: center; }

  input.form-control,
  select.form-control,
  textarea.form-control {
    font-size: 16px;
  }

  /* Modal: scroll form body only; keep action buttons visible */
  .modal-header { flex-shrink: 0; }
  .modal-footer {
    flex-wrap: wrap;
    justify-content: stretch;
  }
  .modal-footer .btn {
    flex: 1 1 auto;
    min-width: 7rem;
    justify-content: center;
  }
}

@media (max-width: 576px) {
  html { font-size: 15px; }

  .jalali-picker--portal {
    top: auto !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: auto !important;
    max-width: 100%;
    border-radius: 16px 16px 0 0;
    padding-bottom: calc(.75rem + env(safe-area-inset-bottom, 0px));
    transform: translateY(100%);
    transform-origin: bottom center;
  }
  .jalali-picker--portal.is-open {
    transform: translateY(0);
  }

  .page-content {
    padding: .75rem;
    padding-bottom: calc(.75rem + env(safe-area-inset-bottom, 0px));
  }
  .top-header {
    padding-inline: calc(.65rem + env(safe-area-inset-right, 0px)) calc(.65rem + env(safe-area-inset-left, 0px));
  }

  .page-header {
    flex-direction: column;
    align-items: stretch;
  }
  .page-actions { flex-direction: column; }
  .page-actions .btn { width: 100%; }

  .stat-card {
    flex-direction: row;
    text-align: right;
  }

  .modal-overlay { padding: 0; align-items: flex-end; }
  .modal {
    margin: 0;
    max-width: 100%;
    max-height: 92vh;
    max-height: 92dvh;
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
  }
  .modal-overlay.open .modal {
    animation: modal-slide-up .28s ease;
  }
  @keyframes modal-slide-up {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
  }
  .modal-header { flex-shrink: 0; }
  .modal-body { padding: 1rem; }
  .modal-footer {
    flex-direction: column-reverse;
    align-items: stretch;
    padding: .75rem 1rem;
    padding-bottom: calc(.75rem + env(safe-area-inset-bottom, 0px));
    gap: .5rem;
  }
  .modal-footer .btn {
    width: 100%;
    justify-content: center;
    min-height: 44px;
  }

  .notif-panel {
    top: var(--header-height);
    left: 0;
    right: 0;
    border-radius: 0 0 var(--border-radius-lg) var(--border-radius-lg);
  }

  .login-card { padding: 1.75rem 1.25rem; }

  .users-stats { grid-template-columns: 1fr 1fr; }
  .user-cell { min-width: 0; }
  .users-table .table-col-actions { width: 56px; }

  .d-flex.gap-3.w-100 { flex-direction: column; }
  .d-flex.gap-3.w-100 .form-group[style*="padding-top"] {
    padding-top: 0 !important;
    width: 100%;
  }
}

@media (max-width: 400px) {
  .users-stats { grid-template-columns: 1fr; }
  .header-actions { gap: .25rem; }
  .notif-panel-header {
    flex-direction: column;
    align-items: flex-start;
    gap: .5rem;
  }
}

/* ── Section Label ──────────────────────────────────────────── */
.section-label {
  font-size: .75rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .08em; color: var(--text-muted);
  padding-bottom: .5rem; border-bottom: 2px solid var(--border-color);
}

/* ── Row highlights ──────────────────────────────────────────── */
.row-danger  { background: rgba(239,68,68,.05); }
.row-highlighted { background: rgba(99,102,241,.08); }

/* ── Card link hover ─────────────────────────────────────────── */
.card-link { transition: box-shadow .2s, transform .15s; }
.card-link:hover { box-shadow: 0 8px 24px rgba(0,0,0,.1); transform: translateY(-2px); }

/* ── fw-bold ─────────────────────────────────────────────────── */
.fw-bold { font-weight: 700; }
.text-end { text-align: left; }

/* ── Button xs / block ──────────────────────────────────────── */
.btn-xs { padding: .2rem .5rem; font-size: .75rem; border-radius: 6px; }
.btn-block { display: flex; width: 100%; justify-content: center; }

/* ── Background color utilities (progress bars, accents) ─────── */
.bg-primary { background: var(--primary) !important; color: #fff; }
.bg-success { background: var(--success) !important; color: #fff; }
.bg-warning { background: var(--warning) !important; color: #fff; }
.bg-danger  { background: var(--danger)  !important; color: #fff; }
.bg-info    { background: var(--info)    !important; color: #fff; }

/* ── d-flex gap ─────────────────────────────────────────────── */
.d-flex { display: flex; }
.d-inline-flex { display: inline-flex; }
.gap-1  { gap: .25rem; }
.gap-2  { gap: .5rem; }
.gap-3  { gap: .75rem; }
.gap-4  { gap: 1rem; }
.align-items-center { align-items: center; }
.align-items-start { align-items: flex-start; }
.align-items-end { align-items: flex-end; }
.justify-content-between { justify-content: space-between; }
.justify-content-center { justify-content: center; }
.justify-content-end { justify-content: flex-end; }
.flex-wrap { flex-wrap: wrap; }
.flex-column { flex-direction: column; }

/* ── Print ───────────────────────────────────────────────────── */
@media print {
  .sidebar, .top-header, .page-actions, .btn, .filter-bar { display: none !important; }
  .main-content { margin-right: 0; }
  .card { box-shadow: none; border: 1px solid #ddd; }
}

/* ── Roles & permissions page ─────────────────────────────────── */
.roles-layout {
  display: grid;
  grid-template-columns: minmax(280px, 320px) minmax(0, 1fr);
  gap: 1.25rem;
  align-items: start;
}
.roles-sidebar {
  position: sticky;
  top: 1rem;
  align-self: start;
  max-height: calc(100vh - 6.5rem);
  display: flex;
  flex-direction: column;
  gap: .75rem;
  overflow: hidden;
}
.roles-list-card {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.roles-list-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .5rem;
  flex-shrink: 0;
}
.roles-list {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 280px;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  scroll-behavior: smooth;
  scrollbar-gutter: stable;
}
.roles-list-item {
  display: flex;
  align-items: center;
  gap: .65rem;
  padding: .85rem 1rem;
  border-bottom: 1px solid var(--border-color);
  text-decoration: none;
  color: inherit;
  transition: background .15s, border-color .15s;
  flex-shrink: 0;
}
.roles-list-item:hover { background: #f8fafc; }
.roles-list-item.active {
  background: var(--primary-light, #eff6ff);
  box-shadow: inset 3px 0 0 var(--primary, #4f46e5);
}
.roles-list-indicator {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--primary, #4f46e5);
  flex-shrink: 0;
  opacity: 0;
  transform: scale(.6);
  transition: opacity .15s, transform .15s;
}
.roles-list-item.active .roles-list-indicator {
  opacity: 1;
  transform: scale(1);
}
.roles-list-item-main { min-width: 0; flex: 1; }
.roles-list-name {
  display: block;
  font-weight: 700;
  font-size: .9rem;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.roles-list-meta {
  display: block;
  margin-top: .15rem;
  font-size: .75rem;
  color: var(--text-muted);
}
.roles-new-role {
  flex-shrink: 0;
}
.roles-new-role-toggle {
  list-style: none;
  cursor: pointer;
  padding: .75rem 1rem;
  border: 1px dashed var(--border-color);
  border-radius: var(--border-radius, 8px);
  font-size: .85rem;
  font-weight: 600;
  color: var(--primary);
  background: var(--bg-card);
}
.roles-new-role-toggle::-webkit-details-marker { display: none; }
.roles-new-role[open] .roles-new-role-toggle {
  border-style: solid;
  background: var(--primary-light, #eff6ff);
}
.roles-new-role-card { margin-top: .75rem; }
.roles-main {
  min-width: 0;
  align-self: start;
}
.roles-panel[hidden] { display: none !important; }
.roles-perm-toolbar {
  display: flex;
  gap: .5rem;
  margin-bottom: 1rem;
  padding-bottom: .75rem;
  border-bottom: 1px dashed var(--border-color);
}
.roles-perm-module-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .5rem;
  margin-bottom: .75rem;
  padding-bottom: .5rem;
  border-bottom: 1px solid var(--border-color);
}
.roles-perm-module-toggle {
  border: none;
  background: transparent;
  color: var(--primary);
  font-size: .75rem;
  font-weight: 700;
  cursor: pointer;
  padding: .15rem .35rem;
  border-radius: 4px;
}
.roles-perm-module-toggle:hover { background: var(--primary-light); }
.roles-edit-card .card-body { padding: 0; }
.roles-edit-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border-color);
  background: linear-gradient(180deg, #f8fafc 0%, #fff 100%);
}
.roles-edit-label {
  font-size: .75rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .04em;
  margin-bottom: .25rem;
}
.roles-edit-title {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--text-primary);
}
.roles-edit-desc {
  margin: .35rem 0 0;
  font-size: .85rem;
  color: var(--text-muted);
}
.roles-edit-form { padding: 1.25rem 1.5rem 1.5rem; }
.roles-perm-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}
.roles-perm-module {
  padding: 1rem;
  background: var(--bg-secondary, #f8fafc);
  border: 1px solid var(--border-color);
  border-radius: 10px;
}
.roles-perm-module-title {
  font-weight: 800;
  font-size: .9rem;
  color: var(--text-primary);
}
.roles-perm-list {
  display: flex;
  flex-direction: column;
  gap: .45rem;
}
.roles-perm-check {
  display: flex;
  align-items: center;
  gap: .5rem;
  font-size: .8rem;
  cursor: pointer;
  color: var(--text-secondary);
}
.roles-perm-check input { flex-shrink: 0; }
.roles-perm-check span { word-break: break-word; }
.roles-edit-footer {
  display: flex;
  flex-wrap: wrap;
  gap: .75rem;
  margin-top: 1.25rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border-color);
  position: sticky;
  bottom: 0;
  background: var(--bg-card);
}
.roles-edit-actions {
  display: flex;
  align-items: center;
  gap: .5rem;
  flex-shrink: 0;
}
.roles-delete-form { margin: 0; }

/* ── Users management page ───────────────────────────────────── */
.users-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1rem;
  margin-bottom: 1rem;
}
.users-stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-lg);
  padding: 1rem 1.1rem;
  box-shadow: var(--shadow-sm);
}
.users-stat-label {
  display: block;
  font-size: .78rem;
  color: var(--text-muted);
  margin-bottom: .35rem;
}
.users-stat-value {
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--text-primary);
}
.users-stat-card--success .users-stat-value { color: var(--success); }
.users-stat-card--muted .users-stat-value { color: var(--text-secondary); }
.users-stat-card--info .users-stat-value { color: var(--primary); }
.users-filter-card { margin-bottom: 1rem; }
.users-filter-form {
  display: flex;
  align-items: flex-end;
  gap: 1rem;
  flex-wrap: wrap;
}
.users-filter-search { flex: 1; min-width: 240px; }
.users-filter-actions {
  display: flex;
  gap: .5rem;
  flex-shrink: 0;
}
.users-table-card { overflow: visible; }
.users-table-card .table-wrapper { overflow-x: auto; overflow-y: visible; }

/* Mobile: stack the users table into cards instead of a horizontal scroll frame */
@media (max-width: 768px) {
  .users-table-card .table-wrapper { overflow: visible; }
  .users-table { border: 0; }
  .users-table thead { display: none; }
  .users-table tbody,
  .users-table tr,
  .users-table td { display: block; width: 100%; }
  .users-table tr {
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: .5rem .25rem;
    margin-bottom: .75rem;
    background: var(--bg-card);
    box-shadow: var(--shadow-sm);
  }
  .users-table td {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: .5rem .85rem;
    border: 0;
    text-align: left;
  }
  .users-table td::before {
    content: attr(data-label);
    font-weight: 600;
    color: var(--text-secondary);
    font-size: .8rem;
    flex-shrink: 0;
  }
  .users-table td[data-label="کاربر"] { justify-content: flex-start; }
  .users-table td[data-label="کاربر"]::before { display: none; }
  .users-table td.table-col-actions {
    width: 100%;
    justify-content: flex-end;
    border-top: 1px solid var(--border-color);
    margin-top: .25rem;
    padding-top: .6rem;
  }
  .users-table td:not([data-label]) { display: block; }
  .users-table td:not([data-label])::before { display: none; }
  .users-table .users-empty { text-align: center; }
}
.table-col-actions {
  width: 72px;
  text-align: center;
  white-space: nowrap;
}
.user-cell {
  display: flex;
  align-items: center;
  gap: .75rem;
  min-width: 200px;
}
.user-avatar-sm {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), #6366f1);
  color: #fff;
  font-weight: 700;
  font-size: .85rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.user-cell-meta { min-width: 0; }
.user-cell-name {
  display: block;
  font-weight: 700;
  color: var(--text-primary);
}
.user-cell-username {
  display: block;
  font-size: .75rem;
  color: var(--text-muted);
  margin-top: .1rem;
}
.dropdown-form { margin: 0; }
.dropdown-hint {
  display: block;
  padding: .5rem 1rem .75rem;
  font-size: .75rem;
  color: var(--text-muted);
}
.users-empty {
  padding: 2.5rem 1rem;
  text-align: center;
  color: var(--text-muted);
}
.users-empty h3 {
  margin: 0 0 .35rem;
  font-size: 1rem;
  color: var(--text-primary);
}
.users-empty p { margin: 0; font-size: .875rem; }
.users-empty-icon { font-size: 2rem; margin-bottom: .75rem; opacity: .85; }
@media (max-width: 900px) {
  .users-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 520px) {
  .users-stats { grid-template-columns: 1fr; }
  .users-filter-actions { width: 100%; }
  .users-filter-actions .btn { flex: 1; }
}
.roles-empty {
  padding: 3rem 2rem;
  text-align: center;
}
.roles-empty-icon { font-size: 3rem; margin-bottom: 1rem; }
.roles-empty-title {
  margin: 0 0 .5rem;
  font-size: 1.1rem;
  font-weight: 700;
}
.roles-empty-text {
  margin: 0;
  color: var(--text-muted);
  font-size: .9rem;
  max-width: 360px;
  margin-inline: auto;
}
@media (max-width: 1100px) {
  .roles-perm-grid { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
  .roles-layout {
    grid-template-columns: 1fr;
  }
  .roles-sidebar {
    position: static;
    max-height: none;
  }
  .roles-list {
    min-height: 220px;
    max-height: 280px;
  }
}

/* ── Jalali datepicker ───────────────────────────────────────── */
.jalali-date-wrap {
  position: relative;
  display: flex;
  align-items: stretch;
  gap: 0;
  z-index: 1;
}
.jalali-date-wrap.is-active {
  z-index: 2;
}
.jalali-date-wrap.is-active .form-control,
.jalali-date-wrap.is-active .jalali-date-btn {
  border-color: var(--primary, #4f46e5);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, .12);
}
.jalali-date-wrap .form-control {
  border-top-left-radius: 0;
  border-bottom-left-radius: 0;
  flex: 1;
}
.jalali-date-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 .75rem;
  border: 1px solid var(--border-color, #e2e8f0);
  border-right: none;
  border-radius: var(--radius, 8px) 0 0 var(--radius, 8px);
  background: var(--bg-secondary, #f8fafc);
  color: var(--text-muted, #64748b);
  cursor: pointer;
  flex-shrink: 0;
}
.jalali-date-btn:hover { background: var(--primary-light, #eff6ff); color: var(--primary, #4f46e5); }

.jalali-picker-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, .4);
  z-index: 3990;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity .2s ease, visibility .2s ease;
}
.jalali-picker-backdrop.is-open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}
body.jalali-picker-open { overflow: hidden; }

.jalali-picker {
  background: var(--bg-card);
  border: 1px solid var(--border-color, #e2e8f0);
  border-radius: 12px;
  box-shadow: 0 20px 48px rgba(15, 23, 42, .18), 0 4px 12px rgba(15, 23, 42, .08);
  padding: .75rem;
}
.jalali-picker--portal {
  position: fixed;
  z-index: 4000;
  width: 288px;
  opacity: 0;
  transform: translateY(6px) scale(.98);
  transform-origin: top right;
  transition: opacity .16s ease, transform .16s ease;
  pointer-events: none;
}
.jalali-picker--portal.is-open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}
.jalali-picker--portal.jalali-picker--above {
  transform-origin: bottom right;
}
.jalali-picker-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: .5rem;
  gap: .25rem;
}
.jalali-picker-title {
  flex: 1;
  text-align: center;
  font-weight: 700;
  font-size: .9rem;
}
.jalali-nav, .jalali-day, .jalali-today-btn, .jalali-clear-btn {
  border: none;
  background: transparent;
  cursor: pointer;
  font-family: inherit;
}
.jalali-nav {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  color: var(--text-muted);
}
.jalali-nav:hover { background: var(--bg-secondary); color: var(--primary); }
.jalali-picker-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  text-align: center;
  font-size: .7rem;
  color: var(--text-muted);
  margin-bottom: .35rem;
}
.jalali-picker-days {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
}
.jalali-day {
  height: 32px;
  border-radius: 6px;
  font-size: .82rem;
  color: var(--text-primary);
}
.jalali-day:hover { background: var(--primary-light); color: var(--primary); }
.jalali-day.selected { background: var(--primary); color: #fff; font-weight: 700; }
.jalali-picker-footer {
  display: flex;
  justify-content: space-between;
  margin-top: .5rem;
  padding-top: .5rem;
  border-top: 1px solid var(--border-color);
}
.jalali-today-btn, .jalali-clear-btn {
  font-size: .78rem;
  padding: .25rem .5rem;
  border-radius: 6px;
  color: var(--primary);
}
.jalali-today-btn:hover, .jalali-clear-btn:hover { background: var(--primary-light); }
.jalali-clear-btn { color: var(--danger, #ef4444); }

/* ============================================================
   TASKS MODULE
   ============================================================ */
.tasks-toolbar {
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: .75rem; margin-bottom: 1rem;
}
.view-switch { display: inline-flex; gap: .25rem; background: var(--bg-card); border: 1px solid var(--border-color); border-radius: var(--border-radius); padding: .25rem; }
.view-switch a {
  display: inline-flex; align-items: center; gap: .35rem;
  padding: .4rem .7rem; border-radius: 6px; font-size: .8rem; font-weight: 600;
  color: var(--text-secondary); transition: all .15s;
}
.view-switch a:hover { background: var(--bg-hover); color: var(--primary); }
.view-switch a.active { background: var(--primary); color: #fff; }
.scope-switch { display: inline-flex; gap: .25rem; }

/* Filter card */
.filter-card { padding: .75rem 1rem; }
.filter-row { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
.filter-search { position: relative; flex: 1; min-width: 220px; }
.filter-search svg { position: absolute; right: .65rem; top: 50%; transform: translateY(-50%); color: var(--text-muted); pointer-events: none; }
.filter-search .form-control { padding-right: 2.2rem; }
.chips { display: flex; align-items: center; gap: .4rem; flex-wrap: wrap; }
.chip {
  padding: .35rem .8rem; border-radius: 999px; font-size: .78rem; font-weight: 600;
  border: 1px solid var(--border-color); color: var(--text-secondary); background: var(--bg-card);
  transition: all .15s;
}
.chip:hover { border-color: var(--primary); color: var(--primary); }
.chip.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.chip.chip-danger.active { background: var(--danger); border-color: var(--danger); }
.chips-sep { width: 1px; height: 20px; background: var(--border-color); margin: 0 .25rem; }

/* Task list + cards */
.task-list { display: flex; flex-direction: column; gap: .55rem; }
.task-row-wrap { display: flex; align-items: stretch; gap: .5rem; }
.task-row-wrap .bulk-check { margin-top: 1.1rem; width: 18px; height: 18px; cursor: pointer; flex-shrink: 0; }
.task-card {
  flex: 1; display: flex; align-items: center; justify-content: space-between; gap: .75rem;
  background: var(--bg-card); border: 1px solid var(--border-color);
  border-right: 4px solid var(--border-color);
  border-radius: var(--border-radius); padding: .7rem .9rem; box-shadow: var(--shadow-sm);
  transition: box-shadow .15s, transform .05s;
}
.task-card:hover { box-shadow: var(--shadow-md); }
.task-card.priority-high   { border-right-color: var(--danger); }
.task-card.priority-medium { border-right-color: #d97706; }
.task-card.priority-low    { border-right-color: var(--text-muted); }
.task-card.is-done { opacity: .62; }
.task-card.dragging { opacity: .4; }
.task-card-main { display: flex; align-items: flex-start; gap: .7rem; flex: 1; min-width: 0; }
.task-card-body { min-width: 0; flex: 1; }
.task-title { display: block; font-weight: 600; color: var(--text-primary); font-size: .92rem; margin-bottom: .25rem; }
.task-title:hover { color: var(--primary); }
.task-title.done { text-decoration: line-through; }
.task-meta { display: flex; align-items: center; gap: .4rem; flex-wrap: wrap; }
.task-meta .badge { font-size: .68rem; }
.task-tag { font-size: .7rem; color: var(--text-muted); background: var(--bg-hover); padding: .1rem .45rem; border-radius: 6px; }
.task-due { display: inline-flex; align-items: center; gap: .25rem; font-size: .72rem; color: var(--text-secondary); }
.task-due.overdue { color: var(--danger); font-weight: 700; }
.task-card-actions { display: flex; align-items: center; gap: .1rem; flex-shrink: 0; }
.label-chip {
  display: inline-flex; align-items: center; font-size: .68rem; font-weight: 700;
  padding: .12rem .5rem; border-radius: 999px;
  color: var(--chip, #2563eb); background: color-mix(in srgb, var(--chip, #2563eb) 14%, #fff);
  border: 1px solid color-mix(in srgb, var(--chip, #2563eb) 35%, #fff);
}
.task-progress { height: 5px; background: var(--bg-hover); border-radius: 999px; overflow: hidden; margin-top: .45rem; }
.task-progress-bar { height: 100%; background: var(--success, #16a34a); border-radius: 999px; transition: width .2s; }

/* Bulk bar */
.bulk-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap;
  background: var(--primary-light); border: 1px solid var(--primary);
  border-radius: var(--border-radius); padding: .6rem 1rem; margin-bottom: .75rem;
}
.bulk-count { font-size: .82rem; color: var(--primary); font-weight: 600; }

/* Kanban */
.kanban { display: grid; grid-template-columns: repeat(3, 1fr); gap: .85rem; align-items: start; }
.kanban-col { background: var(--bg-body); border: 1px solid var(--border-color); border-radius: var(--border-radius); display: flex; flex-direction: column; min-height: 120px; }
.kanban-col-head { display: flex; align-items: center; justify-content: space-between; padding: .65rem .85rem; font-weight: 700; font-size: .85rem; border-bottom: 2px solid var(--border-color); }
.kanban-col.col-pending  .kanban-col-head { border-bottom-color: #0891b2; }
.kanban-col.col-progress .kanban-col-head { border-bottom-color: var(--primary); }
.kanban-col.col-done     .kanban-col-head { border-bottom-color: var(--success, #16a34a); }
.kanban-body { padding: .6rem; display: flex; flex-direction: column; gap: .5rem; min-height: 60px; transition: background .15s; }
.kanban-body.drag-over { background: var(--primary-light); border-radius: var(--border-radius); }
.kanban-body .task-card { cursor: grab; }
.kanban-body .task-card:active { cursor: grabbing; }

/* Calendar */
.cal-head { display: flex; align-items: center; justify-content: space-between; padding: .85rem 1rem; border-bottom: 1px solid var(--border-color); }
.cal-title { font-weight: 700; font-size: 1rem; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 1px; background: var(--border-color); }
.cal-dow { background: var(--bg-body); text-align: center; padding: .5rem 0; font-size: .75rem; font-weight: 700; color: var(--text-secondary); }
.cal-cell { background: var(--bg-card); min-height: 92px; padding: .35rem; display: flex; flex-direction: column; gap: .2rem; }
.cal-cell.empty { background: var(--bg-body); }
.cal-cell.today { background: var(--primary-light); }
.cal-daynum { font-size: .78rem; font-weight: 700; color: var(--text-secondary); align-self: flex-end; }
.cal-cell.today .cal-daynum { color: var(--primary); }
.cal-task { display: block; font-size: .68rem; padding: .12rem .35rem; border-radius: 5px; background: var(--bg-hover); color: var(--text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; border-right: 3px solid var(--text-muted); }
.cal-task.pri-high { border-right-color: var(--danger); }
.cal-task.pri-medium { border-right-color: #d97706; }
.cal-task.done { text-decoration: line-through; opacity: .6; }
.cal-more { font-size: .65rem; color: var(--text-muted); }

/* Subtasks (detail page) */
.subtask-list { display: flex; flex-direction: column; gap: .35rem; }
.subtask-item { display: flex; align-items: center; gap: .55rem; padding: .35rem .15rem; border-bottom: 1px dashed var(--border-color); }
.subtask-item .task-check { width: 18px; height: 18px; }
.subtask-title { font-size: .88rem; }
.subtask-item.done .subtask-title { text-decoration: line-through; color: var(--text-muted); }

/* Detail rows */
.detail-row { display: flex; justify-content: space-between; padding: .4rem 0; border-bottom: 1px solid var(--border-color); }
.detail-row:last-child { border-bottom: none; }
.detail-row span { color: var(--text-muted); }

/* Labels modal */
.label-list { display: flex; flex-direction: column; gap: .4rem; }
.label-row { display: flex; align-items: center; justify-content: space-between; }

@media (max-width: 768px) {
  .kanban { grid-template-columns: 1fr; }
  .cal-cell { min-height: 64px; }
  .tasks-toolbar { flex-direction: column; align-items: stretch; }
}
