/* نمط التصميم المعتمد (link-foundation): ألوان OKLCH بدرجة علامة واحدة 156،
   وخط Tajawal محلي. لا ألوان ثابتة خارج المتغيرات.
   الأنماط الأساسية للحاسوب، وقسم «الهاتف» في الأسفل. */

@font-face { font-family: Tajawal; font-weight: 400; font-display: swap; src: url(/fonts/tajawal-arabic-400-normal.woff2) format("woff2"); unicode-range: U+0600-06FF, U+0750-077F, U+FB50-FDFF, U+FE70-FEFC, U+200C-200E; }
@font-face { font-family: Tajawal; font-weight: 700; font-display: swap; src: url(/fonts/tajawal-arabic-700-normal.woff2) format("woff2"); unicode-range: U+0600-06FF, U+0750-077F, U+FB50-FDFF, U+FE70-FEFC, U+200C-200E; }
@font-face { font-family: Tajawal; font-weight: 800; font-display: swap; src: url(/fonts/tajawal-arabic-800-normal.woff2) format("woff2"); unicode-range: U+0600-06FF, U+0750-077F, U+FB50-FDFF, U+FE70-FEFC, U+200C-200E; }
@font-face { font-family: Tajawal; font-weight: 400; font-display: swap; src: url(/fonts/tajawal-latin-400-normal.woff2) format("woff2"); unicode-range: U+0000-00FF, U+2000-206F; }
@font-face { font-family: Tajawal; font-weight: 700; font-display: swap; src: url(/fonts/tajawal-latin-700-normal.woff2) format("woff2"); unicode-range: U+0000-00FF, U+2000-206F; }
@font-face { font-family: Tajawal; font-weight: 800; font-display: swap; src: url(/fonts/tajawal-latin-800-normal.woff2) format("woff2"); unicode-range: U+0000-00FF, U+2000-206F; }

:root {
  --radius: 0.625rem;
  /* مساحة النوتش وشريط الحالة. theme.js يصححها إن أعادها iOS صفراً */
  --safe-top: env(safe-area-inset-top, 0px);
  --background: oklch(0.99 0.002 250);   --foreground: oklch(0.18 0.01 250);
  --card: oklch(1 0 0);                  --popover: oklch(1 0 0);
  --primary: oklch(0.55 0.13 156);       --primary-foreground: oklch(0.99 0 0);
  --muted: oklch(0.96 0.005 250);        --muted-foreground: oklch(0.5 0.01 250);
  --accent: oklch(0.94 0.03 156);        --accent-foreground: oklch(0.3 0.05 156);
  --destructive: oklch(0.577 0.245 27.325);  --destructive-foreground: oklch(0.99 0 0);
  --success: oklch(0.65 0.15 156);       --warning: oklch(0.75 0.15 65);
  --border: oklch(0.9 0.005 250);        --input: oklch(0.92 0.005 250);   --ring: oklch(0.55 0.13 156);
  --sidebar: oklch(0.985 0.002 250);
  --overlay: oklch(0 0 0 / 50%);
  --shadow-xs: 0 1px 2px 0 oklch(0 0 0 / 5%);
  --shadow-lg: 0 10px 15px -3px oklch(0 0 0 / 10%), 0 4px 6px -4px oklch(0 0 0 / 10%);
  color-scheme: light;
}
.dark {
  --background: oklch(0.16 0.01 250);    --foreground: oklch(0.97 0 0);
  --card: oklch(0.21 0.012 250);         --popover: oklch(0.21 0.012 250);
  --primary: oklch(0.65 0.15 156);       --primary-foreground: oklch(0.15 0.01 250);
  --muted: oklch(0.28 0.01 250);         --muted-foreground: oklch(0.7 0.01 250);
  --accent: oklch(0.32 0.04 156);        --accent-foreground: oklch(0.95 0.02 156);
  --destructive: oklch(0.704 0.191 22.216);
  --border: oklch(1 0 0 / 10%);          --input: oklch(1 0 0 / 15%);
  --sidebar: oklch(0.21 0.012 250);
  color-scheme: dark;
}

/* ---------- الأساس ---------- */
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--background);
  color: var(--foreground);
  font-family: Tajawal, system-ui, sans-serif;
  font-size: 0.875rem;
  line-height: 1.5;
  overscroll-behavior-y: none;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
h1, h2, h3, p { margin: 0; }
button { font: inherit; color: inherit; cursor: pointer; touch-action: manipulation; }
button:disabled { cursor: default; }
a { color: inherit; touch-action: manipulation; }
:focus-visible { outline: 3px solid color-mix(in oklch, var(--ring) 55%, transparent); outline-offset: 1px; }
.muted { color: var(--muted-foreground); }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.icon { width: 1rem; height: 1rem; flex: none; }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 8px; }

/* ---------- الأزرار ---------- */
.btn {
  display: inline-flex; flex: none; align-items: center; justify-content: center; gap: 0.375rem;
  height: 2.25rem; padding: 0 1rem;
  border: 1px solid transparent; border-radius: calc(var(--radius) - 2px);
  background: transparent; color: var(--foreground);
  font-size: 0.875rem; font-weight: 500; text-decoration: none; white-space: nowrap;
  transition: background-color 0.15s, color 0.15s;
}
.btn-primary { background: var(--primary); color: var(--primary-foreground); }
.btn-primary:hover { background: color-mix(in oklch, var(--primary) 90%, transparent); }
.btn-outline { border-color: var(--border); background: var(--card); }
.btn-outline:hover, .btn-ghost:hover { background: var(--accent); color: var(--accent-foreground); }
.btn-destructive { background: var(--destructive); color: var(--destructive-foreground); }
.btn-destructive:hover { background: color-mix(in oklch, var(--destructive) 90%, transparent); }
.btn-lg { height: 2.875rem; padding: 0 1.5rem; font-size: 1rem; }
.btn-block { width: 100%; }
.btn-icon { width: 2.25rem; padding: 0; }
.btn-action { min-width: 2rem; height: 2rem; padding: 0; }
.btn-action.danger { color: var(--destructive); }
.btn-action.success { color: var(--success); }
.btn:disabled { opacity: 0.5; pointer-events: none; }
.btn[aria-busy="true"]::before {
  content: ""; width: 1rem; height: 1rem; border-radius: 50%;
  border: 2px solid currentColor; border-inline-start-color: transparent;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- الحقول ---------- */
.field { display: block; min-width: 0; }
.field > span:first-child { display: block; margin-bottom: 0.25rem; font-weight: 500; }
input, select, textarea {
  width: 100%; height: 2.25rem; padding: 0 0.75rem;
  border: 1px solid var(--input); border-radius: calc(var(--radius) - 2px);
  background: var(--card); color: var(--foreground);
  font: inherit; font-size: 0.875rem;
}
textarea { height: auto; min-height: 5rem; padding-block: 0.5rem; resize: vertical; }
input[type="date"] {
  display: inline-flex; align-items: center; min-width: 0; max-width: 100%;
  -webkit-appearance: none; appearance: none;
}
input[type="date"]::-webkit-date-and-time-value { min-height: 1.5em; margin: 0; text-align: right; }
/* كل الحقول من اليمين عدا التاريخ. plaintext يبقي الهاتف والبريد بترتيبه الصحيح وهو محاذى لليمين. */
input:not([type="checkbox"], [type="radio"], [type="file"], [type="date"]), textarea, select {
  text-align: right;
  unicode-bidi: plaintext;
}
input::placeholder { color: var(--muted-foreground); }
input[type="search"]::-webkit-search-cancel-button { display: none; }
.with-icon { position: relative; display: block; }
.with-icon > .icon { position: absolute; right: 0.75rem; top: 50%; translate: 0 -50%; color: var(--muted-foreground); pointer-events: none; }
.with-icon > input { padding-right: 2.25rem; }
.with-icon.has-reveal > input { padding-left: 2.75rem; }
.reveal {
  position: absolute; left: 0.25rem; top: 50%; translate: 0 -50%;
  display: grid; place-items: center; width: 2.25rem; height: 2.25rem;
  border: 0; background: none; color: var(--muted-foreground);
}
.alert {
  padding: 0.625rem 0.75rem;
  border: 1px solid var(--destructive); border-radius: var(--radius);
  background: color-mix(in oklch, var(--destructive) 10%, transparent); color: var(--destructive);
}
.alert:empty { display: none; }

/* ---------- الهيكل ---------- */
.app {
  position: fixed; inset: 0; display: flex; flex-direction: column;
  padding-inline: env(safe-area-inset-right, 0px) env(safe-area-inset-left, 0px);
}
.safe-probe { position: fixed; top: 0; width: 0; height: env(safe-area-inset-top, 0px); visibility: hidden; }
.topbar {
  display: flex; flex: none; align-items: center; gap: 0.5rem;
  height: 4rem; padding: 0 0.75rem;
  border-bottom: 1px solid var(--border); background: var(--card);
}
.app-icon { flex: none; width: 2.5rem; height: 2.5rem; border-radius: var(--radius); }
.topbar-title { flex: 1; min-width: 0; line-height: 1.3; }
.app-name { color: var(--primary); font-weight: 800; font-size: 1rem; }
.topbar-title small { display: block; overflow: hidden; color: var(--muted-foreground); font-size: 0.75rem; text-overflow: ellipsis; white-space: nowrap; }
/* غلاف الأيقونة داخل الزر لا يأخذ مكاناً: وإلا أزاحت الأيقونة المخفية جارتها عن المنتصف */
.btn > span[data-icon] { display: contents; }
.dark .icon-moon { display: none; }
html:not(.dark) .icon-sun { display: none; }

.shell { display: flex; flex: 1; min-height: 0; }
.sidebar {
  display: flex; flex: none; flex-direction: column; gap: 0.25rem;
  width: 15rem; padding: 0.75rem; overflow-y: auto;
  border-left: 1px solid var(--border); background: var(--sidebar);
}
.nav-item {
  display: flex; align-items: center; gap: 0.75rem; width: 100%; padding: 0.625rem 0.75rem;
  border: 0; border-radius: var(--radius); background: none; font-weight: 500; text-align: right;
}
.nav-item:hover { background: var(--accent); color: var(--accent-foreground); }
.nav-item[aria-current="page"] { background: var(--primary); color: var(--primary-foreground); box-shadow: var(--shadow-xs); }
.main { display: flex; flex: 1; flex-direction: column; min-width: 0; }

.page { display: flex; flex: 1; flex-direction: column; min-height: 0; }
.page-header {
  display: flex; flex-wrap: wrap; align-items: center; gap: 0.75rem; padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border); background: var(--card);
}
.icon-tile {
  display: grid; flex: none; place-items: center; width: 2.25rem; height: 2.25rem;
  border-radius: var(--radius);
  background: color-mix(in oklch, var(--primary) 10%, transparent); color: var(--primary);
}
.icon-tile .icon { width: 1.25rem; height: 1.25rem; }
.page-heading { flex: 1; min-width: 0; }
.page-heading h1 { font-size: 1.125rem; font-weight: 800; line-height: 1.25; }
.page-heading p { color: var(--muted-foreground); font-size: 0.75rem; }
.page-body { display: flex; flex: 1; flex-direction: column; gap: 0.75rem; padding: 1rem; overflow-y: auto; }
.page-body > * { flex: none; }

.screen-tabs { display: flex; flex: none; gap: 0.25rem; padding: 0 0.75rem; overflow-x: auto; border-bottom: 1px solid var(--border); background: var(--card); }
.screen-tabs button {
  flex: none; padding: 0.625rem 0.75rem; white-space: nowrap;
  border: 0; border-bottom: 3px solid transparent; background: none;
  color: var(--muted-foreground); font-weight: 500;
}
.screen-tabs button:hover { background: var(--accent); color: var(--accent-foreground); }
.screen-tabs button[aria-selected="true"] { border-bottom-color: var(--primary); color: var(--primary); font-weight: 700; }

/* ---------- البطاقات والمؤشرات ---------- */
.card { border: 1px solid var(--border); border-radius: calc(var(--radius) + 4px); background: var(--card); box-shadow: var(--shadow-xs); }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr)); gap: 0.75rem; }
.kpi { display: flex; align-items: center; gap: 0.75rem; padding: 1rem; }
.kpi .icon-tile { width: 2.75rem; height: 2.75rem; border-radius: calc(var(--radius) + 4px); }
.kpi div { min-width: 0; }
.kpi span.muted { display: block; font-size: 0.75rem; }
.kpi strong { display: block; font-size: 1.5rem; font-weight: 800; line-height: 1.25; font-variant-numeric: tabular-nums; }
.badge {
  display: inline-flex; padding: 0.125rem 0.5rem;
  border: 1px solid var(--border); border-radius: 999px;
  font-size: 0.75rem; font-weight: 500; white-space: nowrap;
}

/* ---------- البحث والتصفية ---------- */
.toolbar { display: grid; gap: 0.75rem; }
.searchbar .with-icon { max-width: 24rem; }
.filters { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.chip { height: 2rem; padding: 0 0.875rem; }
.note { color: var(--muted-foreground); font-size: 0.75rem; }

/* ---------- الجداول ---------- */
.table-card { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; text-align: right; }
th { padding: 0.625rem; background: var(--muted); font-weight: 500; text-align: right; white-space: nowrap; }
td { padding: 0.625rem; vertical-align: middle; }
tbody tr + tr { border-top: 1px solid var(--border); }
td.state { padding: 2.5rem 1rem; color: var(--muted-foreground); text-align: center; }
td.state p { margin-bottom: 0.75rem; }
td.state > .icon { width: 1.25rem; height: 1.25rem; animation: spin 0.8s linear infinite; }
.cell-customer { overflow-wrap: anywhere; }
.cell-customer > * { display: block; }
.cell-customer strong { font-weight: 700; }
.cell-customer small { color: var(--muted-foreground); font-size: 0.75rem; white-space: pre-line; }
.cell-contact { white-space: nowrap; }
.cell-licenses ul { display: grid; gap: 0.375rem; margin: 0; padding: 0; list-style: none; }
.cell-licenses li { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; }
.license-number {
  display: inline-flex; align-items: center; gap: 0.375rem; max-width: 100%; padding: 0.125rem 0.5rem;
  border: 0; border-radius: calc(var(--radius) - 4px); background: var(--muted);
  font-weight: 700; overflow-wrap: anywhere;
}
.license-number:hover { background: var(--accent); color: var(--accent-foreground); }
.license-number .icon { width: 0.75rem; height: 0.75rem; opacity: 0.6; }
.devices { font-size: 0.75rem; font-weight: 700; white-space: nowrap; }
.date { color: var(--muted-foreground); font-size: 0.75rem; font-variant-numeric: tabular-nums; white-space: nowrap; }
.cell-actions { width: 1%; white-space: nowrap; }
.actions { display: flex; gap: 0.125rem; }
.actions .btn-action span { display: none; }

/* ---------- الإعدادات ---------- */
.panel { display: grid; gap: 0.75rem; max-width: 42rem; width: 100%; }
.panel-card { display: grid; gap: 0.75rem; padding: 1.25rem; }
.panel-card h2 { font-size: 1rem; font-weight: 800; }
.panel-card > .btn { justify-self: start; }
.inline-form { display: flex; align-items: end; gap: 0.5rem; }
.inline-form .field { flex: 1; }
.type-list { margin: 0; padding: 0; list-style: none; }
.type-list li { display: flex; align-items: center; gap: 0.75rem; min-height: 3rem; padding: 0.5rem 0.75rem; }
.type-list li + li { border-top: 1px solid var(--border); }
.type-list li > span:first-child { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.type-list .btn-action span { display: none; }

/* ---------- النوافذ ---------- */
dialog {
  width: min(32rem, calc(100% - 2rem)); max-height: 90dvh; padding: 1.25rem;
  border: 1px solid var(--border); border-radius: calc(var(--radius) + 4px);
  background: var(--popover); color: var(--foreground); box-shadow: var(--shadow-lg);
}
dialog::backdrop { background: var(--overlay); }
/* ورقة النموذج: العنوان والأزرار ثابتة، والمحتوى وحده يُمرَّر */
dialog.sheet { width: min(48rem, calc(100% - 2rem)); padding: 0; overflow: hidden; }
dialog.sheet[open] { display: flex; flex-direction: column; }
.sheet > form { display: flex; flex-direction: column; min-height: 0; }
.dialog-head { position: relative; flex: none; padding: 1rem 1.25rem 0.75rem; padding-left: 3.5rem; border-bottom: 1px solid var(--border); }
.dialog-head.plain { padding: 0 0 1rem; border: 0; }
.dialog-head h2 { font-size: 1.125rem; font-weight: 800; }
.dialog-head p { color: var(--muted-foreground); font-size: 0.75rem; }
.dialog-head .btn { position: absolute; left: 0.75rem; bottom: 0.75rem; }
.dialog-body { min-height: 0; padding: 1rem 1.25rem; overflow-y: auto; overscroll-behavior: contain; }
.dialog-body > * { min-width: 0; }
.dialog-foot { display: flex; flex: none; justify-content: flex-end; gap: 0.5rem; padding: 0.75rem 1.25rem; border-top: 1px solid var(--border); }
.confirm-actions { display: flex; justify-content: flex-end; gap: 0.5rem; }
.stack { display: grid; gap: 1rem; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.75rem; }
fieldset { min-width: 0; margin: 0; padding: 0; border: 0; }
legend { margin-bottom: 0.5rem; font-size: 1rem; font-weight: 800; }
.license-row {
  display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1.2fr) minmax(0, 0.9fr) minmax(0, 1fr) auto; align-items: end; gap: 0.5rem;
  margin-bottom: 0.5rem; padding: 0.75rem;
  border: 1px solid var(--border); border-radius: var(--radius);
}
.license-row .btn-action span { display: none; }
.danger-text { justify-self: start; color: var(--destructive); }

/* ---------- التنبيهات والحالة ---------- */
.toasts { position: fixed; bottom: 1rem; left: 1rem; z-index: 60; display: grid; gap: 0.5rem; width: min(24rem, calc(100% - 2rem)); pointer-events: none; }
.toast {
  display: flex; align-items: flex-start; gap: 0.5rem; padding: 0.75rem;
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--popover); box-shadow: var(--shadow-lg); font-weight: 700; text-align: right; pointer-events: auto;
}
.toast .icon { width: 1.25rem; height: 1.25rem; }
.toast .icon-circle-check { color: var(--success); }
.toast .icon-circle-x { color: var(--destructive); }
.offline-banner { flex: none; padding: 0.375rem 1rem; background: color-mix(in oklch, var(--warning) 25%, var(--card)); font-weight: 700; text-align: center; }
.boot { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0.75rem; min-height: 100dvh; color: var(--muted-foreground); }
.boot img { border-radius: var(--radius); }
.spinning .icon { animation: spin 0.8s linear infinite; }

/* ---------- الدخول ---------- */
.entry {
  position: fixed; inset: 0; display: flex; flex-direction: column; overflow-y: auto;
  background: linear-gradient(to bottom left, color-mix(in oklch, var(--accent) 50%, transparent), var(--background) 50%, var(--background));
}
.entry-header { position: sticky; top: 0; z-index: 5; flex: none; padding-top: var(--safe-top); border-bottom: 1px solid var(--border); background: var(--card); }
.entry-header > div { display: flex; align-items: center; gap: 0.75rem; max-width: 64rem; height: 4rem; margin-inline: auto; padding: 0 1rem; }
.entry-main { display: flex; flex: 1 0 auto; flex-direction: column; gap: 1rem; width: 100%; max-width: 32rem; margin-inline: auto; padding: 2rem 1rem calc(1rem + env(safe-area-inset-bottom)); }
.entry-intro { display: grid; justify-items: center; gap: 0.5rem; text-align: center; }
.entry-intro .icon-tile { width: 4rem; height: 4rem; border-radius: calc(var(--radius) + 6px); }
.entry-intro .icon-tile .icon { width: 2rem; height: 2rem; }
.entry-intro h1 { font-size: 1.75rem; font-weight: 800; line-height: 1.3; }
.entry-card { padding: 1.5rem; box-shadow: var(--shadow-lg); }
.entry-card input { height: 2.875rem; font-size: 1rem; }
.entry-footer { margin-top: auto; padding-top: 0.5rem; color: var(--muted-foreground); font-size: 0.75rem; text-align: center; }
.email-note { display: flex; align-items: center; gap: 0.5rem; padding: 0.75rem; border-radius: var(--radius); background: var(--muted); }
.email-note bdi { font-weight: 800; overflow-wrap: anywhere; }
.entry-card .code-input { height: 3.5rem; font-size: 1.75rem; font-weight: 800; letter-spacing: 0.5rem; }
.link { justify-self: center; min-height: 2.75rem; border: 0; background: none; color: var(--primary); }
.link:hover { text-decoration: underline; }

/* ---------- عناصر الهاتف (مخفية على الحاسوب) ---------- */
.bottom-nav, .mobile-only { display: none; }

/* ---------- الهاتف ---------- */
@media (max-width: 767px) {
  /* 16px يمنع iOS من تكبير الشاشة عند لمس حقل */
  input, select, textarea { height: 2.875rem; font-size: 1rem; }
  textarea { height: auto; }
  .btn { height: 2.75rem; }
  .btn-icon { width: 2.75rem; }
  .mobile-only { display: block; }
  .btn.mobile-only { display: inline-flex; }
  .desktop-only { display: none !important; }

  .topbar { height: calc(3.5rem + var(--safe-top)); padding-top: var(--safe-top); }
  .app-icon { width: 2.25rem; height: 2.25rem; }
  .sidebar { display: none; }
  /* العنوان وزر الإضافة يتكرران في الشريط السفلي */
  .page-header { display: none; }
  .page-body { gap: 0.625rem; padding: 0.75rem 0.75rem 1rem; }
  .kpis { display: none; }

  /* البحث والتصفية يبقيان ظاهرين عند التمرير */
  .toolbar { position: sticky; top: -0.75rem; z-index: 5; gap: 0.5rem; margin: -0.75rem -0.75rem 0; padding: 0.75rem 0.75rem 0.5rem; background: var(--background); }
  .searchbar .with-icon { max-width: none; }
  .searchbar .reveal { left: 0; width: 2.75rem; height: 2.75rem; }
  .filters { flex-wrap: nowrap; margin-inline: -0.75rem; padding-inline: 0.75rem; overflow-x: auto; scrollbar-width: none; }
  .chip { flex: none; height: 2.25rem; border-radius: 999px; }

  .customers { border: 0; background: none; box-shadow: none; overflow: visible; }
  .customers table, .customers tbody, .customers tr, .customers td { display: block; }
  .customers thead { display: none; }
  .customers tbody { display: grid; gap: 0.625rem; }
  .customers tr, .customers tbody tr + tr { overflow: hidden; border: 1px solid var(--border); border-radius: calc(var(--radius) + 4px); background: var(--card); box-shadow: var(--shadow-xs); }
  .customers td { width: auto; padding: 0.25rem 0.875rem; }
  .customers td.cell-customer { padding-top: 0.75rem; }
  .customers td.state { padding: 2.5rem 1rem; }
  .cell-customer strong { font-size: 1.0625rem; }
  .customers .cell-contact { color: var(--muted-foreground); }
  .customers .cell-contact:empty { display: none; }
  .customers td.cell-licenses { padding-block: 0.5rem 0.75rem; }
  .license-number { min-height: 2.25rem; font-size: 0.9375rem; }
  .customers td.cell-actions { padding: 0; border-top: 1px solid var(--border); }
  .actions { gap: 0; }
  .actions .btn-action { flex: 1; width: auto; height: 3rem; border-radius: 0; }
  .actions .btn-action + .btn-action:not(.desktop-only) { border-right-color: var(--border); }
  .actions .btn-action span { display: inline; }

  .screen-tabs { padding: 0; }
  .screen-tabs button { flex: 1 0 auto; min-height: 3rem; }
  .panel-card > .btn { justify-self: stretch; }
  .inline-form .btn { height: 2.875rem; }
  .type-list .btn-action { min-width: 2.75rem; }

  .bottom-nav {
    display: grid; flex: none; grid-template-columns: repeat(3, 1fr);
    padding-bottom: env(safe-area-inset-bottom);
    border-top: 1px solid var(--border); background: var(--card);
  }
  .bottom-nav button {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0.125rem;
    min-height: 3.75rem; border: 0; background: none; color: var(--muted-foreground); font-size: 0.75rem; font-weight: 700;
  }
  .bottom-nav .icon { width: 1.375rem; height: 1.375rem; }
  .bottom-nav button[aria-current="page"] { color: var(--primary); }
  .bottom-nav .add { color: var(--primary); }
  .bottom-nav .add .icon { width: 3rem; height: 1.75rem; padding: 0.25rem 0; border-radius: 999px; background: var(--primary); color: var(--primary-foreground); }

  /* لوحة المفاتيح مفتوحة: نعيد المساحة للمحتوى */
  .app:has(input:focus, textarea:focus) .bottom-nav { display: none; }

  /* النموذج يملأ الشاشة، وزر الحفظ في متناول الإبهام */
  dialog.sheet { width: 100%; max-width: 100%; height: 100dvh; max-height: 100dvh; margin: 0; border: 0; border-radius: 0; }
  .sheet > form { flex: 1; }
  .sheet .dialog-head { padding-top: calc(0.75rem + var(--safe-top)); }
  .sheet .dialog-head .btn { bottom: 0.5rem; }
  .sheet .dialog-body { flex: 1; align-content: start; padding-inline: 1rem; }
  .sheet .dialog-foot { padding: 0.75rem 1rem calc(0.75rem + env(safe-area-inset-bottom)); }
  .sheet .dialog-foot .btn { flex: 1; height: 3rem; font-size: 1rem; }
  .grid-2, .license-row { grid-template-columns: minmax(0, 1fr); }
  .license-row .btn-action { justify-self: end; padding: 0 0.75rem; }
  .license-row .btn-action span { display: inline; }
  .danger-text { justify-self: stretch; }
  .confirm-actions .btn { flex: 1; }
  .toasts { bottom: calc(4.5rem + env(safe-area-inset-bottom)); }
}

@media (min-width: 1920px) { html { font-size: 18px; } }
@media (min-width: 2560px) { html { font-size: 21px; } }
@media (min-width: 3400px) { html { font-size: 28px; } }
@media (prefers-reduced-motion: reduce) { * { transition-duration: 0.001ms !important; animation-duration: 0.001ms !important; } }
