/* ==========================================================
   FixDesk – Design system
   ========================================================== */
:root {
  --bg: #070a13;
  --bg-soft: #0c1120;
  --surface: rgba(255, 255, 255, 0.035);
  --surface-2: rgba(255, 255, 255, 0.06);
  --surface-3: rgba(255, 255, 255, 0.09);
  --surface-solid: #0f1524;
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.15);
  --text: #e9edf6;
  --text-2: #a5afc4;
  --muted: #6b7591;
  --accent: #7c5cff;
  --accent-2: #22d3ee;
  --grad: linear-gradient(135deg, #7c5cff 0%, #4f8bff 55%, #22d3ee 100%);
  --success: #34d399;
  --warning: #fbbf24;
  --danger: #f87171;
  --wa: #25d366;
  --radius: 18px;
  --radius-sm: 11px;
  --shadow: 0 24px 60px -24px rgba(0, 0, 0, 0.7);
  --font: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-ar: 'Cairo', 'Segoe UI', Tahoma, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, Consolas, monospace;
  --ease: cubic-bezier(.2, .8, .2, 1);
}

/* Status colors */
.st-received { --c: #94a3b8; }
.st-diagnosing { --c: #a78bfa; }
.st-waiting_parts { --c: #fbbf24; }
.st-in_repair { --c: #38bdf8; }
.st-ready { --c: #34d399; }
.st-delivered { --c: #818cf8; }
.st-cancelled { --c: #f87171; }

* { box-sizing: border-box; margin: 0; padding: 0; }
html { color-scheme: dark; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
html[lang="ar"] body { font-family: var(--font-ar); }
body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(700px 420px at 8% -8%, rgba(124, 92, 255, 0.20), transparent 60%),
    radial-gradient(600px 420px at 100% 0%, rgba(34, 211, 238, 0.10), transparent 60%),
    radial-gradient(800px 500px at 50% 120%, rgba(79, 139, 255, 0.10), transparent 60%);
}
body.modal-open { overflow: hidden; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; text-decoration: none; }
.ic { width: 18px; height: 18px; flex-shrink: 0; }
[dir="rtl"] .flip { transform: scaleX(-1); }
.mono { font-family: var(--mono); font-size: .92em; letter-spacing: -.01em; }
.muted { color: var(--muted); }
.danger-text { color: var(--danger) !important; }
.spacer { flex: 1; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, .08); border-radius: 10px; border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background-color: rgba(255, 255, 255, .16); }

/* ================= Layout ================= */
.app { display: grid; grid-template-columns: 252px 1fr; min-height: 100vh; }

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 28px;
  padding: 24px 16px;
  background: linear-gradient(180deg, rgba(255,255,255,.03), rgba(255,255,255,.01));
  border-inline-end: 1px solid var(--border);
  backdrop-filter: blur(20px);
}
.brand { display: flex; align-items: center; gap: 12px; padding: 4px 8px; }
.logo {
  width: 42px; height: 42px;
  display: grid; place-items: center;
  border-radius: 13px;
  background: var(--grad);
  color: white;
  box-shadow: 0 10px 30px -8px rgba(124, 92, 255, .7), inset 0 1px 0 rgba(255,255,255,.3);
}
.logo svg { width: 22px; height: 22px; }
.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; max-width: 160px; }
.brand-text span { font-size: 12px; color: var(--muted); }

.nav { display: flex; flex-direction: column; gap: 4px; }
.nav-item {
  position: relative;
  display: flex; align-items: center; gap: 12px;
  padding: 11px 14px;
  border-radius: 12px;
  color: var(--text-2);
  font-weight: 500;
  transition: background .2s, color .2s, transform .2s var(--ease);
}
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.active {
  color: var(--text);
  background: linear-gradient(90deg, rgba(124, 92, 255, .22), rgba(124, 92, 255, .04));
  box-shadow: inset 0 0 0 1px rgba(124, 92, 255, .25);
}
[dir="rtl"] .nav-item.active { background: linear-gradient(-90deg, rgba(124, 92, 255, .22), rgba(124, 92, 255, .04)); }
.nav-item.active::before {
  content: '';
  position: absolute;
  inset-inline-start: -16px;
  top: 10px; bottom: 10px;
  width: 3px;
  border-radius: 3px;
  background: var(--grad);
}
.nav-item .ic { width: 19px; height: 19px; }
.nav-badge {
  margin-inline-start: auto;
  font-style: normal;
  font-size: 11px;
  font-weight: 700;
  min-width: 22px;
  padding: 1px 7px;
  border-radius: 20px;
  background: rgba(124, 92, 255, .25);
  color: #c9bcff;
  text-align: center;
}
.sidebar-footer { margin-top: auto; }
.lang-toggle {
  width: 100%;
  display: flex; align-items: center; justify-content: center; gap: 10px;
  padding: 11px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  font-weight: 600;
  transition: border-color .2s, background .2s;
}
.lang-toggle:hover { border-color: var(--border-strong); background: var(--surface-2); }
#lang-toggle-label { font-family: var(--font-ar); }
html[lang="ar"] #lang-toggle-label { font-family: var(--font); }

.main { min-width: 0; padding: 26px 34px 60px; }
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 20px;
  flex-wrap: wrap;
  margin-bottom: 26px;
}
.page-heading h1 { font-size: 26px; font-weight: 800; letter-spacing: -.02em; }
.page-heading p { color: var(--muted); margin-top: 2px; }
.topbar-actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }

.search {
  display: flex; align-items: center; gap: 10px;
  width: 360px; max-width: 100%;
  padding: 0 12px;
  height: 44px;
  border-radius: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--muted);
  transition: border-color .2s, box-shadow .2s, background .2s;
}
.search:focus-within { border-color: rgba(124, 92, 255, .6); box-shadow: 0 0 0 4px rgba(124, 92, 255, .15); background: var(--surface-2); }
.search input { flex: 1; min-width: 0; background: none; border: 0; outline: 0; color: var(--text); height: 100%; }
.search input::placeholder { color: var(--muted); }
.search kbd { font-family: var(--mono); font-size: 10.5px; padding: 2px 6px; border-radius: 6px; border: 1px solid var(--border); color: var(--muted); white-space: nowrap; }

.view.enter { animation: fadeUp .45s var(--ease); }
@keyframes fadeUp { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* ================= Buttons ================= */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 42px;
  padding: 0 18px;
  border-radius: 12px;
  font-weight: 600;
  white-space: nowrap;
  transition: transform .15s var(--ease), box-shadow .2s, background .2s, border-color .2s, opacity .2s;
}
.btn:active { transform: scale(.97); }
.btn.sm { height: 34px; padding: 0 12px; font-size: 13px; border-radius: 10px; }
.btn-primary {
  color: white;
  background: var(--grad);
  background-size: 160% 100%;
  box-shadow: 0 10px 28px -10px rgba(124, 92, 255, .8), inset 0 1px 0 rgba(255,255,255,.25);
}
.btn-primary:hover { background-position: 100% 0; box-shadow: 0 14px 34px -10px rgba(79, 139, 255, .9), inset 0 1px 0 rgba(255,255,255,.25); transform: translateY(-1px); }
.btn-ghost { background: var(--surface); border: 1px solid var(--border); color: var(--text); }
.btn-ghost:hover { background: var(--surface-3); border-color: var(--border-strong); }
.btn-danger { background: rgba(248, 113, 113, .12); border: 1px solid rgba(248, 113, 113, .3); color: var(--danger); }
.btn-danger:hover { background: rgba(248, 113, 113, .2); }
.btn-wa { background: rgba(37, 211, 102, .12); border: 1px solid rgba(37, 211, 102, .3); color: #4ade80; }
.btn-wa:hover { background: rgba(37, 211, 102, .2); }
.btn-icon {
  width: 38px; height: 38px;
  display: inline-grid; place-items: center;
  border-radius: 10px;
  color: var(--text-2);
  border: 1px solid var(--border);
  background: var(--surface);
  transition: background .2s, color .2s, border-color .2s;
}
.btn-icon:hover { background: var(--surface-3); color: var(--text); }
.btn-icon.danger:hover { color: var(--danger); border-color: rgba(248, 113, 113, .4); background: rgba(248, 113, 113, .1); }
.btn-icon.xs { width: 28px; height: 28px; border-radius: 8px; border-color: transparent; background: none; }
.btn-icon.xs .ic { width: 15px; height: 15px; }
.link { color: #a99bff; font-weight: 600; font-size: 13px; }
.link:hover { color: #c9bfff; text-decoration: underline; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; }
.btn-row.center { justify-content: center; }

/* ================= Cards ================= */
.card {
  position: relative;
  background: linear-gradient(180deg, rgba(255,255,255,.045), rgba(255,255,255,.02));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  backdrop-filter: blur(16px);
}
.card h3, .card h4 { display: flex; align-items: center; gap: 9px; font-weight: 700; }
.card h3 { font-size: 15px; margin-bottom: 16px; }
.card h4 { font-size: 13px; color: var(--text-2); text-transform: uppercase; letter-spacing: .06em; margin-bottom: 12px; }
html[lang="ar"] .card h4 { letter-spacing: 0; }
.card h4 .ic { width: 16px; height: 16px; color: #a99bff; }
.card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.card-head h3 { margin: 0; }

/* ================= Badges ================= */
.badge {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 4px 10px 4px 9px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  color: var(--c);
  background: color-mix(in srgb, var(--c) 14%, transparent);
  border: 1px solid color-mix(in srgb, var(--c) 28%, transparent);
}
.badge i { width: 7px; height: 7px; border-radius: 50%; background: var(--c); box-shadow: 0 0 8px var(--c); }
.pill {
  display: inline-flex; align-items: center;
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  white-space: nowrap;
}
.pill-urgent { background: rgba(251, 146, 60, .15); color: #fb923c; }
.pill-danger { background: rgba(248, 113, 113, .15); color: var(--danger); }

/* ================= Dashboard ================= */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 18px; }
.stat {
  position: relative;
  overflow: hidden;
  text-align: start;
  padding: 20px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(255,255,255,.05), rgba(255,255,255,.015));
  transition: transform .25s var(--ease), border-color .25s, box-shadow .25s;
}
.stat::after {
  content: '';
  position: absolute;
  width: 160px; height: 160px;
  inset-inline-end: -50px; top: -60px;
  border-radius: 50%;
  background: var(--glow);
  filter: blur(40px);
  opacity: .35;
  transition: opacity .3s;
}
.stat:hover { transform: translateY(-3px); border-color: var(--border-strong); box-shadow: var(--shadow); }
.stat:hover::after { opacity: .6; }
.stat-ic {
  width: 40px; height: 40px;
  display: grid; place-items: center;
  border-radius: 12px;
  background: color-mix(in srgb, var(--glow) 18%, transparent);
  color: var(--glow);
  margin-bottom: 16px;
}
.stat-val { display: block; font-size: 30px; font-weight: 800; letter-spacing: -.03em; line-height: 1.1; }
.stat-label { display: block; color: var(--text-2); font-weight: 500; margin-top: 4px; }
.stat-hint { display: block; color: var(--muted); font-size: 12px; margin-top: 8px; }

.dash-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.span-2 { grid-column: span 2; }

.pipeline { display: flex; flex-direction: column; gap: 6px; }
.pipe-row {
  display: grid;
  grid-template-columns: 130px 1fr 30px;
  align-items: center;
  gap: 12px;
  padding: 9px 10px;
  border-radius: 10px;
  text-align: start;
  transition: background .2s;
}
.pipe-row:hover { background: var(--surface-2); }
.pipe-label { font-weight: 500; color: var(--text-2); font-size: 13px; }
.pipe-bar { height: 8px; border-radius: 8px; background: var(--surface-2); overflow: hidden; }
.pipe-bar i { display: block; height: 100%; border-radius: 8px; background: var(--c); box-shadow: 0 0 12px var(--c); animation: grow .9s var(--ease); }
@keyframes grow { from { width: 0 !important; } }
.pipe-row b { text-align: end; font-size: 15px; }

.mini-list { display: flex; flex-direction: column; gap: 6px; }
.mini-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px;
  border-radius: 12px;
  text-align: start;
  width: 100%;
  transition: background .2s;
}
.mini-item:hover { background: var(--surface-2); }
.mini-item .grow { flex: 1; min-width: 0; }
.mini-item strong { display: block; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mini-item small { display: block; color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mini-item .end { text-align: end; flex-shrink: 0; }
.empty-mini { display: flex; flex-direction: column; align-items: center; gap: 8px; color: var(--muted); padding: 26px 10px; text-align: center; }
.empty-mini .ic { width: 28px; height: 28px; color: var(--success); opacity: .8; }

.workload-row { display: flex; align-items: center; gap: 12px; padding: 8px 4px; }
.avatar {
  width: 36px; height: 36px;
  display: grid; place-items: center;
  border-radius: 11px;
  font-weight: 700; font-size: 13px;
  color: white;
  background: var(--grad);
  flex-shrink: 0;
}
.avatar.lg { width: 48px; height: 48px; border-radius: 14px; font-size: 16px; }
.workload-row .grow { flex: 1; }
.workload-row .pipe-bar { margin-top: 6px; }
.workload-row .pipe-bar i { background: var(--grad); box-shadow: none; }

/* Device icon */
.dev-ic {
  width: 40px; height: 40px;
  display: grid; place-items: center;
  border-radius: 12px;
  background: linear-gradient(135deg, rgba(124, 92, 255, .2), rgba(34, 211, 238, .12));
  border: 1px solid rgba(124, 92, 255, .25);
  color: #b9adff;
  flex-shrink: 0;
}
.dev-ic.lg { width: 54px; height: 54px; border-radius: 16px; }
.dev-ic.lg .ic { width: 26px; height: 26px; }

/* ================= Tickets list ================= */
.chips-bar { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.fchip {
  display: inline-flex; align-items: center; gap: 8px;
  height: 36px;
  padding: 0 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-2);
  font-weight: 500;
  font-size: 13px;
  transition: all .2s;
}
.fchip em { font-style: normal; font-size: 11px; font-weight: 700; padding: 1px 7px; border-radius: 10px; background: var(--surface-3); }
.fchip:hover { color: var(--text); border-color: var(--border-strong); }
.fchip.on { color: var(--text); background: rgba(124, 92, 255, .18); border-color: rgba(124, 92, 255, .45); }
.fchip[class*="st-"].on { background: color-mix(in srgb, var(--c) 16%, transparent); border-color: color-mix(in srgb, var(--c) 45%, transparent); }
.fchip[class*="st-"]::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: var(--c); }

.search-note { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; color: var(--text-2); }

.list-card { padding: 6px; }
.t-head, .t-row {
  display: grid;
  grid-template-columns: 120px minmax(200px, 2fr) minmax(150px, 1.3fr) 110px 170px 110px 110px;
  align-items: center;
  gap: 14px;
  padding: 12px 14px;
}
.t-head { color: var(--muted); font-size: 11.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; border-bottom: 1px solid var(--border); }
html[lang="ar"] .t-head { letter-spacing: 0; }
.t-row {
  border-radius: 12px;
  cursor: pointer;
  transition: background .2s, transform .2s var(--ease);
  animation: fadeUp .4s var(--ease) both;
}
.t-row + .t-row { border-top: 1px solid rgba(255,255,255,.035); }
.t-row:hover, .t-row:focus-visible { background: var(--surface-2); outline: none; }
.t-row strong { display: block; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.t-row small { display: block; color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.t-num { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; }
.t-num .mono { font-weight: 600; color: #c4baff; }
.t-device { display: flex; align-items: center; gap: 12px; min-width: 0; }
.t-device > div:last-child, .t-cust { min-width: 0; }
.t-status { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.t-total { font-weight: 700; text-align: end; }
.t-date { font-size: 12.5px; text-align: end; }

/* Empty state */
.empty { text-align: center; padding: 60px 20px; display: flex; flex-direction: column; align-items: center; }
.empty-ic {
  width: 76px; height: 76px;
  display: grid; place-items: center;
  border-radius: 24px;
  background: linear-gradient(135deg, rgba(124, 92, 255, .25), rgba(34, 211, 238, .15));
  border: 1px solid rgba(124, 92, 255, .35);
  color: #c4baff;
  margin-bottom: 20px;
  box-shadow: 0 20px 50px -15px rgba(124, 92, 255, .5);
  animation: float 4s ease-in-out infinite;
}
.empty-ic .ic { width: 34px; height: 34px; }
@keyframes float { 50% { transform: translateY(-8px); } }
.empty h3 { font-size: 20px; font-weight: 700; margin-bottom: 6px; }
.empty p { color: var(--muted); max-width: 420px; margin-bottom: 22px; }
.hero-empty { padding: 90px 20px; }
.hero-empty h3 { font-size: 28px; font-weight: 800; letter-spacing: -.02em; background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }

/* ================= Customers ================= */
.cust-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.cust-card { display: flex; flex-direction: column; gap: 16px; animation: fadeUp .4s var(--ease) both; transition: transform .25s var(--ease), border-color .25s; }
.cust-card:hover { transform: translateY(-3px); border-color: var(--border-strong); }
.cust-top { display: flex; align-items: center; gap: 14px; }
.cust-top strong { display: block; font-size: 16px; }
.cust-top span { display: block; }
.cust-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.cust-stats div { padding: 10px; border-radius: 12px; background: var(--surface); border: 1px solid var(--border); }
.cust-stats b { display: block; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cust-stats span { display: block; font-size: 11px; color: var(--muted); }
.cust-devices { display: flex; flex-direction: column; gap: 4px; }
.cust-devices .mini-item { padding: 7px 8px; }
.cust-devices .dev-ic { width: 30px; height: 30px; border-radius: 9px; }
.cust-devices .dev-ic .ic { width: 15px; height: 15px; }
.cust-actions { display: flex; gap: 8px; margin-top: auto; }
.cust-actions .btn { flex: 1; }

/* ================= Settings ================= */
.settings-grid { display: grid; grid-template-columns: 1.4fr 1fr; gap: 16px; align-items: start; }
.settings-grid .span-2 { grid-column: 1 / -1; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 6px 6px 12px;
  border-radius: 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-weight: 500;
}
[dir="rtl"] .chip { padding: 6px 12px 6px 6px; }
.chip button { width: 22px; height: 22px; display: grid; place-items: center; border-radius: 6px; color: var(--muted); }
.chip button:hover { background: rgba(248, 113, 113, .15); color: var(--danger); }
.chip .ic { width: 13px; height: 13px; }
.inline-form { display: flex; gap: 8px; }
.inline-form .input { flex: 1; }
.seg { display: inline-flex; padding: 4px; border-radius: 12px; background: var(--surface); border: 1px solid var(--border); }
.seg button { padding: 8px 18px; border-radius: 9px; font-weight: 600; color: var(--text-2); transition: all .2s; }
.seg button.on { background: var(--grad); color: white; box-shadow: 0 6px 18px -6px rgba(124, 92, 255, .8); }
.seg button[data-lang="ar"] { font-family: var(--font-ar); }
.seg button[data-lang="en"] { font-family: var(--font); }
.section-gap { margin-top: 26px; }
.backup-hint { color: var(--muted); margin-bottom: 16px; max-width: 720px; }

/* ================= Forms ================= */
.field { display: flex; flex-direction: column; gap: 7px; min-width: 0; }
.field > span { font-size: 12.5px; font-weight: 600; color: var(--text-2); }
.input {
  width: 100%;
  height: 42px;
  padding: 0 13px;
  border-radius: 11px;
  background: rgba(0, 0, 0, .25);
  border: 1px solid var(--border);
  outline: 0;
  transition: border-color .2s, box-shadow .2s, background .2s;
}
textarea.input { height: auto; padding: 11px 13px; resize: vertical; min-height: 80px; line-height: 1.5; }
select.input { cursor: pointer; }
select.input option { background: var(--surface-solid); }
.input:hover { border-color: var(--border-strong); }
.input:focus { border-color: rgba(124, 92, 255, .7); box-shadow: 0 0 0 4px rgba(124, 92, 255, .16); background: rgba(0, 0, 0, .35); }
.input::placeholder { color: var(--muted); }
input[type="date"].input::-webkit-calendar-picker-indicator { filter: invert(.8); cursor: pointer; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.full { grid-column: 1 / -1; }
.form-section { padding: 20px 0; border-bottom: 1px solid var(--border); display: flex; flex-direction: column; gap: 14px; }
.form-section:first-child { padding-top: 4px; }
.form-section:last-child { border-bottom: 0; }
.form-section h3 { display: flex; align-items: center; gap: 10px; font-size: 14px; font-weight: 700; }
.sec-ic { width: 30px; height: 30px; display: grid; place-items: center; border-radius: 9px; background: rgba(124, 92, 255, .15); color: #b9adff; }
.sec-ic .ic { width: 16px; height: 16px; }
.check { display: flex; align-items: center; gap: 10px; cursor: pointer; color: var(--text-2); font-weight: 500; }
.check input { width: 18px; height: 18px; accent-color: var(--accent); }

.type-picker { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 8px; }
.type-opt input { position: absolute; opacity: 0; pointer-events: none; }
.type-opt span {
  display: flex; flex-direction: column; align-items: center; gap: 7px;
  padding: 12px 4px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-2);
  cursor: pointer;
  transition: all .2s var(--ease);
  text-align: center;
}
.type-opt span .ic { width: 22px; height: 22px; }
.type-opt em { font-style: normal; font-size: 11.5px; font-weight: 600; line-height: 1.2; }
.type-opt span:hover { border-color: var(--border-strong); color: var(--text); }
.type-opt input:checked + span {
  color: white;
  border-color: rgba(124, 92, 255, .7);
  background: linear-gradient(135deg, rgba(124, 92, 255, .3), rgba(34, 211, 238, .12));
  box-shadow: 0 8px 22px -10px rgba(124, 92, 255, .9);
  transform: translateY(-2px);
}
.type-opt input:focus-visible + span { box-shadow: 0 0 0 3px rgba(124, 92, 255, .4); }

/* ================= Modal ================= */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  background: rgba(3, 5, 12, .7);
  backdrop-filter: blur(8px);
}
.modal-backdrop.anim { animation: fadeIn .25s ease; }
.modal-backdrop.anim .modal { animation: pop .35s var(--ease); }
@keyframes fadeIn { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: translateY(16px) scale(.98); } }
.modal {
  width: 100%;
  max-height: calc(100vh - 48px);
  display: flex; flex-direction: column;
  border-radius: 22px;
  background: linear-gradient(180deg, #121a2c, #0c1220);
  border: 1px solid var(--border-strong);
  box-shadow: 0 40px 120px -20px rgba(0, 0, 0, .8), 0 0 0 1px rgba(124, 92, 255, .08);
  overflow: hidden;
}
.modal > form { display: flex; flex-direction: column; min-height: 0; flex: 1; }
.modal-form { max-width: 820px; }
.modal-detail { max-width: 1160px; }
.modal-head {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
}
.modal-head h2 { font-size: 20px; font-weight: 700; letter-spacing: -.01em; }
.eyebrow { display: block; font-size: 12px; color: var(--muted); font-weight: 500; margin-bottom: 2px; }
.head-main { display: flex; align-items: center; gap: 16px; min-width: 0; }
.head-main h2 { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.head-badges { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.head-actions { display: flex; gap: 8px; align-items: center; flex-shrink: 0; }
.modal-body { padding: 4px 24px 20px; overflow-y: auto; flex: 1; }
.modal-detail .modal-body { padding: 20px 24px; }
.modal-foot {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  background: rgba(0, 0, 0, .2);
}
.modal-form .modal-foot { justify-content: flex-end; }

/* Stepper */
.stepper-wrap { padding: 16px 24px; border-bottom: 1px solid var(--border); background: rgba(0,0,0,.15); }
.stepper { display: grid; grid-template-columns: repeat(6, 1fr); gap: 0; }
.step {
  position: relative;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  padding: 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  text-align: center;
}
.step::before {
  content: '';
  position: absolute;
  top: 19px;
  inset-inline-start: calc(-50% + 22px);
  inset-inline-end: calc(50% + 22px);
  height: 2px;
  border-radius: 2px;
  background: var(--surface-3);
}
.step:first-child::before { display: none; }
.step.done::before, .step.current::before { background: var(--grad); }
.step .dot {
  width: 32px; height: 32px;
  display: grid; place-items: center;
  border-radius: 50%;
  border: 2px solid var(--surface-3);
  background: var(--surface-solid);
  font-size: 12px;
  transition: all .25s var(--ease);
}
.step .dot .ic { width: 15px; height: 15px; }
.step:hover .dot { border-color: var(--c); color: var(--c); transform: scale(1.08); }
.step:hover { color: var(--text-2); }
.step.done { color: var(--text-2); }
.step.done .dot { background: rgba(124, 92, 255, .25); border-color: rgba(124, 92, 255, .6); color: #c9bfff; }
.step.current { color: var(--c); }
.step.current .dot {
  background: var(--c);
  border-color: var(--c);
  color: #0b0f1a;
  box-shadow: 0 0 0 5px color-mix(in srgb, var(--c) 20%, transparent), 0 0 24px color-mix(in srgb, var(--c) 60%, transparent);
}
.cancel-banner {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px;
  border-radius: 12px;
  background: rgba(248, 113, 113, .1);
  border: 1px solid rgba(248, 113, 113, .3);
  color: var(--danger);
  font-weight: 600;
}
.cancel-banner .btn { margin-inline-start: auto; color: var(--text); }

/* Detail */
.detail-grid { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(300px, 1fr); gap: 16px; align-items: start; }
.detail-main, .detail-side { display: flex; flex-direction: column; gap: 16px; }
.info-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.big { font-size: 17px; font-weight: 700; }
.row-actions { display: flex; gap: 8px; margin-top: 14px; flex-wrap: wrap; }
dl { display: grid; grid-template-columns: auto 1fr; gap: 7px 14px; font-size: 13px; }
dt { color: var(--muted); }
dd { font-weight: 500; word-break: break-word; display: flex; align-items: center; gap: 6px; }
.link-btn { display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 6px; color: var(--muted); }
.link-btn:hover { background: var(--surface-3); color: var(--text); }
.link-btn .ic { width: 14px; height: 14px; }
.issue-text { white-space: pre-wrap; color: var(--text); line-height: 1.6; }

.parts-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.parts-table th { text-align: start; color: var(--muted); font-weight: 600; font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; padding: 0 8px 10px; border-bottom: 1px solid var(--border); }
html[lang="ar"] .parts-table th { letter-spacing: 0; }
.parts-table td { padding: 10px 8px; border-bottom: 1px solid rgba(255,255,255,.04); }
.parts-table .num { text-align: end; white-space: nowrap; }
.parts-table th.num { text-align: end; }
.parts-table .empty-row td { text-align: center; color: var(--muted); padding: 18px; }
.part-form { display: grid; grid-template-columns: 1fr 70px 110px auto; gap: 8px; margin-top: 14px; }
.part-form .input { height: 38px; }
.part-form .btn { height: 38px; }
.bill-inputs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 16px; }
.bill-inputs .input { height: 38px; }
.totals { margin-top: 18px; padding: 16px; border-radius: 14px; background: rgba(0,0,0,.25); border: 1px solid var(--border); display: flex; flex-direction: column; gap: 8px; }
.totals > div { display: flex; justify-content: space-between; color: var(--text-2); }
.totals b { color: var(--text); font-weight: 600; }
.totals .grand { padding-top: 10px; margin-top: 2px; border-top: 1px dashed var(--border-strong); font-size: 16px; }
.totals .grand b { font-size: 20px; font-weight: 800; background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.totals .bal.due b { color: var(--warning); }
.totals .bal.ok b { color: var(--success); }
.totals-note { font-size: 12px; color: var(--muted); margin-top: 8px; }

.job-fields { display: flex; flex-direction: column; gap: 12px; }
.job-fields .input { height: 38px; }

.note-form { display: flex; flex-direction: column; gap: 8px; margin-bottom: 18px; }
.note-form textarea.input { min-height: 64px; }
.note-form .btn { align-self: flex-end; }
.timeline { list-style: none; position: relative; display: flex; flex-direction: column; gap: 16px; max-height: 360px; overflow-y: auto; padding-inline-end: 4px; }
.tl-item { position: relative; display: flex; gap: 12px; padding-inline-start: 2px; }
.tl-item:not(:last-child)::after {
  content: '';
  position: absolute;
  inset-inline-start: 7px;
  top: 18px; bottom: -14px;
  width: 2px;
  background: var(--surface-3);
}
.tl-dot { width: 12px; height: 12px; margin-top: 4px; border-radius: 50%; flex-shrink: 0; background: var(--c, #a99bff); box-shadow: 0 0 0 4px color-mix(in srgb, var(--c, #a99bff) 18%, transparent); }
.tl-item.note .tl-dot { --c: #e9edf6; }
.tl-body { flex: 1; min-width: 0; font-size: 13px; }
.tl-body p { white-space: pre-wrap; padding: 9px 12px; border-radius: 4px 12px 12px 12px; background: var(--surface-2); border: 1px solid var(--border); }
[dir="rtl"] .tl-body p { border-radius: 12px 4px 12px 12px; }
.tl-body .badge { margin-inline-start: 4px; }
.tl-body time { display: block; font-size: 11.5px; color: var(--muted); margin-top: 5px; }

/* ================= Toasts ================= */
#toast-root { position: fixed; bottom: 24px; inset-inline-end: 24px; z-index: 100; display: flex; flex-direction: column; gap: 10px; }
.toast {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px;
  border-radius: 12px;
  background: rgba(17, 24, 39, .92);
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
  font-weight: 500;
  animation: toastIn .35s var(--ease);
}
.toast .ic { color: var(--success); }
.toast.error .ic { color: var(--danger); }
.toast.out { opacity: 0; transform: translateY(8px); transition: all .35s ease; }
@keyframes toastIn { from { opacity: 0; transform: translateY(14px) scale(.96); } }

/* ================= Responsive ================= */
@media (max-width: 1280px) {
  .t-head, .t-row { grid-template-columns: 110px minmax(180px, 2fr) minmax(140px, 1.3fr) 160px 100px; }
  .t-head > :nth-child(4), .t-row > :nth-child(4), .t-head > :nth-child(7), .t-row > :nth-child(7) { display: none; }
}
@media (max-width: 1100px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
  .dash-grid { grid-template-columns: 1fr 1fr; }
  .dash-grid .span-2 { grid-column: 1 / -1; }
  .detail-grid { grid-template-columns: 1fr; }
  .settings-grid { grid-template-columns: 1fr; }
  .type-picker { grid-template-columns: repeat(4, 1fr); }
}
@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed;
    top: auto; bottom: 0; left: 0; right: 0;
    height: auto;
    z-index: 40;
    flex-direction: row;
    padding: 8px;
    gap: 0;
    border-inline-end: 0;
    border-top: 1px solid var(--border);
    background: rgba(10, 14, 25, .92);
  }
  .brand, .sidebar-footer { display: none; }
  .nav { flex-direction: row; width: 100%; justify-content: space-around; }
  .nav-item { flex-direction: column; gap: 4px; padding: 8px 10px; font-size: 11px; flex: 1; }
  .nav-item.active::before { display: none; }
  .nav-badge { position: absolute; top: 2px; inset-inline-end: 18%; margin: 0; font-size: 10px; padding: 0 5px; min-width: 18px; }
  .main { padding: 20px 16px 100px; }
  .search { width: 100%; }
  .search kbd { display: none; }
  .topbar-actions { width: 100%; }
  .topbar-actions .search { flex: 1; }
  .t-head { display: none; }
  .t-row { grid-template-columns: 1fr auto; gap: 8px 12px; padding: 14px; }
  .t-row > :nth-child(n) { display: flex; }
  .t-num { flex-direction: row !important; align-items: center !important; }
  .t-device { grid-column: 1 / -1; order: -1; }
  .t-cust { flex-direction: column; }
  .t-tech, .t-date { display: none !important; }
  .t-total { justify-content: flex-end; }
  .info-cards { grid-template-columns: 1fr; }
  .stepper { grid-template-columns: repeat(6, minmax(70px, 1fr)); overflow-x: auto; }
  .modal-backdrop { padding: 0; align-items: flex-end; }
  .modal { max-height: 94vh; border-radius: 22px 22px 0 0; }
}
@media (max-width: 600px) {
  .stats { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat { padding: 14px; }
  .stat-val { font-size: 22px; }
  .dash-grid { grid-template-columns: 1fr; }
  .grid-2, .grid-3, .bill-inputs { grid-template-columns: 1fr; }
  .part-form { grid-template-columns: 1fr 1fr; }
  .part-form .input:first-child { grid-column: 1 / -1; }
  .type-picker { grid-template-columns: repeat(4, 1fr); }
  .head-actions .btn span { display: none; }
  .page-heading h1 { font-size: 22px; }
}

/* ================= Print ================= */
#print-area { display: none; }
@media print {
  @page { size: A4; margin: 14mm; }
  body { background: white !important; color: #111 !important; font-size: 12px; }
  body::before { display: none; }
  .app, #modal-root, #toast-root { display: none !important; }
  #print-area { display: block; }
}
.pd { color: #111; font-family: var(--font); max-width: 780px; margin: 0 auto; }
.pd[lang="ar"] { font-family: var(--font-ar); }
.pd-head { display: flex; justify-content: space-between; gap: 20px; padding-bottom: 16px; border-bottom: 3px solid #111; margin-bottom: 18px; }
.pd-shop { font-size: 22px; font-weight: 800; margin-bottom: 4px; }
.pd-meta { text-align: end; }
.pd-title { font-size: 15px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; }
.pd-num { font-family: var(--mono); font-size: 24px; font-weight: 700; margin: 4px 0; padding: 4px 10px; border: 2px solid #111; border-radius: 6px; display: inline-block; }
.pd-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 12px; }
.pd-box { border: 1px solid #bbb; border-radius: 8px; padding: 12px; margin-bottom: 12px; }
.pd-grid .pd-box { margin-bottom: 0; }
.pd-box h4 { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: #555; margin-bottom: 6px; }
.pd-box p { margin: 2px 0; }
.pd-table { width: 100%; border-collapse: collapse; margin: 6px 0 12px; }
.pd-table th, .pd-table td { padding: 8px; border-bottom: 1px solid #ccc; text-align: start; }
.pd-table th { background: #f1f1f1; font-size: 11px; text-transform: uppercase; }
.pd-table .n { text-align: end; }
.pd-totals { width: 300px; margin-inline-start: auto; }
.pd-totals div { display: flex; justify-content: space-between; padding: 4px 0; }
.pd-totals .g { border-top: 2px solid #111; margin-top: 4px; padding-top: 8px; font-size: 16px; font-weight: 800; }
.pd-terms { font-size: 10.5px; color: #444; margin-top: 18px; padding-top: 10px; border-top: 1px dashed #aaa; }
.pd-sign { display: grid; grid-template-columns: 1fr 1fr; gap: 40px; margin-top: 44px; }
.pd-sign div { border-top: 1px solid #111; padding-top: 6px; font-size: 11px; color: #444; }
.pd-foot { text-align: center; margin-top: 26px; font-weight: 700; }

/* ================= Login Overlay ================= */
.login-overlay {
  position: fixed; inset: 0;
  background: rgba(7, 10, 19, 0.85);
  display: grid; place-items: center;
  z-index: 9999;
  backdrop-filter: blur(12px);
  opacity: 0; pointer-events: none;
  transition: opacity 0.3s var(--ease);
}
.login-overlay.show {
  opacity: 1; pointer-events: auto;
}
.login-box {
  width: 100%; max-width: 380px;
  background: var(--surface-solid);
  padding: 40px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  text-align: center;
  display: flex; flex-direction: column; gap: 20px;
  transform: translateY(20px);
  transition: transform 0.4s var(--ease);
}
.login-overlay.show .login-box {
  transform: translateY(0);
}
.login-box .logo {
  margin: 0 auto;
}
.login-box h2 {
  font-size: 24px; font-weight: 700; color: white;
}
.login-box p {
  color: var(--text-2); margin-top: -10px;
}
.login-box form {
  display: flex; flex-direction: column; gap: 16px; text-align: left;
}
.login-box .field {
  display: flex; flex-direction: column; gap: 6px;
}
.login-btn {
  margin-top: 10px; height: 44px;
}
