/* White Linen Abaya — shared styles for the order page and the dashboard. */

/*
 * Brand palette: pink (logo identity) for actions and highlights, navy for text and
 * explanatory elements, and a creamy white background. Light theme only.
 */
:root {
  color-scheme: light;
  --cream: #faf7f2;
  --navy: #1e2a38;
  --pink: #f4c2c2;
  --pink-hover: #efb3b5;
  --pink-soft: #fcecec;
  --pink-deep: #d4788a;   /* deeper step of the brand pink: marks, icons, focus (>= 3:1 on white) */

  --bg: var(--cream);
  --surface: #ffffff;
  --surface-2: #f6f1e9;
  --border: #e9e2d7;
  --border-strong: #d6cdbf;
  --text: var(--navy);
  --text-2: #4a5566;
  --muted: #778191;
  --primary: var(--pink);
  --primary-hover: var(--pink-hover);
  --primary-ink: var(--navy);
  --focus: rgba(212, 120, 138, 0.35);
  --chart: var(--pink-deep);
  --grid: #ece6dc;
  --ok: #2e7a4d;      --ok-bg: #e7f4ec;
  --warn: #8a5a00;    --warn-bg: #fdf1dc;
  --info: #2b5c98;    --info-bg: #e8eff9;
  --danger: #b3261e;  --danger-bg: #fbe9e7;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(30, 42, 56, 0.04), 0 6px 20px rgba(30, 42, 56, 0.05);
  --font: "IBM Plex Sans Arabic", system-ui, -apple-system, "Segoe UI", Tahoma, sans-serif;
  --font-brand: "Cormorant Garamond", Georgia, "Times New Roman", serif;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.6;
}
img { max-width: 100%; }
a { color: var(--text); text-decoration: underline; text-decoration-color: var(--pink-deep); text-decoration-thickness: 1.5px; text-underline-offset: 3px; }
a:hover { color: var(--pink-deep); }
h1, h2, h3 { line-height: 1.3; margin: 0 0 0.5em; }
p { margin: 0 0 0.75em; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.nowrap { white-space: nowrap; }
.num { text-align: end; font-variant-numeric: tabular-nums; }
.hp { position: absolute; inset-inline-start: -9999px; }

/* Icons */
.icon { width: 18px; height: 18px; flex: none; }
.icon-sm { width: 14px; height: 14px; }
.icon-lg { width: 36px; height: 36px; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 42px; padding: 0 18px;
  border: 1px solid transparent; border-radius: 999px;
  font: inherit; font-weight: 600; font-size: 0.95rem;
  cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: background-color 0.15s, border-color 0.15s, color 0.15s;
}
.btn, .btn:hover { text-decoration: none; }
.btn-primary { background: var(--primary); color: var(--primary-ink); }
.btn-primary:hover { background: var(--primary-hover); color: var(--primary-ink); }
.btn-ghost { background: var(--surface); border-color: var(--border-strong); color: var(--text); }
.btn-ghost:hover { border-color: var(--pink-deep); color: var(--text); background: var(--pink-soft); }
.btn-soft { background: var(--surface); color: var(--text); border-color: var(--pink); }
.btn-soft:hover { background: var(--pink); color: var(--text); }
.btn-danger { background: var(--danger-bg); color: var(--danger); border-color: transparent; }
.btn-danger:hover { background: var(--danger); color: #fff; }
.btn-danger-text { color: var(--danger); }
.btn-sm { min-height: 34px; padding: 0 14px; font-size: 0.875rem; }
.btn-block { width: 100%; }
.icon-button {
  display: inline-grid; place-items: center; width: 36px; height: 36px;
  border: 0; border-radius: 50%; background: transparent; color: var(--muted); cursor: pointer;
}
.icon-button:hover { background: var(--danger-bg); color: var(--danger); }
.link-button { background: none; border: 0; padding: 0; font: inherit; color: inherit; cursor: pointer; }
:is(a, button, input, select, textarea, summary, [tabindex]):focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

/* Cards & alerts */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
}
.card-title { font-size: 1.05rem; font-weight: 600; margin-bottom: 14px; }
.section-title { font-size: 1.05rem; font-weight: 600; margin: 0; color: var(--text-2); }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.section-head .card-title { margin: 0; }
.subhead { font-size: 0.95rem; font-weight: 600; margin: 18px 0 10px; }
.alert {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 12px 16px; margin-bottom: 16px; border-radius: var(--radius-sm);
  font-weight: 500;
}
.alert .icon { margin-top: 3px; }
.alert-success { background: var(--ok-bg); color: var(--ok); }
.alert-error { background: var(--danger-bg); color: var(--danger); }
.alert-warn { background: var(--warn-bg); color: var(--warn); }
.alert a { color: inherit; text-decoration: underline; }
.empty-state { text-align: center; color: var(--muted); padding: 48px 20px; }
.empty-state p { margin: 12px 0 0; }

/* Forms */
.stack > * + * { margin-top: 14px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 16px; }
.form-grid-3 { grid-template-columns: repeat(3, 1fr); }
.field-wide { grid-column: 1 / -1; }
.field label { display: block; font-weight: 500; font-size: 0.9rem; margin-bottom: 6px; color: var(--text-2); }
.req { color: var(--pink-deep); }
input[type="text"], input[type="tel"], input[type="email"], input[type="url"], input[type="password"],
input[type="number"], input[type="date"], input[type="search"], select, textarea {
  width: 100%; min-height: 44px; padding: 9px 12px;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  font: inherit; font-size: 16px;
}
textarea { resize: vertical; min-height: 70px; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--pink-deep); box-shadow: 0 0 0 3px var(--focus); }
input[type="file"] { font: inherit; max-width: 100%; }
.field-error { color: var(--danger); font-size: 0.85rem; margin: 6px 0 0; }
.field:has(.field-error:not([hidden])) :is(input, select, textarea) { border-color: var(--danger); }
.hint { color: var(--muted); font-size: 0.85rem; margin: 6px 0 0; }
.check { display: inline-flex; align-items: center; gap: 8px; font-size: 0.9rem; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--pink-deep); }
.input-icon { position: relative; }
.input-icon .icon { position: absolute; inset-inline-start: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.input-icon input { padding-inline-start: 38px; }
.code { width: 100%; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 13px; }
.code-line { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 0.85rem; background: var(--surface-2); padding: 10px 12px; border-radius: var(--radius-sm); overflow-x: auto; }
.hint-list { color: var(--text-2); font-size: 0.9rem; padding-inline-start: 20px; }
.button-row { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 14px; }

/* Switch */
.switch { display: inline-flex; align-items: center; gap: 12px; cursor: pointer; font-weight: 600; }
.switch input[type="checkbox"] { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch-track { position: relative; width: 46px; height: 26px; border-radius: 999px; background: var(--border-strong); transition: background-color 0.15s; flex: none; }
.switch-track::after { content: ""; position: absolute; top: 3px; inset-inline-start: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; transition: inset-inline-start 0.15s; box-shadow: 0 1px 2px rgba(0,0,0,.2); }
.switch input:checked + .switch-track { background: var(--pink-deep); }
.switch input:checked + .switch-track::after { inset-inline-start: 23px; }
.switch input:focus-visible + .switch-track { outline: 3px solid var(--focus); outline-offset: 2px; }

/* Item rows (abayas) */
.items { display: grid; gap: 14px; margin-bottom: 14px; }
.item-row {
  position: relative; margin: 0; padding: 16px;
  border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2);
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px 14px;
}
.item-row .field-wide { grid-column: 1 / -1; }
.item-title { padding: 0; font-weight: 600; font-size: 0.9rem; color: var(--text); float: inline-start; }
.item-remove { position: absolute; top: 8px; inset-inline-end: 8px; }
.items:has(.item-row:only-child) .item-remove { display: none; }
.item-row .field:first-of-type { margin-top: 4px; }

/* Component links are never underlined */
.brand, .lang-switch, .icon-link, .sidebar-nav a, .sidebar-foot a, .tabs a, .segmented a,
.stat-tile, .recent-list a, .photo-thumb, .item-thumb, .icon-button { text-decoration: none; }

/* Abaya photo upload */
.field-label { display: block; font-weight: 500; font-size: 0.9rem; margin-bottom: 6px; color: var(--text-2); }
.photo-field { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.field .photo-picker {
  display: inline-flex; margin: 0; align-items: center; gap: 8px; min-height: 44px; padding: 0 16px;
  border: 1.5px dashed var(--pink-deep); border-radius: var(--radius-sm); background: var(--surface);
  color: var(--text); font-weight: 600; font-size: 0.9rem; cursor: pointer;
}
.field .photo-picker:hover { background: var(--pink-soft); }
.photo-picker .icon { color: var(--pink-deep); }
.photo-field:has(input[type="file"]:focus-visible) .photo-picker { outline: 3px solid var(--focus); outline-offset: 2px; }
.photo-thumb { display: block; flex: none; }
a.photo-thumb img, img.photo-thumb { display: block; width: 72px; height: 72px; object-fit: cover; border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--surface-2); }
.photo-attached { display: inline-flex; align-items: center; gap: 6px; color: var(--ok); font-size: 0.85rem; font-weight: 600; }
.field:has(.field-error:not([hidden])) .photo-picker { border-color: var(--danger); }

/* Discount code */
.input-with-button { display: flex; gap: 8px; }
.input-with-button input { flex: 1; min-width: 0; text-transform: uppercase; }
.field-ok { color: var(--ok); font-size: 0.85rem; font-weight: 600; margin: 6px 0 0; }
.discount-row dd { color: var(--ok); }
.discount-note { display: inline-flex; align-items: center; gap: 6px; background: var(--ok-bg); color: var(--ok); padding: 6px 12px; border-radius: 999px; font-size: 0.9rem; font-weight: 600; }
.code-chip { display: inline-block; font-family: ui-monospace, Menlo, Consolas, monospace; font-weight: 600; background: var(--pink-soft); border: 1px solid var(--pink); padding: 2px 10px; border-radius: 8px; letter-spacing: 0.04em; }
.row-actions { display: flex; align-items: center; justify-content: flex-end; gap: 4px; }
.row-actions .icon-button:hover { background: var(--surface-2); color: var(--text); }
.row-actions .icon-button.danger:hover { background: var(--danger-bg); color: var(--danger); }
.two-col.discounts-layout { grid-template-columns: minmax(0, 380px) minmax(0, 1fr); align-items: start; }
.badge-muted { background: var(--surface-2); color: var(--muted); }

/* Brand */
.brand { display: inline-flex; align-items: center; color: var(--text); text-decoration: none; }
.brand:hover { text-decoration: none; }
.wordmark { font-family: var(--font-brand); font-size: 1.6rem; font-weight: 600; letter-spacing: 0.02em; line-height: 1; direction: ltr; }
.brand-logo { max-height: 52px; width: auto; display: block; }
.lang-switch, .icon-link { display: inline-flex; align-items: center; gap: 6px; color: var(--text-2); font-weight: 500; font-size: 0.9rem; }
.lang-switch:hover, .icon-link:hover { color: var(--pink-deep); }

/* ---------- Public order page ---------- */
.site-header { background: var(--surface); border-bottom: 1px solid var(--border); }
.site-header-inner { max-width: 760px; margin: 0 auto; padding: 14px 16px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.site-nav { display: flex; align-items: center; gap: 16px; }
.site-main { max-width: 760px; margin: 0 auto; padding: 0 16px 40px; }
.hero {
  text-align: center; padding: 36px 20px 30px; margin: 20px 0;
  background: linear-gradient(160deg, var(--pink-soft), var(--surface-2));
  border-radius: var(--radius);
}
.hero h1 { font-size: 1.7rem; font-weight: 700; }
.hero p { color: var(--text-2); max-width: 560px; margin: 0 auto 16px; }
.order-form { padding: 24px; }
.form-section-title { font-size: 1.05rem; font-weight: 600; margin: 8px 0 14px; padding-bottom: 8px; border-bottom: 1px solid var(--border); }
.form-section-title:not(:first-of-type) { margin-top: 28px; }
.order-form > .field { margin: 18px 0; }
.order-summary { background: var(--pink-soft); border-radius: var(--radius-sm); padding: 14px 16px; margin: 20px 0; }
.order-summary p { display: flex; gap: 10px; margin: 0; font-size: 0.9rem; color: var(--text-2); }
.order-summary p + p { margin-top: 8px; }
.order-summary .icon { color: var(--pink-deep); margin-top: 3px; }
.notice-card { text-align: center; padding: 40px 24px; color: var(--text-2); }
.notice-card .icon { color: var(--pink-deep); margin-bottom: 12px; }
.thanks-card { text-align: center; padding: 40px 24px; margin-top: 24px; }
.thanks-icon { display: inline-grid; place-items: center; width: 72px; height: 72px; border-radius: 50%; background: var(--ok-bg); color: var(--ok); margin-bottom: 16px; }
.order-number { font-size: 1.1rem; }
.payment-info { text-align: start; background: var(--surface-2); border-radius: var(--radius-sm); padding: 16px; margin: 20px 0; }
.payment-info h2 { font-size: 1rem; }
.site-footer { text-align: center; color: var(--muted); font-size: 0.85rem; padding: 24px 16px; }

/* ---------- Auth / installer ---------- */
.auth-page { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.auth-card { width: 100%; max-width: 400px; padding: 28px; }
.install-card { max-width: 520px; }
.auth-card h1 { font-size: 1.3rem; }
.auth-brand { text-align: center; margin-bottom: 18px; }
.auth-card .lang-switch { margin-top: 18px; }
.checks { list-style: none; padding: 0; margin: 0 0 18px; display: grid; gap: 6px; font-size: 0.9rem; }
.checks li { display: flex; align-items: center; gap: 8px; }
.checks .ok { color: var(--ok); }
.checks .bad { color: var(--danger); }

/* ---------- Admin shell ---------- */
.admin-shell { display: grid; grid-template-columns: 250px 1fr; min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  display: flex; flex-direction: column; gap: 8px; padding: 20px 14px;
  background: var(--surface); border-inline-end: 1px solid var(--border);
}
.sidebar-brand { padding: 4px 10px 18px; }
.sidebar-brand .wordmark { font-size: 1.35rem; }
.sidebar-nav { display: grid; gap: 2px; }
.sidebar-nav a, .sidebar-foot a, .sidebar-foot .link-button {
  display: flex; align-items: center; gap: 12px; width: 100%;
  padding: 10px 12px; border-radius: var(--radius-sm);
  color: var(--text-2); font-weight: 500; text-decoration: none; text-align: start;
}
.sidebar-nav a:hover, .sidebar-foot a:hover, .sidebar-foot .link-button:hover { background: var(--surface-2); color: var(--text); }
.sidebar-nav a.active { background: var(--pink-soft); color: var(--text); font-weight: 600; box-shadow: inset -3px 0 0 var(--pink-deep); }
[dir="ltr"] .sidebar-nav a.active { box-shadow: inset 3px 0 0 var(--pink-deep); }
.sidebar-nav a.active .icon { color: var(--pink-deep); }
.sidebar-foot { margin-top: auto; padding-top: 12px; border-top: 1px solid var(--border); display: grid; gap: 2px; font-size: 0.9rem; }
.sidebar-user { color: var(--muted); font-size: 0.85rem; padding: 8px 12px 0; margin: 0; }
.sidebar-backdrop { display: none; }
.admin-main { min-width: 0; }
.topbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 14px 28px; background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(8px); border-bottom: 1px solid var(--border);
}
.page-title { font-size: 1.3rem; font-weight: 700; margin: 0; flex: 1; min-width: 0; }
.topbar-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.menu-button { display: none; }
.admin-content { padding: 24px 28px 48px; max-width: 1280px; }
.admin-content > * + * { margin-top: 18px; }

/* KPI tiles */
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.kpis-3 { grid-template-columns: repeat(3, 1fr); }
.section-title + .kpis, .section-head + .kpis { margin-top: 0; }
[aria-labelledby="now-title"] .section-title { margin-bottom: 12px; }
.stat-tile { display: flex; flex-direction: column; gap: 6px; color: var(--text); text-decoration: none; padding: 16px 18px; }
a.stat-tile:hover { border-color: var(--pink-deep); }
.stat-label { display: flex; align-items: center; gap: 6px; color: var(--text-2); font-size: 0.875rem; }
.stat-label .icon { color: var(--muted); }
.stat-value { font-size: 1.6rem; font-weight: 600; line-height: 1.2; white-space: nowrap; }
.stat-note { color: var(--muted); font-size: 0.8rem; }

/* Segmented control & tabs */
.segmented { display: inline-flex; background: var(--surface-2); border-radius: 999px; padding: 3px; gap: 2px; flex-wrap: wrap; }
.segmented a { padding: 6px 14px; border-radius: 999px; color: var(--text-2); font-size: 0.875rem; font-weight: 500; text-decoration: none; }
.segmented a.active { background: var(--surface); color: var(--text); font-weight: 600; box-shadow: var(--shadow); }
.tabs { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 2px; }
.tabs a {
  display: inline-flex; align-items: center; gap: 8px; white-space: nowrap;
  padding: 8px 14px; border-radius: 999px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text-2); font-weight: 500; text-decoration: none;
}
.tabs a.active { background: var(--pink); border-color: var(--pink); color: var(--text); font-weight: 600; }
.tabs .count { font-size: 0.8rem; opacity: 0.75; font-variant-numeric: tabular-nums; }

/* Filters */
.filters { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px 14px; padding: 16px; }
.filters .field { min-width: 140px; }
.filters .filter-search { flex: 1 1 260px; }
.filter-checks { display: flex; flex-direction: column; gap: 4px; }
.filter-actions { display: flex; gap: 8px; }
.result-count { margin: 12px 4px 8px; font-size: 0.85rem; }

/* Tables */
.table-wrap { padding: 0; overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.table th {
  text-align: start; font-weight: 600; font-size: 0.8rem; color: var(--muted);
  padding: 12px 14px; border-bottom: 1px solid var(--border); white-space: nowrap;
}
.table td { padding: 12px 14px; border-bottom: 1px solid var(--border); vertical-align: top; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: color-mix(in srgb, var(--surface-2) 60%, transparent); }
.table-compact td, .table-compact th { padding: 8px 12px; }
.table .num { text-align: end; }
.table-foot { padding: 10px 14px; margin: 0; }
.strong-link { font-weight: 600; text-decoration: none; }
.strong-link:hover { text-decoration: underline; text-decoration-color: var(--pink-deep); }
.amount-due { color: var(--danger); font-weight: 600; }
.notes-cell { color: var(--text-2); max-width: 200px; font-size: 0.85rem; }
.items-cell { min-width: 200px; }
.item-line { display: flex; align-items: flex-start; gap: 10px; }
.item-line + .item-line { margin-top: 8px; }
.item-text { display: block; }
.item-thumb, .item-thumb img { display: block; width: 40px; height: 40px; flex: none; object-fit: cover; border-radius: 8px; border: 1px solid var(--border); }
.item-size { display: block; color: var(--muted); font-size: 0.8rem; }
.actions-cell { text-align: end; }
.tag { display: inline-block; font-size: 0.72rem; font-weight: 600; padding: 1px 8px; border-radius: 999px; background: var(--surface-2); color: var(--text-2); margin-inline-start: 4px; vertical-align: middle; }
.tag-warn { background: var(--warn-bg); color: var(--warn); }
.orders-table .tag-warn { margin: 4px 0 0; }

/* Status */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px; border-radius: 999px; font-size: 0.8rem; font-weight: 600; white-space: nowrap; }
.badge-processing { background: var(--warn-bg); color: var(--warn); }
.badge-out_for_delivery { background: var(--info-bg); color: var(--info); }
.badge-completed { background: var(--ok-bg); color: var(--ok); }
.status-select { min-height: 34px; padding: 4px 30px 4px 10px; font-size: 0.85rem; font-weight: 600; border-radius: 999px; width: auto; }
[dir="rtl"] .status-select { padding: 4px 10px 4px 30px; }
.status-select.status-processing { background-color: var(--warn-bg); color: var(--warn); border-color: transparent; }
.status-select.status-out_for_delivery { background-color: var(--info-bg); color: var(--info); border-color: transparent; }
.status-select.status-completed { background-color: var(--ok-bg); color: var(--ok); border-color: transparent; }
.inline-status { display: flex; gap: 6px; align-items: center; }

.pagination { display: flex; align-items: center; justify-content: center; gap: 14px; color: var(--text-2); font-size: 0.9rem; }

/* Order editor */
.order-editor { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 18px; align-items: start; }
.editor-main, .editor-side { display: grid; gap: 18px; }
.editor-side { position: sticky; top: 84px; }
.editor-side .field + .field { margin-top: 14px; }
.inline-links { display: flex; gap: 18px; margin-top: 14px; font-size: 0.9rem; }
.inline-links a { display: inline-flex; align-items: center; gap: 6px; }
.totals-list { margin: 0; }
.totals-list div { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; }
.totals-list dt { color: var(--text-2); }
.totals-list dd { margin: 0; font-weight: 600; font-variant-numeric: tabular-nums; }
.total-row { border-top: 1px solid var(--border); margin-top: 6px; font-size: 1.05rem; }
.balance-row dd { color: var(--danger); font-size: 1.1rem; }
.balance-row.is-zero dd { color: var(--ok); }
.totals .field { margin: 6px 0 10px; }
.meta p { margin: 0 0 4px; }
.danger-zone { margin-top: 24px; }

/* Settings */
.settings-form { display: grid; gap: 18px; }
.rate-rows { display: grid; gap: 8px; margin-bottom: 10px; }
.rate-row { display: grid; grid-template-columns: minmax(0, 1fr) 140px 36px; gap: 8px; align-items: center; }
.logo-preview { display: flex; align-items: center; gap: 16px; margin-bottom: 10px; }
.logo-preview img { max-height: 60px; border-radius: 8px; background: var(--surface-2); padding: 6px; }
.favicon-preview img { width: 48px; height: 48px; object-fit: contain; }
.sticky-save { position: sticky; bottom: 0; padding: 14px 0; background: linear-gradient(transparent, var(--bg) 35%); }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }

/* Customer page */
.customer-head { display: grid; grid-template-columns: auto auto 1fr auto; gap: 24px; align-items: start; }
.customer-head p { margin: 0; }
.customer-phone { font-weight: 600; }

/* Recent orders */
.recent-list { list-style: none; margin: 0; padding: 0; }
.recent-list li { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.recent-list li:last-child { border-bottom: 0; }
.recent-list a { display: grid; gap: 2px; color: var(--text); text-decoration: none; min-width: 0; }
.recent-list a:hover strong { color: var(--pink-deep); }

/* ---------- Charts ---------- */
.chart { margin-inline: 0; margin-bottom: 0; }
.chart figcaption { margin-bottom: 8px; }
.chart figcaption .card-title { margin-bottom: 2px; }
.chart-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; margin-top: 18px; }
.colchart { position: relative; height: 240px; margin: 20px 0 8px; }
.colchart-axis { position: absolute; top: 0; bottom: 24px; inset-inline: 0; pointer-events: none; }
.colchart-axis .tick { position: absolute; inset-inline-start: 36px; inset-inline-end: 0; border-top: 1px solid var(--grid); }
.colchart-axis .tick span {
  position: absolute; inset-inline-end: 100%; top: 0; transform: translateY(-50%); padding-inline-end: 8px;
  font-size: 0.72rem; color: var(--muted); font-variant-numeric: tabular-nums;
}
.colchart-bars { position: absolute; top: 0; bottom: 0; inset-inline-start: 36px; inset-inline-end: 0; display: flex; gap: 2px; }
.col { flex: 1; display: flex; flex-direction: column; min-width: 0; border-radius: 6px; }
.col:hover, .col:focus-visible { background: color-mix(in srgb, var(--surface-2) 70%, transparent); }
.col-plot { flex: 1; display: flex; align-items: flex-end; justify-content: center; }
.col-bar { position: relative; width: min(24px, 70%); background: var(--chart); border-radius: 4px 4px 0 0; min-height: 2px; }
.col-value { position: absolute; bottom: 100%; left: 50%; transform: translateX(-50%); margin-bottom: 4px; font-size: 0.75rem; font-weight: 600; color: var(--text); white-space: nowrap; }
.col-label { height: 24px; line-height: 24px; text-align: center; font-size: 0.72rem; color: var(--muted); white-space: nowrap; }
.chart-table { margin-top: 10px; font-size: 0.85rem; }
.chart-table summary { cursor: pointer; color: var(--text-2); }
.chart-table table { margin-top: 8px; }
.barlist { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 8px; }
.barlist li { display: grid; grid-template-columns: 96px 1fr; align-items: center; gap: 10px; border-radius: 6px; }
.barlist li:hover .barlist-bar, .barlist li:focus-visible .barlist-bar { filter: brightness(1.12); }
.barlist-label { font-size: 0.85rem; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.barlist-track { display: flex; align-items: center; gap: 8px; min-width: 0; }
.barlist-bar { display: block; height: 18px; width: calc((100% - 4rem) * var(--w)); min-width: 2px; background: var(--chart); border-start-end-radius: 4px; border-end-end-radius: 4px; }
.barlist-value { font-size: 0.8rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.chart-tooltip {
  position: fixed; z-index: 50; pointer-events: none;
  background: var(--text); color: var(--bg); border-radius: 8px; padding: 8px 12px;
  font-size: 0.8rem; line-height: 1.4; box-shadow: 0 6px 20px rgba(0,0,0,.18); max-width: 240px;
}
.chart-tooltip strong { display: block; font-size: 0.9rem; }
.chart-tooltip span { opacity: 0.8; }

/* ---------- Print ---------- */
.print-body { background: #fff; color: #222; }
.print-toolbar { display: flex; gap: 10px; justify-content: center; padding: 16px; background: var(--surface-2); }
.print-page { max-width: 780px; margin: 24px auto; padding: 32px; background: #fff; color: #222; }
.print-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; border-bottom: 2px solid #f4c2c2; padding-bottom: 16px; margin-bottom: 18px; }
.print-head .brand { color: #222; }
.print-title { text-align: end; }
.print-title h1 { font-size: 1.4rem; margin: 0; }
.print-title p { margin: 0; color: #555; }
.print-customer p { margin: 0 0 2px; }
.print-customer { margin-bottom: 18px; }
.print-table th, .print-table td { color: #222; border-color: #e3dcd6; }
.print-totals { max-width: 320px; margin: 18px 0 0 auto; }
[dir="rtl"] .print-totals { margin: 18px auto 0 0; }
.print-totals div { display: flex; justify-content: space-between; padding: 4px 0; }
.print-totals dd { margin: 0; font-variant-numeric: tabular-nums; }
.print-totals .total-row { border-top: 1px solid #ddd; font-weight: 700; }
.print-totals .balance-row { font-weight: 700; }
.print-item { display: flex; align-items: flex-start; gap: 10px; }
.print-photo { width: 56px; height: 56px; object-fit: cover; border-radius: 6px; flex: none; }
.print-photo-lg { width: 140px; height: 140px; object-fit: cover; border-radius: 8px; flex: none; }
.print-notes { margin-top: 20px; padding: 12px 14px; background: #faf6f2; border-radius: 8px; }
.print-notes h2 { font-size: 0.95rem; }
.print-thanks { text-align: center; margin-top: 28px; color: #777; }
@media print {
  .no-print { display: none !important; }
  .print-page { margin: 0; padding: 0; max-width: none; }
  body { background: #fff; }
}

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .order-editor { grid-template-columns: 1fr; }
  .editor-side { position: static; }
}

@media (max-width: 900px) {
  .admin-shell { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; inset-block: 0; inset-inline-start: 0; z-index: 30; width: 270px;
    transform: translateX(-100%); transition: transform 0.2s ease;
  }
  [dir="rtl"] .sidebar { transform: translateX(100%); }
  body.sidebar-open .sidebar { transform: none; }
  body.sidebar-open .sidebar-backdrop { display: block; position: fixed; inset: 0; z-index: 20; background: rgba(0,0,0,.35); }
  .menu-button { display: inline-grid; place-items: center; width: 40px; height: 40px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); color: var(--text); cursor: pointer; }
  .topbar { padding: 12px 16px; }
  .admin-content { padding: 16px 16px 40px; }
  .chart-grid, .two-col, .two-col.discounts-layout { grid-template-columns: 1fr; }
  .customer-head { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 640px) {
  body { font-size: 14.5px; }
  .form-grid, .form-grid-3 { grid-template-columns: 1fr; }
  .item-row { grid-template-columns: 1fr 1fr; }
  .card { padding: 16px; }
  .order-form { padding: 18px 16px; }
  .hero { padding: 28px 16px 24px; }
  .hero h1 { font-size: 1.4rem; }
  .topbar-actions .btn span { display: none; }
  .topbar-actions .btn { padding: 0 12px; }
  .stat-value { font-size: 1.1rem; }
  .kpis-3 { grid-template-columns: 1fr; }
  .filters .field { min-width: 0; flex: 1 1 45%; }

  /* Tables become stacked cards */
  .table-wrap { background: transparent; border: 0; box-shadow: none; overflow: visible; }
  .table-wrap .table thead { display: none; }
  .table-wrap .table, .table-wrap .table tbody, .table-wrap .table tr, .table-wrap .table td { display: block; width: 100%; }
  .table-wrap .table tr { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 14px; margin-bottom: 10px; box-shadow: var(--shadow); }
  .table-wrap .table td { display: grid; grid-template-columns: 88px minmax(0, 1fr); column-gap: 12px; padding: 6px 0; border: 0; text-align: end; }
  .table-wrap .table td::before { content: attr(data-label); grid-column: 1; grid-row: 1 / span 20; color: var(--muted); font-size: 0.8rem; font-weight: 500; text-align: start; }
  .table-wrap .table td > * { grid-column: 2; }
  .table-wrap .table td > form { justify-self: end; }
  .table-wrap .table td:not([data-label]) { display: block; }
  .table-wrap .table td:not([data-label])::before { content: none; }
  .items-cell { min-width: 0; }
  .notes-cell { max-width: none; }
  .rate-row { grid-template-columns: minmax(0, 1fr) 110px 36px; }
  .col-label { font-size: 0.66rem; }
  .col:nth-child(odd) .col-label { visibility: hidden; }
  .customer-head { grid-template-columns: 1fr; gap: 12px; }
}
