/* ════════════════════════════════════════════════════════════════
   COOFIX Agents Portal — design system
   Same language as the "كاشف الأسعار" app: ink + amber, hex grid,
   Alexandria headings, IBM Plex Sans Arabic body.
   ════════════════════════════════════════════════════════════════ */

@font-face { font-family: 'Alexandria'; src: url('../fonts/Alexandria.woff2') format('woff2'); font-weight: 100 900; font-display: swap; }
@font-face { font-family: 'Plex'; src: url('../fonts/Plex-Regular.woff2') format('woff2'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'Plex'; src: url('../fonts/Plex-Medium.woff2') format('woff2'); font-weight: 500; font-display: swap; }
@font-face { font-family: 'Plex'; src: url('../fonts/Plex-Bold.woff2') format('woff2'); font-weight: 600 800; font-display: swap; }

:root {
  --ink: #061922;
  --ink-light: #0F3041;
  --ink-mid: #0D2F3E;
  --amber: #FAA21B;
  --amber2: #FFC14F;
  --amber-deep: #E08A00;
  --bg: #F4F3F0;
  --card: #FFFFFF;
  --line: #E6E3DD;
  --line-2: #EFEDE8;
  --muted: #8A8F98;
  --text: #15181D;
  --text-2: #4A5059;
  --danger: #DC2626;
  --ok: #16A34A;
  --info: #2563EB;

  --amber-grad: linear-gradient(225deg, var(--amber2), var(--amber) 55%, var(--amber-deep));
  --dark-grad: linear-gradient(225deg, var(--ink-mid), var(--ink) 60%, #020A0E);
  --radius: 20px;
  --radius-sm: 14px;
  --shadow: 0 1px 2px rgba(6, 25, 34, .04), 0 8px 24px -12px rgba(6, 25, 34, .12);
  --shadow-lg: 0 24px 60px -24px rgba(6, 25, 34, .35);
  --side-w: 270px;
  --head-font: 'Alexandria', 'Plex', system-ui, sans-serif;
  --body-font: 'Plex', system-ui, -apple-system, 'Segoe UI', Tahoma, sans-serif;
  --safe-b: env(safe-area-inset-bottom, 0px);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0; font-family: var(--body-font); font-size: 15px; line-height: 1.6;
  color: var(--text); background: var(--bg); -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 { font-family: var(--head-font); line-height: 1.3; margin: 0; font-weight: 700; letter-spacing: -.01em; }
a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
button, input, select, textarea { font: inherit; color: inherit; }
::selection { background: rgba(250, 162, 27, .35); }
.ltr { direction: ltr; unicode-bidi: isolate; }
.num { font-variant-numeric: tabular-nums; direction: ltr; unicode-bidi: isolate; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.hidden { display: none !important; }
.nowrap { white-space: nowrap; }
.mt-0 { margin-top: 0 !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ─────────────── Icons (inline SVG sprite) ─────────────── */
.ic { width: 20px; height: 20px; flex: none; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.ic-sm { width: 16px; height: 16px; }
.ic-lg { width: 26px; height: 26px; }

/* ─────────────── Buttons ─────────────── */
.btn {
  --h: 46px;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: var(--h); padding: 0 18px; border-radius: calc(var(--h) * .34);
  border: 1px solid transparent; background: #fff; color: var(--text);
  font-family: var(--head-font); font-weight: 600; font-size: 14.5px; white-space: nowrap;
  cursor: pointer; transition: transform .15s, box-shadow .2s, background .2s, opacity .2s; user-select: none;
}
.btn:active { transform: translateY(1px) scale(.99); }
.btn[disabled], .btn.is-loading { opacity: .55; pointer-events: none; }
.btn-amber { background: var(--amber-grad); color: var(--ink); font-weight: 800; box-shadow: 0 10px 28px -10px rgba(250, 162, 27, .75); }
.btn-amber:hover { box-shadow: 0 14px 34px -10px rgba(250, 162, 27, .95); }
.btn-ink { background: var(--ink); color: #fff; box-shadow: 0 10px 24px -14px rgba(6, 25, 34, .8); }
.btn-ink:hover { background: var(--ink-light); }
.btn-ghost { background: #fff; border-color: var(--line); }
.btn-ghost:hover { border-color: #D6D1C8; background: #FBFAF8; }
.btn-glass { background: rgba(255, 255, 255, .08); border-color: rgba(255, 255, 255, .16); color: rgba(255, 255, 255, .92); }
.btn-glass:hover { background: rgba(255, 255, 255, .14); }
.btn-danger { background: #FEF2F2; color: var(--danger); border-color: #FBD5D5; }
.btn-danger:hover { background: #FEE2E2; }
.btn-ok { background: #F0FDF4; color: var(--ok); border-color: #CDEFD9; }
.btn-wa { background: #25D366; color: #fff; box-shadow: 0 10px 26px -12px rgba(37, 211, 102, .9); }
.btn-sm { --h: 36px; padding: 0 12px; font-size: 13px; }
.btn-lg { --h: 56px; font-size: 17px; padding: 0 26px; }
.btn-block { width: 100%; }
.btn-icon { width: var(--h); padding: 0; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

/* ─────────────── Forms ─────────────── */
.form { display: grid; gap: 14px; }
.field { display: grid; gap: 6px; }
.field > span { font-size: 13px; font-weight: 600; color: var(--text-2); }
.field small { color: var(--muted); font-size: 12px; }
.input, .field input, .field select, .field textarea, .select {
  width: 100%; min-height: 48px; padding: 10px 14px; border-radius: var(--radius-sm);
  border: 1.5px solid var(--line); background: #fff; outline: none; font-size: 15px;
  transition: border-color .2s, box-shadow .2s;
}
.field textarea, textarea.input { min-height: 96px; resize: vertical; line-height: 1.6; }
.input:focus, .field input:focus, .field select:focus, .field textarea:focus, .select:focus {
  border-color: var(--amber); box-shadow: 0 0 0 4px rgba(250, 162, 27, .18);
}
.field select, .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 1.5 6 6.5l5-5' fill='none' stroke='%238A8F98' stroke-width='1.8' stroke-linecap='round'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: left 14px center; padding-left: 36px; }
.input-icon { position: relative; }
.input-icon .ic { position: absolute; top: 50%; right: 14px; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.input-icon .input { padding-right: 44px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.form-sec { font-size: 14px; color: var(--amber-deep); margin: 8px 0 -4px; }
.check { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-weight: 500; }
.check input { width: 20px; height: 20px; accent-color: var(--amber-deep); }
.switch { position: relative; display: inline-flex; align-items: center; gap: 10px; cursor: pointer; }
.switch input { position: absolute; opacity: 0; }
.switch i { width: 44px; height: 26px; border-radius: 99px; background: #D9D5CD; position: relative; transition: background .2s; flex: none; }
.switch i::after { content: ''; position: absolute; top: 3px; right: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.2); transition: right .2s; }
.switch input:checked + i { background: var(--amber); }
.switch input:checked + i::after { right: 21px; }
.file-drop { border: 2px dashed #D6D1C8; border-radius: var(--radius); padding: 22px; text-align: center; background: #FBFAF8; cursor: pointer; transition: .2s; display: block; }
.file-drop:hover, .file-drop.drag { border-color: var(--amber); background: #FFF8EC; }
.file-drop input { display: none; }
.file-drop b { display: block; font-family: var(--head-font); margin-bottom: 4px; }

/* ─────────────── Alerts, badges, chips ─────────────── */
.alert { padding: 12px 16px; border-radius: var(--radius-sm); font-size: 14px; border: 1px solid; display: flex; gap: 10px; align-items: flex-start; }
.alert-danger { background: #FEF2F2; border-color: #FBD5D5; color: #991B1B; }
.alert-ok { background: #F0FDF4; border-color: #CDEFD9; color: #166534; }
.alert-warn { background: #FFF8EC; border-color: #FBE1B4; color: #8A5300; }
.alert-info { background: #EFF6FF; border-color: #D3E3FD; color: #1E40AF; }
.badge { display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 11px; border-radius: 99px; font-size: 12.5px; font-weight: 600; white-space: nowrap; background: #F1EFEA; color: var(--text-2); }
.badge::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: currentColor; opacity: .85; }
.badge.plain::before { display: none; }
.st-new { background: #FFF4DF; color: #B86E00; }
.st-proc { background: #E7F0FF; color: #1D4ED8; }
.st-done { background: #E7F8EE; color: #15803D; }
.st-cancel { background: #FDECEC; color: #B91C1C; }
.role-super { background: var(--ink); color: var(--amber); }
.role-admin { background: #E7F0FF; color: #1D4ED8; }
.role-agent { background: #FFF4DF; color: #B86E00; }
.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; height: 38px; padding: 0 16px; border-radius: 99px; border: 1.5px solid var(--line); background: #fff; display: inline-flex; align-items: center; gap: 6px; font-weight: 600; font-size: 13.5px; cursor: pointer; transition: .15s; }
.chip:hover { border-color: #D6D1C8; }
.chip.on { background: var(--ink); color: #fff; border-color: var(--ink); }
.chip .cnt { font-size: 11.5px; opacity: .7; }

/* ─────────────── Auth (login / installer) ─────────────── */
.auth-body { min-height: 100vh; min-height: 100dvh; background: var(--ink); color: #fff; overflow-x: hidden; }
.auth-bg { position: fixed; inset: 0; background: url('../img/hex.svg'), var(--dark-grad); overflow: hidden; }
.auth-bg .glow { position: absolute; border-radius: 50%; pointer-events: none; }
.auth-bg .g1 { width: 95vmin; height: 95vmin; top: -36vmin; right: -28vmin; background: radial-gradient(circle, rgba(250, 162, 27, .22), rgba(250, 162, 27, 0) 70%); }
.auth-bg .g2 { width: 100vmin; height: 100vmin; bottom: -42vmin; left: -36vmin; background: radial-gradient(circle, rgba(250, 162, 27, .12), rgba(250, 162, 27, 0) 70%); }
.auth-wrap { position: relative; min-height: 100vh; min-height: 100dvh; width: 100%; max-width: 440px; margin: 0 auto; padding: 40px 20px calc(28px + var(--safe-b)); display: flex; flex-direction: column; justify-content: center; gap: 26px; }
.auth-wrap.wide { max-width: 640px; }
.auth-logo { width: min(270px, 74%); margin: 0 auto; filter: drop-shadow(0 18px 30px rgba(0, 0, 0, .35)); }
.auth-card { background: rgba(255, 255, 255, .055); border: 1px solid rgba(255, 255, 255, .12); border-radius: 28px; padding: 28px 22px; backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px); box-shadow: 0 30px 80px -30px rgba(0, 0, 0, .7); display: grid; gap: 16px; }
.auth-head h1 { font-size: 22px; }
.auth-head p { margin: 4px 0 0; color: rgba(255, 255, 255, .62); font-size: 14px; }
.auth-card .field > span { color: rgba(255, 255, 255, .72); }
.auth-card .input, .auth-card .field input { background: rgba(255, 255, 255, .07); border-color: rgba(255, 255, 255, .14); color: #fff; }
.auth-card .input::placeholder { color: rgba(255, 255, 255, .38); }
.auth-card .input:focus, .auth-card .field input:focus { background: rgba(255, 255, 255, .1); border-color: var(--amber); }
.auth-card .input-icon .ic { color: rgba(255, 255, 255, .5); }
.auth-card .form-sec { color: var(--amber); }
.auth-foot { text-align: center; color: rgba(255, 255, 255, .38); font-size: 12.5px; margin: 0; letter-spacing: .02em; }
.pass-toggle { position: absolute; left: 6px; top: 50%; transform: translateY(-50%); width: 38px; height: 38px; border: 0; background: none; color: rgba(255,255,255,.55); cursor: pointer; display: grid; place-items: center; border-radius: 10px; }
.auth-card .alert-danger { background: rgba(220, 38, 38, .14); border-color: rgba(248, 113, 113, .35); color: #FECACA; }
.auth-card .alert-warn { background: rgba(250, 162, 27, .12); border-color: rgba(250, 162, 27, .35); color: #FFE0A8; }
.req-list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px 12px; font-size: 13px; }
.req-list .ok { color: #86EFAC; } .req-list .bad { color: #FCA5A5; }

/* ─────────────── App shell ─────────────── */
.shell { min-height: 100vh; min-height: 100dvh; }
.side {
  position: fixed; top: 0; bottom: 0; right: 0; width: var(--side-w); z-index: 60;
  background: url('../img/hex.svg'), var(--dark-grad); color: #fff;
  display: flex; flex-direction: column; padding: 22px 14px 18px; transition: transform .28s cubic-bezier(.2, .8, .2, 1);
}
.side::before { content: ''; position: absolute; width: 360px; height: 360px; top: -160px; right: -140px; border-radius: 50%; background: radial-gradient(circle, rgba(250, 162, 27, .2), transparent 70%); pointer-events: none; }
.side-brand { display: flex; align-items: center; gap: 12px; padding: 0 8px 20px; position: relative; }
.side-brand img { width: 46px; height: 46px; border-radius: 14px; }
.side-brand b { display: block; font-family: var(--head-font); font-size: 17px; }
.side-brand small { color: var(--amber); font-size: 12.5px; opacity: .9; }
.side-nav { display: grid; gap: 3px; overflow-y: auto; flex: 1; position: relative; scrollbar-width: thin; }
.side-label { font-size: 11.5px; color: rgba(255, 255, 255, .38); padding: 14px 12px 6px; font-weight: 600; letter-spacing: .03em; }
.side-nav a { display: flex; align-items: center; gap: 12px; padding: 11px 12px; border-radius: 14px; color: rgba(255, 255, 255, .74); font-weight: 500; transition: background .15s, color .15s; position: relative; }
.side-nav a:hover { background: rgba(255, 255, 255, .06); color: #fff; }
.side-nav a.on { background: rgba(250, 162, 27, .14); color: var(--amber2); }
.side-nav a.on::before { content: ''; position: absolute; right: -14px; top: 10px; bottom: 10px; width: 4px; border-radius: 4px 0 0 4px; background: var(--amber); }
.side-nav .count { margin-right: auto; min-width: 22px; height: 22px; padding: 0 7px; border-radius: 99px; background: var(--amber); color: var(--ink); font-size: 12px; font-weight: 800; display: grid; place-items: center; }
.side-nav .secret { color: rgba(255, 193, 79, .9); }
.side-user { position: relative; display: flex; align-items: center; gap: 10px; padding: 12px; margin-top: 10px; border-radius: 16px; background: rgba(255, 255, 255, .06); border: 1px solid rgba(255, 255, 255, .08); }
.avatar { width: 40px; height: 40px; border-radius: 13px; background: var(--amber-grad); color: var(--ink); display: grid; place-items: center; font-family: var(--head-font); font-weight: 800; flex: none; }
.side-user .who { flex: 1; min-width: 0; }
.side-user .who b { display: block; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.side-user .who small { color: rgba(255, 255, 255, .5); font-size: 12px; }
.side-user a, .side-user button { color: rgba(255, 255, 255, .6); background: none; border: 0; cursor: pointer; width: 36px; height: 36px; display: grid; place-items: center; border-radius: 10px; }
.side-user a:hover, .side-user button:hover { background: rgba(255, 255, 255, .08); color: #fff; }

.main { margin-right: var(--side-w); min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; }
.topbar { display: none; }
.content { flex: 1; width: 100%; max-width: 1240px; margin: 0 auto; padding: 0 28px 48px; }

/* Page hero — the dark rounded header block from the app */
.hero {
  position: relative; overflow: hidden; color: #fff; border-radius: 0 0 32px 32px;
  background: url('../img/hex.svg'), var(--dark-grad); padding: 30px 28px 28px; margin: 0 -28px 24px;
}
.hero::after { content: ''; position: absolute; width: 420px; height: 420px; top: -220px; left: -120px; border-radius: 50%; background: radial-gradient(circle, rgba(250, 162, 27, .16), transparent 70%); pointer-events: none; }
.hero-in { position: relative; z-index: 1; max-width: 1240px; margin: 0 auto; }
.hero-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.hero h1 { font-size: 26px; }
.hero .sub { color: rgba(250, 162, 27, .92); font-size: 14px; margin-top: 4px; font-weight: 500; }
.crumbs { font-size: 13px; color: rgba(255, 255, 255, .5); margin-bottom: 6px; display: flex; gap: 6px; align-items: center; }
.crumbs a:hover { color: #fff; }
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-top: 22px; }
.stat { background: rgba(255, 255, 255, .06); border: 1px solid rgba(255, 255, 255, .1); border-radius: 18px; padding: 14px 16px; display: flex; gap: 12px; align-items: center; min-width: 0; }
.stat .si { width: 42px; height: 42px; border-radius: 13px; background: rgba(250, 162, 27, .16); color: var(--amber); display: grid; place-items: center; flex: none; }
.stat b { display: block; font-family: var(--head-font); font-size: 22px; line-height: 1.15; font-variant-numeric: tabular-nums; }
.stat small { color: rgba(255, 255, 255, .58); font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; }

/* ─────────────── Cards & sections ─────────────── */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-pad { padding: 20px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--line-2); flex-wrap: wrap; }
.card-head h2, .card-head h3 { font-size: 16.5px; display: flex; align-items: center; gap: 10px; }
.card-head h2 .ic { color: var(--amber-deep); }
.card-body { padding: 20px; }
.card + .card, .stack > * + * { margin-top: 18px; }
.cols { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 18px; align-items: start; }
.cols > .card + .card { margin-top: 0; }
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }
.toolbar .grow { flex: 1; min-width: 200px; }
.empty { text-align: center; padding: 48px 20px; color: var(--muted); }
.empty .ei { width: 72px; height: 72px; border-radius: 22px; margin: 0 auto 14px; background: #F1EFEA; display: grid; place-items: center; color: #B3AEA4; }
.empty b { display: block; color: var(--text); font-family: var(--head-font); font-size: 17px; margin-bottom: 4px; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 10px 18px; font-size: 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 600; }
.divider { height: 1px; background: var(--line-2); margin: 16px 0; border: 0; }

/* Quick tiles on dashboard */
.tiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.tile { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; display: grid; gap: 10px; box-shadow: var(--shadow); transition: transform .18s, box-shadow .18s, border-color .18s; }
.tile:hover { transform: translateY(-2px); border-color: #F3D59F; box-shadow: 0 18px 40px -22px rgba(224, 138, 0, .45); }
.tile .ti { width: 46px; height: 46px; border-radius: 15px; background: var(--ink); color: var(--amber); display: grid; place-items: center; }
.tile b { font-family: var(--head-font); font-size: 15.5px; }
.tile small { color: var(--muted); font-size: 13px; line-height: 1.5; }

/* ─────────────── Tables ─────────────── */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: right; font-weight: 600; color: var(--muted); font-size: 12.5px; padding: 12px 16px; background: #FAF9F6; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { padding: 13px 16px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr { transition: background .12s; }
.table tbody tr:hover { background: #FCFBF9; }
.table tr.unseen td:first-child { box-shadow: inset -4px 0 0 var(--amber); }
.table .t-end { text-align: left; }
.table .prod { display: flex; align-items: center; gap: 12px; min-width: 220px; }
.table .prod img { width: 46px; height: 46px; border-radius: 12px; object-fit: cover; background: #F1EFEA; flex: none; border: 1px solid var(--line-2); }
.table .prod b { display: block; font-weight: 600; line-height: 1.4; }
.code { font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace; font-size: 12.5px; background: #F4F2EE; padding: 2px 8px; border-radius: 7px; color: var(--text-2); direction: ltr; unicode-bidi: isolate; white-space: nowrap; }
.qty-ok { color: var(--ok); font-weight: 700; }
.qty-low { color: #B86E00; font-weight: 700; }
.qty-out { color: var(--danger); font-weight: 700; }
.row-actions { display: flex; gap: 6px; justify-content: flex-end; }
.totals { margin-right: auto; width: min(360px, 100%); display: grid; gap: 8px; font-size: 14.5px; }
.totals div { display: flex; justify-content: space-between; gap: 16px; }
.totals .grand { border-top: 1px dashed var(--line); padding-top: 10px; font-family: var(--head-font); font-size: 19px; font-weight: 800; }

/* Discount matrix */
.matrix { border-collapse: separate; border-spacing: 0; font-size: 13.5px; min-width: 100%; }
.matrix th, .matrix td { padding: 8px; border-bottom: 1px solid var(--line-2); text-align: center; white-space: nowrap; }
.matrix thead th { background: #FAF9F6; color: var(--text-2); font-weight: 600; position: sticky; top: 0; z-index: 2; }
.matrix th:first-child, .matrix td:first-child { position: sticky; right: 0; background: #fff; text-align: right; z-index: 1; min-width: 170px; box-shadow: -1px 0 0 var(--line); }
.matrix thead th:first-child { background: #FAF9F6; z-index: 3; }
.matrix .pin { width: 74px; height: 38px; text-align: center; border: 1.5px solid var(--line); border-radius: 10px; font-weight: 600; outline: none; direction: ltr; background: #fff; transition: .15s; }
.matrix .pin:focus { border-color: var(--amber); box-shadow: 0 0 0 3px rgba(250, 162, 27, .18); }
.matrix .pin.changed { border-color: var(--amber); background: #FFF8EC; }
.matrix .pin.def { color: var(--muted); }
.matrix .col-def { background: #FFFBF3; }
.matrix .agent-name b { display: block; }
.matrix .agent-name small { color: var(--muted); }

/* ─────────────── Agent catalog ─────────────── */
.cat-head { position: sticky; top: 0; z-index: 30; background: rgba(244, 243, 240, .92); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); padding: 14px 0 12px; margin-bottom: 4px; display: grid; gap: 12px; }
.search-big { position: relative; }
.search-big .input { height: 54px; border-radius: 18px; padding-right: 50px; font-size: 16px; box-shadow: var(--shadow); }
.search-big .ic { position: absolute; right: 17px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.search-big .clear { position: absolute; left: 8px; top: 50%; transform: translateY(-50%); }
.products { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; }
.pcard { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; display: flex; flex-direction: column; box-shadow: var(--shadow); transition: transform .18s, box-shadow .18s; }
.pcard:hover { transform: translateY(-2px); box-shadow: 0 18px 40px -24px rgba(6, 25, 34, .35); }
.pcard .pimg { aspect-ratio: 1 / 1; background: #F4F2EE; position: relative; overflow: hidden; }
.pcard .pimg img { width: 100%; height: 100%; object-fit: contain; padding: 10px; mix-blend-mode: multiply; }
.pcard .pcat { position: absolute; top: 10px; right: 10px; background: rgba(6, 25, 34, .82); color: #fff; font-size: 11.5px; padding: 3px 10px; border-radius: 99px; backdrop-filter: blur(6px); max-width: 80%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pcard .pstock { position: absolute; bottom: 10px; left: 10px; font-size: 11.5px; font-weight: 700; padding: 3px 10px; border-radius: 99px; background: #fff; box-shadow: 0 2px 8px rgba(0,0,0,.08); }
.pcard .pbody { padding: 12px 14px 14px; display: grid; gap: 8px; flex: 1; align-content: start; }
.pcard .pname { font-weight: 600; font-size: 14.5px; line-height: 1.45; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; min-height: 42px; }
.pcard .pprice { font-family: var(--head-font); font-weight: 800; font-size: 20px; color: var(--ink); }
.pcard .pfoot { display: flex; gap: 8px; align-items: center; margin-top: auto; }
.pcard.out { opacity: .6; }
.pcard.in-cart { border-color: var(--amber); box-shadow: 0 0 0 3px rgba(250, 162, 27, .18), var(--shadow); }
.stepper { display: inline-flex; align-items: center; height: 42px; border: 1.5px solid var(--line); border-radius: 14px; background: #fff; overflow: hidden; flex: 1; }
.stepper button { width: 38px; height: 100%; border: 0; background: none; cursor: pointer; font-size: 20px; color: var(--text-2); display: grid; place-items: center; flex: none; }
.stepper button:hover { background: #F6F4F0; }
.stepper input { width: 100%; min-width: 34px; border: 0; text-align: center; font-weight: 700; outline: none; height: 100%; -moz-appearance: textfield; background: none; direction: ltr; }
.stepper input::-webkit-outer-spin-button, .stepper input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.load-more { display: flex; justify-content: center; margin-top: 20px; }

/* Floating cart bar (agent) */
.cart-bar {
  position: fixed; z-index: 45; left: 50%; transform: translate(-50%, 140%); bottom: calc(18px + var(--safe-b));
  width: min(560px, calc(100% - 28px)); background: var(--ink); color: #fff; border-radius: 22px; padding: 10px 10px 10px 16px;
  display: flex; align-items: center; gap: 12px; box-shadow: 0 24px 50px -16px rgba(6, 25, 34, .7); transition: transform .3s cubic-bezier(.2, .9, .2, 1.1);
}
.main .cart-bar { margin-right: calc(var(--side-w) / 2); }
.cart-bar.show { transform: translate(-50%, 0); }
.cart-bar .cb-ic { width: 44px; height: 44px; border-radius: 14px; background: rgba(250, 162, 27, .16); color: var(--amber); display: grid; place-items: center; position: relative; }
.cart-bar .cb-ic i { position: absolute; top: -5px; left: -5px; min-width: 20px; height: 20px; border-radius: 99px; background: var(--amber); color: var(--ink); font-style: normal; font-size: 11.5px; font-weight: 800; display: grid; place-items: center; padding: 0 5px; }
.cart-bar .cb-t { flex: 1; min-width: 0; }
.cart-bar .cb-t small { display: block; color: rgba(255, 255, 255, .55); font-size: 12px; }
.cart-bar .cb-t b { font-family: var(--head-font); font-size: 18px; }

/* Sheet / modal */
.overlay { position: fixed; inset: 0; background: rgba(2, 10, 14, .55); backdrop-filter: blur(3px); z-index: 80; opacity: 0; pointer-events: none; transition: opacity .25s; }
.overlay.show { opacity: 1; pointer-events: auto; }
.sheet {
  position: fixed; z-index: 90; top: 0; bottom: 0; left: 0; width: min(460px, 100%); background: var(--bg);
  transform: translateX(-105%); transition: transform .32s cubic-bezier(.2, .8, .2, 1); display: flex; flex-direction: column; box-shadow: var(--shadow-lg);
}
.sheet.show { transform: none; }
.sheet-head { background: url('../img/hex.svg'), var(--dark-grad); color: #fff; padding: 20px; display: flex; align-items: center; gap: 12px; }
.sheet-head h3 { flex: 1; font-size: 19px; }
.sheet-body { flex: 1; overflow-y: auto; padding: 16px; display: grid; gap: 10px; align-content: start; }
.sheet-foot { padding: 16px 16px calc(16px + var(--safe-b)); background: #fff; border-top: 1px solid var(--line); display: grid; gap: 12px; }
.citem { background: #fff; border: 1px solid var(--line); border-radius: 18px; padding: 10px; display: grid; grid-template-columns: 62px 1fr; gap: 12px; }
.citem img { width: 62px; height: 62px; border-radius: 13px; object-fit: contain; background: #F4F2EE; }
.citem .cn { font-weight: 600; font-size: 14px; line-height: 1.4; }
.citem .cr { display: flex; align-items: center; gap: 8px; margin-top: 8px; }
.citem .stepper { height: 36px; flex: none; width: 120px; }
.citem .lt { margin-right: auto; font-family: var(--head-font); font-weight: 800; }
.modal { position: fixed; z-index: 95; inset: 0; display: grid; place-items: center; padding: 18px; pointer-events: none; }
.modal .box { pointer-events: auto; background: #fff; border-radius: 24px; width: min(460px, 100%); padding: 24px; box-shadow: var(--shadow-lg); transform: scale(.96); opacity: 0; transition: .2s; display: grid; gap: 14px; max-height: 90vh; overflow: auto; }
.modal.show .box { transform: none; opacity: 1; }
.modal:not(.show) { visibility: hidden; }
.modal h3 { font-size: 19px; }

/* Toasts */
.toasts { position: fixed; z-index: 120; top: 16px; left: 50%; transform: translateX(-50%); display: grid; gap: 8px; width: min(420px, calc(100% - 28px)); pointer-events: none; }
.toast { background: var(--ink); color: #fff; padding: 13px 16px; border-radius: 16px; display: flex; gap: 10px; align-items: center; box-shadow: 0 18px 40px -14px rgba(0, 0, 0, .5); font-size: 14px; animation: tin .3s cubic-bezier(.2, .9, .2, 1.2); pointer-events: auto; }
.toast.err { background: #7F1D1D; }
.toast .ic { color: var(--amber); }
.toast.err .ic { color: #FCA5A5; }
.toast.leave { animation: tout .25s forwards; }
@keyframes tin { from { transform: translateY(-14px); opacity: 0; } }
@keyframes tout { to { transform: translateY(-10px); opacity: 0; } }

/* New-order notification banner (admin) */
.ping { position: fixed; z-index: 110; bottom: calc(20px + var(--safe-b)); left: 20px; width: min(380px, calc(100% - 40px)); background: var(--ink); color: #fff; border-radius: 20px; padding: 14px; display: flex; gap: 12px; align-items: center; box-shadow: 0 24px 60px -18px rgba(0, 0, 0, .65); border: 1px solid rgba(250, 162, 27, .4); transform: translateY(160%); transition: transform .35s cubic-bezier(.2, .9, .2, 1.15); }
.ping.show { transform: none; }
.ping .pi { width: 46px; height: 46px; border-radius: 15px; background: var(--amber-grad); color: var(--ink); display: grid; place-items: center; flex: none; animation: ring 1.2s ease-in-out 2; }
.ping .pt { flex: 1; min-width: 0; }
.ping .pt b { display: block; font-family: var(--head-font); }
.ping .pt small { color: rgba(255, 255, 255, .6); }
@keyframes ring { 0%, 100% { transform: rotate(0); } 20% { transform: rotate(-14deg); } 40% { transform: rotate(12deg); } 60% { transform: rotate(-8deg); } 80% { transform: rotate(5deg); } }

/* Pagination */
.pager { display: flex; gap: 6px; justify-content: center; padding: 18px; flex-wrap: wrap; }
.pager a, .pager span { min-width: 40px; height: 40px; padding: 0 12px; border-radius: 12px; border: 1px solid var(--line); background: #fff; display: grid; place-items: center; font-weight: 600; font-size: 14px; }
.pager .on { background: var(--ink); color: #fff; border-color: var(--ink); }
.pager .gap { border: 0; background: none; }

/* Order timeline */
.timeline { list-style: none; margin: 0; padding: 0; display: grid; gap: 0; }
.timeline li { position: relative; padding: 0 26px 18px 0; font-size: 14px; }
.timeline li::before { content: ''; position: absolute; right: 5px; top: 8px; width: 12px; height: 12px; border-radius: 50%; background: var(--amber); box-shadow: 0 0 0 4px #FFF4DF; }
.timeline li::after { content: ''; position: absolute; right: 10px; top: 24px; bottom: 0; width: 2px; background: var(--line); }
.timeline li:last-child::after { display: none; }
.timeline small { color: var(--muted); display: block; }

/* Status stepper on order page */
.progress { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.progress div { height: 8px; border-radius: 99px; background: #ECE9E3; }
.progress div.on { background: var(--amber-grad); }
.progress-l { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; font-size: 12.5px; color: var(--muted); margin-top: 8px; }
.progress-l span.on { color: var(--text); font-weight: 600; }

/* Stock lookup */
.stock-hit { display: grid; grid-template-columns: 96px 1fr auto; gap: 16px; align-items: center; padding: 14px; }
.stock-hit img { width: 96px; height: 96px; border-radius: 18px; object-fit: contain; background: #F4F2EE; }
.stock-num { text-align: center; min-width: 110px; padding: 12px 14px; border-radius: 18px; background: #F0FDF4; }
.stock-num b { display: block; font-family: var(--head-font); font-size: 30px; line-height: 1.1; color: var(--ok); }
.stock-num small { color: var(--muted); font-size: 12px; }
.stock-num.low { background: #FFF8EC; } .stock-num.low b { color: #B86E00; }
.stock-num.out { background: #FEF2F2; } .stock-num.out b { color: var(--danger); }

/* Evaluation */
.score-row { display: grid; grid-template-columns: minmax(0, 1fr) 220px; gap: 16px; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--line-2); }
.score-row:last-child { border-bottom: 0; }
.score-row b { display: block; }
.score-row small { color: var(--muted); }
.range { display: grid; grid-template-columns: 1fr 64px; gap: 10px; align-items: center; }
.range input[type=range] { width: 100%; accent-color: var(--amber-deep); }
.range output { text-align: center; font-family: var(--head-font); font-weight: 800; font-size: 18px; background: #FFF4DF; color: #8A5300; border-radius: 12px; padding: 4px 0; }
.ring { --p: 0; width: 120px; height: 120px; border-radius: 50%; background: conic-gradient(var(--amber) calc(var(--p) * 1%), rgba(255, 255, 255, .12) 0); display: grid; place-items: center; flex: none; }
.ring div { width: 96px; height: 96px; border-radius: 50%; background: var(--ink); display: grid; place-items: center; font-family: var(--head-font); font-weight: 800; font-size: 26px; color: #fff; }
.secret-tag { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--amber); background: rgba(250, 162, 27, .12); padding: 4px 10px; border-radius: 99px; border: 1px solid rgba(250, 162, 27, .3); }

/* Bottom tab bar (mobile) */
.tabbar { display: none; }

/* ─────────────── Responsive ─────────────── */
@media (max-width: 1180px) {
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .cols { grid-template-columns: 1fr; }
}
@media (max-width: 1023px) {
  .side { transform: translateX(105%); box-shadow: var(--shadow-lg); }
  .side.open { transform: none; }
  .main { margin-right: 0; }
  .main .cart-bar { margin-right: 0; }
  .topbar {
    display: flex; position: sticky; top: 0; z-index: 50; align-items: center; gap: 10px;
    height: 60px; padding: 0 12px; background: var(--ink); color: #fff;
  }
  .topbar .tb-title { flex: 1; display: flex; align-items: center; gap: 10px; font-family: var(--head-font); font-weight: 700; font-size: 16px; min-width: 0; }
  .topbar .tb-title img { width: 34px; height: 34px; border-radius: 10px; }
  .topbar button, .topbar a.tb-btn { width: 42px; height: 42px; border-radius: 13px; border: 0; background: rgba(255, 255, 255, .08); color: #fff; display: grid; place-items: center; cursor: pointer; position: relative; }
  .topbar .dot { position: absolute; top: 7px; left: 7px; min-width: 18px; height: 18px; border-radius: 99px; background: var(--amber); color: var(--ink); font-size: 11px; font-weight: 800; display: grid; place-items: center; padding: 0 4px; }
  .content { padding: 0 16px 40px; }
  .hero { margin: 0 -16px 18px; padding: 22px 18px 22px; border-radius: 0 0 28px 28px; }
  .hero h1 { font-size: 22px; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-top: 18px; }
  .stat { padding: 12px; } .stat .si { width: 38px; height: 38px; } .stat b { font-size: 19px; }
}
@media (max-width: 760px) {
  body { font-size: 14.5px; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .tiles { grid-template-columns: 1fr 1fr; gap: 10px; }
  .tile { padding: 14px; } .tile small { display: none; }
  .products { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .pcard .pbody { padding: 10px; gap: 6px; }
  .pcard .pname { font-size: 13.5px; min-height: 39px; }
  .pcard .pprice { font-size: 17px; }
  .pcard .pfoot { flex-direction: column; align-items: stretch; }
  .pcard .pfoot .btn { width: 100%; }
  .stepper { height: 38px; }
  .card-head, .card-body, .card-pad { padding: 14px 16px; }
  .score-row { grid-template-columns: 1fr; gap: 10px; padding: 14px 16px; }
  .stock-hit { grid-template-columns: 72px 1fr; }
  .stock-hit img { width: 72px; height: 72px; }
  .stock-hit .stock-num { grid-column: 1 / -1; }
  .req-list { grid-template-columns: 1fr; }

  /* Tables become stacked cards on phones */
  .table.stack-sm thead { display: none; }
  .table.stack-sm, .table.stack-sm tbody, .table.stack-sm tr, .table.stack-sm td { display: block; width: 100%; }
  .table.stack-sm tr { padding: 12px 14px; border-bottom: 1px solid var(--line-2); }
  .table.stack-sm td { border: 0; padding: 4px 0; display: flex; justify-content: space-between; gap: 12px; align-items: center; text-align: left; }
  .table.stack-sm td::before { content: attr(data-l); color: var(--muted); font-size: 12.5px; text-align: right; flex: none; }
  .table.stack-sm td.full { display: block; } .table.stack-sm td.full::before { display: none; }
  .table.stack-sm .prod { min-width: 0; }
  .table.stack-sm .row-actions { justify-content: flex-start; padding-top: 6px; }
  .table.stack-sm tr.unseen { box-shadow: inset -4px 0 0 var(--amber); }
  .table.stack-sm tr.unseen td:first-child { box-shadow: none; }

  /* Agent bottom tabs */
  body.has-tabs .content { padding-bottom: calc(96px + var(--safe-b)); }
  body.has-tabs .cart-bar { bottom: calc(80px + var(--safe-b)); }
  .tabbar {
    display: grid; grid-template-columns: repeat(var(--n, 4), 1fr); position: fixed; z-index: 55; bottom: 0; left: 0; right: 0;
    background: rgba(6, 25, 34, .97); backdrop-filter: blur(14px); padding: 8px 8px calc(8px + var(--safe-b)); border-radius: 22px 22px 0 0;
  }
  .tabbar a { display: grid; justify-items: center; gap: 3px; padding: 6px 2px; border-radius: 14px; color: rgba(255, 255, 255, .55); font-size: 11.5px; font-weight: 600; position: relative; }
  .tabbar a.on { color: var(--amber); background: rgba(250, 162, 27, .1); }
  .tabbar .dot { position: absolute; top: 2px; left: calc(50% - 20px); min-width: 18px; height: 18px; border-radius: 99px; background: var(--amber); color: var(--ink); font-size: 11px; font-weight: 800; display: grid; place-items: center; padding: 0 4px; }
}

/* ─────────────── Print (order sheet) ─────────────── */
@media print {
  .side, .topbar, .tabbar, .no-print, .toasts, .ping, .cart-bar { display: none !important; }
  .main { margin: 0 !important; }
  body { background: #fff; }
  .hero { background: none !important; color: #000; margin: 0; padding: 0 0 10px; }
  .card { box-shadow: none; border-color: #ccc; }
}
.table td.cell-name { min-width: 220px; }
.role-staff { background: #EEF7EE; color: #15803D; }
