/* ==========================================================================
   Western Facilities ERP — "Luxe" skin
   Deep emerald sidebar, parchment surfaces, brass details. Loaded after main.css and
   switched off by theme.js when the user picks the classic skin.
   Display: El Messiri (titles, figures)  ·  Text: IBM Plex Sans Arabic
   ========================================================================== */
@import url('https://fonts.googleapis.com/css2?family=El+Messiri:wght@500;600;700&family=IBM+Plex+Sans+Arabic:wght@400;500;600;700&display=swap');

:root {
  --font-text: 'IBM Plex Sans Arabic', 'Segoe UI', Tahoma, 'Noto Sans Arabic', system-ui, sans-serif;
  --font-display: 'El Messiri', 'IBM Plex Sans Arabic', 'Segoe UI', Tahoma, sans-serif;
  --radius-sm: 10px; --radius-md: 12px; --radius-lg: 16px; --radius-xl: 22px;
  --sidebar-width: 268px; --header-height: 68px;
  --border: rgba(var(--ink-rgb), .12);
  --border-bright: rgba(var(--prim-rgb), .5);
  --bg-glass: rgba(var(--ink-rgb), .035);
  --bg-glass-hover: rgba(var(--ink-rgb), .07);
  --bg-card: var(--paper);
  --primary-glow: rgba(var(--prim-rgb), .22);
  --shadow-card: 0 1px 2px rgba(10, 25, 20, .05), 0 10px 28px -14px rgba(10, 25, 20, .16);
  --ring: 0 0 0 3px rgba(var(--prim-rgb), .22);
  --transition: .18s cubic-bezier(.3, .7, .3, 1);
}
html[data-mode=dark] { --shadow-card: 0 1px 0 rgba(255, 255, 255, .03) inset, 0 14px 30px -16px rgba(0, 0, 0, .7); }

body, .btn, .form-control, .search-box input, .tab, select, textarea, button, input { font-family: var(--font-text); }
body { background: var(--bg-dark); font-feature-settings: 'tnum' 1; letter-spacing: 0; line-height: 1.6; }
h1, h2, h3, .page-head h1, .stat-value, .login h1, .modal-title, .stat-lg { font-family: var(--font-display); }
html[data-bg=plain] body { background: var(--bg-dark); }

/* ---------- sidebar ---------- */
.sidebar {
  background:
    radial-gradient(120% 60% at 100% 0%, rgba(var(--gold-rgb), .13), transparent 60%),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='56' height='56' viewBox='0 0 56 56'%3E%3Cpath d='M28 4l6.2 10.8 12.3-1.3-1.3 12.3L56 28l-10.8 6.2 1.3 12.3-12.3-1.3L28 56l-6.2-10.8-12.3 1.3 1.3-12.3L0 28l10.8-6.2-1.3-12.3 12.3 1.3z' fill='none' stroke='%23d4ab55' stroke-opacity='.055' stroke-width='1'/%3E%3C/svg%3E"),
    var(--bg-side);
  border-left: 0; border-right: 0;
  box-shadow: -1px 0 0 var(--sb-line);
  color: var(--sb-text);
  backdrop-filter: none;
}
body.ltr .sidebar { box-shadow: 1px 0 0 var(--sb-line); }
.sidebar-logo { padding: 22px 20px 18px; border-bottom: 1px solid var(--sb-line); position: relative; }
.sidebar-logo::after { content: ''; position: absolute; inset-inline: 20px; bottom: -1px; height: 1px; background: linear-gradient(90deg, rgba(var(--gold-rgb), .7), transparent 70%); }
.logo-icon { width: 44px; height: 44px; border-radius: 13px; background: linear-gradient(145deg, #e6c37a, var(--gold)); color: #1a1507; box-shadow: 0 6px 16px -6px rgba(var(--gold-rgb), .7), inset 0 1px 0 rgba(255, 255, 255, .45); }
.logo-icon .ico, .logo-icon svg { stroke: #1a1507; }
.logo-text h2 { font-family: var(--font-display); font-size: 16px; font-weight: 700; color: var(--sb-text); letter-spacing: 0; }
.logo-text p { font-size: 11px; color: var(--sb-text2); }
.sidebar-nav { padding: 14px 10px; scrollbar-width: thin; scrollbar-color: var(--sb-line) transparent; }
.nav-section { margin-bottom: 14px; }
.nav-section-title { font-size: 11.5px; font-weight: 600; color: rgba(var(--gold-rgb), 1); letter-spacing: 0; text-transform: none; padding: 6px 14px 5px; opacity: .92; }
html[data-mode=dark] .nav-section-title, html[data-sidedark="0"] .nav-section-title { color: var(--sb-text2); }
.nav-item { color: var(--sb-text2); font-size: 13.5px; font-weight: 500; padding: 9px 14px; margin: 1px 0; border-radius: 10px; border: 1px solid transparent; gap: 11px; }
.nav-item:hover { background: var(--sb-hover); color: var(--sb-text); }
.nav-item.active { background: var(--sb-active); color: var(--sb-text); border: 1px solid transparent; font-weight: 600; box-shadow: none; }
.nav-item.active::before { right: -10px; width: 3px; height: 22px; border-radius: 3px 0 0 3px; background: var(--gold); }
body.ltr .nav-item.active::before { right: auto; left: -10px; border-radius: 0 3px 3px 0; }
.nav-item.active .nav-icon { color: var(--gold); }
.nav-icon { width: 19px; height: 19px; opacity: .9; }
.sidebar-footer { border-top: 1px solid var(--sb-line); padding: 14px 16px; }
.user-name { color: var(--sb-text); font-weight: 600; }
.user-role { color: var(--sb-text2); }
.user-avatar { background: linear-gradient(145deg, #e6c37a, var(--gold)); color: #1a1507; font-family: var(--font-display); font-weight: 700; }
.sidebar .btn-icon { background: var(--sb-hover); border-color: var(--sb-line); color: var(--sb-text2); }
.sidebar .btn-icon:hover { color: var(--gold); border-color: rgba(var(--gold-rgb), .5); background: var(--sb-hover); }

/* ---------- header ---------- */
.top-header { background: rgba(var(--bg-rgb), .86); backdrop-filter: saturate(1.4) blur(14px); border-bottom: 1px solid var(--border); padding: 0 28px; }
html[data-mode=light] .top-header { background: rgba(245, 241, 232, .88); }
.header-title h1 { font-family: var(--font-display); font-size: 17px; font-weight: 700; }
.header-title p { color: var(--text-secondary); font-size: 12px; }
.btn-icon { width: 38px; height: 38px; border-radius: 11px; background: transparent; border: 1px solid transparent; color: var(--text-secondary); }
.btn-icon:hover { background: var(--bg-glass-hover); color: var(--primary); border-color: var(--border); }
.btn-icon[aria-pressed=true] { background: rgba(var(--prim-rgb), .12); color: var(--primary); }
.search-box { background: var(--paper); border-color: var(--border); border-radius: 12px; box-shadow: inset 0 1px 2px rgba(10, 25, 20, .04); }
.search-box:focus-within { border-color: var(--primary); box-shadow: var(--ring); background: var(--paper); }
.today-strip .today-i, .today-i { background: var(--paper); border: 1px solid var(--border); border-radius: 12px; }
.hdr-av { background: linear-gradient(145deg, #e6c37a, var(--gold)); color: #1a1507; font-family: var(--font-display); font-style: normal; }
.hdr-day b { font-weight: 600; color: var(--text-secondary); }
.bell-n { background: var(--gold); color: #1a1507; }

/* ---------- page ---------- */
.page-content { padding: 30px 32px 56px; max-width: 1480px; width: 100%; margin-inline: auto; }
.page-head { margin-bottom: 24px; align-items: flex-end; }
.page-head h1 { font-size: 27px; font-weight: 700; letter-spacing: 0; line-height: 1.25; position: relative; padding-top: 14px; }
.page-head h1::before { content: ''; position: absolute; top: 0; inset-inline-start: 0; width: 34px; height: 3px; border-radius: 3px; background: var(--gold); }
.page-head p { color: var(--text-secondary); font-size: 14px; margin-top: 4px; max-width: 70ch; }

/* ---------- cards & stats ---------- */
.card { background: var(--paper); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-card); backdrop-filter: none; }
.card:hover { border-color: var(--border); }
.card-header { padding: 16px 22px; border-bottom: 1px solid var(--border); }
.card-title { font-family: var(--font-display); font-size: 16px; font-weight: 700; }
.card-body { padding: 22px; }
.stats-grid { gap: 16px; }
.stat-card { background: var(--paper); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-card); padding: 20px 22px; }
.stat-card::before { display: none; }
.stat-card:hover { transform: none; border-color: var(--border); box-shadow: var(--shadow-card); }
.stat-icon { width: 40px; height: 40px; border-radius: 12px; margin-bottom: 16px; }
.stat-icon.blue { background: rgba(var(--prim-rgb), .11); color: var(--primary); }
.stat-icon.orange { background: rgba(var(--gold-rgb), .16); color: var(--gold); }
.stat-value { font-size: 27px; font-weight: 700; letter-spacing: -.3px; line-height: 1.2; }
.stat-label { font-size: 13px; color: var(--text-secondary); font-weight: 500; margin-top: 2px; }
.stat-trend { font-size: 12px; font-weight: 600; }

/* ---------- buttons ---------- */
.btn { border-radius: 11px; padding: 0 20px; height: 42px; font-size: 14px; font-weight: 600; letter-spacing: 0; transition: background var(--transition), border-color var(--transition), box-shadow var(--transition), transform .12s; }
.btn:active { transform: translateY(1px); }
.btn-sm { height: 34px; padding: 0 14px; font-size: 12.5px; }
.btn-lg { height: 50px; font-size: 15.5px; border-radius: 13px; }
.btn-primary { background: var(--primary); color: var(--on-primary); box-shadow: 0 1px 0 rgba(255, 255, 255, .18) inset, 0 8px 18px -8px rgba(var(--prim-rgb), .7); }
.btn-primary:hover { background: var(--primary-dark); transform: none; box-shadow: 0 1px 0 rgba(255, 255, 255, .18) inset, 0 10px 22px -8px rgba(var(--prim-rgb), .8); }
.btn-outline { color: var(--primary); border: 1px solid rgba(var(--prim-rgb), .55); background: transparent; }
.btn-outline:hover { background: rgba(var(--prim-rgb), .08); }
.btn-ghost { background: var(--paper); border: 1px solid var(--border); color: var(--text-primary); }
.btn-ghost:hover { background: var(--paper-2); border-color: rgba(var(--ink-rgb), .2); color: var(--text-primary); }
.btn-danger { background: var(--danger); color: #fff; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.btn:focus-visible, .nav-item:focus-visible { outline-offset: 2px; }

/* ---------- forms ---------- */
.form-label { font-size: 13px; font-weight: 600; color: var(--text-secondary); margin-bottom: 6px; }
.form-control { height: 44px; background: var(--paper); border: 1px solid var(--border); border-radius: 11px; color: var(--text-primary); font-size: 14px; padding: 0 14px; box-shadow: inset 0 1px 2px rgba(10, 25, 20, .04); transition: border-color var(--transition), box-shadow var(--transition); }
textarea.form-control { height: auto; padding: 11px 14px; }
.form-control:hover { border-color: rgba(var(--ink-rgb), .22); }
.form-control:focus { border-color: var(--primary); box-shadow: var(--ring); outline: none; background: var(--paper); }
.form-control::placeholder { color: var(--text-muted); }
html[data-mode=dark] .form-control { background: rgba(0, 0, 0, .22); }
input[type=checkbox], input[type=radio] { accent-color: var(--primary); }

/* ---------- tables ---------- */
.table-wrapper { scrollbar-width: thin; }
table { font-size: 13.5px; }
thead th { background: var(--paper-2); color: var(--text-secondary); font-weight: 600; font-size: 12.5px; letter-spacing: 0; padding: 12px 16px; border-bottom: 1px solid var(--border); }
tbody tr { border-bottom: 1px solid var(--border); }
tbody tr:last-child { border-bottom: 0; }
tbody tr:hover { background: rgba(var(--prim-rgb), .045); }
tbody td { padding: 13px 16px; }
td.num, th.num, .num { font-variant-numeric: tabular-nums; }
td a { color: var(--primary); font-weight: 600; text-decoration: none; }
td a:hover { text-decoration: underline; }
.rx-total td { background: var(--paper-2); border-top: 1px solid var(--border-bright); }

/* ---------- badges, tabs, chips ---------- */
.badge { border-radius: 999px; padding: 3px 11px; font-size: 12px; font-weight: 600; }
.badge-success { background: rgba(0, 135, 108, .12); color: var(--success); }
.badge-warning { background: rgba(var(--gold-rgb), .17); color: var(--warning); }
.badge-danger { background: rgba(196, 65, 42, .11); color: var(--danger); }
.badge-info, .badge-primary { background: rgba(var(--prim-rgb), .11); color: var(--primary); }
html[data-mode=dark] .badge-success { background: rgba(47, 191, 148, .14); }
.tab { background: transparent; border: 1px solid transparent; color: var(--text-secondary); border-radius: 999px; padding: 8px 18px; font-weight: 600; font-size: 13.5px; }
.tab:hover { background: var(--bg-glass-hover); color: var(--text-primary); }
.tab.active { background: var(--primary); border-color: var(--primary); color: var(--on-primary); box-shadow: 0 6px 14px -8px rgba(var(--prim-rgb), .8); }
.chip, .range-tabs button { border-radius: 999px; }
.filters .card-body, .filters { background: var(--paper); }

/* ---------- modal ---------- */
.overlay { background: rgba(6, 22, 18, .55); backdrop-filter: blur(5px); }
.t-modal { background: var(--paper); border: 1px solid var(--border); border-radius: 20px; box-shadow: 0 30px 80px -20px rgba(0, 0, 0, .55); }
.modal-header { border-bottom: 1px solid var(--border); padding: 18px 24px; }
.modal-title { font-size: 18px; font-weight: 700; }
.modal-footer { border-top: 1px solid var(--border); background: var(--paper-2); }
.modal-close { border-radius: 10px; }
.toast { background: var(--paper); border: 1px solid var(--border); border-radius: 14px; box-shadow: 0 18px 40px -16px rgba(0, 0, 0, .4); color: var(--text-primary); }

/* ---------- misc components ---------- */
.hub-card, .nt-card { background: var(--paper); border: 1px solid var(--border); box-shadow: var(--shadow-card); }
.hub-card:hover { border-color: rgba(var(--gold-rgb), .7); background: var(--paper); transform: translateY(-2px); }
.hub-ico { background: rgba(var(--prim-rgb), .1); color: var(--primary); border-radius: 13px; }
.hub-card b { font-family: var(--font-display); font-size: 16px; }
.nt-card[open] { border-color: rgba(var(--gold-rgb), .7); }
.empty-state { color: var(--text-secondary); }
.calc-panel { background: var(--paper); border: 1px solid var(--border); border-radius: 22px; box-shadow: 0 30px 70px -20px rgba(0, 0, 0, .5); }
.calc-screen { background: var(--paper-2); }
.calc-input { font-family: var(--font-display); }
.calc-keys button { background: var(--paper); border-color: var(--border); }
.calc-keys button:hover { background: var(--paper-2); }
.calc-keys .k-op { color: var(--primary); }
.calc-keys .k-eq { background: var(--primary); border-color: var(--primary); }
.calc-vat button { background: rgba(var(--gold-rgb), .12); border-color: rgba(var(--gold-rgb), .4); color: var(--text-primary); }
.rt-editor { border-radius: 14px; }
.sheet, .sheet * { font-family: var(--font-text); }
.sheet { box-shadow: 0 20px 50px -24px rgba(0, 0, 0, .45); }

/* ---------- login ---------- */
body.login-page { display: grid; align-items: stretch; justify-content: stretch; grid-template-columns: minmax(0, 1.05fr) minmax(0, .95fr); padding: 0; min-height: 100vh; background: var(--bg-dark); }
.login-brand { min-height: 100vh; position: relative; display: flex; flex-direction: column; justify-content: space-between; padding: 54px 56px; color: #f4f0e4; overflow: hidden;
  background: radial-gradient(90% 70% at 100% 0%, rgba(212, 171, 85, .22), transparent 60%), radial-gradient(80% 60% at 0% 100%, rgba(13, 122, 95, .5), transparent 65%), #0a2823; }
.login-brand::before { content: ''; position: absolute; inset: 0; opacity: .9; background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='84' height='84' viewBox='0 0 56 56'%3E%3Cpath d='M28 4l6.2 10.8 12.3-1.3-1.3 12.3L56 28l-10.8 6.2 1.3 12.3-12.3-1.3L28 56l-6.2-10.8-12.3 1.3 1.3-12.3L0 28l10.8-6.2-1.3-12.3 12.3 1.3z' fill='none' stroke='%23d4ab55' stroke-opacity='.13' stroke-width='.8'/%3E%3C/svg%3E"); }
.login-brand > * { position: relative; }
.login-brand .bm { display: flex; align-items: center; gap: 14px; }
.login-brand .bm i { width: 52px; height: 52px; border-radius: 15px; display: grid; place-items: center; background: linear-gradient(145deg, #e6c37a, #b58a3c); color: #1a1507; font-style: normal; }
.login-brand .bm svg { width: 28px; height: 28px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.login-brand .bm b { font-family: var(--font-display); font-size: 20px; font-weight: 700; }
.login-brand h2 { font-family: var(--font-display); font-size: clamp(34px, 4.2vw, 58px); font-weight: 700; line-height: 1.15; max-width: 14ch; margin: 0; }
.login-brand p { color: rgba(244, 240, 228, .72); font-size: 16px; max-width: 42ch; margin: 18px 0 0; }
.login-brand small { color: rgba(244, 240, 228, .5); font-size: 12.5px; }
.login-pane { display: flex; align-items: center; justify-content: center; padding: 32px 24px; }
.login { background: transparent !important; border: 0 !important; box-shadow: none !important; padding: 0 !important; max-width: 400px !important; }
.login-mark { display: none !important; }
.login h1 { text-align: start !important; font-size: 28px !important; }
.login .en { text-align: start !important; }
@media (max-width: 900px) { body.login-page { grid-template-columns: 1fr; } .login-brand { display: none; } }

/* ---------- print: never colour the paper ---------- */
@media print {
  body, html { background: #fff !important; }
  .card, .stat-card { box-shadow: none !important; }
  .page-head h1::before { display: none; }
}

/* ---------- phones ---------- */
@media (max-width: 900px) {
  .page-content { padding: 20px 14px 48px; }
  .page-head h1 { font-size: 22px; }
  .top-header { padding: 0 14px; }
  .btn { height: 44px; }
  .stat-value { font-size: 20px; letter-spacing: -.4px; }
  .stat-card { padding: 16px; }
  .stat-icon { width: 34px; height: 34px; margin-bottom: 10px; }
  .stat-label { font-size: 12px; }
}
@media (prefers-reduced-motion: reduce) { * { transition-duration: .01ms !important; animation-duration: .01ms !important; scroll-behavior: auto !important; } }

/* ===== 3.6.0 — phone sidebar: close button, scrim, true viewport height; header avatar; calmer stat tiles ===== */
.side-scrim { display: none; }
.side-close { display: none; }
@media (max-width: 768px) {
  .sidebar { top: 0; bottom: auto; height: 100vh; height: var(--sbh, 100dvh); max-height: 100vh; width: min(86vw, 320px); z-index: 1100; overscroll-behavior: contain; will-change: transform; }
  .sidebar-nav { overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
  .side-scrim { display: block; position: fixed; top: 0; left: 0; right: 0; bottom: 0; height: 100lvh; background: rgba(6, 22, 18, .52); opacity: 0; visibility: hidden; transition: opacity .22s ease, visibility .22s; z-index: 1050; }
  .side-scrim.on { opacity: 1; visibility: visible; }
  .side-close { display: inline-flex; position: absolute; top: 14px; inset-inline-start: 12px; z-index: 2; width: 38px; height: 38px; border-radius: 12px; background: var(--sb-hover); border: 1px solid var(--sb-line); color: var(--sb-text2); }
  .side-close .ico { width: 20px; height: 20px; }
  .side-close:hover, .side-close:focus-visible { color: var(--gold); border-color: rgba(var(--gold-rgb), .55); }
  html.side-open, html.side-open body { overflow: hidden; touch-action: none; }
  html.side-open .sidebar { touch-action: pan-y; }
  .sidebar-logo { padding-inline-start: 60px; }
  .hdr-user { display: none; }
}
/* the version tag lives in the page corner without covering cards */
.wf-ver { position: fixed; bottom: 6px; inset-inline-start: 10px; font: 11px/1 monospace; opacity: .4; z-index: 5; pointer-events: none; }
@media (max-width: 768px) { .wf-ver { display: none; } }
.hdr-user { overflow: visible; }
.hdr-av { flex: none; }

/* stat tiles: separated, airy, one accent line */
.stats-grid { gap: 14px; }
.stat-card { position: relative; overflow: hidden; padding: 18px 18px 16px; border-radius: 18px; background: var(--paper); border: 1px solid var(--border); box-shadow: 0 1px 0 rgba(var(--ink-rgb, 20, 32, 51), .03), 0 10px 24px -18px rgba(var(--ink-rgb, 20, 32, 51), .35); }
.stat-card .stat-icon { margin-bottom: 12px; }
.stat-card .stat-value { font-variant-numeric: tabular-nums; }
.stat-card .stat-label { margin-top: 4px; }
@media (max-width: 720px) {
  .stats-grid, .stats-grid.six { gap: 10px; }
  .stat-card { padding: 14px 14px 12px; border-radius: 16px; }
  .stat-card .stat-icon { width: 34px; height: 34px; margin-bottom: 8px; }
  .stat-card .stat-value { font-size: clamp(14px, 4.15vw, 19px); letter-spacing: -.3px; text-overflow: clip; }
}
.side-ver { margin-top: 10px; font: 11px/1 monospace; color: var(--sb-text2); opacity: .55; text-align: center; }

/* "today" strip: four separate tiles instead of one boxed table */
.today { gap: 12px; border: 0; background: transparent; border-radius: 0; overflow: visible; margin-bottom: 18px; }
.today .today-i, .today .today-i:nth-child(n) { position: relative; padding: 14px 16px 13px; gap: 8px; background: var(--paper); border: 1px solid var(--border); border-radius: 16px; box-shadow: 0 10px 24px -20px rgba(var(--ink-rgb, 20, 32, 51), .45); }
.today .today-i span { display: flex; align-items: center; gap: 8px; font-size: 12.5px; font-weight: 600; color: var(--text-secondary); }
.today .today-i span::before { content: ''; flex: none; width: 9px; height: 9px; border-radius: 50%; background: var(--dot, var(--primary)); box-shadow: 0 0 0 4px color-mix(in srgb, var(--dot, var(--primary)) 16%, transparent); }
.today .today-i:nth-child(1) { --dot: var(--primary); }
.today .today-i:nth-child(2) { --dot: var(--gold); }
.today .today-i:nth-child(3) { --dot: #4a78a6; }
.today .today-i:nth-child(4) { --dot: #b4533d; }
.today .today-i b { font-size: 21px; font-weight: 800; letter-spacing: -.2px; }
@media (max-width: 720px) { .today { gap: 10px; } .today .today-i, .today .today-i:nth-child(n) { padding: 12px 13px 11px; border-radius: 14px; } .today .today-i b { font-size: 17px; } }
