/* QR Store SaaS — store owner dashboard + login. Mobile-first, RTL-aware, light/dark. */
:root {
	--d-primary: #e4572e;
	--d-bg: #f4f5f7;
	--d-surface: #ffffff;
	--d-surface-2: #f7f8fa;
	--d-ink: #15171c;
	--d-ink-2: #545b67;
	--d-ink-3: #8b919c;
	--d-line: #e6e8ec;
	--d-good: #12823b;
	--d-good-bg: #e7f6ec;
	--d-warn: #9a6200;
	--d-warn-bg: #fff4d6;
	--d-crit: #b42318;
	--d-crit-bg: #fef3f2;
	--d-info: #2a78d6;
	--d-info-bg: #eaf2fd;
	--d-series: #2a78d6;
	--d-radius: 14px;
	--d-shadow: 0 1px 2px rgba(16,24,40,.05), 0 2px 8px rgba(16,24,40,.04);
	--d-font: system-ui, -apple-system, "Segoe UI", Tahoma, "Noto Sans Arabic", "Geeza Pro", Roboto, Arial, sans-serif;
	color-scheme: light;
}
@media (prefers-color-scheme: dark) {
	:root {
		--d-bg: #121316;
		--d-surface: #1b1d21;
		--d-surface-2: #23262b;
		--d-ink: #f2f3f5;
		--d-ink-2: #b8bdc6;
		--d-ink-3: #868c96;
		--d-line: #2e3238;
		--d-good: #4ccf7c;
		--d-good-bg: #173322;
		--d-warn: #f0b545;
		--d-warn-bg: #3a2c10;
		--d-crit: #ff7b6e;
		--d-crit-bg: #3b1916;
		--d-info: #6aa8f0;
		--d-info-bg: #16263b;
		--d-series: #3987e5;
		--d-shadow: none;
		color-scheme: dark;
	}
}
* { box-sizing: border-box; }
body.d-body { margin: 0; font-family: var(--d-font); background: var(--d-bg); color: var(--d-ink); font-size: 14.5px; line-height: 1.5; -webkit-font-smoothing: antialiased; }
body.d-locked { overflow: hidden; }
a { color: var(--d-primary); }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }
svg { fill: currentColor; }
h1, h2, h3 { margin: 0; line-height: 1.3; }
h2 { font-size: 16px; }

/* ---------------------------------------------------------------- Layout */
.d-app { min-height: 100vh; }
.d-side { position: fixed; z-index: 30; inset-inline: 0; bottom: 0; background: var(--d-surface); border-top: 1px solid var(--d-line); padding-bottom: env(safe-area-inset-bottom); }
.d-brand, .d-side-foot { display: none; }
.d-nav { display: flex; overflow-x: auto; scrollbar-width: none; }
.d-nav::-webkit-scrollbar { display: none; }
.d-nav a { flex: 1 0 auto; min-width: 64px; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 6px; font-size: 11px; color: var(--d-ink-3); text-decoration: none; position: relative; }
.d-nav a svg { width: 22px; height: 22px; }
.d-nav a.is-active { color: var(--d-primary); }
.d-badge { position: absolute; inset-block-start: 4px; inset-inline-start: calc(50% + 6px); background: var(--d-crit); color: #fff; font-size: 10.5px; min-width: 18px; height: 18px; border-radius: 9px; display: grid; place-items: center; padding: 0 5px; font-style: normal; }
.d-main { padding-bottom: 84px; min-width: 0; }
.d-top { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; background: color-mix(in srgb, var(--d-bg) 92%, transparent); backdrop-filter: blur(8px); }
.d-top h1 { font-size: 20px; font-weight: 800; }
.d-top-actions { display: flex; gap: 6px; }
.d-content { padding: 4px 16px 24px; }
.d-notice-area { padding: 0 16px; }
.d-hide-sm { display: none !important; }

@media (min-width: 900px) {
	.d-app { display: grid; grid-template-columns: 248px 1fr; }
	.d-side { position: sticky; top: 0; inset: auto; height: 100vh; border-top: 0; border-inline-end: 1px solid var(--d-line); display: flex; flex-direction: column; padding: 18px 12px; }
	.d-brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 18px; }
	.d-brand strong { display: block; font-size: 15px; }
	.d-brand small { color: var(--d-ink-3); font-size: 12px; }
	.d-nav { flex-direction: column; gap: 2px; overflow: visible; }
	.d-nav a { flex: none; flex-direction: row; gap: 10px; padding: 10px 12px; border-radius: 10px; font-size: 14.5px; color: var(--d-ink-2); font-weight: 600; }
	.d-nav a svg { width: 20px; height: 20px; }
	.d-nav a:hover { background: var(--d-surface-2); }
	.d-nav a.is-active { background: color-mix(in srgb, var(--d-primary) 12%, transparent); color: var(--d-primary); }
	.d-badge { position: static; margin-inline-start: auto; }
	.d-side-foot { display: flex; flex-direction: column; gap: 4px; margin-top: auto; padding: 12px; border-top: 1px solid var(--d-line); font-size: 13px; }
	.d-user { font-weight: 700; }
	.d-main { padding-bottom: 24px; }
	.d-top { padding: 18px 28px; }
	.d-top h1 { font-size: 24px; }
	.d-content, .d-notice-area { padding-inline: 28px; }
	.d-hide-sm { display: inline-flex !important; }
	.d-show-sm { display: none !important; }
}
.d-brand-mark { width: 38px; height: 38px; border-radius: 10px; background: var(--d-primary); color: #fff; display: grid; place-items: center; flex: none; }
.d-brand-mark svg { width: 22px; height: 22px; }

/* ---------------------------------------------------------------- Primitives */
.d-card { background: var(--d-surface); border: 1px solid var(--d-line); border-radius: var(--d-radius); padding: 16px; box-shadow: var(--d-shadow); margin-bottom: 16px; min-width: 0; }
.d-card h2 { margin-bottom: 12px; }
.d-card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.d-card-head h2 { margin: 0; }
.d-card-head a { font-size: 13px; text-decoration: none; font-weight: 600; }
.d-grid-2 { display: grid; gap: 16px; grid-template-columns: 1fr; }
.d-grid-2 > .d-card, .d-grid-2 > div > .d-card:last-child { margin-bottom: 0; }
.d-grid-2 + .d-grid-2 { margin-top: 16px; }
@media (min-width: 1100px) { .d-grid-2 { grid-template-columns: 1fr 1fr; } }
.d-mt { margin-top: 20px; }
.d-muted { color: var(--d-ink-3); }
.d-help { color: var(--d-ink-3); font-size: 13px; margin: 6px 0 0; }
.d-empty { text-align: center; color: var(--d-ink-3); padding: 28px 12px; }
.d-center { text-align: center; margin-top: 12px; }
.d-btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid var(--d-line); background: var(--d-surface); color: var(--d-ink); padding: 8px 14px; border-radius: 10px; font-weight: 600; font-size: 14px; cursor: pointer; text-decoration: none; min-height: 38px; white-space: nowrap; }
.d-btn:hover { border-color: var(--d-ink-3); }
.d-btn:disabled { opacity: .55; cursor: not-allowed; }
.d-btn-primary { background: var(--d-primary); border-color: var(--d-primary); color: #fff; }
.d-btn-primary:hover { filter: brightness(.95); border-color: var(--d-primary); }
.d-btn-ghost { background: transparent; }
.d-btn-danger { color: var(--d-crit); }
.d-btn-wa { background: #1fa855; border-color: #1fa855; color: #fff; }
.d-btn-wa:hover { filter: brightness(.95); border-color: #1fa855; color: #fff; }
.d-notify-toggle { flex: 1 1 100%; }
.d-btn-sm { padding: 5px 10px; min-height: 32px; font-size: 13px; }
.d-btn-lg { padding: 12px 22px; font-size: 15px; }
.d-btn-block { width: 100%; }
.d-link { background: none; border: 0; padding: 0; cursor: pointer; text-decoration: underline; font-size: 13px; }
.d-danger { color: var(--d-crit); }
.d-icon-btn { width: 32px; height: 32px; border-radius: 8px; border: 1px solid var(--d-line); background: var(--d-surface); cursor: pointer; display: inline-grid; place-items: center; font-size: 16px; flex: none; }
.d-icon-btn:disabled { opacity: .35; }
.d-input { width: 100%; border: 1px solid var(--d-line); background: var(--d-surface); border-radius: 10px; padding: 9px 12px; min-height: 40px; outline: none; font-size: 15px; }
.d-input:focus { border-color: var(--d-primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--d-primary) 18%, transparent); }
.d-input:disabled { background: var(--d-surface-2); color: var(--d-ink-3); }
.d-input-sm { max-width: 130px; }
.d-input-xs { width: 70px; display: inline-block; min-height: 32px; padding: 4px 8px; }
textarea.d-input { resize: vertical; }
.d-field { display: block; margin-bottom: 14px; flex: 1; min-width: 0; }
.d-label { display: block; font-weight: 600; font-size: 13px; margin-bottom: 5px; color: var(--d-ink-2); }
.d-row { display: flex; gap: 12px; flex-wrap: wrap; }
.d-row > * { flex: 1 1 160px; }
.d-row-center { align-items: center; margin: 6px 0; }
.d-row-center > * { flex: 0 1 auto; }
.d-check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; margin-inline-end: 16px; }
.d-check input { width: 18px; height: 18px; accent-color: var(--d-primary); }
.d-checks { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.d-inline { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--d-ink-2); }
.d-alert { padding: 12px 14px; border-radius: 10px; margin-bottom: 14px; font-size: 14px; }
.d-alert-error { background: var(--d-crit-bg); color: var(--d-crit); }
.d-alert-warn { background: var(--d-warn-bg); color: var(--d-warn); }
.d-toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 14px; }
.d-toolbar .d-search { flex: 1 1 220px; width: auto; }
.d-toolbar select.d-input { width: auto; flex: 0 1 200px; }
.d-grow { flex: 1 1 220px; width: auto; }
.d-usage { font-size: 13px; }

/* Switch */
.d-switch { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; user-select: none; }
.d-switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.d-switch span { width: 38px; height: 22px; border-radius: 11px; background: var(--d-line); position: relative; transition: .15s; flex: none; }
.d-switch span::after { content: ""; position: absolute; top: 3px; inset-inline-start: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: .15s; box-shadow: 0 1px 2px rgba(0,0,0,.2); }
.d-switch input:checked + span { background: var(--d-good); }
.d-switch input:checked + span::after { inset-inline-start: 19px; }
.d-switch input:focus-visible + span { outline: 2px solid var(--d-primary); outline-offset: 2px; }
.d-switch em { font-style: normal; font-size: 13px; color: var(--d-ink-2); }
.d-switches { display: flex; flex-wrap: wrap; gap: 18px; margin: 4px 0 16px; }

/* Spinner / toast */
.d-loading { display: grid; place-items: center; padding: 60px; }
.d-spinner { width: 28px; height: 28px; border: 3px solid var(--d-line); border-top-color: var(--d-primary); border-radius: 50%; animation: d-spin .8s linear infinite; display: inline-block; }
@keyframes d-spin { to { transform: rotate(360deg); } }
.d-toast { position: fixed; z-index: 100; bottom: 90px; inset-inline: 0; margin: 0 auto; width: max-content; max-width: 90vw; background: var(--d-ink); color: var(--d-bg); padding: 10px 18px; border-radius: 999px; font-weight: 600; box-shadow: 0 6px 20px rgba(0,0,0,.2); }
.d-toast.is-error { background: var(--d-crit); color: #fff; }
.d-toast.is-success { background: var(--d-good); color: #fff; }
@media (min-width: 900px) { .d-toast { bottom: 24px; } }

/* Read-only mode */
.d-readonly .d-write { display: none !important; }

/* ---------------------------------------------------------------- Stats */
.d-stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 16px; }
@media (min-width: 700px) { .d-stats { grid-template-columns: repeat(4, 1fr); } }
@media (min-width: 1300px) { .d-stats { grid-template-columns: repeat(7, 1fr); } }
.d-stat { background: var(--d-surface); border: 1px solid var(--d-line); border-radius: var(--d-radius); padding: 14px; text-decoration: none; color: var(--d-ink); display: flex; flex-direction: column; gap: 2px; box-shadow: var(--d-shadow); min-width: 0; }
.d-stat strong { font-size: 22px; font-weight: 800; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.d-stat span { font-size: 12.5px; color: var(--d-ink-3); }
.d-stat-date { font-size: 17px !important; }
.d-stat-status { display: flex; align-items: center; gap: 6px; font-size: 17px !important; }
.d-dot { width: 9px; height: 9px; border-radius: 50%; background: currentColor; display: inline-block; }
.d-stat-good .d-stat-status { color: var(--d-good); }
.d-stat-warning .d-stat-status { color: var(--d-warn); }
.d-stat-critical .d-stat-status { color: var(--d-crit); }

.d-mini-list { list-style: none; margin: 0; padding: 0; }
.d-mini-list a { display: flex; justify-content: space-between; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--d-line); text-decoration: none; color: var(--d-ink); }
.d-mini-list li:last-child a { border-bottom: 0; }
.d-mini-list small { display: block; color: var(--d-ink-3); font-size: 12px; }
.d-end { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; }

/* Status pills (icon dot + label: never color alone) */
.d-status { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 700; padding: 2px 9px; border-radius: 999px; background: var(--d-surface-2); color: var(--d-ink-2); white-space: nowrap; }
.d-status::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.d-status-new { background: var(--d-info-bg); color: var(--d-info); }
.d-status-confirmed, .d-status-preparing { background: var(--d-warn-bg); color: var(--d-warn); }
.d-status-ready, .d-status-out_for_delivery { background: var(--d-info-bg); color: var(--d-info); }
.d-status-completed, .d-sub-active { background: var(--d-good-bg); color: var(--d-good); }
.d-status-cancelled, .d-sub-expired, .d-sub-suspended { background: var(--d-crit-bg); color: var(--d-crit); }
.d-sub-pending { background: var(--d-warn-bg); color: var(--d-warn); }

/* ---------------------------------------------------------------- Orders */
.d-tabs { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; flex: 1 1 100%; padding-bottom: 2px; }
.d-tabs::-webkit-scrollbar { display: none; }
.d-tabs button { flex: none; border: 1px solid var(--d-line); background: var(--d-surface); border-radius: 999px; padding: 6px 12px; font-weight: 600; font-size: 13px; cursor: pointer; color: var(--d-ink-2); }
.d-tabs button i { font-style: normal; color: var(--d-ink-3); margin-inline-start: 4px; font-variant-numeric: tabular-nums; }
.d-tabs button.is-active { background: var(--d-ink); color: var(--d-bg); border-color: var(--d-ink); }
.d-tabs button.is-active i { color: inherit; opacity: .7; }
.d-orders { display: grid; gap: 12px; grid-template-columns: 1fr; }
@media (min-width: 1100px) { .d-orders { grid-template-columns: 1fr 1fr; } }
@media (min-width: 1600px) { .d-orders { grid-template-columns: 1fr 1fr 1fr; } }
.d-order { background: var(--d-surface); border: 1px solid var(--d-line); border-radius: var(--d-radius); box-shadow: var(--d-shadow); display: flex; flex-direction: column; border-inline-start: 4px solid var(--d-line); }
.d-order-new { border-inline-start-color: var(--d-info); }
.d-order-confirmed, .d-order-preparing { border-inline-start-color: var(--d-warn); }
.d-order-ready, .d-order-out_for_delivery { border-inline-start-color: var(--d-info); }
.d-order-completed { border-inline-start-color: var(--d-good); }
.d-order-cancelled { border-inline-start-color: var(--d-crit); opacity: .75; }
.d-order header { display: flex; justify-content: space-between; gap: 8px; padding: 12px 14px; border-bottom: 1px solid var(--d-line); }
.d-order header > div { display: flex; flex-direction: column; }
.d-order-no { font-size: 17px; }
.d-type { font-size: 12.5px; font-weight: 700; background: var(--d-surface-2); padding: 3px 10px; border-radius: 999px; align-self: flex-start; }
.d-order-body { padding: 12px 14px; flex: 1; }
.d-order-cust { display: flex; flex-direction: column; margin-bottom: 8px; font-size: 14px; }
.d-order-cust a { text-decoration: none; width: max-content; }
.d-order-cust span { color: var(--d-ink-2); }
.d-order-items { list-style: none; margin: 0; padding: 8px 0; border-top: 1px dashed var(--d-line); border-bottom: 1px dashed var(--d-line); }
.d-order-items li { display: flex; justify-content: space-between; gap: 10px; padding: 3px 0; }
.d-order-items small { display: block; color: var(--d-ink-3); font-size: 12px; }
.d-note { background: var(--d-warn-bg); color: var(--d-warn); padding: 6px 10px; border-radius: 8px; margin: 8px 0 0; font-size: 13px; }
.d-order-totals { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 4px 14px; margin-top: 8px; font-size: 13px; color: var(--d-ink-2); }
.d-order-totals b { color: var(--d-ink); font-size: 15px; }
.d-order footer { display: flex; flex-wrap: wrap; gap: 6px; padding: 10px 14px; border-top: 1px solid var(--d-line); background: var(--d-surface-2); border-radius: 0 0 var(--d-radius) var(--d-radius); }
.d-status-select { width: auto; flex: 1 1 150px; font-weight: 600; }

/* ---------------------------------------------------------------- Products */
.d-products { display: grid; gap: 10px; }
.d-product { display: flex; align-items: center; gap: 12px; background: var(--d-surface); border: 1px solid var(--d-line); border-radius: var(--d-radius); padding: 10px; flex-wrap: wrap; }
.d-product.is-hidden { opacity: .6; }
.d-product img, .d-ph { width: 60px; height: 60px; border-radius: 10px; object-fit: cover; flex: none; }
.d-ph { display: grid; place-items: center; background: var(--d-surface-2); font-weight: 800; color: var(--d-ink-3); font-size: 22px; }
.d-product-info { flex: 1 1 180px; display: flex; flex-direction: column; min-width: 0; }
.d-product-info > b { overflow-wrap: anywhere; }
.d-tag { font-size: 11px; background: var(--d-warn-bg); color: var(--d-warn); padding: 1px 6px; border-radius: 6px; font-weight: 700; }
.d-product-actions { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }

/* Image picker */
.d-imgpick-box { display: flex; align-items: center; gap: 12px; }
.d-imgpick-preview { width: 84px; height: 84px; border-radius: 12px; border: 1px dashed var(--d-line); background: var(--d-surface-2); display: grid; place-items: center; overflow: hidden; flex: none; }
.d-imgpick-preview img { width: 100%; height: 100%; object-fit: cover; }
.d-imgpick-btns { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }

/* Option groups */
.d-fieldset { border: 1px solid var(--d-line); border-radius: 12px; padding: 12px; margin: 0 0 12px; }
.d-fieldset legend { font-weight: 700; padding: 0 6px; }
.d-optgroup { background: var(--d-surface-2); border-radius: 10px; padding: 10px; margin-bottom: 10px; }
.d-optgroup .d-row { margin-bottom: 6px; }
.d-optitem { flex-wrap: nowrap; align-items: center; }
.d-optitem > .d-input:first-child { flex: 1 1 auto; }
.d-optitem .d-input-sm { flex: 0 0 110px; }

/* ---------------------------------------------------------------- Categories */
.d-cats { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.d-cat { display: flex; align-items: center; gap: 10px; background: var(--d-surface); border: 1px solid var(--d-line); border-radius: 12px; padding: 8px 10px; flex-wrap: wrap; }
.d-cat.is-hidden { opacity: .65; }
.d-cat-name { flex: 1 1 180px; width: auto; font-weight: 600; }
.d-order-btns { display: flex; gap: 4px; }

/* ---------------------------------------------------------------- Settings */
.d-hours-row { display: grid; grid-template-columns: 1fr 128px auto 128px; gap: 8px; align-items: center; padding: 6px 0; border-bottom: 1px solid var(--d-line); }
.d-hours-row:last-child { border-bottom: 0; }
.d-hours-row .d-input { min-height: 36px; padding: 6px 8px; }
.d-hours-row em { font-weight: 600; color: var(--d-ink) !important; }
@media (max-width: 420px) { .d-hours-row { grid-template-columns: 1fr 1fr auto 1fr; } .d-hours-row .d-switch { grid-column: 1 / -1; } }
.d-sticky-save { position: sticky; bottom: 76px; padding: 12px 0; display: flex; justify-content: flex-end; pointer-events: none; }
.d-sticky-save .d-btn { pointer-events: auto; box-shadow: 0 6px 20px rgba(0,0,0,.18); }
@media (min-width: 900px) { .d-sticky-save { bottom: 0; } }

/* ---------------------------------------------------------------- QR + subscription */
.d-qr-card { display: flex; flex-direction: column; align-items: center; gap: 16px; }
.d-qr-preview { width: 100%; max-width: 280px; background: #fff; border-radius: 12px; padding: 8px; border: 1px solid var(--d-line); }
.d-qr-preview svg { width: 100%; height: auto; display: block; }
.d-qr-actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.d-copy { display: flex; gap: 8px; align-items: center; background: var(--d-surface-2); padding: 8px 10px; border-radius: 10px; margin-bottom: 12px; }
.d-copy code { flex: 1; overflow-wrap: anywhere; font-size: 13px; }
.d-sub-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; margin-bottom: 12px; }
.d-sub-head h2 { font-size: 22px; margin: 0; }
.d-dl { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; margin: 0; }
.d-dl dt { color: var(--d-ink-3); }
.d-dl dd { margin: 0; font-weight: 600; }
.d-usage-row { margin-bottom: 12px; }
.d-usage-row > div:first-child { display: flex; justify-content: space-between; font-size: 13.5px; margin-bottom: 4px; }
.d-meter { height: 8px; border-radius: 4px; background: var(--d-surface-2); overflow: hidden; }
.d-meter i { display: block; height: 100%; background: var(--d-series); border-radius: 4px; }
.d-features { list-style: none; padding: 0; margin: 0; display: grid; gap: 6px; }
.d-features .is-on { color: var(--d-ink); }
.d-features .is-off { color: var(--d-ink-3); }

/* ---------------------------------------------------------------- Modal */
.d-modal { position: fixed; inset: 0; z-index: 80; background: rgba(8,10,14,.55); display: flex; align-items: flex-end; justify-content: center; }
.d-modal-box { background: var(--d-surface); width: 100%; max-height: 94vh; max-height: 94dvh; border-radius: 18px 18px 0 0; display: flex; flex-direction: column; overflow: hidden; }
.d-modal-box form { display: flex; flex-direction: column; min-height: 0; flex: 1; }
.d-modal-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--d-line); }
.d-modal-body { padding: 16px 18px; overflow-y: auto; flex: 1; }
.d-modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 18px calc(12px + env(safe-area-inset-bottom)); border-top: 1px solid var(--d-line); }
@media (min-width: 720px) {
	.d-modal { align-items: center; padding: 24px; }
	.d-modal-box { max-width: 640px; border-radius: 18px; max-height: 90vh; }
}

/* ---------------------------------------------------------------- Charts */
.qc { position: relative; --qc-series: var(--d-series); }
.qc svg { display: block; overflow: visible; }
.qc-grid { stroke: var(--d-line); stroke-width: 1; }
.qc-axis { stroke: var(--d-ink-3); stroke-width: 1; opacity: .5; }
.qc-label { fill: var(--d-ink-3); font-size: 11px; font-variant-numeric: tabular-nums; }
.qc-bar { fill: var(--qc-series); transition: opacity .1s; }
.qc svg:hover .qc-bar:not(.is-hover) { opacity: .55; }
.qc-hit { fill: transparent; cursor: default; outline: none; }
.qc-tip { position: absolute; pointer-events: none; background: var(--d-ink); color: var(--d-bg); padding: 6px 10px; border-radius: 8px; font-size: 12.5px; white-space: nowrap; box-shadow: 0 4px 12px rgba(0,0,0,.15); display: flex; flex-direction: column; z-index: 2; }
.qc-table { margin-top: 8px; font-size: 13px; }
.qc-table summary { cursor: pointer; color: var(--d-ink-3); }
.qc-table table { width: 100%; border-collapse: collapse; margin-top: 6px; }
.qc-table td, .qc-table th { padding: 3px 6px; border-bottom: 1px solid var(--d-line); text-align: start; }
.qc-hbars { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.qc-hbars li { display: grid; grid-template-columns: minmax(80px, 34%) 1fr auto; gap: 10px; align-items: center; font-size: 13.5px; }
.qc-hl { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--d-ink-2); }
.qc-track { height: 14px; display: block; }
.qc-fill { display: block; height: 100%; background: var(--qc-series); border-radius: 0 4px 4px 0; min-width: 2px; }
[dir="rtl"] .qc-fill { border-radius: 4px 0 0 4px; }
.qc-hv { font-weight: 700; font-variant-numeric: tabular-nums; min-width: 2ch; text-align: end; }

/* ---------------------------------------------------------------- Login */
.d-login-body { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: radial-gradient(1200px 600px at 50% -10%, color-mix(in srgb, var(--d-primary) 16%, transparent), transparent), var(--d-bg); }
.d-login { width: 100%; max-width: 400px; }
.d-login-card { background: var(--d-surface); border: 1px solid var(--d-line); border-radius: 20px; padding: 28px 24px; box-shadow: 0 10px 40px rgba(16,24,40,.08); }
.d-login-brand { text-align: center; margin-bottom: 20px; }
.d-login-brand img { max-height: 56px; margin: 0 auto 10px; display: block; }
.d-login-brand .d-brand-mark { margin: 0 auto 12px; width: 52px; height: 52px; border-radius: 14px; }
.d-login-brand h1 { font-size: 22px; }
.d-login-brand p { color: var(--d-ink-3); margin: 4px 0 0; }
.d-login-card .d-field input { width: 100%; border: 1px solid var(--d-line); background: var(--d-surface); border-radius: 10px; padding: 11px 12px; font-size: 16px; outline: none; }
.d-login-card .d-field input:focus { border-color: var(--d-primary); }
.d-login-card .d-field > span { display: block; font-weight: 600; font-size: 13px; margin-bottom: 5px; }
.d-login-card .d-check { margin: 0 0 16px; font-size: 13.5px; }
.d-login-links { display: flex; justify-content: space-between; margin-top: 14px; font-size: 13px; }
.d-login-links a { text-decoration: none; }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation-duration: 1ms !important; } }
@media print { .d-side, .d-top, .d-toolbar, .d-order footer { display: none !important; } }

/* ---- Self sign-up ---- */
.d-signup { max-width: 560px; }
.d-signup .d-login-card { padding: 24px 20px; }
.d-login-card .d-field select { width: 100%; border: 1px solid var(--d-line); background: var(--d-surface); border-radius: 10px; padding: 10px 12px; font-size: 16px; min-height: 46px; }
.d-signup .d-fieldset { padding: 14px 14px 4px; }
.d-signup .d-help { margin: -8px 0 12px; }
.d-signup [data-slug-preview] { word-break: break-all; }
.d-signup .d-help b { color: var(--d-ink); }
.d-trial-pill { display: inline-block; margin-top: 8px !important; background: var(--d-good-bg); color: var(--d-good) !important; font-weight: 700; font-size: 13px; padding: 5px 12px; border-radius: 99px; }
.d-plan-pick { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); margin-bottom: 12px; }
.d-plan-opt { position: relative; cursor: pointer; }
.d-plan-opt input { position: absolute; opacity: 0; inset: 0; }
.d-plan-opt > span { display: flex; flex-direction: column; gap: 2px; border: 1.5px solid var(--d-line); border-radius: 12px; padding: 12px; height: 100%; transition: .15s; }
.d-plan-opt b { font-size: 15px; }
.d-plan-opt em { font-style: normal; font-weight: 700; color: var(--d-primary); font-size: 14px; }
.d-plan-opt small { color: var(--d-ink-3); font-size: 12.5px; }
.d-plan-opt input:checked + span { border-color: var(--d-primary); background: color-mix(in srgb, var(--d-primary) 7%, transparent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--d-primary) 15%, transparent); }
.d-plan-opt input:focus-visible + span { outline: 2px solid var(--d-primary); outline-offset: 2px; }
.d-btn-lg { min-height: 48px; font-size: 16px; }
.d-btn-block { width: 100%; }
.d-alert ul { margin: 0; padding-inline-start: 18px; }
.d-login-signup { text-align: center; margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--d-line); font-size: 13.5px; color: var(--d-ink-2); }
.d-login-signup a { font-weight: 700; text-decoration: none; }

/* ---- Billing (owner) ---- */
.d-trial-banner { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; justify-content: space-between; background: var(--d-info-bg); color: var(--d-info); border-radius: 12px; padding: 12px 14px; margin-bottom: 16px; font-weight: 600; }
.d-trial-banner.is-urgent { background: var(--d-warn-bg); color: var(--d-warn); }
.d-plans-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.d-plan-card { border: 1.5px solid var(--d-line); border-radius: 14px; padding: 16px; display: flex; flex-direction: column; gap: 8px; position: relative; background: var(--d-surface); }
.d-plan-card.is-highlighted { border-color: var(--d-primary); }
.d-plan-card.is-current { background: var(--d-surface-2); }
.d-plan-card h4 { margin: 0; font-size: 16px; }
.d-plan-price { font-size: 24px; font-weight: 800; }
.d-plan-price small { font-size: 13px; font-weight: 500; color: var(--d-ink-3); }
.d-plan-card ul { margin: 0; padding-inline-start: 18px; color: var(--d-ink-2); font-size: 13.5px; }
.d-plan-card .d-btn { margin-top: auto; }
.d-plan-tag { position: absolute; top: -10px; inset-inline-end: 12px; background: var(--d-primary); color: #fff; font-size: 11.5px; font-weight: 700; padding: 2px 10px; border-radius: 99px; }
.d-gw-pick { display: flex; flex-direction: column; gap: 8px; margin: 10px 0 14px; }
.d-gw-opt { display: flex; gap: 10px; align-items: flex-start; border: 1.5px solid var(--d-line); border-radius: 12px; padding: 12px; cursor: pointer; }
.d-gw-opt input { margin-top: 3px; accent-color: var(--d-primary); width: 18px; height: 18px; flex: none; }
.d-gw-opt b { display: block; }
.d-gw-opt small { color: var(--d-ink-3); }
.d-gw-opt:has(input:checked) { border-color: var(--d-primary); }
.d-instructions { white-space: pre-wrap; background: var(--d-surface-2); border: 1px dashed var(--d-line); border-radius: 12px; padding: 12px 14px; margin: 0 0 14px; font-size: 14px; }
.d-invoice-open { border: 1.5px solid var(--d-warn); background: var(--d-warn-bg); border-radius: 12px; padding: 14px; margin-bottom: 16px; color: var(--d-ink); }
.d-invoice-open .d-row-center { gap: 8px; flex-wrap: wrap; }
.d-inv-status { display: inline-block; font-size: 12px; font-weight: 700; padding: 2px 9px; border-radius: 99px; background: var(--d-surface-2); color: var(--d-ink-2); }
.d-inv-paid { background: var(--d-good-bg); color: var(--d-good); }
.d-inv-pending, .d-inv-pending_review { background: var(--d-warn-bg); color: var(--d-warn); }
.d-inv-failed, .d-inv-cancelled { background: var(--d-crit-bg); color: var(--d-crit); }
.d-hp { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; border: 0; padding: 0; margin: -1px; }
.d-table-wrap { overflow-x: auto; margin: 0 -4px; }
.d-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.d-table th, .d-table td { padding: 9px 8px; border-bottom: 1px solid var(--d-line); text-align: start; white-space: nowrap; }
.d-table th { color: var(--d-ink-3); font-weight: 600; font-size: 12.5px; }
.d-alert-success { background: var(--d-good-bg); color: var(--d-good); }
.d-alert-act { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.d-alert-act .d-btn { flex: none; }
.d-sub-head h2 small { font-size: 12px; vertical-align: middle; }
