/* =====================================================================
   Coffee Shop Management — stylesheet
   Uses logical properties (inline-start/end) so RTL (Kurdish) flips automatically.
   ===================================================================== */

/* ------------------------------------------------------------------ Themes
   A color theme only sets five base hues on <html data-color="…">:
     --p primary, --p-hover, --p-light (primary used as text on dark backgrounds),
     --a accent (main action buttons, active nav), --a-hover.
   Light / dark mode (<html data-mode="…">) derives every surface, border and tint from them. */

:root {
  --p: #6f4e37; --p-hover: #5b3e2b; --p-light: #e0bf9f; --a: #b5732e; --a-hover: #9a5f22;
  --on-primary: #fff;
  --on-accent: #fff;
}
[data-color="amber"]  { --p: #92400e; --p-hover: #78350f; --p-light: #fbbf77; --a: #b45309; --a-hover: #92400e; }
[data-color="red"]    { --p: #b42318; --p-hover: #912018; --p-light: #fda29b; --a: #d92d20; --a-hover: #b42318; }
[data-color="rose"]   { --p: #be185d; --p-hover: #9d174d; --p-light: #f9a8d4; --a: #db2777; --a-hover: #be185d; }
[data-color="purple"] { --p: #6d28d9; --p-hover: #5b21b6; --p-light: #c4b5fd; --a: #7c3aed; --a-hover: #6d28d9; }
[data-color="indigo"] { --p: #4338ca; --p-hover: #3730a3; --p-light: #a5b4fc; --a: #4f46e5; --a-hover: #4338ca; }
[data-color="blue"]   { --p: #1d4ed8; --p-hover: #1e40af; --p-light: #93c5fd; --a: #2563eb; --a-hover: #1d4ed8; }
[data-color="sky"]    { --p: #0369a1; --p-hover: #075985; --p-light: #7dd3fc; --a: #0284c7; --a-hover: #0369a1; }
[data-color="teal"]   { --p: #0f766e; --p-hover: #115e59; --p-light: #5eead4; --a: #0d9488; --a-hover: #0f766e; }
[data-color="green"]  { --p: #15803d; --p-hover: #166534; --p-light: #86efac; --a: #16a34a; --a-hover: #15803d; }
[data-color="olive"]  { --p: #4d7c0f; --p-hover: #3f6212; --p-light: #bef264; --a: #4d7c0f; --a-hover: #3f6212; }
[data-color="orange"] { --p: #c2410c; --p-hover: #9a3412; --p-light: #fdba74; --a: #ea580c; --a-hover: #c2410c; }
[data-color="slate"]  { --p: #334155; --p-hover: #1e293b; --p-light: #cbd5e1; --a: #475569; --a-hover: #334155; }
[data-color="mono"]   { --p: #18181b; --p-hover: #000000; --p-light: #f4f4f5; --a: #18181b; --a-hover: #000000; }
/* Black & white in dark mode: white buttons with black text. */
[data-mode="dark"][data-color="mono"] { --p: #f4f4f5; --p-hover: #ffffff; --a: #f4f4f5; --a-hover: #ffffff; --on-primary: #18181b; --on-accent: #18181b; }

/* Light mode (default) */
:root {
  color-scheme: light;
  --bg: color-mix(in srgb, var(--p) 5%, #f7f6f4);
  --surface: #ffffff;
  --surface-2: color-mix(in srgb, var(--p) 3%, #fbfbfa);
  --surface-3: color-mix(in srgb, var(--p) 8%, #f2f1ef);
  --border: color-mix(in srgb, var(--p) 10%, #e6e4e1);
  --border-strong: color-mix(in srgb, var(--p) 16%, #d2cfcb);
  --text: #1f1c1a;
  --text-2: #4f4a46;
  --muted: #7b746e;
  --primary: var(--p);
  --primary-hover: var(--p-hover);
  --primary-text: var(--p);
  --primary-soft: color-mix(in srgb, var(--p) 11%, #ffffff);
  --accent: var(--a);
  --accent-hover: var(--a-hover);
  --chart: var(--a);
  --ring: color-mix(in srgb, var(--a) 40%, transparent);
  --table-hover: color-mix(in srgb, var(--p) 3%, #ffffff);
  --topbar-bg: color-mix(in srgb, var(--bg) 92%, transparent);
  --overlay: rgba(15, 12, 10, .5);
  --success: #2f7d4f;       --success-soft: #e4f2e9; --success-text: #1f5a37; --success-border: #c6e4d1;
  --danger: #b83a3a;        --danger-soft: #fbe8e8;  --danger-text: #8e2a2a;  --danger-border: #f1c9c9;
  --warning: #9a5f0c;       --warning-soft: #fdf0d9; --warning-text: #7a4a08; --warning-border: #f2d9ac;
  --info: #2f6690;          --info-soft: #e5eef6;    --info-text: #234e6e;    --info-border: #c8dbea;
  --success-solid: #2f7d4f;
  --danger-solid: #b83a3a;
  --sidebar-bg: color-mix(in srgb, var(--p) 22%, #141414);
  --sidebar-hover: color-mix(in srgb, #ffffff 8%, var(--sidebar-bg));
  --sidebar-text: #e4e0dc;
  --sidebar-muted: #9b948e;
  --shadow-sm: 0 1px 2px rgba(20, 16, 12, .06);
  --shadow: 0 4px 18px rgba(20, 16, 12, .07);
  --shadow-lg: 0 24px 60px rgba(20, 16, 12, .22);
  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;
  --font: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-ku: "Noto Sans Arabic", "Segoe UI", Tahoma, sans-serif;
  --sidebar-w: 248px;
  --topbar-h: 64px;
}

/* Dark mode */
[data-mode="dark"] {
  color-scheme: dark;
  --bg: color-mix(in srgb, var(--p) 6%, #0f0f10);
  --surface: color-mix(in srgb, var(--p) 5%, #18181a);
  --surface-2: color-mix(in srgb, var(--p) 6%, #1d1d20);
  --surface-3: color-mix(in srgb, var(--p) 10%, #26262a);
  --border: color-mix(in srgb, var(--p) 10%, #2e2e33);
  --border-strong: color-mix(in srgb, var(--p) 14%, #42424a);
  --text: #ececec;
  --text-2: #c4c4c9;
  --muted: #8f8f97;
  --primary-text: var(--p-light);
  --primary-soft: color-mix(in srgb, var(--p) 24%, #18181a);
  --chart: var(--p-light);
  --table-hover: color-mix(in srgb, #ffffff 3%, var(--surface));
  --overlay: rgba(0, 0, 0, .65);
  --success: #4ade80;  --success-soft: color-mix(in srgb, #22c55e 15%, #18181a); --success-text: #86efac; --success-border: color-mix(in srgb, #22c55e 32%, #18181a);
  --danger: #f87171;   --danger-soft: color-mix(in srgb, #ef4444 15%, #18181a);  --danger-text: #fca5a5;  --danger-border: color-mix(in srgb, #ef4444 32%, #18181a);
  --warning: #fbbf24;  --warning-soft: color-mix(in srgb, #f59e0b 15%, #18181a); --warning-text: #fcd34d; --warning-border: color-mix(in srgb, #f59e0b 32%, #18181a);
  --info: #60a5fa;     --info-soft: color-mix(in srgb, #3b82f6 15%, #18181a);    --info-text: #93c5fd;    --info-border: color-mix(in srgb, #3b82f6 32%, #18181a);
  --sidebar-bg: color-mix(in srgb, var(--p) 10%, #0b0b0c);
  --sidebar-text: #d8d8dc;
  --sidebar-muted: #85858d;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .35);
  --shadow: 0 4px 18px rgba(0, 0, 0, .35);
  --shadow-lg: 0 24px 60px rgba(0, 0, 0, .6);
}

*, *::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.5;
}
[dir="rtl"] body { font-family: var(--font-ku); }

h1, h2, h3, h4 { margin: 0; line-height: 1.25; font-weight: 650; }
p { margin: 0; }
a { color: var(--primary-text); text-decoration: none; }
a:hover { text-decoration: underline; }
img, svg { display: block; }
.icon { flex-shrink: 0; }
[dir="rtl"] .flip-rtl { transform: scaleX(-1); }

.muted { color: var(--muted); }
.small { font-size: 13px; }
.nowrap { white-space: nowrap; }
.num { font-variant-numeric: tabular-nums; }
.text-end { text-align: end; }
.text-center { text-align: center; }
.text-danger { color: var(--danger); }
.text-success { color: var(--success); }
.text-warning { color: var(--warning); }
.ltr { direction: ltr; unicode-bidi: isolate; }
[hidden] { display: none !important; }

/* ------------------------------------------------------------- App shell */

.app { display: flex; min-height: 100vh; }

.sidebar {
  position: fixed;
  inset-block: 0;
  inset-inline-start: 0;
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  z-index: 40;
  transition: transform .2s ease;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  height: var(--topbar-h);
  padding-inline: 20px;
  color: #fff;
  font-weight: 650;
  font-size: 17px;
  border-bottom: 1px solid rgba(255, 255, 255, .06);
}
.brand:hover { text-decoration: none; }
.brand-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.brand-mark {
  display: inline-grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--accent), var(--primary));
  color: var(--on-accent);
  flex-shrink: 0;
}
.brand-mark.lg { width: 52px; height: 52px; border-radius: 14px; }

.nav { flex: 1; overflow-y: auto; padding: 14px 12px; }

.nav-section {
  margin: 18px 10px 6px;
  font-size: 11px;
  font-weight: 650;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--sidebar-muted);
}
[dir="rtl"] .nav-section { letter-spacing: 0; }

.nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  margin-bottom: 2px;
  border-radius: var(--radius-sm);
  color: var(--sidebar-text);
  font-weight: 500;
}
.nav-link:hover { background: var(--sidebar-hover); color: #fff; text-decoration: none; }
.nav-link.active { background: var(--accent); color: var(--on-accent); }
.nav-link .icon { opacity: .9; }

.sidebar-foot { padding: 14px 20px 18px; border-top: 1px solid rgba(255, 255, 255, .06); }

.rate-chip {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, .07);
  font-size: 12px;
  color: var(--sidebar-text);
  direction: ltr;
}

.sidebar-backdrop { display: none; }

.main {
  flex: 1;
  min-width: 0;
  margin-inline-start: var(--sidebar-w);
  display: flex;
  flex-direction: column;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: 12px;
  padding-inline: 28px;
  background: var(--topbar-bg);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}
.page-title { font-size: 20px; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.menu-btn { display: none; }

.content { padding: 24px 28px 40px; flex: 1; min-width: 0; }

/* User menu */
.user-menu { position: relative; }
.user-menu summary {
  list-style: none;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 5px 10px 5px 6px;
  border-radius: 999px;
  cursor: pointer;
  border: 1px solid transparent;
}
[dir="rtl"] .user-menu summary { padding: 5px 6px 5px 10px; }
.user-menu summary::-webkit-details-marker { display: none; }
.user-menu summary:hover, .user-menu[open] summary { background: var(--surface); border-color: var(--border); }
.avatar {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--primary);
  color: var(--on-primary);
  font-weight: 650;
}
.user-meta { display: flex; flex-direction: column; line-height: 1.2; }
.user-name { font-weight: 600; font-size: 14px; }
.user-role { font-size: 12px; color: var(--muted); }
.user-dropdown {
  position: absolute;
  inset-inline-end: 0;
  top: calc(100% + 6px);
  min-width: 200px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 6px;
  z-index: 50;
}
.user-dropdown a, .user-dropdown button {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 12px;
  border: 0;
  border-radius: var(--radius-sm);
  background: none;
  color: var(--text);
  font: inherit;
  cursor: pointer;
  text-align: start;
}
.user-dropdown a:hover, .user-dropdown button:hover { background: var(--surface-3); text-decoration: none; }
.user-dropdown form { margin: 0; }

/* ---------------------------------------------------------------- Buttons */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  padding: 8px 16px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-weight: 600;
  font-size: 14px;
  line-height: 1.2;
  cursor: pointer;
  white-space: nowrap;
  transition: background .15s, border-color .15s, color .15s, box-shadow .15s;
}
.btn:hover { text-decoration: none; }
.btn:focus-visible, .icon-btn:focus-visible { outline: 3px solid var(--ring); outline-offset: 2px; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: var(--on-primary); }
.btn-primary:hover:not(:disabled) { background: var(--primary-hover); }
.btn-accent { background: var(--accent); color: var(--on-accent); }
.btn-accent:hover:not(:disabled) { background: var(--accent-hover); }
.btn-outline { border-color: var(--border-strong); background: var(--surface); }
.btn-outline:hover:not(:disabled) { background: var(--surface-3); }
.btn-ghost { background: transparent; color: var(--text-2); }
.btn-ghost:hover:not(:disabled) { background: var(--surface-3); color: var(--text); }
.btn-danger { background: var(--danger-solid); color: #fff; }
.btn-danger:hover:not(:disabled) { background: color-mix(in srgb, var(--danger-solid) 85%, #000); }
.btn-danger-soft { background: var(--danger-soft); color: var(--danger); }
.btn-danger-soft:hover:not(:disabled) { background: color-mix(in srgb, var(--danger) 22%, var(--surface)); }
.btn-success { background: var(--success-solid); color: #fff; }
.btn-success:hover:not(:disabled) { background: color-mix(in srgb, var(--success-solid) 85%, #000); }
.btn-sm { min-height: 32px; padding: 5px 11px; font-size: 13px; }
.btn-lg { min-height: 50px; padding: 12px 22px; font-size: 16px; }
.btn-block { width: 100%; }

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-2);
  cursor: pointer;
}
.icon-btn:hover { background: var(--surface-3); color: var(--text); }
.icon-btn.danger:hover { background: var(--danger-soft); color: var(--danger); }
.icon-btn.sm { width: 30px; height: 30px; }

.actions { display: flex; align-items: center; gap: 4px; justify-content: flex-end; }
.actions form { margin: 0; display: inline; }

/* ----------------------------------------------------------- Page layout */

.page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.page-head h2 { font-size: 18px; }
.page-head p { color: var(--muted); margin-top: 2px; }
.page-head-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  min-width: 0;
}
.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.card-head h3 { font-size: 16px; }
.card-head .muted { font-size: 13px; }
.card-body { padding: 20px; }
.card-body.flush { padding: 0; }

.grid { display: grid; gap: 20px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-main-side { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.grid-side-main { grid-template-columns: minmax(280px, 360px) minmax(0, 1fr); align-items: start; }
.mt { margin-top: 20px; }

/* Stat tiles */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-bottom: 20px; }
.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  box-shadow: var(--shadow-sm);
}
.stat-label { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; font-weight: 600; }
.stat-icon {
  display: inline-grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: var(--primary-soft);
  color: var(--primary-text);
}
.stat-icon.warn { background: var(--warning-soft); color: var(--warning); }
.stat-icon.ok { background: var(--success-soft); color: var(--success); }
.stat-icon.info { background: var(--info-soft); color: var(--info); }
.stat-value { margin-top: 10px; font-size: 26px; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.15; }
.stat-sub { margin-top: 4px; font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.delta-up { color: var(--success); font-weight: 600; }
.delta-down { color: var(--danger); font-weight: 600; }

/* Money: IQD first, USD equivalent below */
.money { display: inline-flex; flex-direction: column; line-height: 1.25; font-variant-numeric: tabular-nums; }
.money-iqd { font-weight: 600; white-space: nowrap; }
.money-usd { font-size: 12px; color: var(--muted); white-space: nowrap; direction: ltr; text-align: start; }
[dir="rtl"] .money-usd { text-align: end; }
.money.inline { flex-direction: row; gap: 8px; align-items: baseline; }

/* ----------------------------------------------------------------- Tables */

.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th {
  padding: 11px 16px;
  text-align: start;
  font-size: 12px;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--muted);
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
[dir="rtl"] .table th { letter-spacing: 0; }
.table td { padding: 12px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: var(--table-hover); }
.table .text-end { text-align: end; }
.table tr.row-muted td { color: var(--muted); }
.table tfoot td { font-weight: 650; background: var(--surface-2); border-top: 1px solid var(--border); border-bottom: 0; }
.cell-title { font-weight: 600; }
.cell-sub { font-size: 12px; color: var(--muted); }

.empty {
  padding: 48px 20px;
  text-align: center;
  color: var(--muted);
}
.empty .icon { margin: 0 auto 10px; opacity: .5; }

/* ----------------------------------------------------------------- Badges */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  background: var(--surface-3);
  color: var(--text-2);
}
.badge-success { background: var(--success-soft); color: var(--success); }
.badge-danger { background: var(--danger-soft); color: var(--danger); }
.badge-warning { background: var(--warning-soft); color: var(--warning); }
.badge-info { background: var(--info-soft); color: var(--info); }
.badge-primary { background: var(--primary-soft); color: var(--primary-text); }

/* ------------------------------------------------------------------ Forms */

.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > span { font-size: 13px; font-weight: 600; color: var(--text-2); }
.field small { font-size: 12px; }

input[type="text"], input[type="number"], input[type="password"], input[type="date"], input[type="search"],
input:not([type]), select, textarea {
  width: 100%;
  min-height: 40px;
  padding: 8px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 14px;
}
textarea { min-height: 80px; resize: vertical; }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent);
}
input[type="number"] { font-variant-numeric: tabular-nums; }

.check { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-size: 14px; }
.check input { width: 18px; height: 18px; accent-color: var(--primary); }

.stack { display: flex; flex-direction: column; gap: 16px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.span-2 { grid-column: 1 / -1; }
.form-section {
  font-size: 13px;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--muted);
  padding-top: 6px;
  border-top: 1px solid var(--border);
  margin-top: 4px;
}
.form-section:first-of-type { border-top: 0; padding-top: 0; margin-top: 0; }
[dir="rtl"] .form-section { letter-spacing: 0; }
.form-actions { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; }

.toolbar {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.toolbar .field { min-width: 150px; }
.toolbar .field.grow { flex: 1; min-width: 200px; }

.input-group { display: flex; }
.input-group input { border-start-end-radius: 0; border-end-end-radius: 0; }
.input-group select { width: auto; border-start-start-radius: 0; border-end-start-radius: 0; border-inline-start: 0; background: var(--surface-2); }

/* Dynamic rows (sizes, recipe) */
.rows { display: flex; flex-direction: column; gap: 10px; }
.row-item {
  display: grid;
  gap: 10px;
  align-items: end;
  padding: 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.row-item .field > span { font-size: 12px; }
.size-row { grid-template-columns: 1fr 1fr 130px 110px auto; }
.recipe-row { grid-template-columns: minmax(0, 2fr) 140px auto auto; }
.recipe-row .check { min-height: 40px; font-size: 13px; }
.unit-suffix { font-size: 12px; color: var(--muted); }

/* ----------------------------------------------------------------- Alerts */

.alert {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  margin-bottom: 16px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  font-size: 14px;
}
.alert > span { flex: 1; }
.alert-success { background: var(--success-soft); color: var(--success-text); border-color: var(--success-border); }
.alert-error { background: var(--danger-soft); color: var(--danger-text); border-color: var(--danger-border); }
.alert-warning { background: var(--warning-soft); color: var(--warning-text); border-color: var(--warning-border); }
.alert-info { background: var(--info-soft); color: var(--info-text); border-color: var(--info-border); }
.alert-close { border: 0; background: none; color: inherit; opacity: .6; cursor: pointer; padding: 0; }
.alert-close:hover { opacity: 1; }

/* ------------------------------------------------------------------ Tabs */

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 20px; overflow-x: auto; }
.tab {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  color: var(--muted);
  font-weight: 600;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  white-space: nowrap;
}
.tab:hover { color: var(--text); text-decoration: none; }
.tab.active { color: var(--primary-text); border-bottom-color: var(--accent); }

.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  display: inline-flex;
  align-items: center;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text-2);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.chip:hover { background: var(--surface-3); text-decoration: none; }
.chip.active { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }

/* Segmented control */
.seg { display: flex; padding: 4px; background: var(--surface-3); border-radius: 10px; gap: 4px; }
.seg label { flex: 1; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 36px;
  padding: 6px 10px;
  border-radius: 7px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-2);
  cursor: pointer;
  text-align: center;
}
.seg input:checked + span { background: var(--surface); color: var(--primary-text); box-shadow: var(--shadow-sm); }
.seg input:focus-visible + span { outline: 2px solid var(--accent); }

/* ------------------------------------------------------------- Pagination */

.pagination { display: flex; gap: 4px; justify-content: center; padding: 16px; flex-wrap: wrap; }
.page-link {
  min-width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  padding: 0 8px;
  border-radius: var(--radius-sm);
  color: var(--text-2);
  font-weight: 600;
  font-size: 14px;
}
.page-link:hover { background: var(--surface-3); text-decoration: none; }
.page-link.active { background: var(--primary); color: var(--on-primary); }
.page-gap { align-self: center; color: var(--muted); padding: 0 4px; }

/* ----------------------------------------------------------------- Modals */

.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 16px;
  background: var(--overlay);
  animation: fade .15s ease;
}
.modal-dialog {
  width: 100%;
  max-width: 480px;
  max-height: calc(100vh - 32px);
  overflow-y: auto;
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  animation: pop .18s ease;
}
.modal-dialog.wide { max-width: 640px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 22px; border-bottom: 1px solid var(--border); }
.modal-head h3 { font-size: 17px; }
.modal-body { padding: 22px; }
.modal-foot { display: flex; gap: 10px; justify-content: flex-end; padding: 16px 22px; border-top: 1px solid var(--border); background: var(--surface-2); border-radius: 0 0 var(--radius-lg) var(--radius-lg); }
body.modal-open { overflow: hidden; }

@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.98); } }

/* ------------------------------------------------------------- Bar charts */

/* Time runs left to right in both languages. */
.bar-chart { display: flex; align-items: flex-end; gap: 6px; height: 200px; padding-top: 24px; direction: ltr; }
.bar-col { flex: 1; min-width: 0; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 6px; position: relative; }
.bar {
  width: 100%;
  max-width: 44px;
  background: var(--chart);
  border-radius: 4px 4px 0 0;
  min-height: 2px;
  position: relative;
}
.bar.zero { background: var(--border); }
.bar-col:hover .bar { background: var(--primary); }
.bar-value {
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  margin-bottom: 4px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-2);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  opacity: 0;
  pointer-events: none;
  transition: opacity .1s;
  background: var(--text);
  color: var(--surface);
  padding: 3px 7px;
  border-radius: 6px;
  direction: ltr;
}
.bar-col:hover .bar-value, .bar-chart.show-values .bar-value { opacity: 1; }
.bar-chart.show-values .bar-value { background: none; color: var(--text-2); padding: 0; }
.bar-label { font-size: 11px; color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; direction: ltr; }
.bar-chart.dense .bar-label { font-size: 10px; }

/* Horizontal share bars in tables */
.share { display: flex; align-items: center; gap: 10px; min-width: 120px; }
.share-track { flex: 1; height: 6px; border-radius: 3px; background: var(--surface-3); overflow: hidden; }
.share-fill { height: 100%; background: var(--chart); border-radius: 3px; }
.share-pct { font-size: 12px; color: var(--muted); width: 38px; text-align: end; font-variant-numeric: tabular-nums; }

/* Simple list rows */
.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 20px; border-bottom: 1px solid var(--border); }
.list li:last-child { border-bottom: 0; }
.rank { display: inline-grid; place-items: center; min-width: 24px; padding: 0 6px; height: 24px; border-radius: 6px; background: var(--surface-3); font-size: 12px; font-weight: 700; color: var(--text-2); flex-shrink: 0; }
.list-main { display: flex; align-items: center; gap: 12px; min-width: 0; }

/* =================================================================== POS */

body.pos-page .content { padding: 0; }
body.pos-page .main { height: 100vh; }

.pos { display: grid; grid-template-columns: minmax(0, 1fr) 400px; height: calc(100vh - var(--topbar-h)); }

.pos-catalog { display: flex; flex-direction: column; min-width: 0; min-height: 0; padding: 20px 24px 0; }
.pos-toolbar { display: flex; gap: 12px; margin-bottom: 14px; }
.search-box { position: relative; flex: 1; }
.search-box .icon { position: absolute; top: 50%; inset-inline-start: 12px; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.search-box input { padding-inline-start: 40px; min-height: 44px; border-radius: var(--radius); }

.cat-tabs { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 14px; scrollbar-width: thin; }
.cat-tab {
  flex-shrink: 0;
  padding: 9px 18px;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text-2);
  font: inherit;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
}
.cat-tab:hover { background: var(--surface-3); }
.cat-tab.active { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }

.product-grid {
  flex: 1;
  overflow-y: auto;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 14px;
  align-content: start;
  padding-bottom: 24px;
}
.product-card {
  display: block;
  width: 100%;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  font: inherit;
  color: inherit;
  text-align: start;
  cursor: pointer;
  transition: transform .1s, box-shadow .15s, border-color .15s;
}
.product-card-inner { display: flex; flex-direction: column; gap: 8px; min-height: 104px; height: 100%; }
.product-card-inner > * { flex-shrink: 0; }
.product-card:hover { border-color: var(--accent); box-shadow: var(--shadow); }
.product-card:active { transform: scale(.98); }
.product-thumb {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 12px;
  font-weight: 700;
  font-size: 18px;
  color: #fff;
}
.product-name { font-weight: 650; font-size: 15px; line-height: 1.3; flex: 1 0 auto; }
.product-price { display: flex; flex-direction: column; font-variant-numeric: tabular-nums; }
.product-price b { font-size: 15px; }
.product-price small { color: var(--muted); font-size: 12px; direction: ltr; text-align: start; }
[dir="rtl"] .product-price small { text-align: end; }
.product-sizes-hint { font-size: 11px; color: var(--muted); font-weight: 600; }

.pos-cart {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--surface);
  border-inline-start: 1px solid var(--border);
}
.cart-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px 12px; }
.cart-head h2 { font-size: 17px; }
.cart-meta { padding: 0 20px 14px; display: flex; flex-direction: column; gap: 10px; border-bottom: 1px solid var(--border); }
.cart-meta-row { display: flex; gap: 10px; }
.cart-meta-row .seg { flex: 1; }
.cart-meta-row input { width: 110px; }

.cart-items { flex: 1; overflow-y: auto; padding: 8px 12px; }
.cart-empty { height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; color: var(--muted); text-align: center; padding: 30px; }
.cart-empty .icon { opacity: .4; }

.cart-line { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px 10px; padding: 12px 8px; border-bottom: 1px dashed var(--border); }
.cart-line:last-child { border-bottom: 0; }
.cart-line-name { font-weight: 600; font-size: 14px; }
.cart-line-size { font-size: 12px; color: var(--muted); }
.cart-line-total { font-weight: 650; text-align: end; font-variant-numeric: tabular-nums; white-space: nowrap; }
.cart-line-controls { display: flex; align-items: center; gap: 6px; }
.cart-line-unit { font-size: 12px; color: var(--muted); text-align: end; align-self: center; font-variant-numeric: tabular-nums; }
.qty-btn {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}
.qty-btn:hover { background: var(--surface-3); }
.qty-btn.remove { border-color: transparent; color: var(--muted); }
.qty-btn.remove:hover { background: var(--danger-soft); color: var(--danger); }
.qty-val { min-width: 28px; text-align: center; font-weight: 650; font-variant-numeric: tabular-nums; }

.cart-summary { padding: 14px 20px 18px; border-top: 1px solid var(--border); background: var(--surface-2); }
.sum-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 4px 0; font-size: 14px; color: var(--text-2); font-variant-numeric: tabular-nums; }
.sum-row.discount-row .input-group { width: 170px; }
.sum-row.discount-row input { min-height: 34px; padding: 4px 8px; }
.sum-row.discount-row select { min-height: 34px; padding: 4px 6px; font-size: 13px; }
.sum-total { display: flex; justify-content: space-between; align-items: flex-end; margin: 10px 0 14px; padding-top: 10px; border-top: 1px solid var(--border); }
.sum-total-label { font-weight: 650; font-size: 16px; }
.sum-total-value { text-align: end; }
.sum-total-value b { display: block; font-size: 26px; line-height: 1.1; font-variant-numeric: tabular-nums; }
.sum-total-value small { color: var(--muted); font-size: 14px; direction: ltr; display: block; }

/* Size picker */
.size-options { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; }
.size-option {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 16px 10px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface);
  font: inherit;
  cursor: pointer;
}
.size-option:hover { border-color: var(--accent); background: var(--primary-soft); }
.size-option b { font-size: 16px; }
.size-option span { font-variant-numeric: tabular-nums; font-weight: 600; }
.size-option small { color: var(--muted); direction: ltr; }

/* Payment */
.pay-due { text-align: center; padding: 6px 0 18px; }
.pay-due small { color: var(--muted); font-weight: 600; }
.pay-due b { display: block; font-size: 32px; font-variant-numeric: tabular-nums; line-height: 1.2; }
.pay-due span { color: var(--muted); direction: ltr; display: block; }
.pay-row { display: flex; flex-direction: column; gap: 8px; }
.quick-amounts { display: grid; grid-template-columns: repeat(auto-fill, minmax(70px, 1fr)); gap: 6px; }
.quick-amounts .btn { padding-inline: 6px; direction: ltr; }

/* Theme menu & light/dark toggle */
.mode-toggle .icon-sun, [data-mode="dark"] .mode-toggle .icon-moon { display: none; }
[data-mode="dark"] .mode-toggle .icon-sun { display: block; }
.dropdown { position: relative; }
.dropdown > summary { list-style: none; }
.dropdown > summary::-webkit-details-marker { display: none; }
.theme-dropdown {
  position: absolute;
  inset-inline-end: 0;
  top: calc(100% + 6px);
  width: 268px;
  padding: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  z-index: 50;
}
.theme-dropdown h4 { font-size: 12px; font-weight: 650; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; margin: 0 0 8px; }
[dir="rtl"] .theme-dropdown h4 { letter-spacing: 0; }
.theme-dropdown h4 + .swatches, .theme-dropdown .mode-buttons + h4 { margin-top: 0; }
.mode-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-bottom: 14px; }
.mode-buttons button {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 38px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text-2); font: inherit; font-size: 13px; font-weight: 600; cursor: pointer;
}
.mode-buttons button:hover { background: var(--surface-3); }
.mode-buttons button.active { border-color: var(--primary); background: var(--primary); color: var(--on-primary); }
.swatches { display: grid; grid-template-columns: repeat(7, 1fr); gap: 8px; }
.swatch {
  width: 28px; height: 28px; border-radius: 50%; padding: 0; cursor: pointer;
  border: 2px solid var(--surface);
  background: linear-gradient(135deg, var(--sw1) 50%, var(--sw2) 50%);
  box-shadow: 0 0 0 1px var(--border-strong);
  justify-self: center;
}
.swatch:hover { transform: scale(1.1); }
.swatch.active { box-shadow: 0 0 0 2px var(--text); }

/* Shift indicator in the top bar */
.shift-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 11px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  background: var(--success-soft);
  color: var(--success);
}
.shift-chip:hover { text-decoration: none; filter: brightness(.97); }
.shift-chip.off { background: var(--warning-soft); color: var(--warning); }
.change-box { display: flex; justify-content: space-between; align-items: center; padding: 14px 16px; border-radius: var(--radius); background: var(--success-soft); color: var(--success-text); font-weight: 650; }
.change-box.short { background: var(--danger-soft); color: var(--danger-text); }
.change-box b { font-size: 20px; font-variant-numeric: tabular-nums; }
.pay-input { font-size: 20px !important; min-height: 50px !important; font-weight: 650; text-align: center; }

.success-check { width: 64px; height: 64px; margin: 0 auto 12px; border-radius: 50%; display: grid; place-items: center; background: var(--success-soft); color: var(--success); }
.order-number { font-size: 40px; font-weight: 800; color: var(--primary-text); line-height: 1; margin: 6px 0 14px; font-variant-numeric: tabular-nums; }

/* ============================================================ Auth pages */

.auth-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px 16px;
  background:
    radial-gradient(circle at 15% 20%, color-mix(in srgb, var(--accent) 18%, transparent), transparent 40%),
    radial-gradient(circle at 85% 80%, color-mix(in srgb, var(--primary) 18%, transparent), transparent 45%),
    var(--bg);
}
.auth-card {
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  box-shadow: var(--shadow-lg);
  padding: 32px;
}
.auth-card-wide { max-width: 560px; }
.auth-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.auth-card h1 { font-size: 24px; margin-bottom: 6px; }
.auth-card > .muted { margin-bottom: 22px; }

/* ============================================================ Responsive */

@media (max-width: 1200px) {
  .pos { grid-template-columns: minmax(0, 1fr) 360px; }
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 1024px) {
  .sidebar { transform: translateX(-100%); box-shadow: var(--shadow-lg); }
  [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: 35; background: var(--overlay); }
  .main { margin-inline-start: 0; }
  .menu-btn { display: inline-grid; }
  .grid-main-side, .grid-side-main, .grid-2 { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 820px) {
  body.pos-page .main { height: auto; }
  .pos { grid-template-columns: minmax(0, 1fr); height: auto; }
  .pos-catalog { padding: 16px 16px 0; }
  .product-grid { overflow: visible; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
  .pos-cart { border-inline-start: 0; border-top: 1px solid var(--border); }
  .cart-items { max-height: none; overflow: visible; }
}

@media (max-width: 640px) {
  .topbar { padding-inline: 16px; }
  .content { padding: 16px 16px 32px; }
  .user-meta, .lang-btn span, .shift-chip span { display: none; }
  .grid-3, .form-grid { grid-template-columns: minmax(0, 1fr); }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .stat { padding: 14px; }
  .stat-value { font-size: 20px; }
  .size-row, .recipe-row { grid-template-columns: 1fr 1fr; }
  .size-row .row-remove, .recipe-row .row-remove { justify-self: end; }
  .recipe-row .field:first-child { grid-column: 1 / -1; }
  .auth-card { padding: 24px 20px; }
  .card-head, .card-body { padding-inline: 16px; }
  .table th, .table td { padding-inline: 12px; }
  .quick-amounts { grid-template-columns: repeat(2, 1fr); }
}

@media print {
  .sidebar, .topbar, .no-print { display: none !important; }
  .main { margin: 0; }
  body { background: #fff; }
}
