/* =========================================================
   Cinderella Call Center — design system
   Brand: red / yellow / green from the logo, on warm neutrals.
   RTL first. No build step: plain CSS custom properties.
   ========================================================= */

:root {
  --brand-red: #d4281c;
  --brand-red-dark: #a81f15;
  --brand-red-soft: #fbe9ea;
  --brand-yellow: #f9b826;
  --brand-navy: #10204e;
  --brand-navy-dark: #0a1535;
  --brand-yellow-soft: #fff6d6;
  --brand-green: #1f8a4c;
  --brand-green-soft: #e3f4ea;

  --bg: #f6f3ee;
  --surface: #ffffff;
  --surface-2: #faf8f5;
  --surface-3: #f1ede6;
  --border: #e7e1d8;
  --border-strong: #d6cec2;
  --text: #1f1b18;
  --text-2: #4f4842;
  --muted: #857b72;

  --info: #2563eb;
  --info-soft: #e6eefc;
  --warning: #b45309;
  --warning-soft: #fdf1dc;
  --success: var(--brand-green);
  --success-soft: var(--brand-green-soft);
  --danger: var(--brand-red);
  --danger-soft: var(--brand-red-soft);

  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 18px;
  --shadow-sm: 0 1px 2px rgba(31, 27, 24, .06);
  --shadow: 0 4px 14px rgba(31, 27, 24, .08);
  --shadow-lg: 0 14px 40px rgba(31, 27, 24, .14);

  --font: "Tajawal", "Segoe UI", Tahoma, Arial, sans-serif;
  --header-h: 64px;
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  direction: rtl;
  text-align: right;
  min-height: 100vh;
}

img { max-width: 100%; display: block; }
a { color: var(--brand-red); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0 0 .5rem; line-height: 1.3; font-weight: 700; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.05rem; }
p { margin: 0 0 .75rem; }
small, .text-muted { color: var(--muted); }
.text-sm { font-size: .875rem; }
.text-xs { font-size: .78rem; }
.fw-700 { font-weight: 700; }
.ltr { direction: ltr; unicode-bidi: isolate; display: inline-block; }
.num { font-variant-numeric: tabular-nums; }
.nowrap { white-space: nowrap; }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ---------- Layout ---------- */
.app-header {
  position: sticky; top: 0; z-index: 40;
  height: var(--header-h);
  background: var(--brand-navy);
  color: #fff;
  box-shadow: var(--shadow);
}
.app-header .inner {
  max-width: 1440px; margin: 0 auto; padding: 0 20px;
  height: 100%; display: flex; align-items: center; gap: 18px;
}
.brand { display: flex; align-items: center; gap: 12px; color: #fff; font-weight: 700; font-size: 1.05rem; }
.brand:hover { text-decoration: none; }
.brand img { width: 44px; height: 44px; border-radius: 50%; background: #fff; box-shadow: 0 0 0 2px var(--brand-yellow); }
.brand span small { display: block; font-weight: 400; color: #c9c0b6; font-size: .72rem; line-height: 1.1; }

.nav { display: flex; align-items: center; gap: 4px; margin-inline-start: 12px; }
.nav a {
  color: #d9d2c9; padding: 8px 14px; border-radius: 999px; font-weight: 500;
  display: inline-flex; align-items: center; gap: 6px;
}
.nav a:hover { color: #fff; background: rgba(255,255,255,.08); text-decoration: none; }
.nav a.active { color: var(--text); background: var(--brand-yellow); font-weight: 700; }

.header-spacer { flex: 1; }
.user-chip { display: flex; align-items: center; gap: 10px; color: #d9d2c9; font-size: .875rem; }
.user-chip .avatar {
  width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center;
  background: var(--brand-red); color: #fff; font-weight: 700;
}
.user-chip b { color: #fff; display: block; line-height: 1.1; }
.user-chip small { display: block; color: #a39a90; font-size: .72rem; }

.menu-toggle { display: none; background: none; border: 0; color: #fff; font-size: 1.5rem; cursor: pointer; padding: 4px 8px; }

.app-main { max-width: 1440px; margin: 0 auto; padding: 24px 20px 60px; }
.app-main.narrow { max-width: 980px; }

.page-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.page-head p { margin: 0; color: var(--muted); }

.app-footer { text-align: center; color: var(--muted); font-size: .78rem; padding: 10px 20px 24px; }

/* Admin sub navigation */
.subnav { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 22px; background: var(--surface); padding: 6px; border-radius: 999px; border: 1px solid var(--border); width: max-content; max-width: 100%; }
.subnav a { padding: 8px 16px; border-radius: 999px; color: var(--text-2); font-weight: 500; white-space: nowrap; }
.subnav a:hover { background: var(--surface-3); text-decoration: none; }
.subnav a.active { background: var(--text); color: #fff; }

/* ---------- Cards ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); }
.card-body { padding: 22px; }
.card-head { padding: 16px 22px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.card-head h2, .card-head h3 { margin: 0; }
.stack > * + * { margin-top: 16px; }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-customer { grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); }
.grid-dash { grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr) minmax(0, 1fr); }

/* Stat tiles */
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 18px 20px; position: relative; overflow: hidden; }
.stat .label { color: var(--muted); font-size: .85rem; display: flex; align-items: center; gap: 8px; }
.stat .label::before { content: ""; width: 10px; height: 10px; border-radius: 50%; background: var(--accent, var(--brand-red)); flex-shrink: 0; }
.stat .value { font-size: 1.7rem; font-weight: 800; line-height: 1.2; margin-top: 4px; }
.stat .value small { font-size: .85rem; font-weight: 500; color: var(--muted); margin-inline-start: 4px; }
.stat.red { --accent: var(--brand-red); }
.stat.yellow { --accent: var(--brand-yellow); }
.stat.green { --accent: var(--brand-green); }
.stat.blue { --accent: var(--info); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 18px; border-radius: var(--radius-sm); border: 1px solid transparent;
  font: inherit; font-weight: 700; cursor: pointer; transition: .15s; white-space: nowrap;
  background: var(--surface-3); color: var(--text);
}
.btn:hover { text-decoration: none; filter: brightness(.96); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--brand-red); color: #fff; }
.btn-primary:hover { background: var(--brand-red-dark); }
.btn-success { background: var(--brand-green); color: #fff; }
.btn-success:hover { background: #176e3c; }
.btn-whatsapp { background: #25d366; color: #fff; }
.btn-whatsapp:hover { background: #1eb558; }
.btn-dark { background: var(--text); color: #fff; }
.btn-outline { background: transparent; border-color: var(--border-strong); color: var(--text-2); }
.btn-outline:hover { background: var(--surface-3); }
.btn-danger-outline { background: transparent; border-color: var(--danger); color: var(--danger); }
.btn-danger-outline:hover { background: var(--danger-soft); }
.btn-sm { padding: 6px 12px; font-size: .85rem; }
.btn-lg { padding: 14px 22px; font-size: 1.05rem; }
.btn-block { width: 100%; }
.btn-icon { padding: 6px; width: 34px; height: 34px; border-radius: 50%; }

/* ---------- Forms ---------- */
.field { margin-bottom: 16px; }
.field label, .label { display: block; font-weight: 700; margin-bottom: 6px; font-size: .9rem; }
.field .hint { color: var(--muted); font-size: .8rem; margin-top: 4px; }
.input, .select, .textarea {
  width: 100%; font: inherit; color: var(--text);
  padding: 11px 14px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--surface); transition: .15s;
}
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--brand-red); box-shadow: 0 0 0 3px rgba(193, 39, 45, .15); }
.input.is-invalid, .select.is-invalid, .textarea.is-invalid { border-color: var(--danger); }
.textarea { min-height: 90px; resize: vertical; }
.select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%23857b72' stroke-width='2'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: left 14px center; padding-left: 36px; }
.error { color: var(--danger); font-size: .82rem; margin-top: 5px; }
.input-group { display: flex; gap: 8px; }
.input-group .input { flex: 1; }
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-weight: 500; }
.check input { width: 18px; height: 18px; accent-color: var(--brand-green); }
.form-actions { display: flex; gap: 10px; align-items: center; margin-top: 8px; flex-wrap: wrap; }
.file-drop { border: 2px dashed var(--border-strong); border-radius: var(--radius); padding: 14px; background: var(--surface-2); display: flex; align-items: center; gap: 14px; }
.file-drop img { width: 72px; height: 72px; object-fit: cover; border-radius: var(--radius-sm); background: var(--surface-3); }
.file-drop input { flex: 1; font: inherit; }

/* ---------- Alerts / badges ---------- */
.alert { padding: 12px 16px; border-radius: var(--radius); border: 1px solid; margin-bottom: 18px; display: flex; gap: 10px; align-items: flex-start; }
.alert-success { background: var(--success-soft); border-color: #bfe3cc; color: #14532d; }
.alert-danger { background: var(--danger-soft); border-color: #f3c3c6; color: #7f1d1d; }
.alert-info { background: var(--info-soft); border-color: #c7d7f9; color: #1e3a8a; }
.alert ul { margin: 0; padding-inline-start: 18px; }
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px; border-radius: 999px; font-size: .78rem; font-weight: 700; line-height: 1.5; }
.badge-info { background: var(--info-soft); color: var(--info); }
.badge-warning { background: var(--warning-soft); color: var(--warning); }
.badge-success { background: var(--success-soft); color: var(--success); }
.badge-danger { background: var(--danger-soft); color: var(--danger); }
.badge-muted { background: var(--surface-3); color: var(--muted); }
.badge-dot::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface); }
.table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.table th, .table td { padding: 12px 14px; text-align: right; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table th { background: var(--surface-2); color: var(--text-2); font-weight: 700; font-size: .82rem; white-space: nowrap; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: #fcfbf9; }
.table .thumb { width: 44px; height: 44px; border-radius: var(--radius-sm); object-fit: cover; background: var(--surface-3); }
.table .actions { display: flex; gap: 6px; justify-content: flex-end; }
.empty { padding: 40px 20px; text-align: center; color: var(--muted); }
.empty .icon { font-size: 2.2rem; margin-bottom: 8px; }

/* Filters bar */
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: end; margin-bottom: 16px; }
.filters .field { margin: 0; min-width: 160px; flex: 1; }
.filters .field.grow { flex: 2; }

/* Pagination */
.pagination { display: flex; gap: 6px; justify-content: center; margin-top: 20px; flex-wrap: wrap; }
.pagination a, .pagination span { padding: 7px 13px; border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--surface); color: var(--text-2); font-size: .9rem; }
.pagination a:hover { background: var(--surface-3); text-decoration: none; }
.pagination .current { background: var(--text); color: #fff; border-color: var(--text); }
.pagination .disabled { opacity: .45; }

/* ---------- Auth ---------- */
.auth-page {
  min-height: 100vh; display: grid; place-items: center; padding: 24px;
  background:
    radial-gradient(900px 500px at 85% -10%, rgba(247, 201, 75, .35), transparent 60%),
    radial-gradient(700px 500px at 0% 110%, rgba(193, 39, 45, .18), transparent 60%),
    var(--bg);
}
.auth-card { width: 100%; max-width: 400px; background: var(--surface); border-radius: 24px; box-shadow: var(--shadow-lg); padding: 36px 32px 28px; text-align: center; }
.auth-card .logo { width: 96px; height: 96px; margin: 0 auto 14px; border-radius: 50%; box-shadow: 0 0 0 4px var(--brand-yellow-soft), 0 0 0 6px var(--brand-yellow); }
.auth-card h1 { font-size: 1.35rem; }
.auth-card .sub { color: var(--muted); margin-bottom: 22px; }
.auth-card form { text-align: right; }

/* ---------- POS: customer step ---------- */
.pos-steps { display: flex; gap: 8px; align-items: center; margin-bottom: 22px; color: var(--muted); font-size: .9rem; }
.pos-steps .step { display: inline-flex; align-items: center; gap: 8px; }
.pos-steps .step i { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; font-style: normal; font-weight: 700; background: var(--surface-3); font-size: .8rem; }
.pos-steps .step.active { color: var(--text); font-weight: 700; }
.pos-steps .step.active i { background: var(--brand-red); color: #fff; }
.pos-steps .step.done i { background: var(--brand-green); color: #fff; }
.pos-steps .sep { width: 36px; height: 1px; background: var(--border-strong); }

.lookup { position: relative; }
.lookup-results { position: absolute; inset-inline: 0; top: calc(100% + 6px); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-lg); z-index: 20; max-height: 300px; overflow: auto; }
.lookup-results button { display: block; width: 100%; text-align: right; background: none; border: 0; border-bottom: 1px solid var(--border); padding: 10px 14px; font: inherit; cursor: pointer; }
.lookup-results button:last-child { border-bottom: 0; }
.lookup-results button:hover { background: var(--surface-2); }
.lookup-results b { display: block; }
.lookup-results small { color: var(--muted); }

.customer-list { display: grid; gap: 10px; }
.customer-item { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.customer-item .avatar { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; background: var(--brand-yellow-soft); color: var(--warning); font-weight: 700; flex-shrink: 0; }
.customer-item .info { flex: 1; min-width: 0; }
.customer-item .info b { display: block; }
.customer-item .info small { display: block; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- POS: order builder ---------- */
.pos { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 20px; align-items: start; }
.pos > section { min-width: 0; }
.pos-toolbar { display: flex; gap: 10px; align-items: center; margin-bottom: 14px; }
.pos-toolbar .input { flex: 1; }

.cat-strip { display: flex; gap: 10px; overflow-x: auto; padding: 4px 2px 12px; scrollbar-width: thin; }
.cat-chip {
  flex: 0 0 auto; display: flex; align-items: center; gap: 10px; padding: 6px 14px 6px 6px;
  border-radius: 999px; border: 1px solid var(--border); background: var(--surface); cursor: pointer;
  font: inherit; font-weight: 700; color: var(--text-2); transition: .15s;
}
.cat-chip img, .cat-chip .ph { width: 36px; height: 36px; border-radius: 50%; object-fit: cover; background: var(--surface-3); display: grid; place-items: center; font-size: 1rem; }
.cat-chip:hover { border-color: var(--border-strong); }
.cat-chip.active { background: var(--text); color: #fff; border-color: var(--text); }

.product-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }
#productGrid { display: grid; gap: 22px; }
.cat-section { scroll-margin-top: calc(var(--header-h) + 12px); }
.cat-title { display: flex; align-items: center; gap: 10px; margin: 0 0 10px; padding-bottom: 6px; border-bottom: 2px solid var(--brand-yellow); font-size: 1.05rem; }
.cat-title .badge { font-size: .72rem; }
.product-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden;
  cursor: pointer; text-align: right; padding: 0; font: inherit; color: var(--text); transition: .15s; position: relative;
}
.product-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); border-color: var(--border-strong); }
.product-card:active { transform: scale(.98); }
.product-card .img { aspect-ratio: 4 / 3; background: var(--surface-3); display: grid; place-items: center; color: var(--muted); font-size: 1.8rem; }
.product-card .img img { width: 100%; height: 100%; object-fit: cover; }
.product-card .body { padding: 10px 12px 12px; }
.product-card .name { font-weight: 700; font-size: .92rem; line-height: 1.35; min-height: 2.6em; }
.product-card .price { color: var(--brand-red); font-weight: 800; margin-top: 4px; }
.product-card .qty-badge { position: absolute; top: 8px; inset-inline-start: 8px; background: var(--brand-green); color: #fff; font-weight: 800; border-radius: 999px; min-width: 26px; height: 26px; display: grid; place-items: center; font-size: .85rem; box-shadow: var(--shadow); }

.cart { position: sticky; top: calc(var(--header-h) + 16px); }
.cart .card-head { background: var(--surface-2); border-radius: var(--radius-lg) var(--radius-lg) 0 0; }
.cart-customer { padding: 14px 22px; border-bottom: 1px solid var(--border); background: var(--brand-yellow-soft); font-size: .9rem; }
.cart-customer b { display: block; font-size: 1rem; }
.cart-items { max-height: 36vh; overflow: auto; }
.cart-item { display: flex; align-items: center; gap: 10px; padding: 10px 22px; border-bottom: 1px solid var(--border); }
.cart-item .name { flex: 1; min-width: 0; font-weight: 700; font-size: .9rem; }
.cart-item .name small { display: block; color: var(--muted); font-weight: 400; }
.cart-item .line { font-weight: 800; white-space: nowrap; min-width: 70px; text-align: left; }
.qty { display: inline-flex; align-items: center; border: 1px solid var(--border-strong); border-radius: 999px; overflow: hidden; }
.qty button { width: 28px; height: 28px; border: 0; background: var(--surface-2); cursor: pointer; font-size: 1rem; font-weight: 700; color: var(--text-2); }
.qty button:hover { background: var(--surface-3); }
.qty span { min-width: 28px; text-align: center; font-weight: 700; font-size: .9rem; }
.cart-empty { padding: 30px 20px; text-align: center; color: var(--muted); }
.cart-foot { padding: 16px 22px 20px; border-top: 1px solid var(--border); }
.cart-total { display: flex; justify-content: space-between; align-items: baseline; font-weight: 800; font-size: 1.15rem; margin: 10px 0 14px; }
.cart-total .amount { color: var(--brand-red); font-size: 1.5rem; }

/* Success overlay */
.overlay { position: fixed; inset: 0; background: rgba(31, 27, 24, .55); z-index: 60; display: grid; place-items: center; padding: 20px; }
.overlay .box { background: var(--surface); border-radius: 24px; padding: 32px 28px; max-width: 420px; width: 100%; text-align: center; box-shadow: var(--shadow-lg); }
.overlay .tick { width: 72px; height: 72px; border-radius: 50%; background: var(--brand-green); color: #fff; display: grid; place-items: center; margin: 0 auto 14px; font-size: 2rem; }
.overlay .box .btn { margin-top: 8px; }

/* Order detail */
.kv { display: grid; grid-template-columns: 130px 1fr; gap: 8px 12px; font-size: .95rem; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 500; }
.wa-preview { background: #e6f7ec; border: 1px solid #bfe3cc; border-radius: var(--radius); padding: 14px 16px; white-space: pre-wrap; font-size: .9rem; line-height: 1.7; }

/* Dashboard lists */
.rank { display: grid; gap: 10px; }
.rank .row { display: grid; grid-template-columns: 24px 1fr auto; gap: 10px; align-items: center; }
.rank .bar { height: 8px; border-radius: 999px; background: var(--surface-3); overflow: hidden; grid-column: 2 / 4; }
.rank .bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--brand-yellow), var(--brand-red)); }
.rank .n { width: 24px; height: 24px; border-radius: 50%; background: var(--surface-3); display: grid; place-items: center; font-size: .78rem; font-weight: 700; }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .pos { grid-template-columns: minmax(0, 1fr) 330px; }
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 900px) {
  .menu-toggle { display: block; }
  .nav { display: none; position: absolute; top: var(--header-h); inset-inline: 0; background: var(--brand-navy); flex-direction: column; align-items: stretch; padding: 10px 16px 16px; gap: 4px; margin: 0; box-shadow: var(--shadow-lg); }
  .nav.open { display: flex; }
  .nav a { border-radius: var(--radius-sm); }
  .user-chip small { display: none; }
  .pos { grid-template-columns: minmax(0, 1fr); }
  .cart { position: static; }
  .grid-2, .grid-3, .grid-customer, .grid-dash { grid-template-columns: minmax(0, 1fr); }
  .kv { grid-template-columns: 1fr; gap: 2px 0; }
  .kv dt { margin-top: 8px; }
}
@media (max-width: 600px) {
  .app-main { padding: 16px 16px 50px; }
  .card-body { padding: 16px; }
  .grid-4 { grid-template-columns: 1fr; }
  .product-grid { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); }
  .user-chip b { display: none; }
  .brand span { display: none; }
}

@media print {
  .app-header, .app-footer, .no-print { display: none !important; }
  body { background: #fff; }
}

/* ---------- Header extras ---------- */
.btn-logout { background: transparent; border-color: rgba(255,255,255,.3); color: #e6e1d8; }
.btn-logout:hover { background: rgba(255,255,255,.1); }
.app-footer { display: flex; justify-content: center; align-items: center; gap: 8px; flex-wrap: wrap; }
.app-footer .dev-credit { color: var(--muted); }
.app-footer .dev-credit b { color: var(--brand-navy); }
.app-footer .dev-credit:hover { color: var(--brand-red); text-decoration: none; }
.app-footer .dev-credit:hover b { color: var(--brand-red); }
.auth-page .app-footer { margin-top: 10px; }

/* ---------- Form subsections ---------- */
.subsection { border-top: 1px dashed var(--border-strong); margin-top: 8px; padding-top: 16px; }
.subsection h3 { margin-bottom: 2px; }
code { font-family: ui-monospace, Consolas, monospace; background: var(--surface-3); padding: 2px 8px; border-radius: 6px; font-size: .9rem; }

/* ---------- POS: delivery fee ---------- */
.fee-row { display: grid; gap: 8px; }
.fee-row .input { text-align: center; font-weight: 700; }
.fee-quick { display: flex; gap: 6px; flex-wrap: wrap; }
.fee-quick .btn { flex: 1; padding: 6px 4px; font-size: .82rem; }
.cart-sub { display: flex; justify-content: space-between; color: var(--text-2); font-size: .9rem; padding: 2px 0; }

/* ---------- Agent: small order cards ---------- */
.mini-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.mini-card {
  position: relative; aspect-ratio: 1 / 1; display: flex; flex-direction: column; gap: 4px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px;
  color: var(--text); overflow: hidden; transition: .15s;
}
.mini-card:hover { text-decoration: none; transform: translateY(-2px); box-shadow: var(--shadow); border-color: var(--border-strong); }
.mc-top { display: flex; justify-content: space-between; align-items: baseline; font-size: .85rem; flex-wrap: wrap; gap: 0 8px; }
.mc-top b { white-space: nowrap; }
.mc-top > span { white-space: nowrap; }
.mc-top b { color: var(--brand-navy); }
.mc-customer { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }
.mc-branch { font-size: .8rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mc-total { margin-top: auto; font-weight: 800; color: var(--brand-red); font-size: 1.05rem; }
.mc-status { align-self: flex-start; }
.mc-stamp {
  position: absolute; inset-inline-end: -6px; bottom: -14px; font-size: 5.5rem; line-height: 1; font-weight: 800;
  color: var(--brand-green); opacity: 0; transform: rotate(-12deg) scale(.6); transition: .35s; pointer-events: none;
}
.mini-card.is-received { border-color: #bfe3cc; background: linear-gradient(160deg, #fff 55%, var(--brand-green-soft)); }
.mini-card.is-received .mc-stamp { opacity: .28; transform: rotate(-12deg) scale(1); }
.mini-card.is-cancelled { opacity: .55; }
.mini-card.is-cancelled .mc-customer { text-decoration: line-through; }

/* ---------- Branch dashboard ---------- */
.live-pill { display: inline-flex; align-items: center; gap: 8px; padding: 6px 14px; border-radius: 999px; background: var(--surface); border: 1px solid var(--border); font-size: .85rem; color: var(--text-2); }
.live-pill i { width: 9px; height: 9px; border-radius: 50%; background: var(--brand-green); box-shadow: 0 0 0 0 rgba(31,138,76,.5); animation: pulse 2s infinite; }
.live-pill.offline i { background: var(--danger); animation: none; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(31,138,76,.5); } 70% { box-shadow: 0 0 0 8px rgba(31,138,76,0); } 100% { box-shadow: 0 0 0 0 rgba(31,138,76,0); } }

.branch-board { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: 20px; align-items: start; }
.board-col { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 14px; min-height: 300px; }
.board-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; padding: 0 4px; }
.board-head h2 { margin: 0; font-size: 1.1rem; }
.order-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }

.order-card {
  position: relative; background: var(--surface); border: 2px solid var(--border); border-radius: var(--radius);
  padding: 12px 14px; cursor: pointer; transition: .15s; overflow: hidden; display: flex; flex-direction: column; gap: 8px;
}
.order-card:hover { border-color: var(--border-strong); box-shadow: var(--shadow); }
.order-card.selected { background: var(--brand-yellow-soft); box-shadow: 0 0 0 4px rgba(249,184,38,.35), var(--shadow); transform: translateY(-2px); }
.order-card .oc-receive { display: none; margin-top: 4px; }
.order-card.selected .oc-receive { display: inline-flex; }
.order-card.is-received { cursor: default; border-color: #bfe3cc; background: linear-gradient(160deg, #fff 60%, var(--brand-green-soft)); }
.oc-head { display: flex; justify-content: space-between; align-items: baseline; }
.oc-number { color: var(--brand-navy); font-size: 1.05rem; }
.oc-time { font-size: .8rem; color: var(--muted); }
.oc-customer { display: grid; gap: 1px; font-size: .9rem; }
.oc-customer small { color: var(--muted); }
.oc-items { list-style: none; margin: 0; padding: 8px 0; border-top: 1px dashed var(--border-strong); border-bottom: 1px dashed var(--border-strong); display: grid; gap: 4px; font-size: .9rem; }
.oc-items li { display: grid; grid-template-columns: 34px 1fr auto; gap: 6px; align-items: baseline; }
.oc-qty { font-weight: 800; color: var(--brand-red); }
.oc-price { color: var(--text-2); }
.oc-sums { display: grid; gap: 2px; font-size: .88rem; }
.oc-sum { display: flex; justify-content: space-between; color: var(--text-2); }
.oc-sum.strong { font-weight: 800; color: var(--text); font-size: 1rem; }
.oc-sum.strong .num { color: var(--brand-red); }
.oc-notes { font-size: .85rem; background: var(--surface-3); border-radius: var(--radius-sm); padding: 6px 10px; }
.oc-stamp { position: absolute; inset-inline-end: 6px; top: 34px; font-size: 4rem; font-weight: 800; color: var(--brand-green); opacity: .18; transform: rotate(-12deg); pointer-events: none; line-height: 1; }

@media (max-width: 900px) {
  .branch-board { grid-template-columns: minmax(0, 1fr); }
  .mini-cards { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
}

/* ---------- Order age tiers (outline colour by minutes since the order was placed) ---------- */
.order-card.age-fresh, .mini-card.age-fresh { border-color: var(--brand-green); }
.order-card.age-warn, .mini-card.age-warn { border-color: var(--brand-yellow); }
.order-card.age-late, .mini-card.age-late { border-color: var(--brand-red); }
.order-card.age-critical, .mini-card.age-critical { border-color: var(--brand-red); animation: late-pulse 1.4s infinite; }
.mini-card.age-fresh, .mini-card.age-warn, .mini-card.age-late, .mini-card.age-critical { border-width: 2px; }
.age-label { font-weight: 700; }
.order-card.age-fresh .age-label, .mini-card.age-fresh .age-label { color: var(--brand-green); }
.order-card.age-warn .age-label, .mini-card.age-warn .age-label { color: var(--warning); }
.order-card.age-late .age-label, .order-card.age-critical .age-label,
.mini-card.age-late .age-label, .mini-card.age-critical .age-label { color: var(--brand-red); }
@keyframes late-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(212, 40, 28, .45); }
  50% { box-shadow: 0 0 0 6px rgba(212, 40, 28, 0); }
}

.age-legend { display: inline-flex; gap: 6px; flex-wrap: wrap; }
.age-legend span { font-size: .75rem; font-weight: 700; padding: 3px 10px; border-radius: 999px; border: 2px solid; background: var(--surface); }
.age-legend .age-fresh { border-color: var(--brand-green); color: var(--brand-green); }
.age-legend .age-warn { border-color: var(--brand-yellow); color: var(--warning); }
.age-legend .age-late { border-color: var(--brand-red); color: var(--brand-red); }
.head-tools { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }

/* Reminder banner for orders the branch has not received yet */
.late-banner {
  position: sticky; top: calc(var(--header-h) + 8px); z-index: 30;
  display: flex; align-items: center; gap: 12px;
  background: var(--brand-yellow-soft); border: 2px solid var(--brand-yellow); color: #5a3d00;
  border-radius: var(--radius); padding: 12px 16px; margin-bottom: 18px; font-weight: 700; box-shadow: var(--shadow);
}
.late-banner .lb-icon { font-size: 1.4rem; animation: ring 1.6s infinite; display: inline-block; }
.late-banner.is-late { background: var(--brand-red-soft); border-color: var(--brand-red); color: #7f1d1d; }
@keyframes ring {
  0%, 100% { transform: rotate(0); }
  10% { transform: rotate(14deg); } 20% { transform: rotate(-12deg); }
  30% { transform: rotate(10deg); } 40% { transform: rotate(-8deg); } 50% { transform: rotate(0); }
}
