/* GIOLIV CRM — UI */
@font-face {
  font-family: "Inter";
  src: url("fonts/inter-latin-wght-normal.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
}
@font-face {
  font-family: "Cairo";
  src: url("fonts/cairo-arabic-wght-normal.woff2") format("woff2");
  font-weight: 200 1000;
  font-display: swap;
  unicode-range: U+0600-06FF, U+0750-077F, U+0870-088E, U+0890-0891, U+0898-08E1, U+08E3-08FF, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FE74, U+FE76-FEFC;
}

:root {
  --bg: #f7f7f8;
  --bg-grad: radial-gradient(1200px 600px at 100% -10%, rgba(99, 102, 241, .08), transparent 60%),
             radial-gradient(900px 500px at -10% 110%, rgba(236, 72, 153, .05), transparent 60%);
  --surface: #ffffff;
  --surface-2: #f4f4f5;
  --surface-3: #ececee;
  --border: #e6e6ea;
  --border-strong: #d4d4d8;
  --text: #0a0a0b;
  --text-2: #52525b;
  --text-3: #8b8b94;
  --accent: #6366f1;
  --accent-2: #8b5cf6;
  --accent-soft: rgba(99, 102, 241, .1);
  --accent-text: #4f46e5;
  --green: #16a34a;  --green-soft: rgba(22, 163, 74, .1);
  --amber: #d97706;  --amber-soft: rgba(217, 119, 6, .12);
  --red: #dc2626;    --red-soft: rgba(220, 38, 38, .1);
  --blue: #2563eb;   --blue-soft: rgba(37, 99, 235, .1);
  --gray-soft: rgba(113, 113, 122, .12);
  --shadow-sm: 0 1px 2px rgba(16, 16, 24, .04);
  --shadow: 0 1px 2px rgba(16, 16, 24, .04), 0 4px 16px -4px rgba(16, 16, 24, .06);
  --shadow-lg: 0 24px 64px -12px rgba(16, 16, 24, .25), 0 0 0 1px rgba(16, 16, 24, .05);
  --sidebar: #fbfbfc;
  --radius: 14px;
  --radius-sm: 10px;
  --ease: cubic-bezier(.2, .8, .2, 1);
  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg: #09090b;
  --bg-grad: radial-gradient(1200px 600px at 100% -10%, rgba(99, 102, 241, .14), transparent 60%),
             radial-gradient(900px 500px at -10% 110%, rgba(168, 85, 247, .08), transparent 60%);
  --surface: #111113;
  --surface-2: #18181b;
  --surface-3: #222226;
  --border: #232327;
  --border-strong: #333338;
  --text: #fafafa;
  --text-2: #a1a1aa;
  --text-3: #71717a;
  --accent: #818cf8;
  --accent-2: #a78bfa;
  --accent-soft: rgba(129, 140, 248, .14);
  --accent-text: #a5b4fc;
  --green: #4ade80;  --green-soft: rgba(74, 222, 128, .12);
  --amber: #fbbf24;  --amber-soft: rgba(251, 191, 36, .12);
  --red: #f87171;    --red-soft: rgba(248, 113, 113, .12);
  --blue: #60a5fa;   --blue-soft: rgba(96, 165, 250, .12);
  --gray-soft: rgba(161, 161, 170, .12);
  --shadow-sm: none;
  --shadow: 0 0 0 1px rgba(255, 255, 255, .02);
  --shadow-lg: 0 24px 64px -12px rgba(0, 0, 0, .7), 0 0 0 1px rgba(255, 255, 255, .06);
  --sidebar: #0c0c0e;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: "Inter", "Cairo", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans Arabic", sans-serif;
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg-grad), var(--bg);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  font-feature-settings: "cv11", "ss01";
}
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
svg.i { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.num, .tabular { font-variant-numeric: tabular-nums; }
::selection { background: var(--accent-soft); }

/* ---------- Shell ---------- */
.shell { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column; gap: 4px;
  padding: 18px 12px;
  background: var(--sidebar);
  border-right: 1px solid var(--border);
  z-index: 40;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 18px; }
.brand-mark {
  width: 32px; height: 32px; border-radius: 9px;
  display: grid; place-items: center;
  background: linear-gradient(135deg, var(--accent), var(--accent-2) 60%, #ec4899);
  color: #fff; font-weight: 800; font-size: 15px; letter-spacing: -.02em;
  box-shadow: 0 6px 20px -6px var(--accent);
}
.brand-name { font-weight: 700; letter-spacing: -.02em; font-size: 15px; }
.brand-name small { display: block; font-weight: 500; font-size: 11px; color: var(--text-3); letter-spacing: 0; }
.nav-label { font-size: 11px; font-weight: 600; color: var(--text-3); text-transform: uppercase; letter-spacing: .06em; padding: 14px 12px 6px; }
.nav a {
  position: relative;
  display: flex; align-items: center; gap: 11px;
  padding: 8px 12px; border-radius: 9px;
  color: var(--text-2); font-weight: 500;
  transition: background .15s, color .15s;
}
.nav a:hover { background: var(--surface-2); color: var(--text); }
.nav a.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm), 0 0 0 1px var(--border); }
.nav a.active svg { color: var(--accent); }
.nav .count { margin-left: auto; font-size: 11px; font-weight: 600; padding: 1px 7px; border-radius: 99px; background: var(--amber-soft); color: var(--amber); }
.sidebar-foot { margin-top: auto; display: flex; flex-direction: column; gap: 6px; }
.user-chip { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 10px; }
.avatar {
  width: 32px; height: 32px; border-radius: 50%;
  display: grid; place-items: center; flex: none;
  background: var(--accent-soft); color: var(--accent-text);
  font-weight: 650; font-size: 12px; letter-spacing: .02em;
}
.avatar.lg { width: 56px; height: 56px; font-size: 19px; }
.user-chip .who { min-width: 0; flex: 1; }
.user-chip .who b { display: block; font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-chip .who span { display: block; font-size: 12px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 12px;
  padding: 12px 32px;
  background: color-mix(in srgb, var(--bg) 78%, transparent);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid transparent;
  transition: border-color .2s;
}
.topbar.scrolled { border-bottom-color: var(--border); }
.search-trigger {
  display: flex; align-items: center; gap: 10px;
  width: min(420px, 100%); height: 38px; padding: 0 12px;
  border: 1px solid var(--border); border-radius: 10px;
  background: var(--surface); color: var(--text-3);
  cursor: pointer; box-shadow: var(--shadow-sm);
  transition: border-color .15s, box-shadow .15s;
}
.search-trigger:hover { border-color: var(--border-strong); }
.search-trigger span { flex: 1; text-align: left; }
kbd {
  font-family: inherit; font-size: 11px; font-weight: 600;
  padding: 2px 6px; border-radius: 6px;
  background: var(--surface-2); border: 1px solid var(--border); color: var(--text-3);
}
.topbar .spacer { flex: 1; }
.menu-btn { display: none; }

.page { padding: 28px 32px 64px; width: 100%; max-width: 1360px; margin: 0 auto; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 24px; }
.page-head h1 { margin: 0; font-size: 26px; font-weight: 700; letter-spacing: -.03em; line-height: 1.2; }
.page-head p { margin: 6px 0 0; color: var(--text-2); }
.crumbs { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text-3); margin-bottom: 8px; }
.crumbs a:hover { color: var(--text); }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* page enter animation */
.page > * { animation: rise .35s var(--ease) both; }
.page > *:nth-child(2) { animation-delay: .03s; }
.page > *:nth-child(3) { animation-delay: .06s; }
.page > *:nth-child(4) { animation-delay: .09s; }
.page > *:nth-child(n+5) { animation-delay: .12s; }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 36px; padding: 0 14px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  font-weight: 550; font-size: 13.5px; white-space: nowrap; cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: background .15s, border-color .15s, transform .08s, box-shadow .15s, opacity .15s;
}
.btn:hover { background: var(--surface-2); border-color: var(--border-strong); }
.btn:active { transform: scale(.98); }
.btn svg.i { width: 16px; height: 16px; }
.btn-primary {
  border-color: transparent; color: #fff;
  background: linear-gradient(180deg, color-mix(in srgb, var(--accent) 92%, #fff), var(--accent));
  box-shadow: 0 1px 0 rgba(255, 255, 255, .2) inset, 0 4px 14px -4px var(--accent);
}
.btn-primary:hover { background: var(--accent); border-color: transparent; filter: brightness(1.06); }
:root[data-theme="dark"] .btn-primary { color: #0b0b12; background: linear-gradient(180deg, #a5b4fc, var(--accent)); }
.btn-danger { color: var(--red); }
.btn-danger:hover { background: var(--red-soft); border-color: transparent; }
.btn-success { color: var(--green); }
.btn-success:hover { background: var(--green-soft); border-color: transparent; }
.btn-ghost { border-color: transparent; background: transparent; box-shadow: none; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); border-color: transparent; }
.btn-sm { height: 30px; padding: 0 10px; font-size: 13px; border-radius: 8px; }
.btn-icon { width: 32px; height: 32px; padding: 0; border-radius: 8px; }
.btn[disabled], .btn.loading { opacity: .6; pointer-events: none; }
.btn.loading::after {
  content: ""; width: 14px; height: 14px; border-radius: 50%;
  border: 2px solid currentColor; border-right-color: transparent;
  animation: spin .6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Cards / KPIs ---------- */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.card-head h3 { margin: 0; font-size: 14.5px; font-weight: 650; letter-spacing: -.01em; }
.card-head p { margin: 2px 0 0; font-size: 12.5px; color: var(--text-3); }
.card-body { padding: 20px; }
.card-foot { padding: 12px 20px; border-top: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }

.grid { display: grid; gap: 16px; }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-main { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.stack { display: flex; flex-direction: column; gap: 16px; }
.mt { margin-top: 16px; }

.kpi { position: relative; padding: 18px 20px; overflow: hidden; transition: transform .2s var(--ease), box-shadow .2s, border-color .2s; }
a.kpi:hover { transform: translateY(-2px); border-color: var(--border-strong); }
.kpi-label { display: flex; align-items: center; gap: 8px; color: var(--text-2); font-size: 13px; font-weight: 500; }
.kpi-icon { width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center; background: var(--surface-2); color: var(--text-2); }
.kpi-icon svg.i { width: 15px; height: 15px; }
.kpi-value { margin-top: 12px; font-size: 28px; font-weight: 700; letter-spacing: -.035em; line-height: 1.1; font-variant-numeric: tabular-nums; }
.kpi-value small { font-size: 13px; font-weight: 600; color: var(--text-3); letter-spacing: 0; margin-left: 4px; }
.kpi-sub { margin-top: 6px; font-size: 12.5px; color: var(--text-3); display: flex; align-items: center; gap: 6px; }
.kpi.tone-green .kpi-icon { background: var(--green-soft); color: var(--green); }
.kpi.tone-amber .kpi-icon { background: var(--amber-soft); color: var(--amber); }
.kpi.tone-red .kpi-icon { background: var(--red-soft); color: var(--red); }
.kpi.tone-accent .kpi-icon { background: var(--accent-soft); color: var(--accent-text); }
.kpi.hero {
  color: #fff; border-color: transparent;
  background:
    radial-gradient(500px 200px at 110% -20%, rgba(255, 255, 255, .25), transparent 60%),
    linear-gradient(135deg, #4f46e5, #7c3aed 55%, #db2777);
  box-shadow: 0 20px 40px -18px rgba(99, 102, 241, .7);
}
.kpi.hero .kpi-label, .kpi.hero .kpi-sub, .kpi.hero .kpi-value small { color: rgba(255, 255, 255, .8); }
.kpi.hero .kpi-icon { background: rgba(255, 255, 255, .18); color: #fff; }

.delta { display: inline-flex; align-items: center; gap: 2px; font-weight: 600; font-size: 12px; padding: 1px 6px; border-radius: 99px; }
.delta.up { color: var(--green); background: var(--green-soft); }
.delta.down { color: var(--red); background: var(--red-soft); }
.kpi.hero .delta { color: #fff; background: rgba(255, 255, 255, .2); }

/* ---------- Chart ---------- */
.chart { position: relative; height: 240px; display: flex; align-items: flex-end; gap: 10px; padding: 8px 4px 0; }
.chart-grid { position: absolute; inset: 8px 0 26px; display: flex; flex-direction: column; justify-content: space-between; pointer-events: none; }
.chart-grid span { border-top: 1px dashed var(--border); position: relative; }
.chart-grid span::after { content: attr(data-v); position: absolute; right: 0; top: -9px; font-size: 10.5px; color: var(--text-3); background: var(--surface); padding-left: 6px; }
.bar-col { flex: 1; height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 8px; position: relative; z-index: 1; min-width: 0; }
.bars { width: 100%; height: calc(100% - 26px); display: flex; align-items: flex-end; justify-content: center; gap: 3px; }
.bar {
  width: min(22px, 45%); border-radius: 6px 6px 3px 3px; min-height: 3px;
  background: linear-gradient(180deg, var(--accent-2), var(--accent));
  transform-origin: bottom; animation: grow .7s var(--ease) both;
  transition: filter .15s;
}
.bar.exp { background: var(--surface-3); }
.bar-col.current .bar:not(.exp) { box-shadow: 0 0 0 3px var(--accent-soft); }
.bar-col:hover .bar { filter: brightness(1.15); }
.bar-col .lbl { font-size: 11px; color: var(--text-3); font-weight: 500; }
.bar-col.current .lbl { color: var(--accent-text); font-weight: 650; }
.bar-tip {
  position: absolute; bottom: calc(100% + 6px); left: 50%; transform: translateX(-50%) translateY(4px);
  background: var(--text); color: var(--bg); font-size: 11.5px; font-weight: 600; white-space: nowrap;
  padding: 5px 8px; border-radius: 7px; opacity: 0; pointer-events: none; transition: .15s;
}
.bar-col:hover .bar-tip { opacity: 1; transform: translateX(-50%); }
@keyframes grow { from { transform: scaleY(0); } to { transform: scaleY(1); } }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--text-2); }
.legend i { display: inline-block; width: 8px; height: 8px; border-radius: 3px; margin-right: 6px; background: var(--accent); }
.legend i.exp { background: var(--surface-3); }

/* ---------- Lists ---------- */
.list { list-style: none; margin: 0; padding: 6px; }
.list li > a, .list li > .row {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px;
  transition: background .15s;
}
.list li > a:hover { background: var(--surface-2); }
.list .grow { flex: 1; min-width: 0; }
.list .t { font-weight: 550; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list .s { font-size: 12.5px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list .r { text-align: right; flex: none; }

.meter { height: 6px; border-radius: 99px; background: var(--surface-3); overflow: hidden; }
.meter > span { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--accent), var(--accent-2)); }
.meter.low > span { background: var(--red); }

/* ---------- Badges ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  height: 22px; padding: 0 9px; border-radius: 99px;
  font-size: 12px; font-weight: 600; white-space: nowrap;
  background: var(--gray-soft); color: var(--text-2);
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .9; }
.badge.plain::before { display: none; }
.badge.green { background: var(--green-soft); color: var(--green); }
.badge.amber { background: var(--amber-soft); color: var(--amber); }
.badge.red { background: var(--red-soft); color: var(--red); }
.badge.blue { background: var(--blue-soft); color: var(--blue); }
.badge.accent { background: var(--accent-soft); color: var(--accent-text); }

/* ---------- Toolbar / filters ---------- */
.toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.seg { display: inline-flex; gap: 2px; padding: 3px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--border); overflow-x: auto; max-width: 100%; scrollbar-width: none; }
.seg::-webkit-scrollbar { display: none; }
.seg a {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 11px; border-radius: 7px;
  font-size: 13px; font-weight: 550; color: var(--text-2); white-space: nowrap;
  transition: background .15s, color .15s;
}
.seg a:hover { color: var(--text); }
.seg a.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm), 0 0 0 1px var(--border); }
.seg a .c { font-size: 11px; color: var(--text-3); font-weight: 600; }
.search-box { position: relative; flex: 1; min-width: 200px; max-width: 340px; margin-left: auto; }
.search-box svg.i { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--text-3); }
.search-box input { padding-left: 34px !important; }

/* ---------- Table ---------- */
.table-wrap { overflow-x: auto; }
table.t { width: 100%; border-collapse: separate; border-spacing: 0; }
table.t th {
  text-align: left; font-size: 12px; font-weight: 600; color: var(--text-3);
  padding: 10px 16px; white-space: nowrap; background: var(--surface);
  border-bottom: 1px solid var(--border);
}
table.t td { padding: 12px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; white-space: nowrap; }
table.t tbody tr { transition: background .12s; }
table.t tbody tr:hover { background: var(--surface-2); }
table.t tbody tr:last-child td { border-bottom: 0; }
table.t .right { text-align: right; }
table.t .muted { color: var(--text-3); }
table.t .wrap { white-space: normal; min-width: 180px; }
.cell-user { display: flex; align-items: center; gap: 12px; }
.cell-user b { font-weight: 600; display: block; }
.cell-user span { font-size: 12.5px; color: var(--text-3); }
.row-actions { display: flex; gap: 4px; justify-content: flex-end; opacity: .55; transition: opacity .15s; }
tr:hover .row-actions { opacity: 1; }
.empty { padding: 56px 20px; text-align: center; color: var(--text-3); }
.empty svg.i { width: 36px; height: 36px; margin-bottom: 10px; color: var(--text-3); stroke-width: 1.4; }
.empty b { display: block; color: var(--text); font-size: 15px; margin-bottom: 4px; }

/* Pagination */
.pager { display: flex; align-items: center; gap: 4px; }
.pager a, .pager span { min-width: 32px; height: 32px; padding: 0 8px; display: inline-grid; place-items: center; border-radius: 8px; font-weight: 550; font-size: 13px; color: var(--text-2); }
.pager a:hover { background: var(--surface-2); color: var(--text); }
.pager .on { background: var(--accent-soft); color: var(--accent-text); }
.pager .off { opacity: .35; }
.pager-info { font-size: 12.5px; color: var(--text-3); }

/* ---------- Forms ---------- */
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 18px; }
.form-grid .full { grid-column: 1 / -1; }
.field label { display: block; font-size: 13px; font-weight: 550; margin-bottom: 6px; color: var(--text); }
.field label .opt { color: var(--text-3); font-weight: 450; }
.field .hint { font-size: 12px; color: var(--text-3); margin-top: 5px; }
.input, .field input:not([type=checkbox]):not([type=radio]), .field select, .field textarea, .search-box input {
  width: 100%; height: 38px; padding: 0 12px;
  border-radius: 10px; border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--text);
  outline: none; box-shadow: var(--shadow-sm);
  transition: border-color .15s, box-shadow .15s;
}
.field textarea { height: auto; min-height: 92px; padding: 10px 12px; resize: vertical; line-height: 1.5; }
.field select, select.input {
  appearance: none; -webkit-appearance: none; padding-right: 34px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%238b8b94' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m4 6 4 4 4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center;
}
.input:focus, .field input:focus, .field select:focus, .field textarea:focus, .search-box input:focus {
  border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft);
}
.field.has-error input, .field.has-error select, .field.has-error textarea { border-color: var(--red); box-shadow: 0 0 0 4px var(--red-soft); }
.field .err { color: var(--red); font-size: 12.5px; margin-top: 5px; font-weight: 500; }
.form-error { display: none; margin-bottom: 14px; padding: 10px 12px; border-radius: 10px; background: var(--red-soft); color: var(--red); font-weight: 500; font-size: 13px; }
.form-error.show { display: block; }
.choice { display: flex; gap: 8px; flex-wrap: wrap; }
.choice label { margin: 0; }
.choice input { position: absolute; opacity: 0; pointer-events: none; }
.choice span {
  display: inline-flex; align-items: center; height: 36px; padding: 0 14px; border-radius: 10px;
  border: 1px solid var(--border-strong); background: var(--surface); cursor: pointer;
  font-weight: 550; font-size: 13px; color: var(--text-2); transition: .15s;
}
.choice input:checked + span { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-text); box-shadow: 0 0 0 3px var(--accent-soft); }
.choice input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.check { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-2); cursor: pointer; }
.check input { width: 16px; height: 16px; accent-color: var(--accent); }
.form-actions { display: flex; justify-content: flex-end; gap: 8px; padding-top: 20px; margin-top: 20px; border-top: 1px solid var(--border); }
.section-title { font-size: 12px; font-weight: 650; text-transform: uppercase; letter-spacing: .06em; color: var(--text-3); margin: 6px 0 12px; grid-column: 1 / -1; }
.preview-pill { display: inline-flex; align-items: center; gap: 8px; padding: 8px 12px; border-radius: 10px; background: var(--accent-soft); color: var(--accent-text); font-weight: 600; font-size: 13px; }

/* ---------- Definition list ---------- */
.dl { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0; }
.dl > div { padding: 12px 0; border-bottom: 1px solid var(--border); }
.dl > div:nth-last-child(-n+2) { border-bottom: 0; }
.dl dt { font-size: 12px; color: var(--text-3); font-weight: 500; margin-bottom: 3px; }
.dl dd { margin: 0; font-weight: 550; word-break: break-word; }
.copy { cursor: pointer; border-bottom: 1px dashed var(--border-strong); }
.copy:hover { color: var(--accent-text); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; }

.profile-hero { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.profile-hero h1 { margin: 0; font-size: 24px; letter-spacing: -.03em; }
.ring { --p: 50; --c: var(--accent); width: 112px; height: 112px; border-radius: 50%; display: grid; place-items: center;
  background: conic-gradient(var(--c) calc(var(--p) * 1%), var(--surface-3) 0); }
.ring > div { width: 92px; height: 92px; border-radius: 50%; background: var(--surface); display: grid; place-items: center; text-align: center; }
.ring b { display: block; font-size: 24px; letter-spacing: -.03em; line-height: 1; }
.ring span { font-size: 11px; color: var(--text-3); }

.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { display: flex; gap: 14px; position: relative; padding-bottom: 18px; }
.timeline li::before { content: ""; position: absolute; left: 6px; top: 18px; bottom: 0; width: 2px; background: var(--border); }
.timeline li:last-child::before { display: none; }
.timeline .dot { width: 14px; height: 14px; border-radius: 50%; margin-top: 3px; background: var(--surface); border: 3px solid var(--accent); flex: none; }
.timeline .grow { flex: 1; min-width: 0; }

/* sortable list */
.sortable li { cursor: grab; }
.sortable li.dragging { opacity: .5; }
.handle { color: var(--text-3); cursor: grab; }

/* ---------- Modal ---------- */
dialog.modal {
  width: min(520px, calc(100vw - 24px)); max-height: calc(100vh - 40px);
  padding: 0; border: 0; border-radius: 18px;
  background: var(--surface); color: var(--text); box-shadow: var(--shadow-lg);
  overflow: auto;
}
dialog.modal[open] { animation: pop .22s var(--ease); }
dialog.modal::backdrop { background: rgba(9, 9, 11, .45); backdrop-filter: blur(3px); animation: fade .2s; }
dialog.modal.closing { animation: pop-out .15s ease forwards; }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes pop-out { to { opacity: 0; transform: translateY(6px) scale(.98); } }
@keyframes fade { from { opacity: 0; } }
.modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 20px 22px 4px; }
.modal-head h3 { margin: 0; font-size: 17px; letter-spacing: -.02em; }
.modal-head p { margin: 4px 0 0; color: var(--text-3); font-size: 13px; }
.modal-body { padding: 16px 22px 4px; }
.modal-body .form-grid { grid-template-columns: 1fr; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 16px 22px 20px; }
dialog.modal.wide { width: min(760px, calc(100vw - 24px)); }
dialog.modal.wide .modal-body .form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }

/* Command palette */
dialog.palette { width: min(620px, calc(100vw - 24px)); margin-top: 12vh; padding: 0; border: 0; border-radius: 16px; background: var(--surface); color: var(--text); box-shadow: var(--shadow-lg); overflow: hidden; }
dialog.palette[open] { animation: pop .18s var(--ease); }
dialog.palette::backdrop { background: rgba(9, 9, 11, .4); backdrop-filter: blur(4px); }
.palette-input { display: flex; align-items: center; gap: 12px; padding: 0 18px; border-bottom: 1px solid var(--border); }
.palette-input input { flex: 1; height: 56px; border: 0; outline: 0; background: transparent; font-size: 16px; }
.palette-list { max-height: 420px; overflow-y: auto; padding: 8px; }
.palette-group { font-size: 11px; font-weight: 650; color: var(--text-3); text-transform: uppercase; letter-spacing: .06em; padding: 10px 10px 6px; }
.palette-item { display: flex; align-items: center; gap: 12px; padding: 9px 10px; border-radius: 10px; cursor: pointer; }
.palette-item .grow { flex: 1; min-width: 0; }
.palette-item b { font-weight: 550; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.palette-item small { color: var(--text-3); font-size: 12px; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.palette-item .ic { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; background: var(--surface-2); color: var(--text-2); flex: none; }
.palette-item.sel { background: var(--accent-soft); }
.palette-item.sel .ic { background: var(--accent); color: #fff; }
.palette-foot { display: flex; gap: 14px; padding: 10px 16px; border-top: 1px solid var(--border); font-size: 12px; color: var(--text-3); }

/* ---------- Toasts ---------- */
.toasts { position: fixed; z-index: 100; bottom: 20px; right: 20px; display: flex; flex-direction: column; gap: 8px; pointer-events: none; }
.toast {
  pointer-events: auto; display: flex; align-items: center; gap: 10px;
  min-width: 260px; max-width: 380px; padding: 12px 14px; border-radius: 12px;
  background: var(--text); color: var(--bg); box-shadow: var(--shadow-lg);
  font-weight: 550; font-size: 13.5px;
  animation: toast-in .3s var(--ease);
}
.toast.out { animation: toast-out .25s ease forwards; }
.toast .ti { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; background: var(--green); color: #fff; flex: none; }
.toast.error .ti { background: var(--red); }
.toast .ti svg.i { width: 13px; height: 13px; stroke-width: 3; }
@keyframes toast-in { from { opacity: 0; transform: translateY(12px) scale(.96); } }
@keyframes toast-out { to { opacity: 0; transform: translateX(20px); } }

/* Top progress */
#progress { position: fixed; top: 0; left: 0; height: 2px; width: 0; z-index: 200; background: linear-gradient(90deg, var(--accent), var(--accent-2), #ec4899); box-shadow: 0 0 10px var(--accent); opacity: 0; transition: width .25s ease, opacity .3s; }
#progress.on { opacity: 1; }
.main.busy .page { opacity: .55; transition: opacity .2s .1s; }

/* ---------- Login ---------- */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.auth-card { width: min(400px, 100%); padding: 32px; }
.auth-card h1 { margin: 18px 0 6px; font-size: 22px; letter-spacing: -.03em; }
.auth-card p { margin: 0 0 24px; color: var(--text-2); }
.auth-card .btn { width: 100%; height: 40px; }

.scrim { display: none; }
.hide-sm { }
.only-sm { display: none !important; }

/* ---------- Responsive ---------- */
@media (max-width: 1200px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-main { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; width: 270px; transform: translateX(-100%); transition: transform .25s var(--ease); box-shadow: var(--shadow-lg); }
  body.nav-open .sidebar { transform: none; }
  body.nav-open .scrim { display: block; position: fixed; inset: 0; z-index: 35; background: rgba(9, 9, 11, .4); }
  .menu-btn { display: inline-flex; }
  .topbar { padding: 10px 16px; }
  .page { padding: 20px 16px 48px; }
  .grid-3, .grid-2 { grid-template-columns: 1fr; }
  .form-grid, dialog.modal.wide .modal-body .form-grid { grid-template-columns: 1fr; }
  .search-trigger span, .search-trigger kbd { display: none; }
  .search-trigger { width: 38px; padding: 0; justify-content: center; }
  .hide-sm { display: none !important; }
  .only-sm { display: revert !important; }
  .search-box { max-width: none; margin-left: 0; }
  .row-actions { opacity: 1; }
  .toasts { left: 16px; right: 16px; bottom: 16px; }
  .toast { max-width: none; }
}
@media (max-width: 520px) {
  .grid-4 { grid-template-columns: 1fr 1fr; gap: 10px; }
  .kpi { padding: 14px; }
  .kpi-value { font-size: 22px; }
  .page-head h1 { font-size: 22px; }
  .dl { grid-template-columns: 1fr; }
  .dl > div:nth-last-child(2) { border-bottom: 1px solid var(--border); }
  .chart { gap: 4px; height: 200px; }
  .chart-grid span::after { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

.preview-pill.warn { background: var(--red-soft); color: var(--red); }
.dl.one { grid-template-columns: 1fr; margin: 0; }
.dl.one > div:nth-last-child(2) { border-bottom: 1px solid var(--border); }
.list .row .kpi-icon { flex: none; }

/* Dropdown menu */
details.menu { position: relative; }
details.menu > summary { list-style: none; }
details.menu > summary::-webkit-details-marker { display: none; }
.menu-pop {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 20; min-width: 220px; padding: 6px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow-lg);
  animation: pop .15s var(--ease);
}
.menu-pop a { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 9px 10px; border-radius: 8px; font-weight: 550; }
.menu-pop a:hover { background: var(--surface-2); }
/* Page header sits above the animated sections below it, so its dropdowns aren't covered. */
.page-head { position: relative; z-index: 10; }
.menu-pop { max-width: calc(100vw - 32px); }
@media (max-width: 900px) { .menu-pop { left: 0; right: auto; } }

/* Trial toggle in the client form */
form.is-trial .paid-only { display: none; }
.trial-switch { padding: 12px 14px; border-radius: 12px; background: var(--blue-soft); }

/* ---------- RTL (Arabic) ---------- */
[dir="rtl"] body { font-family: "Cairo", "Inter", ui-sans-serif, system-ui, sans-serif; }
[dir="rtl"] .sidebar { border-right: 0; border-left: 1px solid var(--border); }
[dir="rtl"] .search-trigger span { text-align: right; }
[dir="rtl"] .search-box { margin-left: 0; margin-right: auto; }
[dir="rtl"] .search-box svg.i { left: auto; right: 11px; }
[dir="rtl"] .search-box input { padding-left: 12px !important; padding-right: 34px !important; }
[dir="rtl"] table.t th { text-align: right; }
[dir="rtl"] table.t .right { text-align: left; }
[dir="rtl"] .list .r { text-align: left; }
[dir="rtl"] .nav .count { margin-left: 0; margin-right: auto; }
[dir="rtl"] .kpi-value small { margin-left: 0; margin-right: 4px; }
[dir="rtl"] .field select, [dir="rtl"] select.input { padding-right: 12px; padding-left: 34px; background-position: left 10px center; }
[dir="rtl"] .toasts { right: auto; left: 20px; }
[dir="rtl"] .menu-pop { right: auto; left: 0; }
[dir="rtl"] .chart-grid span::after { right: auto; left: 0; padding-left: 0; padding-right: 6px; }
[dir="rtl"] .timeline li::before { left: auto; right: 6px; }
[dir="rtl"] .legend i { margin-right: 0; margin-left: 6px; }
[dir="rtl"] svg.i.flip { transform: scaleX(-1); }
[dir="rtl"] .mono, [dir="rtl"] .num { unicode-bidi: plaintext; }
@media (max-width: 900px) {
  [dir="rtl"] .sidebar { left: auto; right: 0; transform: translateX(100%); }
  [dir="rtl"] body.nav-open .sidebar { transform: none; }
  [dir="rtl"] .menu-pop { left: auto; right: 0; }
  [dir="rtl"] .search-box { margin-right: 0; }
}

/* ---------- Print (reports) ---------- */
@media print {
  .sidebar, .topbar, .no-print, .row-actions, #progress, .toasts { display: none !important; }
  .shell { display: block; }
  body { background: #fff; }
  .page { padding: 0; max-width: none; }
  .page > * { animation: none !important; }
  .card { box-shadow: none; break-inside: avoid; }
  .kpi.hero { color: #000; background: #f4f4f5; box-shadow: none; }
  .kpi.hero .kpi-label, .kpi.hero .kpi-sub, .kpi.hero .kpi-value small { color: #52525b; }
}

/* ---------- iPhone notch / home bar (installed app uses the full screen) ---------- */
.topbar {
  padding-top: calc(12px + env(safe-area-inset-top));
  padding-left: calc(32px + env(safe-area-inset-left));
  padding-right: calc(32px + env(safe-area-inset-right));
}
.sidebar {
  padding-top: calc(18px + env(safe-area-inset-top));
  padding-bottom: calc(18px + env(safe-area-inset-bottom));
  padding-left: calc(12px + env(safe-area-inset-left));
}
.page { padding-bottom: calc(64px + env(safe-area-inset-bottom)); }
.toasts { bottom: calc(20px + env(safe-area-inset-bottom)); }
dialog.modal { max-height: calc(100vh - 40px - env(safe-area-inset-top) - env(safe-area-inset-bottom)); }
@media (max-width: 900px) {
  .topbar {
    padding-top: calc(10px + env(safe-area-inset-top));
    padding-left: calc(16px + env(safe-area-inset-left));
    padding-right: calc(16px + env(safe-area-inset-right));
  }
  .page {
    padding-left: calc(16px + env(safe-area-inset-left));
    padding-right: calc(16px + env(safe-area-inset-right));
    padding-bottom: calc(48px + env(safe-area-inset-bottom));
  }
  .toasts { bottom: calc(16px + env(safe-area-inset-bottom)); }
}
[dir="rtl"] .sidebar { padding-left: 12px; padding-right: calc(12px + env(safe-area-inset-right)); }

/* Clients list: username / password stacked, click to copy */
.login-cell { line-height: 1.35; }
.login-cell { cursor: pointer; }
.login-cell span { display: block; width: max-content; }
.login-cell:hover span { color: var(--accent-text); }
.login-cell .muted { color: var(--text-3); }

/* iPhone zooms the page when a focused field's text is under 16px, and the installed app then
   stays zoomed and shifted. 16px fields on touch screens prevent that. */
@media (max-width: 900px), (pointer: coarse) {
  .input, .field input:not([type=checkbox]):not([type=radio]), .field select, .field textarea,
  .search-box input, select.input, .palette-input input { font-size: 16px; }
}
/* Only tables scroll sideways; the page itself never does. */
.main { overflow-x: clip; }

/* No double-tap zoom on buttons and copy targets */
html { touch-action: manipulation; }
.copy, [data-copy] { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
