/* =========================================================================
   Insurance Broker System — design system
   Navy (trust) + Teal (protection) + Sand-gold (premium accent).
   RTL-ready: only logical properties (inline-start/end) are used for
   direction-sensitive spacing, so dir="rtl" flips the whole UI for free.
   ========================================================================= */

:root {
  --navy-950: #071426;
  --navy-900: #0b1f3a;
  --navy-800: #12294b;
  --navy-700: #1b3a66;
  --teal-700: #0a5f5e;
  --teal-600: #0e7c7b;
  --teal-500: #14a39a;
  --teal-100: #d5f2ef;
  --teal-50:  #ecfaf8;
  --gold-500: #c8a04b;
  --gold-100: #f6edd8;

  --primary:       var(--teal-600);
  --primary-hover: var(--teal-700);
  --primary-soft:  var(--teal-50);
  --primary-ring:  rgba(14, 124, 123, .22);

  --bg:        #f4f6f9;
  --surface:   #ffffff;
  --surface-2: #f8fafc;
  --border:    #e3e8ef;
  --border-2:  #cfd7e3;
  --text:      #0f1b2d;
  --text-2:    #475569;
  --muted:     #7a8699;

  --success: #16a34a;  --success-soft: #e8f7ee;
  --danger:  #dc2626;  --danger-soft:  #fdecec;
  --warning: #d97706;  --warning-soft: #fef4e2;
  --info:    #2563eb;  --info-soft:    #e9f0fe;
  --purple:  #7c3aed;  --purple-soft:  #f1ebfe;

  --sidebar-bg: var(--navy-900);
  --sidebar-text: #b8c4d6;
  --sidebar-active: #ffffff;

  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 2px rgba(15, 27, 45, .06);
  --shadow: 0 1px 3px rgba(15, 27, 45, .06), 0 6px 16px rgba(15, 27, 45, .05);
  --shadow-lg: 0 12px 32px rgba(15, 27, 45, .14);
  --sidebar-w: 264px;
  --topbar-h: 64px;
  --font: "Inter", "IBM Plex Sans Arabic", system-ui, -apple-system, "Segoe UI", sans-serif;
  --ease: cubic-bezier(.2, .7, .2, 1);
  color-scheme: light;
}
[dir="rtl"] { --font: "IBM Plex Sans Arabic", "Inter", system-ui, sans-serif; }

:root[data-theme="dark"] {
  --bg: #0a1220;
  --surface: #111c2e;
  --surface-2: #0e1828;
  --border: #1f2d44;
  --border-2: #2b3c57;
  --text: #e6ecf5;
  --text-2: #a9b6c9;
  --muted: #7d8aa0;
  --primary: #18b3a7;
  --primary-hover: #22c8bb;
  --primary-soft: rgba(24, 179, 167, .12);
  --success-soft: rgba(22,163,74,.14); --danger-soft: rgba(220,38,38,.15);
  --warning-soft: rgba(217,119,6,.15); --info-soft: rgba(37,99,235,.16); --purple-soft: rgba(124,58,237,.16);
  --sidebar-bg: #08111f;
  --shadow: 0 1px 3px rgba(0,0,0,.4);
  --shadow-lg: 0 12px 32px rgba(0,0,0,.5);
  color-scheme: dark;
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.55;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-hover); }
h1, h2, h3, h4 { margin: 0; line-height: 1.25; letter-spacing: -.01em; }
h1 { font-size: 24px; font-weight: 700; }
h2 { font-size: 18px; font-weight: 700; }
h3 { font-size: 15px; font-weight: 650; }
p { margin: 0 0 .5em; }
code { font-size: 12.5px; background: var(--surface-2); padding: 1px 6px; border-radius: 6px; border: 1px solid var(--border); }
hr { border: 0; border-top: 1px solid var(--border); margin: 16px 0; }
.ico { flex-shrink: 0; vertical-align: middle; }
[dir="rtl"] .flip-rtl { transform: scaleX(-1); }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.mono { font-family: ui-monospace, "SF Mono", Consolas, monospace; font-size: 12.5px; }
.nowrap { white-space: nowrap; }
.ltr { direction: ltr; unicode-bidi: embed; display: inline-block; }
.text-end { text-align: end; }
.text-center { text-align: center; }
.text-danger { color: var(--danger); }
.text-success { color: var(--success); }
.text-warning { color: var(--warning); }
.fw-600 { font-weight: 600; }
.cur { font-size: .8em; color: var(--muted); font-weight: 500; }
.mt-1 { margin-top: 4px; } .mt-2 { margin-top: 8px; } .mt-3 { margin-top: 16px; } .mt-4 { margin-top: 24px; }
.mb-2 { margin-bottom: 8px; } .mb-3 { margin-bottom: 16px; } .mb-4 { margin-bottom: 24px; }
.flex { display: flex; align-items: center; gap: 8px; }
.flex-wrap { flex-wrap: wrap; }
.between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }
.hidden { display: none !important; }

/* ---------- Shell ---------- */
.shell { display: flex; min-height: 100vh; }
.sidebar {
  position: fixed; inset-block: 0; inset-inline-start: 0;
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  background-image: radial-gradient(120% 60% at 0% 0%, rgba(20,163,154,.18), transparent 60%);
  color: var(--sidebar-text);
  display: flex; flex-direction: column;
  z-index: 40;
  transition: width .2s var(--ease), transform .2s var(--ease);
}
.brand {
  display: flex; align-items: center; gap: 12px;
  height: var(--topbar-h); padding-inline: 20px;
  color: #fff; border-bottom: 1px solid rgba(255,255,255,.06);
}
.brand:hover { color: #fff; }
.brand img { height: 36px; width: auto; max-width: 140px; }
.brand-mark {
  width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center; flex-shrink: 0;
  background: linear-gradient(135deg, var(--teal-500), var(--teal-700));
  color: #fff; box-shadow: 0 4px 12px rgba(20,163,154,.35), inset 0 1px 0 rgba(255,255,255,.2);
}
.brand-text { display: flex; flex-direction: column; min-width: 0; }
.brand-text strong { font-size: 15px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-text small { font-size: 11px; color: var(--gold-500); letter-spacing: .04em; text-transform: uppercase; font-weight: 600; }
[dir="rtl"] .brand-text small { text-transform: none; letter-spacing: 0; }

.nav { flex: 1; overflow-y: auto; padding: 12px 10px 20px; scrollbar-width: thin; scrollbar-color: rgba(255,255,255,.12) transparent; }
.nav-link {
  display: flex; align-items: center; gap: 12px; width: 100%;
  padding: 9px 12px; margin-block: 1px; border-radius: 9px;
  color: var(--sidebar-text); font: inherit; font-size: 13.5px; font-weight: 500;
  background: none; border: 0; cursor: pointer; text-align: start;
  transition: background .15s, color .15s;
}
.nav-link > span { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav-link:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav-link.active { background: linear-gradient(90deg, rgba(20,163,154,.28), rgba(20,163,154,.10)); color: var(--sidebar-active); box-shadow: inset 3px 0 0 var(--teal-500); }
[dir="rtl"] .nav-link.active { background: linear-gradient(-90deg, rgba(20,163,154,.28), rgba(20,163,154,.10)); box-shadow: inset -3px 0 0 var(--teal-500); }
.nav-link.soon { opacity: .45; cursor: default; }
.nav-link.soon:hover { background: none; color: var(--sidebar-text); }
.nav-link em { font-style: normal; font-size: 10px; padding: 1px 6px; border-radius: 99px; border: 1px solid rgba(255,255,255,.2); }
.nav-group .caret { transition: transform .2s; opacity: .6; }
.nav-group.open > .nav-toggle { color: #fff; }
.nav-group.open .caret { transform: rotate(180deg); }
.nav-sub { display: none; padding-inline-start: 14px; margin-inline-start: 18px; border-inline-start: 1px solid rgba(255,255,255,.08); }
.nav-group.open .nav-sub { display: block; }
.nav-sub .nav-link { font-size: 13px; padding-block: 7px; }
.sidebar-foot { padding: 12px 20px; font-size: 11px; color: rgba(255,255,255,.3); border-top: 1px solid rgba(255,255,255,.06); }

.main { flex: 1; min-width: 0; margin-inline-start: var(--sidebar-w); transition: margin .2s var(--ease); }
.sb-collapsed .sidebar { width: 76px; }
.sb-collapsed .main { margin-inline-start: 76px; }
.sb-collapsed .brand-text, .sb-collapsed .nav-link > span, .sb-collapsed .nav-link em, .sb-collapsed .caret, .sb-collapsed .sidebar-foot { display: none; }
.sb-collapsed .nav-link { justify-content: center; }
.sb-collapsed .nav-sub { padding: 0; margin: 0; border: 0; }
.sb-collapsed .brand { justify-content: center; padding: 0; }

.topbar {
  position: sticky; top: 0; z-index: 30;
  height: var(--topbar-h);
  display: flex; align-items: center; gap: 14px;
  padding-inline: 24px;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(160%) blur(10px);
  border-bottom: 1px solid var(--border);
}
.topsearch {
  display: flex; align-items: center; gap: 8px; flex: 1; max-width: 460px;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px;
  padding: 0 12px; height: 40px; color: var(--muted);
}
.topsearch:focus-within { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-ring); }
.topsearch input { border: 0; background: none; outline: none; flex: 1; font: inherit; color: var(--text); height: 100%; }
.topbar-right { margin-inline-start: auto; display: flex; align-items: center; gap: 6px; }
.icon-btn {
  position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 4px;
  min-width: 40px; height: 40px; padding: 0 8px; border-radius: 10px;
  background: none; border: 1px solid transparent; color: var(--text-2); cursor: pointer;
}
.icon-btn:hover { background: var(--surface-2); border-color: var(--border); color: var(--text); }
.lang-code { font-size: 11px; font-weight: 700; }
.dot-count {
  position: absolute; top: 4px; inset-inline-end: 4px; min-width: 17px; height: 17px; padding: 0 4px;
  background: var(--danger); color: #fff; font-size: 10px; font-weight: 700; border-radius: 99px;
  display: grid; place-items: center; border: 2px solid var(--surface);
}
.user-pill {
  display: flex; align-items: center; gap: 10px; padding: 4px 10px 4px 4px; height: 44px;
  background: none; border: 1px solid var(--border); border-radius: 12px; cursor: pointer; color: var(--text); font: inherit;
}
[dir="rtl"] .user-pill { padding: 4px 4px 4px 10px; }
.user-pill:hover { background: var(--surface-2); }
.user-meta { display: flex; flex-direction: column; text-align: start; line-height: 1.2; }
.user-meta strong { font-size: 13px; font-weight: 600; }
.user-meta small { font-size: 11px; color: var(--muted); }
.avatar {
  width: 34px; height: 34px; border-radius: 9px; flex-shrink: 0;
  display: grid; place-items: center; font-size: 12px; font-weight: 700; color: #fff;
  background: linear-gradient(135deg, var(--navy-700), var(--teal-600));
}
.avatar.sm { width: 26px; height: 26px; font-size: 10px; border-radius: 7px; }

.dropdown { position: relative; }
.dropdown-menu {
  position: absolute; inset-inline-end: 0; top: calc(100% + 6px); min-width: 200px; z-index: 50;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow-lg);
  padding: 6px; display: none;
}
.dropdown.open .dropdown-menu { display: block; }
.dropdown-menu a, .dropdown-menu button {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 10px; border-radius: 8px;
  color: var(--text); font: inherit; background: none; border: 0; cursor: pointer; text-align: start;
}
.dropdown-menu a:hover, .dropdown-menu button:hover { background: var(--surface-2); }

.content { padding: 24px 28px 48px; max-width: 1600px; }
.sidebar-backdrop { display: none; }

/* ---------- Page head / crumbs / tabs ---------- */
.crumbs { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); margin-bottom: 14px; flex-wrap: wrap; }
.crumbs a { color: var(--muted); display: inline-flex; }
.crumbs a:hover { color: var(--primary); }
.crumbs .sep { opacity: .5; }
.crumbs span:last-child { color: var(--text-2); }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head p { margin: 4px 0 0; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.module-tabs {
  display: flex; gap: 4px; padding: 5px; margin-bottom: 20px; overflow-x: auto;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow-sm);
}
.module-tabs a {
  display: inline-flex; align-items: center; gap: 8px; padding: 8px 14px; border-radius: 8px;
  color: var(--text-2); font-weight: 500; white-space: nowrap; font-size: 13.5px;
}
.module-tabs a:hover { background: var(--surface-2); color: var(--text); }
.module-tabs a.active { background: var(--primary); color: #fff; box-shadow: 0 2px 8px var(--primary-ring); }

/* ---------- Cards ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); }
.card + .card { margin-top: 16px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.card-head h2, .card-head h3 { display: flex; align-items: center; gap: 8px; }
.card-head .count { color: var(--muted); font-weight: 500; font-size: 13px; }
.card-body { padding: 20px; }
.card-body.p0 { padding: 0; }
.card-foot { padding: 12px 20px; border-top: 1px solid var(--border); background: var(--surface-2); border-radius: 0 0 var(--radius-lg) var(--radius-lg); }

.grid { display: grid; gap: 16px; }
.g-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g-6 { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.span-2 { grid-column: span 2; }
.span-all { grid-column: 1 / -1; }
.layout-main-side { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 20px; align-items: start; }
.stack > * + * { margin-top: 16px; }

/* ---------- KPIs ---------- */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; margin-bottom: 20px; }
.kpi {
  position: relative; display: flex; align-items: flex-start; gap: 14px; padding: 18px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm); color: var(--text); overflow: hidden;
  transition: transform .15s var(--ease), box-shadow .15s;
}
a.kpi:hover { transform: translateY(-2px); box-shadow: var(--shadow); color: var(--text); }
.kpi::before { content: ""; position: absolute; inset-inline: 0; top: 0; height: 3px; background: var(--tone); }
.kpi-icon { width: 42px; height: 42px; border-radius: 11px; display: grid; place-items: center; background: var(--tone-soft); color: var(--tone); flex-shrink: 0; }
.kpi-body { display: flex; flex-direction: column; min-width: 0; }
.kpi-label { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
[dir="rtl"] .kpi-label { text-transform: none; letter-spacing: 0; }
.kpi-value { font-size: clamp(19px, 1.7vw, 26px); font-weight: 750; line-height: 1.2; margin-top: 2px; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.kpi-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.kpi-primary { --tone: var(--primary); --tone-soft: var(--primary-soft); }
.kpi-navy    { --tone: var(--navy-700); --tone-soft: #e6ecf5; }
.kpi-success { --tone: var(--success); --tone-soft: var(--success-soft); }
.kpi-danger  { --tone: var(--danger);  --tone-soft: var(--danger-soft); }
.kpi-warning { --tone: var(--warning); --tone-soft: var(--warning-soft); }
.kpi-info    { --tone: var(--info);    --tone-soft: var(--info-soft); }
.kpi-purple  { --tone: var(--purple);  --tone-soft: var(--purple-soft); }
.kpi-gold    { --tone: var(--gold-500);--tone-soft: var(--gold-100); }
:root[data-theme="dark"] .kpi-navy { --tone: #7ea3d8; --tone-soft: rgba(126,163,216,.14); }
:root[data-theme="dark"] .kpi-gold { --tone-soft: rgba(200,160,75,.15); }

/* Quick-action tiles */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; margin-bottom: 20px; }
.tile {
  display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 18px 10px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  color: var(--text); font-weight: 600; font-size: 13px; text-align: center;
  transition: transform .15s var(--ease), box-shadow .15s, border-color .15s;
}
.tile:hover { transform: translateY(-2px); box-shadow: var(--shadow); border-color: var(--primary); color: var(--text); }
.tile .ti { width: 48px; height: 48px; border-radius: 13px; display: grid; place-items: center; background: var(--primary-soft); color: var(--primary); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 38px; padding: 0 16px; border-radius: 10px; border: 1px solid var(--border-2);
  background: var(--surface); color: var(--text); font: inherit; font-weight: 600; font-size: 13.5px;
  cursor: pointer; white-space: nowrap; transition: background .15s, border-color .15s, box-shadow .15s, color .15s;
}
.btn:hover { background: var(--surface-2); color: var(--text); }
.btn:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--primary-ring); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; box-shadow: 0 1px 2px rgba(14,124,123,.3); }
.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); color: #fff; }
.btn-navy { background: var(--navy-800); border-color: var(--navy-800); color: #fff; }
.btn-navy:hover { background: var(--navy-700); color: #fff; }
.btn-success { background: var(--success); border-color: var(--success); color: #fff; }
.btn-success:hover { filter: brightness(.95); background: var(--success); color: #fff; }
.btn-danger { background: var(--surface); border-color: #f3c4c4; color: var(--danger); }
.btn-danger:hover { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-ghost { border-color: transparent; background: none; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-sm { height: 32px; padding: 0 11px; font-size: 12.5px; border-radius: 8px; }
.btn-xs { height: 26px; padding: 0 8px; font-size: 12px; border-radius: 7px; gap: 4px; }
.btn-lg { height: 46px; padding: 0 22px; font-size: 15px; }
.btn-block { width: 100%; }
.btn-icon { width: 32px; padding: 0; }

/* ---------- Forms ---------- */
.form-section {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; font-weight: 700; color: var(--text-2); text-transform: uppercase; letter-spacing: .05em;
  margin: 24px 0 12px; padding-bottom: 8px; border-bottom: 1px dashed var(--border-2);
}
[dir="rtl"] .form-section { text-transform: none; letter-spacing: 0; }
.form-section:first-child { margin-top: 0; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > span { font-size: 12.5px; font-weight: 600; color: var(--text-2); }
.field > span .req { color: var(--danger); }
.field small { font-size: 11.5px; color: var(--muted); }
input:not([type=checkbox]):not([type=radio]):not([type=file]), select, textarea {
  width: 100%; height: 40px; padding: 0 12px;
  border: 1px solid var(--border-2); border-radius: 10px;
  background: var(--surface); color: var(--text); font: inherit; font-size: 14px;
  transition: border-color .15s, box-shadow .15s;
}
textarea { height: auto; min-height: 84px; padding: 10px 12px; resize: vertical; }
select { appearance: none; padding-inline-end: 34px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%237a8699' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center; }
[dir="rtl"] select { background-position: left 10px center; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-ring); }
input[readonly] { background: var(--surface-2); }
input[type=checkbox], input[type=radio] { accent-color: var(--primary); width: 16px; height: 16px; }
input[type=color] { padding: 3px; width: 56px; }
input[type=file] { font: inherit; font-size: 13px; }
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-weight: 500; }
.field.invalid input, .field.invalid select { border-color: var(--danger); }
.field .err { color: var(--danger); font-size: 12px; }
.form-actions { display: flex; gap: 10px; justify-content: flex-end; padding-top: 20px; margin-top: 20px; border-top: 1px solid var(--border); }
.seg { display: inline-flex; padding: 3px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; }
.seg label { cursor: pointer; }
.seg input { display: none; }
.seg span { display: inline-flex; align-items: center; gap: 6px; padding: 6px 14px; border-radius: 8px; font-weight: 600; font-size: 13px; color: var(--text-2); }
.seg input:checked + span { background: var(--surface); color: var(--primary); box-shadow: var(--shadow-sm); }

/* Filter bar */
.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.filters .field { min-width: 150px; }
.filters .field.search { flex: 1; min-width: 220px; }
.filters input, .filters select { height: 36px; font-size: 13px; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th {
  text-align: start; font-size: 11.5px; font-weight: 700; color: var(--muted);
  text-transform: uppercase; letter-spacing: .04em; white-space: nowrap;
  padding: 11px 16px; background: var(--surface-2); border-bottom: 1px solid var(--border);
}
[dir="rtl"] .table th { text-transform: none; letter-spacing: 0; font-size: 12.5px; }
.table td { padding: 12px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: var(--surface-2); }
.table .actions { text-align: end; white-space: nowrap; }
.table .num { text-align: end; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table .title-cell { display: flex; align-items: center; gap: 10px; }
.table .title-cell strong { display: block; color: var(--text); font-weight: 600; }
.table .title-cell small { color: var(--muted); font-size: 12px; }
.table tr.row-link { cursor: pointer; }
.table-compact td, .table-compact th { padding: 8px 12px; }

.pager { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; border-top: 1px solid var(--border); font-size: 13px; }
.pager-links { display: flex; gap: 4px; }
.pager-links a { min-width: 32px; height: 32px; display: grid; place-items: center; padding: 0 8px; border-radius: 8px; color: var(--text-2); border: 1px solid var(--border); }
.pager-links a:hover { background: var(--surface-2); }
.pager-links a.active { background: var(--primary); border-color: var(--primary); color: #fff; }

/* ---------- Badges / chips ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 9px;
  border-radius: 99px; font-size: 11.5px; font-weight: 600; white-space: nowrap;
  background: var(--surface-2); color: var(--text-2); border: 1px solid var(--border);
}
.badge-primary { background: var(--primary-soft); color: var(--primary); border-color: transparent; }
.badge-success { background: var(--success-soft); color: var(--success); border-color: transparent; }
.badge-danger  { background: var(--danger-soft);  color: var(--danger);  border-color: transparent; }
.badge-warning { background: var(--warning-soft); color: var(--warning); border-color: transparent; }
.badge-info    { background: var(--info-soft);    color: var(--info);    border-color: transparent; }
.badge-purple  { background: var(--purple-soft);  color: var(--purple);  border-color: transparent; }
.badge-gold    { background: var(--gold-100); color: #8a6a24; border-color: transparent; }
.badge-color { background: color-mix(in srgb, var(--bc) 13%, transparent); color: var(--bc); border-color: transparent; }
.badge-color::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--bc); }
.chip-line { display: inline-flex; align-items: center; gap: 6px; padding: 3px 9px 3px 4px; border-radius: 99px; font-size: 12px; font-weight: 600; background: color-mix(in srgb, var(--lc) 10%, transparent); color: var(--lc); }
[dir="rtl"] .chip-line { padding: 3px 4px 3px 9px; }
.chip-line i { width: 20px; height: 20px; display: grid; place-items: center; border-radius: 50%; background: var(--lc); color: #fff; }
.prio { display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; }
.prio::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.prio-urgent { color: var(--danger); } .prio-high { color: var(--warning); } .prio-normal { color: var(--info); } .prio-low { color: var(--muted); }

/* ---------- Alerts ---------- */
.alert {
  display: flex; align-items: flex-start; gap: 10px; padding: 12px 16px; margin-bottom: 16px;
  border-radius: 12px; border: 1px solid; font-weight: 500;
}
.alert-success { background: var(--success-soft); border-color: color-mix(in srgb, var(--success) 25%, transparent); color: var(--success); }
.alert-danger  { background: var(--danger-soft);  border-color: color-mix(in srgb, var(--danger) 25%, transparent);  color: var(--danger); }
.alert-warning { background: var(--warning-soft); border-color: color-mix(in srgb, var(--warning) 25%, transparent); color: var(--warning); }
.alert-info    { background: var(--info-soft);    border-color: color-mix(in srgb, var(--info) 25%, transparent);    color: var(--info); }

/* ---------- Empty state ---------- */
.empty-state { text-align: center; padding: 48px 20px; color: var(--muted); }
.empty-state .ico { color: var(--border-2); margin-bottom: 8px; }
.empty-state h3 { color: var(--text-2); margin-bottom: 4px; }
.empty-state .btn { margin-top: 12px; }
.empty-mini { padding: 20px; text-align: center; color: var(--muted); font-size: 13px; }

/* ---------- Lists (tasks, reminders) ---------- */
.list-rows > * { display: flex; gap: 12px; align-items: flex-start; padding: 13px 20px; border-bottom: 1px solid var(--border); }
.list-rows > *:last-child { border-bottom: 0; }
.list-rows .lr-main { flex: 1; min-width: 0; }
.list-rows .lr-main strong { display: block; font-weight: 600; }
.list-rows .lr-meta { font-size: 12.5px; color: var(--muted); display: flex; gap: 10px; flex-wrap: wrap; margin-top: 2px; }
.list-rows .lr-side { text-align: end; font-size: 12.5px; flex-shrink: 0; }
.task-check {
  width: 22px; height: 22px; border-radius: 7px; border: 2px solid var(--border-2); background: var(--surface);
  display: grid; place-items: center; cursor: pointer; flex-shrink: 0; color: transparent; padding: 0; margin-top: 1px;
}
.task-check:hover { border-color: var(--success); color: var(--success); }
.task-done .task-check { background: var(--success); border-color: var(--success); color: #fff; }
.task-done .lr-main strong { text-decoration: line-through; color: var(--muted); }

/* Detail definition list */
.dl { display: grid; grid-template-columns: minmax(120px, 38%) 1fr; gap: 10px 16px; font-size: 13.5px; margin: 0; }
.dl dt { color: var(--muted); font-weight: 500; }
.dl dd { margin: 0; font-weight: 500; word-break: break-word; }

/* Entity header (view pages) */
.entity-head { display: flex; gap: 18px; align-items: center; padding: 22px; }
.entity-avatar {
  width: 64px; height: 64px; border-radius: 16px; display: grid; place-items: center; flex-shrink: 0;
  background: linear-gradient(135deg, var(--navy-800), var(--teal-600)); color: #fff; font-size: 22px; font-weight: 700;
}
.entity-head h1 { font-size: 22px; }
.entity-meta { display: flex; flex-wrap: wrap; gap: 8px 16px; margin-top: 6px; color: var(--muted); font-size: 13px; }
.entity-meta span { display: inline-flex; align-items: center; gap: 5px; }
.stage-track { display: flex; gap: 4px; padding: 0 22px 20px; }
.stage-track button {
  flex: 1; min-width: 0; height: 34px; border: 0; cursor: pointer; font: inherit; font-size: 12px; font-weight: 600;
  background: var(--surface-2); color: var(--muted); clip-path: polygon(0 0, calc(100% - 10px) 0, 100% 50%, calc(100% - 10px) 100%, 0 100%, 10px 50%);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding: 0 14px;
}
[dir="rtl"] .stage-track button { clip-path: polygon(10px 0, 100% 0, calc(100% - 10px) 50%, 100% 100%, 10px 100%, 0 50%); }
.stage-track button:first-child { clip-path: polygon(0 0, calc(100% - 10px) 0, 100% 50%, calc(100% - 10px) 100%, 0 100%); border-radius: 8px 0 0 8px; }
[dir="rtl"] .stage-track button:first-child { clip-path: polygon(10px 0, 100% 0, 100% 100%, 10px 100%, 0 50%); border-radius: 0 8px 8px 0; }
.stage-track button.done { background: color-mix(in srgb, var(--sc) 18%, transparent); color: var(--sc); }
.stage-track button.current { background: var(--sc); color: #fff; }
.stage-track button:hover:not(.current) { filter: brightness(.96); }

/* Tabs inside a card */
.tabs { display: flex; gap: 2px; padding: 0 12px; border-bottom: 1px solid var(--border); overflow-x: auto; }
.tabs button {
  display: inline-flex; align-items: center; gap: 7px; padding: 13px 12px; border: 0; background: none; cursor: pointer;
  font: inherit; font-weight: 600; font-size: 13.5px; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap;
}
.tabs button:hover { color: var(--text); }
.tabs button.active { color: var(--primary); border-bottom-color: var(--primary); }
.tabs .n { background: var(--surface-2); border: 1px solid var(--border); border-radius: 99px; font-size: 11px; padding: 0 7px; color: var(--text-2); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* Timeline */
.timeline { list-style: none; margin: 0; padding: 8px 20px 16px; }
.timeline li { position: relative; padding: 10px 0 10px 32px; }
[dir="rtl"] .timeline li { padding: 10px 32px 10px 0; }
.timeline li::before { content: ""; position: absolute; inset-inline-start: 11px; top: 0; bottom: 0; width: 2px; background: var(--border); }
.timeline li:last-child::before { bottom: 50%; }
.timeline .tl-dot { position: absolute; inset-inline-start: 2px; top: 12px; width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center; background: var(--surface); border: 2px solid var(--primary); color: var(--primary); }
.timeline .tl-body { font-size: 13.5px; }
.timeline .tl-meta { font-size: 12px; color: var(--muted); }

/* Progress bars (pipeline by stage) */
.bar-row { padding: 10px 20px; }
.bar-row .bar-top { display: flex; justify-content: space-between; font-size: 13px; margin-bottom: 6px; }
.bar { height: 8px; background: var(--surface-2); border-radius: 99px; overflow: hidden; border: 1px solid var(--border); }
.bar > i { display: block; height: 100%; border-radius: 99px; background: var(--bc, var(--primary)); }

/* ---------- Modal ---------- */
.modal { position: fixed; inset: 0; z-index: 100; display: none; align-items: flex-start; justify-content: center; padding: 6vh 16px; background: rgba(7, 20, 38, .55); backdrop-filter: blur(2px); overflow-y: auto; }
.modal.open { display: flex; }
.modal-box { width: 100%; max-width: 560px; background: var(--surface); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); animation: pop .18s var(--ease); }
.modal-box.lg { max-width: 820px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.modal-body { padding: 20px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--border); background: var(--surface-2); border-radius: 0 0 var(--radius-lg) var(--radius-lg); }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.98); } }

/* ---------- Kanban ---------- */
.kanban { display: flex; gap: 14px; overflow-x: auto; padding-bottom: 12px; align-items: flex-start; min-height: calc(100vh - 260px); }
.kb-col { flex: 0 0 292px; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-lg); display: flex; flex-direction: column; max-height: calc(100vh - 220px); }
.kb-head { padding: 12px 14px; border-bottom: 1px solid var(--border); border-top: 3px solid var(--sc); border-radius: var(--radius-lg) var(--radius-lg) 0 0; background: var(--surface); }
.kb-head .flex strong { flex: 1; }
.kb-head small { color: var(--muted); font-size: 12px; }
.kb-body { padding: 10px; overflow-y: auto; flex: 1; min-height: 80px; }
.kb-body.drag-over { background: var(--primary-soft); outline: 2px dashed var(--primary); outline-offset: -6px; border-radius: 0 0 var(--radius-lg) var(--radius-lg); }
.kb-card { background: var(--surface); border: 1px solid var(--border); border-radius: 11px; padding: 12px; margin-bottom: 8px; cursor: grab; box-shadow: var(--shadow-sm); transition: box-shadow .15s, transform .15s; }
.kb-card:hover { box-shadow: var(--shadow); }
.kb-card.dragging { opacity: .5; transform: rotate(2deg); }
.kb-card a.kb-title { font-weight: 600; color: var(--text); display: block; }
.kb-card .kb-meta { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; font-size: 12px; color: var(--muted); align-items: center; }
.kb-card .kb-foot { display: flex; justify-content: space-between; align-items: center; margin-top: 10px; padding-top: 8px; border-top: 1px dashed var(--border); font-size: 12.5px; }

/* ---------- Calendar ---------- */
.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); border-top: 1px solid var(--border); }
.cal-dow { padding: 8px; font-size: 12px; font-weight: 700; color: var(--muted); text-align: center; background: var(--surface-2); border-bottom: 1px solid var(--border); }
.cal-day { min-height: 118px; padding: 6px; border-inline-end: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.cal-day:nth-child(7n) { border-inline-end: 0; }
.cal-day.other { background: var(--surface-2); opacity: .55; }
.cal-day.today { background: var(--primary-soft); }
.cal-day .d { font-size: 12px; font-weight: 700; color: var(--text-2); display: flex; justify-content: space-between; }
.cal-day .d small { font-weight: 500; color: var(--muted); font-size: 10.5px; }
.cal-ev { display: block; margin-top: 4px; padding: 3px 6px; border-radius: 6px; font-size: 11.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; background: var(--info-soft); color: var(--info); }
.cal-ev.rem { background: var(--warning-soft); color: var(--warning); }
.cal-ev.ren { background: var(--purple-soft); color: var(--purple); }
.cal-ev.done { text-decoration: line-through; opacity: .6; }

/* ---------- Auth ---------- */
.guest { min-height: 100vh; }
.auth-split { display: grid; grid-template-columns: 1.1fr 1fr; min-height: 100vh; }
.auth-hero {
  position: relative; overflow: hidden; color: #fff; padding: 56px;
  display: flex; flex-direction: column; justify-content: space-between;
  background: radial-gradient(90% 70% at 10% 0%, rgba(20,163,154,.45), transparent 60%),
              radial-gradient(70% 60% at 100% 100%, rgba(200,160,75,.25), transparent 60%),
              linear-gradient(160deg, var(--navy-900), var(--navy-950));
}
.auth-hero::after {
  content: ""; position: absolute; inset: 0; opacity: .07; pointer-events: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='60' height='60' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='1'%3E%3Cpath d='M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z'/%3E%3C/svg%3E");
}
.auth-hero h2 { font-size: 42px; font-weight: 800; line-height: 1.1; letter-spacing: -.02em; max-width: 520px; }
.auth-hero h2 em { font-style: normal; color: var(--teal-500); }
.auth-hero p { color: #b8c4d6; font-size: 16px; max-width: 480px; margin-top: 16px; }
.auth-feats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; max-width: 560px; position: relative; z-index: 1; }
.auth-feats div { padding: 14px; border-radius: 12px; background: rgba(255,255,255,.06); border: 1px solid rgba(255,255,255,.1); backdrop-filter: blur(4px); }
.auth-feats strong { display: flex; align-items: center; gap: 6px; font-size: 14px; }
.auth-feats small { color: #9fb0c6; font-size: 12px; }
.auth-panel { display: flex; align-items: center; justify-content: center; padding: 40px 24px; background: var(--surface); }
.auth-wrap { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 40px 16px; }
.auth-card { width: 100%; max-width: 400px; }
.auth-card.wide { max-width: 760px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow); padding: 32px; }
.auth-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 28px; }
.auth-brand strong { display: block; font-size: 17px; }
.auth-brand small { color: var(--muted); }
.auth-card h1 { font-size: 30px; font-weight: 800; letter-spacing: -.02em; }
.auth-card .lead { color: var(--muted); margin: 6px 0 28px; }
.auth-card .field { margin-bottom: 16px; }
.auth-card input { height: 46px !important; }
.auth-top { position: absolute; top: 20px; inset-inline-end: 24px; }

/* ---------- Misc ---------- */
.stat-inline { display: flex; gap: 24px; flex-wrap: wrap; }
.stat-inline div { display: flex; flex-direction: column; }
.stat-inline small { color: var(--muted); font-size: 12px; }
.stat-inline strong { font-size: 17px; font-variant-numeric: tabular-nums; }
.color-dot { width: 12px; height: 12px; border-radius: 50%; display: inline-block; background: var(--c); flex-shrink: 0; }
.drag-handle { cursor: grab; color: var(--muted); }
.search-group h3 { padding: 14px 20px 6px; font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.perm-grid td, .perm-grid th { text-align: center; }
.perm-grid td:first-child, .perm-grid th:first-child { text-align: start; }

/* ---------- Responsive ---------- */
@media (max-width: 1200px) {
  .layout-main-side { grid-template-columns: 1fr; }
  .g-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .g-6 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 960px) {
  .sidebar { transform: translateX(-100%); width: var(--sidebar-w) !important; }
  [dir="rtl"] .sidebar { transform: translateX(100%); }
  .sb-open .sidebar { transform: none !important; }
  .sb-open .sidebar-backdrop { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 35; }
  .main, .sb-collapsed .main { margin-inline-start: 0; }
  .sb-collapsed .brand-text, .sb-collapsed .nav-link > span, .sb-collapsed .caret { display: initial; }
  .auth-split { grid-template-columns: 1fr; }
  .auth-hero { display: none; }
  .user-meta { display: none; }
}
@media (max-width: 720px) {
  .content { padding: 16px 16px 40px; }
  .topbar { padding-inline: 12px; gap: 8px; }
  .g-2, .g-3, .g-4, .g-6 { grid-template-columns: 1fr; }
  .span-2 { grid-column: auto; }
  .dl { grid-template-columns: 1fr; gap: 2px 0; }
  .dl dd { margin-bottom: 8px; }
  .cal-day { min-height: 70px; }
  .cal-ev { font-size: 0; height: 6px; padding: 0; }
  .stage-track { overflow-x: auto; }
  .stage-track button { flex: 0 0 auto; }
}

@media print {
  .sidebar, .topbar, .page-actions, .module-tabs, .btn { display: none !important; }
  .main { margin: 0 !important; }
  .card { box-shadow: none; }
}

/* Autocomplete */
.ac { position: relative; }
.ac-list { position: absolute; inset-inline: 0; top: calc(100% + 4px); z-index: 60; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow-lg); max-height: 280px; overflow-y: auto; padding: 4px; }
.ac-list button { display: block; width: 100%; text-align: start; padding: 8px 10px; border: 0; background: none; border-radius: 7px; cursor: pointer; font: inherit; color: var(--text); }
.ac-list button:hover { background: var(--surface-2); }
.ac-list small { display: block; color: var(--muted); font-size: 12px; }

/* Repeating line rows in forms */
.rows-editor { border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
.rows-editor .re-row { display: grid; grid-template-columns: 1.4fr 1.2fr 1fr 1fr 1fr 40px; gap: 8px; padding: 10px; border-bottom: 1px solid var(--border); align-items: end; }
.rows-editor .re-row:last-of-type { border-bottom: 0; }
.rows-editor .re-head { background: var(--surface-2); font-size: 12px; font-weight: 600; color: var(--muted); padding-block: 8px; align-items: center; }
.rows-editor .re-foot { padding: 10px; background: var(--surface-2); border-top: 1px solid var(--border); }
@media (max-width: 900px) { .rows-editor .re-row { grid-template-columns: 1fr 1fr; } .rows-editor .re-head { display: none; } }
.span-3 { grid-column: span 3; }
@media (max-width: 720px) { .span-3 { grid-column: auto; } }

/* Quotation comparison matrix */
.compare td.best { background: var(--success-soft) !important; box-shadow: inset 3px 0 0 var(--success); }
[dir="rtl"] .compare td.best { box-shadow: inset -3px 0 0 var(--success); }
.compare input, .compare select { min-width: 120px; }
