/* ============================================================================
   PFMS — UI v2 (مطابق لواجهة التطبيق الأصلي: last_edit/poultry-management-main)
   Tailwind v4 palette + Inter + بطاقات rounded-2xl + شريط جانبي indigo-950.
   RTL-aware (Arabic), responsive to 360px, no external CSS dependencies.
   ============================================================================ */

:root {
  /* surfaces */
  --bg: #f8fafc;
  --card: #ffffff;
  --line: #e2e8f0;
  --line-soft: #f1f5f9;
  /* text */
  --ink: #0f172a;
  --ink-soft: #334155;
  --muted: #64748b;
  --muted-2: #94a3b8;
  /* brand */
  --primary: #4f46e5;
  --primary-dark: #4338ca;
  --primary-soft: #eef2ff;
  --primary-line: #c7d2fe;
  --sidebar: #1e1b4b;
  --sidebar-2: #231f57;
  --sidebar-ink: #c7d2fe;
  /* semantic */
  --success: #059669;
  --success-soft: #ecfdf5;
  --success-line: #a7f3d0;
  --warning: #d97706;
  --warning-soft: #fffbeb;
  --warning-line: #fde68a;
  --danger: #e11d48;
  --danger-soft: #fff1f2;
  --danger-line: #fecdd3;
  --purple: #9333ea;
  --purple-soft: #faf5ff;
  --purple-line: #e9d5ff;
  --blue: #2563eb;
  --blue-soft: #eff6ff;
  --blue-line: #bfdbfe;
  /* shape */
  --radius-sm: 6px;
  --radius: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --radius-2xl: 24px;
  --shadow-xs: 0 1px 2px rgba(15, 23, 42, .04);
  --shadow-sm: 0 1px 3px rgba(15, 23, 42, .05), 0 1px 2px rgba(15, 23, 42, .03);
  --shadow: 0 4px 16px rgba(15, 23, 42, .06);
  --shadow-lg: 0 20px 45px rgba(15, 23, 42, .16);
  --topbar-h: 72px;
  --sidebar-w: 256px;
}

/* ---------- base ---------- */
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: 'Inter', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: none; }
h1, h2, h3, h4 { margin: 0 0 .5rem; line-height: 1.22; letter-spacing: -.015em; }
h1 { font-size: 1.65rem; font-weight: 700; }
h2 { font-size: 1.05rem; font-weight: 700; }
h3 { font-size: .95rem; font-weight: 600; }
p { margin: 0 0 .75rem; }
.muted { color: var(--muted); }
.small { font-size: .75rem; }
.strong, .fw-700 { font-weight: 700; }
.nowrap { white-space: nowrap; }
.subtitle { color: var(--muted); font-size: .875rem; margin: 0; }
.text-primary { color: var(--primary); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-end { text-align: end; }
.num { font-variant-numeric: tabular-nums; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

/* ---------- utilities (subset used across views) ---------- */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.items-start { align-items: flex-start; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: .25rem; }
.gap-2 { gap: .5rem; }
.gap-3 { gap: .75rem; }
.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.hidden { display: none !important; }
.mb-0 { margin-bottom: 0 !important; }
.mb-2 { margin-bottom: .5rem !important; }
.mb-3 { margin-bottom: .75rem !important; }
.mb-4 { margin-bottom: 1rem !important; }
.mt-2 { margin-top: .5rem !important; }
.mt-3 { margin-top: .75rem !important; }
.mt-4 { margin-top: 1rem !important; }

/* ---------- icons (lucide parity) ---------- */
.ico {
  width: 18px; height: 18px; flex: 0 0 auto;
  display: inline-block; vertical-align: middle;
  stroke-width: 1.8;
}
.btn .ico { width: 16px; height: 16px; }
.btn-sm .ico { width: 14px; height: 14px; }
.btn-icon .ico { width: 18px; height: 18px; }
.badge .ico { width: 12px; height: 12px; }
.card__head .ico { width: 18px; height: 18px; color: var(--primary); }
.modal__head h3 { display: flex; align-items: center; gap: .5rem; }
.modal__head h3 .ico { width: 18px; height: 18px; color: var(--primary); }
.page-header h1 .ico { width: 20px; height: 20px; }
.table .ico { width: 14px; height: 14px; }
.dropdown__item .ico { width: 16px; height: 16px; color: var(--muted-2); }
.dropdown__item:hover .ico { color: var(--primary); }
.empty .ico { width: 32px; height: 32px; color: #cbd5e1; }

/* ---------- app shell ---------- */
.shell { display: flex; min-height: 100vh; background: var(--bg); }

.sidebar {
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  background: linear-gradient(180deg, #1e1b4b 0%, #221f57 60%, #2a2568 100%);
  color: var(--sidebar-ink);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  z-index: 40;
  transition: transform .2s ease, width .2s ease;
}

.sidebar__brand {
  display: flex; align-items: center; gap: .65rem;
  min-height: var(--topbar-h);
  padding: .75rem 1rem;
  color: #fff;
  border-bottom: 1px solid rgba(255, 255, 255, .07);
  position: relative;
}
.sidebar__brand-logo {
  width: 36px; height: 36px; border-radius: 10px; flex: 0 0 36px;
  background: rgba(255, 255, 255, .08); object-fit: contain; padding: 3px;
}
.sidebar__brand-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.sidebar__brand-name { font-size: .9rem; font-weight: 600; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar__brand-sub { font-size: .72rem; font-weight: 400; color: #a5b4fc; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-mark {
  width: 38px; height: 38px; border-radius: 10px; display: inline-flex; align-items: center; justify-content: center;
  background: rgba(255, 255, 255, .1); color: #fff; font-weight: 800; font-size: 1rem; flex: 0 0 38px;
}
.brand-mark--sm { width: 32px; height: 32px; border-radius: 9px; font-size: .9rem; flex: 0 0 32px; }

/* workspace / branch switcher */
.branch-switcher { position: relative; width: 100%; }
.branch-switcher__trigger {
  display: flex; align-items: center; gap: .65rem; width: 100%;
  background: none; border: 0; color: inherit; cursor: pointer; text-align: start;
  padding: .35rem .4rem; border-radius: 10px; font: inherit;
}
.branch-switcher__trigger:hover { background: rgba(255, 255, 255, .06); }
.branch-switcher__meta { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.branch-switcher__name { font-size: .875rem; font-weight: 600; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.branch-switcher__type { font-size: .72rem; color: #a5b4fc; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.branch-switcher__chevron { color: #a5b4fc; width: 16px; height: 16px; }

.branchmenu {
  position: absolute; top: calc(100% + .4rem); inset-inline-start: 0; inset-inline-end: 0;
  background: #fff; color: var(--ink); border: 1px solid var(--line); border-radius: 14px;
  box-shadow: var(--shadow-lg); padding: .4rem; z-index: 70; display: none; max-height: 60vh; overflow-y: auto;
}
.branch-switcher.is-open .branchmenu { display: block; }
.branchmenu__label {
  padding: .45rem .55rem .25rem; font-size: .62rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .1em; color: var(--muted-2);
}
.branchmenu__row { display: flex; align-items: center; gap: .2rem; }
.branchmenu__item {
  flex: 1; display: flex; align-items: center; gap: .5rem; min-width: 0;
  padding: .45rem .55rem; border: 0; border-radius: 9px; background: none;
  font-size: .8rem; font-weight: 500; color: var(--ink-soft); cursor: pointer; text-align: start;
}
.branchmenu__item span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.branchmenu__item:hover { background: var(--line-soft); }
.branchmenu__item.is-active { background: var(--primary-soft); color: var(--primary-dark); font-weight: 600; }
.branchmenu__dot { width: 8px; height: 8px; border-radius: 9999px; background: var(--success); flex: 0 0 8px; }
.branchmenu__icon {
  border: 0; background: none; cursor: pointer; color: var(--muted-2);
  padding: .3rem; border-radius: 7px; display: inline-flex;
}
.branchmenu__icon:hover { background: var(--line-soft); color: var(--primary); }
.branchmenu__icon--danger:hover { background: var(--danger-soft); color: var(--danger); }
.branchmenu__add {
  display: flex; align-items: center; gap: .45rem; width: 100%;
  margin-top: .35rem; padding: .5rem .55rem; border: 0; border-top: 1px solid var(--line-soft);
  background: none; color: var(--primary); font-size: .78rem; font-weight: 600; cursor: pointer; text-align: start;
}
.branchmenu__add:hover { background: var(--primary-soft); border-radius: 8px; }

.sidebar__group { padding: .9rem 1.1rem .3rem; font-size: .65rem; font-weight: 700; text-transform: uppercase; letter-spacing: .12em; color: #818cf8; }

.sidebar__nav {
  flex: 1; overflow-y: auto; padding: .55rem .6rem 1rem;
  scrollbar-width: thin; scrollbar-color: rgba(129, 140, 248, .3) transparent;
}
.sidebar__nav::-webkit-scrollbar { width: 5px; }
.sidebar__nav::-webkit-scrollbar-thumb { background: rgba(129, 140, 248, .25); border-radius: 9999px; }
.sidebar__nav::-webkit-scrollbar-thumb:hover { background: rgba(129, 140, 248, .6); }

.sidebar__link {
  display: flex; align-items: center; gap: .75rem;
  padding: .62rem .8rem; margin-bottom: .15rem;
  border-radius: 10px; color: #c7d2fe; font-size: .875rem; font-weight: 500;
  border: 0; position: relative;
}
.sidebar__link:hover { background: rgba(255, 255, 255, .07); color: #fff; }
.sidebar__link.active {
  background: #4338ca; color: #fff; font-weight: 600;
  box-shadow: inset 3px 0 0 #fff;
}
.sidebar__link .ico { width: 20px; height: 20px; flex: 0 0 20px; opacity: .95; }
.sidebar__link span.grow { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar__pro {
  margin-inline-start: auto; font-size: 9px; font-weight: 700; letter-spacing: .08em;
  color: #c4b5fd; border: 1px solid rgba(196, 181, 253, .45); border-radius: 9999px; padding: 0 .35rem;
}
.sidebar__plan {
  margin: .35rem .7rem .55rem; padding: .7rem .75rem; border-radius: 12px;
  background: linear-gradient(100deg, rgba(245, 158, 11, .16), rgba(99, 102, 241, .2));
  border: 1px solid rgba(245, 158, 11, .35);
}
.sidebar__plan-head { display: flex; align-items: center; justify-content: space-between; gap: .35rem; margin-bottom: .3rem; }
.sidebar__plan-name { font-size: .68rem; font-weight: 700; letter-spacing: .06em; color: #fcd34d; }
.sidebar__plan-tag { font-size: .6rem; font-weight: 700; background: #f59e0b; color: #1e1b4b; border-radius: 6px; padding: 0 .35rem; }
.sidebar__plan p { margin: 0 0 .5rem; font-size: .68rem; color: #c7d2fe; line-height: 1.4; }
.sidebar__plan .btn { width: 100%; background: var(--primary); color: #fff; font-size: .74rem; padding: .45rem .5rem; box-shadow: none; }
.sidebar__plan .btn:hover { background: var(--primary-dark); }
.sidebar__tier {
  margin: .35rem .7rem .55rem; padding: .4rem .65rem; border-radius: 10px;
  background: rgba(16, 185, 129, .12); border: 1px solid rgba(16, 185, 129, .3);
  display: flex; align-items: center; gap: .45rem; font-size: .72rem; font-weight: 700; color: #6ee7b7;
}
.sidebar__tier::before { content: ""; width: 8px; height: 8px; border-radius: 9999px; background: #34d399; }

.sidebar__footer { padding: .5rem .6rem .9rem; border-top: 1px solid rgba(255, 255, 255, .07); }
.sidebar__foot-link,
.sidebar__foot-button {
  display: flex; align-items: center; gap: .75rem; width: 100%;
  padding: .62rem .8rem; border: 0; border-radius: 10px; background: none;
  color: #c7d2fe; font-size: .875rem; font-weight: 500; cursor: pointer; text-align: start; font-family: inherit;
}
.sidebar__foot-link:hover, .sidebar__foot-button:hover { background: rgba(255, 255, 255, .07); color: #fff; }
.sidebar__foot-button { color: #fda4af; }
.sidebar__foot-button:hover { background: rgba(225, 29, 72, .18); color: #fecdd3; }
.sidebar__foot-link .ico, .sidebar__foot-button .ico { width: 20px; height: 20px; flex: 0 0 20px; }
.sidebar__foot-row {
  display: flex; align-items: center; justify-content: space-between; gap: .5rem;
  margin-top: .45rem; padding: .45rem .8rem 0; font-size: .68rem; color: #818cf8;
  border-top: 1px solid rgba(255, 255, 255, .06);
}
.sidebar__foot-row .badge { background: rgba(255, 255, 255, .1); color: #e0e7ff; border-color: transparent; }

.shell__main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

/* ---------- topbar ---------- */
.topbar {
  height: var(--topbar-h);
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: 0 1.25rem;
  background: #fff; border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 30;
}
.topbar__left { display: flex; align-items: center; gap: .75rem; min-width: 0; flex: 1; }
.topbar__title { font-weight: 600; font-size: .95rem; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar__user { display: flex; align-items: center; gap: .5rem; }
.topbar__filters { display: flex; align-items: center; gap: .5rem; }
.topbar .select { width: auto; height: 38px; padding-top: 0; padding-bottom: 0; font-size: .8rem; background-color: #fff; }
.topbar__upgrade { display: inline-flex; }

/* top search (rounded-full) */
.topbar__search { position: relative; display: flex; align-items: center; flex: 1; max-width: 560px; }
.topbar__search .ico { position: absolute; inset-inline-start: .85rem; width: 17px; height: 17px; color: var(--muted-2); pointer-events: none; }
.topbar__search input {
  width: 100%; height: 40px; border-radius: 9999px; border: 1px solid var(--line);
  background: #fff; padding: 0 1rem; padding-inline-start: 2.35rem; font-size: .82rem; color: var(--ink);
  outline: none; transition: border-color .15s, box-shadow .15s;
}
.topbar__search input::placeholder { color: var(--muted-2); }
.topbar__search input:focus { border-color: var(--primary-line); box-shadow: 0 0 0 3px rgba(79, 70, 229, .1); }

/* ---------- content / page header ---------- */
.content { flex: 1; padding: 1.5rem; max-width: 1560px; width: 100%; margin: 0 auto; }
.content > * + * { margin-top: 1rem; }

.page-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.page-header h1 { margin-bottom: .15rem; font-size: 1.75rem; font-weight: 700; letter-spacing: -.02em; }
.page-header .subtitle { color: var(--muted); font-size: .85rem; margin: 0; }
.page-header__actions { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.meta-row { display: flex; align-items: center; gap: .45rem; flex-wrap: wrap; font-size: .8rem; color: var(--muted); }
.meta-row .ico { width: 14px; height: 14px; color: var(--muted-2); }
.meta-row .dot-sep { color: #cbd5e1; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  padding: .55rem 1rem; border-radius: var(--radius); border: 1px solid transparent;
  font-size: .82rem; font-weight: 600; line-height: 1.2; cursor: pointer;
  transition: background .15s ease, border-color .15s ease, transform .08s ease, box-shadow .15s ease;
  text-decoration: none; background: #fff; color: var(--ink-soft); white-space: nowrap;
}
.btn:active { transform: scale(.98); }
.btn-primary { background: var(--primary); color: #fff; box-shadow: 0 4px 12px rgba(79, 70, 229, .22); }
.btn-primary:hover { background: var(--primary-dark); color: #fff; }
.btn-secondary { background: #fff; border-color: var(--line); color: var(--ink-soft); box-shadow: var(--shadow-xs); }
.btn-secondary:hover { background: #f8fafc; }
.btn-ghost { background: transparent; color: var(--muted); }
.btn-ghost:hover { background: var(--line-soft); color: var(--ink); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #be123c; color: #fff; }
.btn-success { background: var(--success); color: #fff; }
.btn-sm { padding: .38rem .7rem; font-size: .75rem; border-radius: 9px; }
.btn-icon { padding: .45rem; border-radius: 10px; }
.btn-block { width: 100%; }
.btn-upper { text-transform: uppercase; letter-spacing: .06em; font-size: .72rem; font-weight: 700; }
.btn:disabled { opacity: .55; cursor: not-allowed; transform: none; }

/* ---------- forms ---------- */
.field { margin-bottom: .9rem; }
.label { display: block; font-size: .78rem; font-weight: 500; color: var(--ink-soft); margin-bottom: .3rem; }
.input, .select, .textarea {
  width: 100%; padding: .55rem .8rem; border: 1px solid #cbd5e1; border-radius: var(--radius);
  font-size: .85rem; background: #fff; color: var(--ink); outline: none; font-family: inherit;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.input:focus, .select:focus, .textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(79, 70, 229, .14); }
.input::placeholder, .textarea::placeholder { color: var(--muted-2); }
.textarea { min-height: 84px; resize: vertical; }
.hint { font-size: .72rem; color: var(--muted); margin-top: .25rem; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 .9rem; }
@media (max-width: 640px) { .form-grid { grid-template-columns: 1fr; } }
.form-section {
  grid-column: 1 / -1; display: flex; align-items: center; gap: .45rem;
  margin: .45rem 0 .2rem; padding: .35rem .6rem;
  background: var(--primary-soft); color: var(--primary-dark);
  border: 1px solid var(--primary-line); border-radius: 9px;
  font-size: .72rem; font-weight: 700; letter-spacing: .05em; text-transform: uppercase;
}
.form-section .ico { width: 14px; height: 14px; color: var(--primary); }
.form-section:first-child { margin-top: 0; }
.error-box { display: none; background: var(--danger-soft); border: 1px solid var(--danger-line); color: #9f1239; padding: .6rem .75rem; border-radius: 10px; font-size: .78rem; margin-bottom: .9rem; }
.error-box.visible { display: block; }

/* ---------- grid & cards ---------- */
.grid { display: grid; gap: 1rem; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-main { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.grid-main-3 { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1fr); }
@media (max-width: 1280px) { .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 1100px) { .grid-main, .grid-main-3, .grid-3 { grid-template-columns: 1fr; } }
@media (max-width: 760px) { .grid-4, .grid-3, .grid-2 { grid-template-columns: 1fr; } }

.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xs); padding: 1.25rem 1.4rem;
}
.card--flush { padding: 0; overflow: hidden; }
.card__head { display: flex; align-items: center; justify-content: space-between; gap: .75rem; margin-bottom: 1rem; flex-wrap: wrap; }
.card__head h2 {
  margin: 0; font-size: 1rem; font-weight: 600; letter-spacing: -.01em;
  color: var(--ink); display: flex; align-items: center; gap: .5rem;
}
.card__head h2 .ico { color: var(--muted-2); }
.card__head--caps h2 {
  font-size: .8rem; font-weight: 700; letter-spacing: .07em;
  text-transform: uppercase; color: var(--ink-soft);
}
.card__head--caps h2 .ico { color: var(--primary); }
.card__head h3 { margin: 0; }
.card__sub { font-size: .75rem; color: var(--muted); margin: -.5rem 0 .9rem; }
.card--dark {
  background: linear-gradient(100deg, #1e1b4b 0%, #312e81 60%, #3b2f8f 100%);
  border-color: #312e81; color: #e0e7ff;
}

/* ---------- KPI / stat cards ---------- */
.stat {
  display: flex; flex-direction: column; gap: .3rem; position: relative;
  background: var(--card); border: 1px solid var(--line); border-radius: 14px;
  padding: 1.35rem 1.45rem; box-shadow: var(--shadow-xs);
  transition: border-color .15s ease, box-shadow .15s ease;
}
.stat:hover { border-color: var(--primary-line); box-shadow: var(--shadow-sm); }
.stat__label {
  font-size: .72rem; font-weight: 600; color: var(--muted);
  text-transform: uppercase; letter-spacing: .07em; padding-inline-end: 2.6rem;
}
.stat__value { font-size: 1.85rem; font-weight: 700; letter-spacing: -.025em; color: var(--ink); }
.stat__meta { font-size: .75rem; font-weight: 500; color: var(--success); }
.stat__icon {
  position: absolute; inset-inline-end: 1.3rem; top: 1.3rem;
  color: var(--primary); display: inline-flex;
}
.stat__icon .ico { width: 26px; height: 26px; stroke-width: 1.6; }
.stat--emerald .stat__icon { color: var(--success); }
.stat--emerald .stat__meta { color: var(--success); }
.stat--indigo .stat__icon { color: var(--primary); }
.stat--indigo .stat__meta { color: var(--primary); }
.stat--amber .stat__icon { color: #f59e0b; }
.stat--amber .stat__meta { color: var(--warning); }
.stat--purple .stat__icon { color: var(--purple); }
.stat--purple .stat__meta { color: var(--purple); }
.stat--rose .stat__icon { color: var(--danger); }
.stat--rose .stat__meta { color: var(--danger); }
.stat--blue .stat__icon { color: var(--blue); }
.stat--blue .stat__meta { color: var(--blue); }
.stat--slate .stat__icon { color: var(--muted-2); }
.stat--slate .stat__meta { color: var(--muted); }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: .8rem; }
.table thead th {
  text-align: start; font-size: .66rem; letter-spacing: .08em; text-transform: uppercase;
  color: var(--muted); font-weight: 600; background: #f8fafc; padding: .7rem 1rem;
  border-bottom: 1px solid var(--line); white-space: nowrap;
}
.table tbody td { padding: .78rem 1rem; border-bottom: 1px solid var(--line-soft); vertical-align: middle; color: var(--ink-soft); }
.table tbody tr:hover { background: #f8fafc; }
.table tbody tr:last-child td { border-bottom: 0; }
.table .num { font-variant-numeric: tabular-nums; }
.table .actions { display: flex; gap: .35rem; justify-content: flex-end; }
.table-empty { padding: 2rem 1rem; text-align: center; color: var(--muted); font-size: .82rem; }

/* ---------- badges ---------- */
.badge {
  display: inline-flex; align-items: center; gap: .3rem; padding: .16rem .55rem;
  border-radius: 9999px; font-size: .68rem; font-weight: 600; line-height: 1.5;
  background: var(--line-soft); color: var(--ink-soft); border: 1px solid var(--line);
}
.badge--primary { background: var(--primary-soft); color: var(--primary-dark); border-color: var(--primary-line); }
.badge--success { background: var(--success-soft); color: #047857; border-color: var(--success-line); }
.badge--warning { background: var(--warning-soft); color: #b45309; border-color: var(--warning-line); }
.badge--danger { background: var(--danger-soft); color: #be123c; border-color: var(--danger-line); }
.badge--info { background: var(--blue-soft); color: var(--blue); border-color: var(--blue-line); }
.badge--purple { background: var(--purple-soft); color: var(--purple); border-color: var(--purple-line); }
.badge--dot::before { content: ""; width: 6px; height: 6px; border-radius: 9999px; background: currentColor; }

/* ---------- toolbar / tabs / pagination ---------- */
.toolbar { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.toolbar .grow { flex: 1; min-width: 140px; }
.toolbar__search { position: relative; }
.toolbar__search .ico { position: absolute; inset-inline-start: .7rem; top: 50%; transform: translateY(-50%); width: 15px; height: 15px; color: var(--muted-2); }
.toolbar__search .input { padding-inline-start: 2.1rem; }
.toolbar .select { width: auto; height: 34px; padding-top: 0; padding-bottom: 0; font-size: .75rem; }

.tabs { display: flex; gap: .25rem; border-bottom: 1px solid var(--line); margin-bottom: 1rem; overflow-x: auto; }
.tab {
  padding: .6rem .95rem; font-size: .8rem; font-weight: 600; color: var(--muted);
  border: 0; border-bottom: 2px solid transparent; background: none; cursor: pointer; white-space: nowrap;
}
.tab:hover { color: var(--ink); }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }

.pagination {
  display: flex; align-items: center; justify-content: space-between; gap: .75rem;
  padding: .7rem 1rem; font-size: .72rem; color: var(--muted); flex-wrap: wrap;
  border-top: 1px solid var(--line-soft);
}
.pagination__pages { display: flex; align-items: center; gap: .3rem; }
.pagination__pages button { min-width: 28px; }
.pagination .select { width: auto; height: 30px; padding: 0 .4rem; font-size: .72rem; }

/* ---------- dashboard-specific components ---------- */
.onboard { padding: 1.15rem 1.35rem; border-radius: var(--radius-lg); }
.onboard__head { display: flex; align-items: center; justify-content: space-between; gap: .75rem; flex-wrap: wrap; }
.onboard__title { display: flex; align-items: center; gap: .5rem; font-size: .95rem; font-weight: 600; color: #fff; }
.onboard__title .ico { width: 18px; height: 18px; color: #a5b4fc; }
.onboard__badge {
  font-size: .6rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase;
  background: linear-gradient(90deg, #6366f1, #a855f7); color: #fff; border-radius: 9999px; padding: .18rem .55rem;
}
.onboard p { margin: .35rem 0 .7rem; font-size: .75rem; color: #c7d2fe; }
.onboard__bar { height: 6px; border-radius: 9999px; background: rgba(255, 255, 255, .15); overflow: hidden; }
.onboard__bar i { display: block; height: 100%; border-radius: 9999px; background: linear-gradient(90deg, #818cf8, #c084fc); }
.onboard__foot { display: flex; align-items: center; justify-content: space-between; gap: .5rem; margin-top: .45rem; font-size: .68rem; color: #a5b4fc; }

.locked-panel {
  border: 1px dashed var(--primary-line); border-radius: var(--radius); background: #fbfbff;
  padding: 1.5rem 1rem; text-align: center; display: flex; flex-direction: column; align-items: center; gap: .5rem;
}
.locked-panel .badge { font-size: .6rem; letter-spacing: .08em; text-transform: uppercase; }
.locked-panel h3 { font-size: 1rem; margin: 0; color: var(--ink); }
.locked-panel p { margin: 0; font-size: .78rem; color: var(--muted); max-width: 34rem; }

.tile-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .6rem; }
@media (max-width: 560px) { .tile-grid { grid-template-columns: 1fr; } }
.info-tile { border: 1px solid var(--line); border-radius: 10px; background: #f8fafc; padding: .6rem .7rem; }
.info-tile__label { display: block; font-size: .58rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin-bottom: .15rem; }
.info-tile__value { display: block; font-size: .78rem; font-weight: 600; color: var(--ink); }
.info-tile__note { display: block; font-size: .68rem; color: var(--muted); }
.info-tile--emerald { background: var(--success-soft); border-color: var(--success-line); }
.info-tile--emerald .info-tile__label { color: #047857; }
.info-tile--indigo { background: var(--primary-soft); border-color: var(--primary-line); }
.info-tile--indigo .info-tile__label { color: var(--primary-dark); }
.info-tile--purple { background: var(--purple-soft); border-color: var(--purple-line); }
.info-tile--purple .info-tile__label { color: var(--purple); }
.info-tile--amber { background: var(--warning-soft); border-color: var(--warning-line); }
.info-tile--amber .info-tile__label { color: #b45309; }

.plan-banner {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap;
  background: linear-gradient(90deg, #fffbeb 0%, #fef3c7 45%, #eef2ff 100%);
  border: 1px solid #fcd34d; border-radius: var(--radius-lg); padding: .9rem 1.15rem;
}
.plan-banner__icon {
  width: 34px; height: 34px; border-radius: 10px; background: rgba(245, 158, 11, .18);
  color: #b45309; display: inline-flex; align-items: center; justify-content: center; flex: 0 0 34px;
}
.plan-banner__title { font-size: .85rem; font-weight: 700; color: #92400e; }
.plan-banner__sub { font-size: .75rem; color: #a16207; }
.plan-banner .btn { background: linear-gradient(90deg, #f59e0b, #f97316); box-shadow: none; }

.kv { display: grid; grid-template-columns: 1fr auto; gap: .45rem .75rem; margin: 0; font-size: .8rem; }
.kv dt { color: var(--muted); font-weight: 500; }
.kv dd { margin: 0; text-align: end; font-weight: 600; color: var(--ink); }

.status-line { font-size: .78rem; padding: .55rem .75rem; border-radius: 10px; background: var(--line-soft); color: var(--ink-soft); margin-top: .75rem; }
.progress { height: 6px; border-radius: 9999px; background: var(--primary-soft); overflow: hidden; }
.progress i { display: block; height: 100%; border-radius: 9999px; background: var(--primary); }

.fab {
  position: fixed; inset-inline-end: 1.35rem; bottom: 1.35rem; z-index: 60;
  width: 54px; height: 54px; border-radius: 9999px; border: 0; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  background: linear-gradient(140deg, #7c3aed, #4f46e5 70%); color: #fff;
  box-shadow: 0 12px 28px rgba(79, 70, 229, .38);
  transition: transform .15s ease, box-shadow .15s ease;
}
.fab:hover { transform: translateY(-2px); box-shadow: 0 16px 34px rgba(79, 70, 229, .45); }
.fab .ico { width: 24px; height: 24px; }
@media print { .fab { display: none !important; } }

/* ---------- charts (pure SVG/CSS) ---------- */
.chart { width: 100%; height: 220px; display: block; }
.chart-legend { display: flex; gap: 1rem; flex-wrap: wrap; font-size: .72rem; color: var(--muted); margin-top: .5rem; }
.chart-legend span { display: inline-flex; align-items: center; gap: .35rem; }
.chart-legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.spark { display: flex; align-items: flex-end; gap: 3px; height: 32px; }
.spark i { flex: 1; background: var(--primary-soft); border-radius: 2px 2px 0 0; min-height: 3px; }
.spark i.on { background: var(--primary); }

/* ---------- impersonation banner ---------- */
.impersonation-banner {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  background: #fef3c7; border-bottom: 1px solid #fcd34d; color: #78350f;
  padding: .55rem 1.25rem; font-size: .8rem; font-weight: 600;
}

/* ---------- modal / dropdown / toast ---------- */
.modal {
  position: fixed; inset: 0; z-index: 100; display: none;
  align-items: center; justify-content: center; padding: 1rem;
  background: rgba(15, 23, 42, .55); backdrop-filter: blur(3px);
}
.modal.is-open { display: flex; }
.modal__panel {
  background: #fff; border-radius: var(--radius-2xl); border: 1px solid var(--line);
  box-shadow: var(--shadow-lg); width: 100%; max-width: 560px; max-height: 92vh; overflow-y: auto;
}
.modal__head { display: flex; align-items: center; justify-content: space-between; gap: .75rem; padding: 1.15rem 1.4rem; border-bottom: 1px solid var(--line-soft); }
.modal__head h3 { margin: 0; font-size: 1rem; font-weight: 700; color: var(--ink); }
.modal__body { padding: 1.15rem 1.4rem; }
.modal__foot { display: flex; justify-content: flex-end; gap: .5rem; padding: .95rem 1.4rem; border-top: 1px solid var(--line-soft); background: #fafbff; }
.modal--dark .modal__head { background: linear-gradient(100deg, #1e1b4b, #312e81); border-bottom: 0; }
.modal--dark .modal__head h3 { color: #fff; }
.modal--dark .modal__head .ico { color: #c7d2fe; }

.dropdown { position: relative; }
.dropdown__menu {
  position: absolute; inset-inline-end: 0; top: calc(100% + 6px); min-width: 210px;
  background: #fff; border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow);
  padding: .35rem; display: none; z-index: 60; max-height: 340px; overflow-y: auto;
}
.dropdown.is-open .dropdown__menu { display: block; }
.dropdown__item {
  display: flex; align-items: center; gap: .55rem; width: 100%; text-align: start;
  padding: .5rem .6rem; border-radius: 9px; border: 0; background: none; cursor: pointer;
  font-size: .8rem; font-weight: 500; color: var(--ink-soft); font-family: inherit;
}
.dropdown__item:hover { background: var(--line-soft); }
.dropdown__item.is-active { background: var(--primary-soft); color: var(--primary-dark); font-weight: 600; }
.dropdown__item--danger { color: var(--danger); }
.dropdown__item--danger .ico { color: var(--danger); }
.dropdown__item--danger:hover { background: var(--danger-soft); }
.dropdown__label { padding: .45rem .6rem .25rem; font-size: .62rem; font-weight: 700; text-transform: uppercase; letter-spacing: .1em; color: var(--muted-2); }

#toast-root, .toast-host { position: fixed; top: 1rem; inset-inline-end: 1rem; z-index: 200; display: flex; flex-direction: column; gap: .5rem; max-width: 380px; }
.toast {
  display: flex; align-items: flex-start; gap: .5rem; padding: .7rem .9rem; border-radius: 12px;
  background: #fff; border: 1px solid var(--line); box-shadow: var(--shadow); font-size: .8rem; font-weight: 500;
  animation: toast-in .18s ease;
}
.toast--success { border-inline-start: 4px solid var(--success); }
.toast--error { border-inline-start: 4px solid var(--danger); }
.toast--info { border-inline-start: 4px solid var(--primary); }
@keyframes toast-in { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }

.empty { display: flex; flex-direction: column; align-items: center; gap: .4rem; padding: 2.4rem 1rem; text-align: center; color: var(--muted); }
.empty strong { font-size: .82rem; font-weight: 600; color: var(--ink-soft); }

/* ---------- panels / admin / enterprise ---------- */
.feature-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: .85rem; }
.feature-tile {
  border: 1px solid var(--line); border-radius: 14px; padding: 1rem; background: #fff;
  display: flex; flex-direction: column; gap: .35rem; box-shadow: var(--shadow-xs);
  transition: border-color .15s ease, transform .15s ease;
}
.feature-tile:hover { border-color: var(--primary-line); transform: translateY(-1px); }
.feature-tile .ico { width: 22px; height: 22px; color: var(--primary); }
.feature-tile h3 { font-size: .88rem; margin: 0; font-weight: 600; }
.feature-tile p { font-size: .76rem; color: var(--muted); margin: 0; }
.locked { opacity: .68; position: relative; }
.locked::after {
  content: ""; position: absolute; inset: 0; border-radius: inherit;
  background: repeating-linear-gradient(45deg, rgba(255,255,255,0), rgba(255,255,255,0) 8px, rgba(148,163,184,.06) 8px, rgba(148,163,184,.06) 16px);
  pointer-events: none;
}
/* ---------- auth & setup ---------- */
.auth-wrap { min-height: 100vh; display: grid; grid-template-columns: 1fr 1fr; }
.auth-hero {
  background: radial-gradient(1200px 600px at 10% 10%, #4338ca 0%, #1e1b4b 60%);
  color: #fff; padding: 3rem; display: flex; flex-direction: column; justify-content: center; gap: .5rem;
}
.auth-hero h1 { font-size: 2.1rem; margin-bottom: .75rem; color: #fff; }
.auth-hero p { color: #c7d2fe; line-height: 1.8; max-width: 30rem; }
.auth-panel { display: flex; align-items: center; justify-content: center; padding: 2rem; background: var(--bg); }
.auth-card { width: 100%; max-width: 26rem; }
@media (max-width: 900px) {
  .auth-wrap { grid-template-columns: 1fr; }
  .auth-hero { display: none; }
}

.wizard { max-width: 920px; margin: 0 auto; padding: 2rem 1rem 3rem; }
.wizard__steps { display: flex; gap: .5rem; margin: 1.25rem 0; flex-wrap: wrap; }
.wizard__step { flex: 1; min-width: 140px; padding: .65rem .8rem; border-radius: 12px; background: #fff; border: 1px solid var(--line); font-size: .75rem; color: var(--muted); }
.wizard__step.active { border-color: var(--primary); color: var(--primary); font-weight: 700; background: var(--primary-soft); }
.wizard__panel { display: none; }
.wizard__panel.active { display: block; }
.wizard__actions { display: flex; justify-content: space-between; gap: .5rem; margin-top: 1rem; }
.denied { max-width: 34rem; margin: 3rem auto; text-align: center; padding: 2rem; }

/* ---------- public marketing ---------- */
.site-nav {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: .9rem 2rem; background: rgba(255, 255, 255, .92); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20;
}
.site-nav__links { display: flex; align-items: center; gap: 1.15rem; font-size: .84rem; color: var(--muted); flex-wrap: wrap; }
.site-nav__links a { color: var(--muted); font-weight: 500; }
.site-nav__links a:hover { color: var(--primary); }
.hero { padding: 4rem 2rem 3rem; max-width: 72rem; margin: 0 auto; }
.hero__banner { display: inline-block; background: var(--primary-soft); color: var(--primary-dark); padding: .35rem .85rem; border-radius: 9999px; font-size: .72rem; font-weight: 700; margin-bottom: 1rem; }
.hero h1 { font-size: clamp(1.9rem, 4vw, 2.9rem); max-width: 48rem; }
.hero p { color: var(--muted); max-width: 42rem; line-height: 1.8; font-size: 1.02rem; }
.hero__actions { display: flex; gap: .75rem; margin-top: 1.6rem; flex-wrap: wrap; }
.section { max-width: 72rem; margin: 0 auto; padding: 2rem; }
.section h2 { font-size: 1.4rem; }
.plans { display: grid; gap: 1rem; grid-template-columns: repeat(3, minmax(0, 1fr)); margin-top: 1.5rem; }
.plan { display: flex; flex-direction: column; gap: .65rem; }
.plan--featured { border-color: var(--primary); box-shadow: 0 18px 50px rgba(79, 70, 229, .18); }
.plan__price { font-size: 1.9rem; font-weight: 800; letter-spacing: -.02em; }
.plan ul { margin: 0; padding-inline-start: 1.1rem; color: var(--muted); font-size: .82rem; line-height: 1.7; }
.price-monthly.hidden, .price-annual.hidden { display: none; }
.price-period { font-size: .72rem; color: var(--muted); }
.site-footer {
  border-top: 1px solid var(--line); background: #fff; padding: 1.5rem 2rem; color: var(--muted);
  font-size: .78rem; display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap;
}
@media (max-width: 900px) {
  .plans { grid-template-columns: 1fr; }
  .hero { padding: 2.5rem 1rem; }
  .section { padding: 1.25rem 1rem; }
  .site-nav { padding: .8rem 1rem; }
}

/* ---------- offline ---------- */
.offline { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 1.5rem; }
.offline__card { max-width: 26rem; text-align: center; display: flex; flex-direction: column; align-items: center; gap: .6rem; }

/* ---------- responsive shell ---------- */
@media (max-width: 1024px) {
  .sidebar { position: fixed; inset-inline-start: 0; transform: translateX(-102%); box-shadow: var(--shadow-lg); }
  [dir="rtl"] .sidebar { transform: translateX(102%); }
  .sidebar.is-open { transform: translateX(0); }
  .content { padding: 1rem; }
  .topbar { padding: 0 .8rem; gap: .5rem; }
  .topbar__search { max-width: none; }
  .topbar__filters .select { display: none; }
}
@media (max-width: 640px) {
  .content { padding: .75rem; }
  .page-header h1 { font-size: 1.35rem; }
  .stat { padding: 1.1rem; }
  .stat__value { font-size: 1.55rem; }
  .topbar__search { display: none; }
  .topbar__upgrade { display: none; }
  .modal__panel { border-radius: var(--radius-xl); }
}

/* ---------- RTL ---------- */
[dir="rtl"] .sidebar__link.active { box-shadow: inset -3px 0 0 #fff; }
[dir="rtl"] .table thead th, [dir="rtl"] .table tbody td { text-align: right; }
[dir="rtl"] .stat__icon { inset-inline-end: auto; inset-inline-start: 1.3rem; }
[dir="rtl"] .stat__label { padding-inline-end: 0; padding-inline-start: 2.6rem; }
[dir="rtl"] .topbar__search .ico, [dir="rtl"] .toolbar__search .ico { inset-inline-start: .7rem; }
[dir="rtl"] .hero, [dir="rtl"] .section { text-align: right; }

/* ---------- installer requirements ---------- */
.req-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr)); gap: .4rem .9rem; }
.req-item {
  display: flex; align-items: flex-start; gap: .5rem;
  padding: .45rem .6rem; border-radius: var(--radius);
  border: 1px solid var(--line); background: var(--surface-2); font-size: .8rem; line-height: 1.45;
}
.req-item .req-mark { font-weight: 700; line-height: 1.3; }
.req-ok { border-color: var(--success-line); background: var(--success-soft); }
.req-ok .req-mark { color: #047857; }
.req-bad { border-color: var(--danger-line); background: var(--danger-soft); }
.req-bad .req-mark { color: #be123c; }
.req-warn { border-color: var(--warning-line); background: var(--warning-soft); }
.req-warn .req-mark { color: #b45309; }

/* ---------- print ---------- */
@media print {
  .sidebar, .topbar, .page-header__actions, .toolbar, .pagination, #toast-root, .fab { display: none !important; }
  .content { padding: 0; max-width: none; }
  .card { box-shadow: none; border-color: #cbd5e1; break-inside: avoid; }
}

/* ---------- motion ---------- */
@keyframes fade-in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
.content > * { animation: fade-in .18s ease both; }
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}








