/* ========================================
   Western Facilities ERP - Luxury Dark Theme
   Sky Blue #00b4d8 + Dark Navy #0d1b2a
   ======================================== */

@import url('https://fonts.googleapis.com/css2?family=Cairo:wght@300;400;500;600;700;900&family=Tajawal:wght@300;400;500;700&family=Noto+Sans+Arabic:wght@400;600;700;800&display=swap');

:root {
  --primary: #00b4d8;
  --primary-light: #48cae4;
  --primary-dark: #0096b3;
  --primary-glow: rgba(var(--prim-rgb), 0.3);
  --accent: #90e0ef;
  --bg-deep: #060d14;
  --bg-dark: #0d1b2a;
  --bg-card: rgba(var(--bg-rgb), 0.8);
  --bg-glass: rgba(var(--prim-rgb), 0.05);
  --bg-glass-hover: rgba(var(--prim-rgb), 0.1);
  --border: rgba(var(--prim-rgb), 0.15);
  --border-bright: rgba(var(--prim-rgb), 0.4);
  --text-primary: #e8f4f8;
  --text-secondary: rgba(232, 244, 248, 0.6);
  --text-muted: rgba(232, 244, 248, 0.35);
  --success: #00b894;
  --success-light: rgba(0, 184, 148, 0.15);
  --warning: #fdcb6e;
  --warning-light: rgba(253, 203, 110, 0.15);
  --danger: #e17055;
  --danger-light: rgba(225, 112, 85, 0.15);
  --info: #74b9ff;
  --shadow-sm: 0 2px 10px rgba(0,0,0,0.3);
  --shadow-md: 0 4px 20px rgba(0,0,0,0.4);
  --shadow-lg: 0 8px 40px rgba(0,0,0,0.5);
  --shadow-glow: 0 0 20px var(--primary-glow);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --sidebar-width: 260px;
  --header-height: 64px;
  --transition: background-color .2s ease, border-color .2s ease, color .2s ease, box-shadow .2s ease, opacity .2s ease, transform .2s cubic-bezier(0.22, 1, 0.36, 1);
}

* {
  margin: 0; padding: 0;
  box-sizing: border-box;
}

html {
  direction: rtl;
  scroll-behavior: smooth;
}

body {
  font-family: 'Cairo', 'Tajawal', sans-serif;
  background: var(--bg-deep);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

body.ltr { direction: ltr; font-family: 'Cairo', sans-serif; }

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg-dark); }
::-webkit-scrollbar-thumb { background: var(--border-bright); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--primary); }

/* ===== LAYOUT ===== */
.app-layout {
  display: flex;
  min-height: 100vh;
}

/* ===== SIDEBAR ===== */
.sidebar {
  width: var(--sidebar-width);
  background: linear-gradient(180deg, var(--bg-side) 0%, var(--bg-dark) 100%);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; bottom: 0; right: 0;
  z-index: 1000;
  transition: var(--transition);
  backdrop-filter: blur(20px);
}

body.ltr .sidebar { right: auto; left: 0; border-left: none; border-right: 1px solid var(--border); }

.sidebar-logo {
  padding: 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo-icon {
  width: 42px; height: 42px;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
  box-shadow: var(--shadow-glow);
}

.logo-text h2 { font-size: 13px; font-weight: 700; color: var(--primary); }
.logo-text p { font-size: 10px; color: var(--text-muted); }

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

.nav-section {
  margin-bottom: 8px;
}

.nav-section-title {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 1.5px;
  text-transform: uppercase;
  padding: 8px 20px 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 20px;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  border-radius: var(--radius-sm);
  margin: 1px 8px;
  transition: var(--transition);
  position: relative;
  cursor: pointer;
}

.nav-item:hover {
  background: var(--bg-glass-hover);
  color: var(--text-primary);
}

.nav-item.active {
  background: linear-gradient(135deg, rgba(var(--prim-rgb),0.2), rgba(0,150,179,0.1));
  color: var(--primary);
  border: 1px solid var(--border);
}

.nav-item.active::before {
  content: '';
  position: absolute;
  right: 0; top: 50%;
  transform: translateY(-50%);
  width: 3px; height: 24px;
  background: var(--primary);
  border-radius: 2px 0 0 2px;
}

body.ltr .nav-item.active::before { right: auto; left: 0; border-radius: 0 2px 2px 0; }

.nav-icon { width: 20px; height: 20px; flex-shrink: 0; }

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--border);
}

.user-info {
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 12px;
}

.user-avatar {
  width: 36px; height: 36px;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 700;
  color: var(--on-primary);
  flex-shrink: 0;
}

.user-name { font-size: 13px; font-weight: 600; }
.user-role { font-size: 11px; color: var(--text-muted); }

.sidebar-actions {
  display: flex; gap: 8px;
}

.btn-icon {
  width: 32px; height: 32px;
  background: var(--bg-glass);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  color: var(--text-secondary);
  cursor: pointer;
  transition: var(--transition);
  text-decoration: none;
}

.btn-icon:hover { background: var(--bg-glass-hover); color: var(--primary); border-color: var(--border-bright); }

/* ===== MAIN CONTENT ===== */
.main-content {
  flex: 1;
  margin-right: var(--sidebar-width);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

body.ltr .main-content { margin-right: 0; margin-left: var(--sidebar-width); }

/* ===== HEADER ===== */
.top-header {
  height: var(--header-height);
  background: rgba(var(--bg-rgb), 0.9);
  backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-title h1 { font-size: 18px; font-weight: 700; }
.header-title p { font-size: 12px; color: var(--text-muted); }

.header-actions { display: flex; align-items: center; gap: 12px; }

.search-box {
  display: flex; align-items: center; gap: 8px;
  background: var(--bg-glass);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 8px 14px;
  min-width: 220px;
  transition: var(--transition);
}

.search-box:focus-within { border-color: var(--primary); background: var(--bg-glass-hover); }
.search-box input { background: none; border: none; outline: none; color: var(--text-primary); font-size: 13px; font-family: 'Cairo', sans-serif; flex: 1; }
.search-box input::placeholder { color: var(--text-muted); }

/* ===== PAGE CONTENT ===== */
.page-content {
  flex: 1;
  padding: 24px;
}

/* ===== CARDS ===== */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  backdrop-filter: blur(20px);
  overflow: hidden;
  transition: var(--transition);
}

.card:hover { border-color: var(--border-bright); }

.card-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

.card-title { font-size: 15px; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.card-body { padding: 20px; }

/* ===== STAT CARDS ===== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  position: relative;
  overflow: hidden;
  transition: var(--transition);
  cursor: default;
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--primary), transparent);
}

.stat-card:hover { transform: translateY(-2px); border-color: var(--border-bright); box-shadow: var(--shadow-md); }

.stat-icon {
  width: 44px; height: 44px;
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 14px;
}

.stat-icon.blue { background: rgba(var(--prim-rgb),0.15); color: var(--primary); }
.stat-icon.green { background: var(--success-light); color: var(--success); }
.stat-icon.orange { background: var(--warning-light); color: var(--warning); }
.stat-icon.red { background: var(--danger-light); color: var(--danger); }

.stat-value { font-size: 24px; font-weight: 900; margin-bottom: 4px; letter-spacing: -1px; }
.stat-label { font-size: 12px; color: var(--text-muted); font-weight: 500; }

.stat-trend {
  display: flex; align-items: center; gap: 4px;
  font-size: 12px;
  margin-top: 8px;
  font-weight: 600;
}

.trend-up { color: var(--success); }
.trend-down { color: var(--danger); }

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-family: 'Cairo', sans-serif;
  font-size: 14px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: var(--transition);
  text-decoration: none;
  white-space: nowrap;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: var(--on-primary);
  box-shadow: 0 4px 15px var(--primary-glow);
}

.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 6px 20px var(--primary-glow); }

.btn-outline {
  background: transparent;
  color: var(--primary);
  border: 1px solid var(--primary);
}

.btn-outline:hover { background: rgba(var(--prim-rgb),0.1); }

.btn-ghost {
  background: var(--bg-glass);
  color: var(--text-secondary);
  border: 1px solid var(--border);
}

.btn-ghost:hover { background: var(--bg-glass-hover); color: var(--text-primary); }

.btn-danger { background: var(--danger); color: white; }
.btn-sm { padding: 6px 14px; font-size: 12px; }
.btn-lg { padding: 14px 28px; font-size: 16px; }

/* ===== TABLES ===== */
.table-wrapper {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

thead th {
  background: rgba(var(--prim-rgb),0.08);
  color: var(--primary);
  font-weight: 700;
  padding: 12px 16px;
  text-align: right;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  font-size: 12px;
  letter-spacing: 0.5px;
}

body.ltr thead th { text-align: left; }

tbody tr {
  border-bottom: 1px solid rgba(var(--prim-rgb),0.05);
  transition: var(--transition);
}

tbody tr:hover { background: var(--bg-glass); }

tbody td { padding: 12px 16px; vertical-align: middle; }

.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
}

.badge-success { background: var(--success-light); color: var(--success); }
.badge-warning { background: var(--warning-light); color: var(--warning); }
.badge-danger { background: var(--danger-light); color: var(--danger); }
.badge-info { background: rgba(116,185,255,0.15); color: var(--info); }
.badge-primary { background: rgba(var(--prim-rgb),0.15); color: var(--primary); }

/* ===== FORMS ===== */
.form-group { margin-bottom: 16px; }

.form-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.form-control {
  width: 100%;
  background: rgba(var(--bg-rgb),0.6);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  padding: 10px 14px;
  font-family: 'Cairo', sans-serif;
  font-size: 14px;
  transition: var(--transition);
  -webkit-appearance: none;
}

.form-control:focus {
  outline: none;
  border-color: var(--primary);
  background: rgba(var(--prim-rgb),0.05);
  box-shadow: 0 0 0 3px rgba(var(--prim-rgb),0.1);
}

.form-control::placeholder { color: var(--text-muted); }

select.form-control { cursor: pointer; }

textarea.form-control { resize: vertical; min-height: 80px; }

/* ===== UPLOAD BOXES ===== */
.upload-boxes {
  display: flex; gap: 12px; flex-wrap: wrap;
  margin-top: 8px;
}

.upload-box {
  flex: 1; min-width: 140px;
  background: var(--bg-glass);
  border: 1.5px dashed var(--border);
  border-radius: var(--radius-md);
  padding: 16px 12px;
  text-align: center;
  cursor: pointer;
  transition: var(--transition);
  position: relative;
  overflow: hidden;
}

.upload-box:hover, .upload-box.drag-over {
  border-color: var(--primary);
  background: rgba(var(--prim-rgb),0.08);
  transform: translateY(-2px);
  box-shadow: var(--shadow-sm), 0 0 0 1px var(--primary-glow);
}

.upload-box input[type="file"] {
  position: absolute; inset: 0;
  opacity: 0; cursor: pointer;
  width: 100%; height: 100%;
}

.upload-box-icon {
  font-size: 28px;
  margin-bottom: 8px;
  display: block;
  transition: transform 0.3s ease;
}

.upload-box:hover .upload-box-icon { transform: scale(1.2); }

.upload-box-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 4px;
}

.upload-box-hint {
  font-size: 10px;
  color: var(--text-muted);
}

.upload-box.has-file {
  border-style: solid;
  border-color: var(--success);
  background: var(--success-light);
}

.upload-box.has-file .upload-box-label { color: var(--success); }

/* Date picker box */
.date-box {
  flex: 1; min-width: 140px;
  background: var(--bg-glass);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px;
  transition: var(--transition);
  position: relative;
}

.date-box:focus-within {
  border-color: var(--primary);
  background: rgba(var(--prim-rgb),0.05);
  box-shadow: 0 0 0 3px rgba(var(--prim-rgb),0.1);
}

.date-box label {
  font-size: 11px;
  font-weight: 700;
  color: var(--primary);
  display: block;
  margin-bottom: 4px;
}

.date-box input[type="date"] {
  background: none;
  border: none;
  outline: none;
  color: var(--text-primary);
  font-family: 'Cairo', sans-serif;
  font-size: 14px;
  font-weight: 600;
  width: 100%;
  cursor: pointer;
}

/* ===== MODALS ===== */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(6,13,20,0.85);
  backdrop-filter: blur(8px);
  z-index: 2000;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  opacity: 0; visibility: hidden;
  transition: var(--transition);
}

.modal-overlay.active { opacity: 1; visibility: visible; }

.modal {
  background: var(--bg-dark);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  width: 100%; max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
  transform: scale(0.95) translateY(20px);
  transition: var(--transition);
  box-shadow: var(--shadow-lg);
}

.modal-overlay.active .modal { transform: scale(1) translateY(0); }

.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0;
  background: var(--bg-dark);
  z-index: 1;
}

.modal-title { font-size: 16px; font-weight: 700; }

.modal-close {
  width: 32px; height: 32px;
  background: var(--bg-glass);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  color: var(--text-secondary);
  transition: var(--transition);
  font-size: 18px;
}

.modal-close:hover { background: var(--danger-light); color: var(--danger); border-color: var(--danger); }

.modal-body { padding: 24px; }

.modal-footer {
  display: flex; gap: 10px; justify-content: flex-end;
  padding: 16px 24px;
  border-top: 1px solid var(--border);
}

/* ===== ALERTS / TOAST ===== */
.toast-container {
  position: fixed;
  bottom: 24px; left: 24px;
  z-index: 9999;
  display: flex; flex-direction: column; gap: 10px;
}

body.ltr .toast-container { left: auto; right: 24px; }

.toast {
  display: flex; align-items: center; gap: 12px;
  background: var(--bg-dark);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px 18px;
  min-width: 280px; max-width: 380px;
  box-shadow: var(--shadow-lg);
  animation: slideInUp 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
  backdrop-filter: blur(20px);
}

@keyframes slideInUp {
  from { transform: translateY(60px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.toast.toast-success { border-color: var(--success); }
.toast.toast-error { border-color: var(--danger); }
.toast.toast-warning { border-color: var(--warning); }

.toast-icon { font-size: 20px; flex-shrink: 0; }
.toast-message { font-size: 13px; font-weight: 500; flex: 1; }
.toast-close { cursor: pointer; color: var(--text-muted); font-size: 16px; flex-shrink: 0; }

/* ===== PAGINATION ===== */
.pagination {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px;
  border-top: 1px solid var(--border);
  font-size: 13px;
}

.page-info { color: var(--text-muted); }

.page-btns { display: flex; gap: 6px; }

.page-btn {
  width: 32px; height: 32px;
  border: 1px solid var(--border);
  background: var(--bg-glass);
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  color: var(--text-secondary);
  transition: var(--transition);
  font-size: 12px;
}

.page-btn:hover, .page-btn.active {
  background: var(--primary);
  color: var(--on-primary);
  border-color: var(--primary);
}

/* ===== GRIDS ===== */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }

@media (max-width: 768px) {
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .sidebar { transform: translateX(100%); }
  body.ltr .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-right: 0; margin-left: 0; }
}

/* ===== UTILITY ===== */
.flex { display: flex; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.gap-16 { gap: 16px; }
.mb-16 { margin-bottom: 16px; }
.mb-24 { margin-bottom: 24px; }
.mt-16 { margin-top: 16px; }
.text-primary { color: var(--primary); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-warning { color: var(--warning); }
.text-muted { color: var(--text-muted); }
.text-sm { font-size: 12px; }
.text-lg { font-size: 18px; }
.fw-700 { font-weight: 700; }
.fw-900 { font-weight: 900; }

/* ===== LOADING ===== */
.loading-spinner {
  width: 40px; height: 40px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 40px auto;
}

@keyframes spin { to { transform: rotate(360deg); } }

.skeleton {
  background: linear-gradient(90deg, var(--border) 25%, rgba(var(--prim-rgb),0.08) 50%, var(--border) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius-sm);
}

@keyframes shimmer { to { background-position: -200% 0; } }

/* ===== EMPTY STATE ===== */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}

.empty-state svg, .empty-state .empty-icon { margin: 0 auto 16px; opacity: 0.4; }
.empty-state h3 { font-size: 16px; margin-bottom: 8px; color: var(--text-secondary); }
.empty-state p { font-size: 13px; }

/* ===== LANG SWITCHER ===== */
.lang-btn {
  background: var(--bg-glass);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: var(--transition);
  font-family: 'Cairo', sans-serif;
}

.lang-btn:hover { border-color: var(--primary); color: var(--primary); }

/* ===== BACKGROUND GRID ===== */
body::before { content:''; position:fixed; inset:0; pointer-events:none; z-index:-1; }

/* ===== v2 additions ===== */
:root { --c1:#0098b8; --c2:#cc7f3c; --c3:#7584e8; }
.hidden { display:none !important; }
.ico { width:18px; height:18px; flex-shrink:0; stroke:currentColor; fill:none; stroke-width:2; stroke-linecap:round; stroke-linejoin:round; }
.menu-btn { display:none; }
.page-head { display:flex; align-items:center; justify-content:space-between; gap:12px; flex-wrap:wrap; margin-bottom:20px; }
.page-head h1 { font-size:22px; font-weight:800; }
.page-head p { font-size:13px; color:var(--text-muted); }
.filters { display:flex; gap:10px; flex-wrap:wrap; align-items:flex-end; padding:16px; }
.filters .form-group { margin:0; flex:1; min-width:140px; }
.chips { display:flex; gap:10px; flex-wrap:wrap; padding:0 16px 16px; }
.chip { background:var(--bg-glass); border:1px solid var(--border); border-radius:20px; padding:5px 14px; font-size:12px; color:var(--text-secondary); }
.chip b { color:var(--text-primary); margin-inline-start:6px; font-variant-numeric:tabular-nums; }
td.num, th.num { text-align:left; font-variant-numeric:tabular-nums; white-space:nowrap; direction:ltr; }
body.ltr td.num, body.ltr th.num { text-align:right; }
tr.clickable { cursor:pointer; }
td.note { max-width:320px; color:var(--text-secondary); font-size:12px; }
.stat-trend.flat { color:var(--text-muted); }
.stat-card .stat-value { font-size:22px; font-variant-numeric:tabular-nums; direction:ltr; text-align:right; }
body.ltr .stat-card .stat-value { text-align:left; }
.dash-grid { display:grid; grid-template-columns:2fr 1fr; gap:20px; margin-bottom:20px; }
.dash-grid.even { grid-template-columns:1fr 1fr; }
@media (max-width:980px){ .dash-grid, .dash-grid.even { grid-template-columns:1fr; } }
.legend { display:flex; gap:16px; font-size:12px; color:var(--text-secondary); }
.legend i { display:inline-block; width:10px; height:10px; border-radius:3px; margin-inline-end:6px; }
.chart { position:relative; }
.chart svg { display:block; width:100%; height:auto; overflow:visible; }
.chart-tip { position:absolute; pointer-events:none; background:#06111c; border:1px solid var(--border-bright); border-radius:8px; padding:8px 12px; font-size:12px; white-space:nowrap; box-shadow:var(--shadow-md); z-index:5; direction:rtl; }
.chart-tip b { font-variant-numeric:tabular-nums; }
.bar-row { display:grid; grid-template-columns:minmax(90px,38%) 1fr auto; gap:10px; align-items:center; padding:7px 0; font-size:13px; }
.bar-row .bar-name { overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.bar-track { height:10px; background:rgba(var(--ink-rgb),.06); border-radius:5px; overflow:hidden; }
.bar-fill { height:100%; border-radius:5px; background:var(--c1); transition:width .6s ease; }
.bar-row .bar-val { font-variant-numeric:tabular-nums; color:var(--text-secondary); font-size:12px; direction:ltr; }
.bar-row:hover .bar-fill { filter:brightness(1.25); }
.modal.wide { max-width:860px; }
.kv { display:grid; grid-template-columns:140px 1fr; gap:8px 14px; font-size:14px; }
.kv dt { color:var(--text-muted); font-size:12px; padding-top:2px; }
.kv dd { word-break:break-word; }
.note-box { background:var(--bg-glass); border:1px solid var(--border); border-radius:8px; padding:12px 14px; font-size:14px; line-height:1.8; white-space:pre-wrap; }
.line-table input, .line-table select { min-width:70px; }
.line-table td { padding:6px 8px; }
.totals-box { margin-inline-start:auto; width:300px; max-width:100%; font-size:14px; }
.totals-box div { display:flex; justify-content:space-between; padding:6px 0; border-bottom:1px dashed var(--border); }
.totals-box .grand { font-size:18px; font-weight:800; color:var(--primary); border-bottom:none; }
.banner { background:var(--warning-light); border:1px solid var(--warning); color:var(--warning); border-radius:10px; padding:10px 14px; font-size:13px; margin-bottom:16px; }
.tabs { display:flex; gap:6px; margin-bottom:16px; flex-wrap:wrap; }
.tab { background:var(--bg-glass); border:1px solid var(--border); color:var(--text-secondary); padding:7px 16px; border-radius:20px; font-family:inherit; font-size:13px; font-weight:600; cursor:pointer; }
.tab.active { background:var(--primary); border-color:var(--primary); color:var(--on-primary); }

/* upload tiles */
.upload-boxes { display:grid; grid-template-columns:repeat(3,1fr); gap:14px; }
@media (max-width:700px){ .upload-boxes { grid-template-columns:1fr; } }
.up-tile { position:relative; min-height:132px; border-radius:16px; padding:16px 12px; text-align:center; cursor:pointer; overflow:hidden; display:flex; flex-direction:column; align-items:center; justify-content:center; gap:6px;
  background:linear-gradient(160deg, rgba(var(--prim-rgb),.10), rgba(var(--bg-rgb),.6)); border:1.5px dashed var(--border-bright); transition:transform .25s cubic-bezier(.34,1.56,.64,1), box-shadow .25s, border-color .25s, background .25s; }
.up-tile::after { content:''; position:absolute; inset:0; background:radial-gradient(circle at 50% 0%, rgba(var(--prim-rgb),.25), transparent 60%); opacity:0; transition:opacity .3s; pointer-events:none; }
.up-tile:hover, .up-tile:focus-within { transform:translateY(-4px); border-color:var(--primary); box-shadow:0 10px 30px rgba(var(--prim-rgb),.18); }
.up-tile:hover::after, .up-tile.drag::after { opacity:1; }
.up-tile:active { transform:scale(.97); }
.up-tile.drag { border-style:solid; border-color:var(--primary-light); transform:scale(1.03); box-shadow:0 0 0 4px rgba(var(--prim-rgb),.2); }
.up-tile input[type=file], .up-tile input[type=date] { position:absolute; inset:0; width:100%; height:100%; opacity:0; cursor:pointer; }
.up-ico { width:46px; height:46px; border-radius:14px; display:flex; align-items:center; justify-content:center; background:rgba(var(--prim-rgb),.15); color:var(--primary); transition:transform .3s cubic-bezier(.34,1.56,.64,1); }
.up-ico .ico { width:24px; height:24px; }
.up-tile:hover .up-ico { transform:scale(1.12) rotate(-4deg); }
.up-title { font-weight:800; font-size:14px; color:var(--text-primary); }
.up-hint { font-size:11px; color:var(--text-muted); max-width:100%; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; padding:0 6px; }
.up-tile.done { border-style:solid; border-color:var(--success); background:linear-gradient(160deg, rgba(0,184,148,.14), rgba(var(--bg-rgb),.6)); }
.up-tile.done .up-ico { background:var(--success-light); color:var(--success); animation:pop .5s cubic-bezier(.34,1.56,.64,1); }
.up-tile.busy .up-ico { animation:spin 1s linear infinite; }
.up-tile.err { border-color:var(--danger); animation:shake .4s; }
.up-thumb { position:absolute; inset:0; background-size:cover; background-position:center; opacity:.28; }
.up-clear { position:absolute; top:8px; inset-inline-end:8px; z-index:3; width:24px; height:24px; border-radius:50%; border:none; background:rgba(0,0,0,.55); color:#fff; cursor:pointer; font-size:14px; line-height:1; }
.up-tile > *:not(.up-thumb):not(input) { position:relative; z-index:1; }
.up-tile .up-clear { position:absolute; }
@keyframes pop { 0%{transform:scale(.5)} 70%{transform:scale(1.25)} 100%{transform:scale(1)} }
@keyframes shake { 25%{transform:translateX(-6px)} 75%{transform:translateX(6px)} }

/* POS */
.pos { display:grid; grid-template-columns:1fr 360px; gap:20px; align-items:start; }
@media (max-width:980px){ .pos { grid-template-columns:1fr; } }
.pos-grid { display:grid; grid-template-columns:repeat(auto-fill,minmax(150px,1fr)); gap:12px; }
.pos-item { background:var(--bg-card); border:1px solid var(--border); border-radius:14px; padding:16px 12px; text-align:center; cursor:pointer; transition:var(--transition); font-family:inherit; color:inherit; }
.pos-item:hover { border-color:var(--primary); transform:translateY(-3px); box-shadow:var(--shadow-glow); }
.pos-item:active { transform:scale(.96); }
.pos-item b { display:block; font-size:14px; margin-bottom:6px; }
.pos-item span { color:var(--primary); font-weight:700; font-size:13px; }
.cart-row { display:grid; grid-template-columns:1fr auto auto; gap:8px; align-items:center; padding:8px 0; border-bottom:1px solid var(--border); font-size:13px; }
.qty { display:flex; align-items:center; gap:6px; }
.qty button { width:26px; height:26px; border-radius:8px; border:1px solid var(--border); background:var(--bg-glass); color:var(--text-primary); cursor:pointer; font-size:15px; }
.qty input { width:54px; text-align:center; padding:4px; }

@media (max-width:768px){
  .menu-btn { display:inline-flex; }
  .sidebar { box-shadow:var(--shadow-lg); }
  .page-content { padding:14px; }
  .stats-grid { grid-template-columns:1fr 1fr; gap:10px; }
  .kv { grid-template-columns:100px 1fr; }
}

/* ===== invoice sheets ===== */
.sheet-wrap { display:flex; justify-content:center; }
.sheet { background:#fff; color:#111; width:210mm; max-width:100%; min-height:270mm; padding:14mm; border-radius:6px; box-shadow:var(--shadow-lg); font-size:13px; direction:rtl; }
.sheet table { color:#111; font-size:12.5px; }
.sheet tbody tr:hover { background:transparent; }
.sheet .num { direction:ltr; }
/* old (archive) layout: plain bordered A4 */
.sheet.old { font-family:Tahoma, Arial, sans-serif; }
.sheet.old .inv-h { text-align:center; border-bottom:2px solid #000; padding-bottom:10px; margin-bottom:12px; }
.sheet.old .inv-h h2 { font-size:20px; margin-bottom:4px; }
.sheet.old .inv-title { text-align:center; font-size:17px; font-weight:bold; margin:10px 0; }
.sheet.old .inv-meta { display:grid; grid-template-columns:1fr 1fr; gap:12px; margin-bottom:12px; }
.sheet.old .inv-meta div { line-height:1.9; }
.sheet.old table.items { border:1px solid #000; }
.sheet.old table.items th { background:#e9e9e9; color:#000; border:1px solid #000; padding:6px; text-align:center; font-size:11.5px; }
.sheet.old table.items td { border:1px solid #000; padding:6px; text-align:center; }
.sheet.old .inv-foot { display:grid; grid-template-columns:1fr 280px; gap:16px; margin-top:14px; align-items:start; }
.sheet.old table.sum td { border:1px solid #000; padding:6px 8px; }
.sheet.old table.sum td:first-child { background:#f3f3f3; font-weight:bold; }
/* new layout */
.sheet.new { font-family:'Cairo', Tahoma, sans-serif; padding:0; overflow:hidden; }
.sheet.new .n-head { background:linear-gradient(135deg,#0d1b2a,#12324a); color:#fff; padding:12mm 14mm; display:flex; justify-content:space-between; align-items:center; gap:16px; }
.sheet.new .n-head h2 { font-size:21px; font-weight:800; }
.sheet.new .n-head small { opacity:.75; display:block; margin-top:2px; }
.sheet.new .n-badge { text-align:center; border:1px solid rgba(255,255,255,.3); border-radius:12px; padding:10px 18px; }
.sheet.new .n-badge b { display:block; font-size:16px; color:#48cae4; }
.sheet.new .n-body { padding:10mm 14mm 12mm; }
.sheet.new .n-cards { display:grid; grid-template-columns:1fr 1fr; gap:12px; margin-bottom:14px; }
.sheet.new .n-card { border:1px solid #dfe8ee; border-radius:12px; padding:12px 14px; line-height:1.9; }
.sheet.new .n-card h4 { color:#0096b3; font-size:12px; margin-bottom:4px; }
.sheet.new table.items th { background:#00b4d8; color:#fff; padding:9px 8px; font-size:11.5px; text-align:center; border:none; }
.sheet.new table.items th:first-child { border-radius:0 10px 10px 0; } .sheet.new table.items th:last-child { border-radius:10px 0 0 10px; }
.sheet.new table.items td { padding:9px 8px; text-align:center; border-bottom:1px solid #e8eef2; }
.sheet.new .inv-foot { display:grid; grid-template-columns:1fr 290px; gap:16px; margin-top:16px; align-items:start; }
.sheet.new table.sum td { padding:7px 10px; border-bottom:1px solid #e8eef2; }
.sheet.new table.sum tr.grand td { background:#0d1b2a; color:#fff; font-weight:800; font-size:14px; border:none; }
.sheet.new table.sum tr.grand td:first-child { border-radius:0 10px 10px 0; } .sheet.new table.sum tr.grand td:last-child { border-radius:10px 0 0 10px; }
.sheet .qr svg { width:38mm; height:38mm; display:block; }
.sheet .inv-note { margin-top:12px; padding:8px 12px; border:1px dashed #999; border-radius:6px; font-size:12px; white-space:pre-wrap; }
.sheet .archive-tag { margin-top:14px; font-size:10.5px; color:#666; text-align:center; }
@media print {
  @page { size:A4; margin:0; }
  body { background:#fff !important; } body::before { display:none; }
  .sidebar, .top-header, .no-print, .toast-container { display:none !important; }
  .main-content { margin:0 !important; } .page-content { padding:0 !important; }
  .sheet { box-shadow:none; border-radius:0; width:210mm; min-height:297mm; -webkit-print-color-adjust:exact; print-color-adjust:exact; }
}

/* ===== craft pass (Impeccable craft-floor + Web Interface Guidelines) ===== */
html { color-scheme: dark; }
::selection { background: rgba(var(--prim-rgb),.35); color:#fff; }
:focus-visible { outline: 2px solid var(--primary-light); outline-offset: 2px; border-radius: 6px; }
input, select, textarea, button { caret-color: var(--primary); touch-action: manipulation; }
select.form-control { background-color:var(--bg-dark); color: var(--text-primary); }
h1, h2, h3 { text-wrap: balance; }
a { color: var(--primary-light); text-underline-offset: 3px; }
.skip { position:absolute; inset-inline-start:-999px; top:8px; background:var(--primary); color:#fff; padding:8px 14px; border-radius:8px; z-index:5000; }
.skip:focus { inset-inline-start:8px; }
.text-muted, .stat-label { color: var(--text-secondary); }
.btn:disabled { opacity:.55; cursor:not-allowed; transform:none; }
.btn .spin { width:14px; height:14px; border:2px solid rgba(255,255,255,.4); border-top-color:#fff; border-radius:50%; animation:spin .7s linear infinite; }
.toast-icon .ico { width:20px; height:20px; }
.toast-success .toast-icon { color:var(--success); } .toast-error .toast-icon { color:var(--danger); }

/* transitions.dev — root tokens + modal, success check, error shake, number pop-in */
:root {
  --digit-dur: 500ms; --digit-distance: 8px; --digit-stagger: 70ms; --digit-blur: 2px; --digit-ease: cubic-bezier(0.34, 1.45, 0.64, 1); --digit-dir-x: 0; --digit-dir-y: 1;
  --modal-open-dur: 250ms; --modal-close-dur: 150ms; --modal-scale: 0.96; --modal-scale-close: 0.96; --modal-ease: cubic-bezier(0.22, 1, 0.36, 1);
  --check-opacity-dur: 550ms; --check-rotate-dur: 550ms; --check-rotate-from: 80deg; --check-bob-dur: 450ms; --check-y-amount: 40px; --check-blur-dur: 500ms; --check-blur-from: 10px; --check-path-dur: 550ms; --check-path-delay: 80ms;
  --check-ease-out: cubic-bezier(0.22, 1, 0.36, 1); --check-ease-opacity: cubic-bezier(0.22, 1, 0.36, 1); --check-ease-rotate: cubic-bezier(0.22, 1, 0.36, 1); --check-ease-bob: cubic-bezier(0.34, 1.35, 0.64, 1); --check-ease-path: cubic-bezier(0.22, 1, 0.36, 1);
  --shake-distance: 6px; --shake-overshoot: 4px; --shake-dur-a: 80ms; --shake-dur-b: 60ms; --shake-ease: cubic-bezier(0.22, 1, 0.36, 1); --revert-hold: 3000ms; --revert-dur: 280ms;
}
.overlay { position:fixed; inset:0; z-index:2000; display:flex; align-items:center; justify-content:center; padding:16px; background:rgba(6,13,20,.8); opacity:0; pointer-events:none; transition:opacity var(--modal-open-dur) var(--modal-ease); overscroll-behavior:contain; }
.overlay.is-open { opacity:1; pointer-events:auto; }
.t-modal { transform-origin:center; transform:scale(var(--modal-scale)); opacity:0; pointer-events:none;
  transition: transform var(--modal-open-dur) var(--modal-ease), opacity var(--modal-open-dur) var(--modal-ease); will-change:transform, opacity;
  background:var(--bg-dark); border:1px solid var(--border); border-radius:20px; width:100%; max-width:560px; max-height:90vh; overflow-y:auto; overscroll-behavior:contain; box-shadow:0 20px 60px rgba(0,0,0,.55); }
.t-modal.wide { max-width:860px; }
.t-modal.is-open { transform:scale(1); opacity:1; pointer-events:auto; }
.t-modal.is-closing { transform:scale(var(--modal-scale-close)); opacity:0; pointer-events:none; transition: transform var(--modal-close-dur) var(--modal-ease), opacity var(--modal-close-dur) var(--modal-ease); }
.t-success-check { display:inline-block; transform-origin:center; opacity:0; will-change:transform, opacity, filter; }
.t-success-check svg { display:block; overflow:visible; }
.t-success-check svg path { stroke-dasharray:20; stroke-dashoffset:20; }
.t-success-check[data-state="in"] { animation: t-check-fade var(--check-opacity-dur) var(--check-ease-opacity) forwards, t-check-rotate var(--check-rotate-dur) var(--check-ease-rotate) forwards, t-check-blur var(--check-blur-dur) var(--check-ease-out) forwards, t-check-bob var(--check-bob-dur) var(--check-ease-bob) forwards; }
.t-success-check[data-state="in"] svg path { animation: t-check-draw var(--check-path-dur) var(--check-ease-path) var(--check-path-delay, 0ms) forwards; }
@keyframes t-check-fade { from { opacity:0; } to { opacity:1; } }
@keyframes t-check-rotate { from { transform:rotate(var(--check-rotate-from)); } to { transform:rotate(0deg); } }
@keyframes t-check-blur { from { filter:blur(var(--check-blur-from)); } to { filter:blur(0); } }
@keyframes t-check-bob { from { translate:0 var(--check-y-amount); } to { translate:0 0; } }
@keyframes t-check-draw { to { stroke-dashoffset:0; } }
.t-input { transition:border-color 150ms ease-out; will-change:transform; }
.t-input.is-error { border-color:var(--danger) !important; transition:border-color var(--revert-dur, 280ms) ease-out; }
.t-error-msg { color:var(--danger); font-size:12.5px; margin-top:6px; opacity:0; visibility:hidden; transition:opacity var(--revert-dur, 280ms) ease-out, visibility 0s linear var(--revert-dur, 280ms); }
.t-input-wrap.is-error .t-error-msg { opacity:1; visibility:visible; transition:opacity var(--revert-dur, 280ms) ease-out, visibility 0s linear 0s; }
.t-input.is-shaking { animation:t-input-shake calc(var(--shake-dur-a) * 2 + var(--shake-dur-b) * 2) linear; }
@keyframes t-input-shake {
  0% { transform:translateX(0); animation-timing-function:var(--shake-ease); }
  28.57% { transform:translateX(var(--shake-distance)); animation-timing-function:var(--shake-ease); }
  57.14% { transform:translateX(calc(var(--shake-distance) * -1)); animation-timing-function:var(--shake-ease); }
  78.57% { transform:translateX(var(--shake-overshoot)); animation-timing-function:var(--shake-ease); }
  100% { transform:translateX(0); }
}
@keyframes t-digit-pop-in { 0% { transform:translate(calc(var(--digit-distance) * var(--digit-dir-x)), calc(var(--digit-distance) * var(--digit-dir-y))); opacity:0; filter:blur(var(--digit-blur)); } 100% { transform:translate(0,0); opacity:1; filter:blur(0); } }
.t-digit-group { display:inline-flex; align-items:baseline; direction:ltr; }
.t-digit { display:inline-block; will-change:transform, opacity, filter; white-space:pre; }
.t-digit-group.is-animating .t-digit { animation:t-digit-pop-in var(--digit-dur) var(--digit-ease) both; }
.t-digit-group.is-animating .t-digit[data-stagger="1"] { animation-delay:var(--digit-stagger); }
.t-digit-group.is-animating .t-digit[data-stagger="2"] { animation-delay:calc(var(--digit-stagger) * 2); }

/* spotlight (adapted from React Bits SpotlightCard, vanilla) */
.spot { position:relative; isolation:isolate; }
.spot::after { content:''; position:absolute; inset:0; border-radius:inherit; pointer-events:none; z-index:-1; opacity:0; transition:opacity .3s ease;
  background:radial-gradient(260px circle at var(--mx,50%) var(--my,50%), rgba(var(--prim-rgb),.16), transparent 70%); }
.spot:hover::after { opacity:1; }

@media (prefers-reduced-motion: reduce) {
  .t-modal, .overlay { transition:none !important; }
  .t-success-check { animation:none !important; opacity:1; } .t-success-check svg path { animation:none !important; stroke-dashoffset:0 !important; }
  .t-input { animation:none !important; transform:none !important; }
  .t-digit-group .t-digit { animation:none !important; }
  .up-tile, .up-ico, .bar-fill, .pos-item, .stat-card, .btn, .toast, .skeleton, .loading-spinner { transition:none !important; animation:none !important; }
}

.main-content, .page-content, .card { min-width:0; }
.nw, td span[dir=ltr] { white-space:nowrap; }
.stats-grid.six { grid-template-columns:repeat(3,1fr); }
@media (max-width:980px){ .stats-grid.six { grid-template-columns:1fr 1fr; } }
@media (max-width:768px){ .top-header { padding:0 14px; gap:10px; } .filters .form-group { min-width:100%; } .t-modal { max-height:94vh; } .totals-box { width:100%; } }
.sheet-wrap { display:block; max-width:100%; overflow-x:auto; }
.sheet { margin:0 auto; }
@media (max-width:820px){ .sheet { width:100%; min-height:0; padding:16px; font-size:12px; } .sheet.new { padding:0; } .sheet.new .n-head, .sheet.new .n-body { padding:16px; } .sheet .n-cards, .sheet .inv-meta, .sheet .inv-foot { grid-template-columns:1fr !important; } .sheet .n-head { flex-wrap:wrap; } .sheet table.items { display:block; overflow-x:auto; } }
@media print { .sheet { width:210mm !important; max-width:210mm !important; box-sizing:border-box !important; padding:12mm !important; margin:0 !important; } .sheet.new { padding:0 !important; } }
.nav-section-title { text-transform:none; letter-spacing:.3px; font-size:11px; }
thead th { letter-spacing:0; }
@media (max-width:768px){ .filters .form-group { min-width:calc(50% - 5px); } .filters .form-group:first-child { min-width:100%; } }

.tr-short { display:none; }

/* ===== mobile polish (≤ 720px) ===== */
@media (max-width:720px) {
  .hide-m { display:none; }
  .top-header .btn-sm { padding:9px 12px; }
  .header-title { flex:1; min-width:0; text-align:center; }
  .header-title p { white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
  .page-content { padding:14px 12px 28px; }
  .page-head { margin-bottom:14px; }
  .page-head > div:first-child { flex:1 1 100%; }
  .page-head > .flex { width:100%; }
  .page-head > .flex .btn { flex:1; justify-content:center; }
  .page-head h1 { font-size:20px; }
  .banner { font-size:12.5px; line-height:1.7; }

  /* stat cards: two per row, fluid numbers, short trend text */
  .stats-grid, .stats-grid.six { grid-template-columns:1fr 1fr; gap:10px; }
  .stat-card { padding:14px 12px; min-width:0; }
  .stat-icon { width:36px; height:36px; margin-bottom:10px; }
  .stat-card .stat-value { font-size:clamp(15px, 4.7vw, 20px); letter-spacing:-.5px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
  .stat-label { font-size:11.5px; line-height:1.5; }
  .stat-trend { flex-wrap:wrap; gap:3px 5px; font-size:11px; margin-top:6px; }
  .tr-lbl { display:none; }
  .tr-short { display:inline; font-weight:500; opacity:.85; }

  /* filters: search on top, the rest two-by-two, compact */
  .filters { padding:12px; gap:8px; }
  .filters .form-group { min-width:calc(50% - 4px); flex:1 1 calc(50% - 4px); }
  .filters .form-group:first-child { min-width:100%; flex-basis:100%; }
  .filters .form-control { padding:9px 10px; font-size:13px; min-height:40px; }
  .filters .form-label { font-size:11.5px; margin-bottom:4px; }
  .chips { padding:0 12px 12px; gap:6px; }
  .chip { font-size:11.5px; padding:4px 10px; }

  /* tables → cards */
  .table-wrapper { overflow:visible; }
  table.stack, table.stack tbody { display:block; width:100%; }
  table.stack thead { display:none; }
  table.stack tr { display:block; margin:0 12px 10px; padding:6px 12px; background:var(--bg-glass); border:1px solid var(--border); border-radius:14px; }
  table.stack tr.clickable:active { background:var(--bg-glass-hover); }
  table.stack td { display:flex; align-items:baseline; justify-content:space-between; gap:12px; padding:7px 0; border:none; border-bottom:1px dashed rgba(var(--ink-rgb),.1); text-align:start; min-width:0; max-width:none; white-space:normal; font-size:13px; }
  table.stack td:last-child { border-bottom:none; }
  table.stack td::before { content:attr(data-label); flex:0 0 auto; color:var(--text-muted); font-size:11.5px; font-weight:600; }
  table.stack td > * { min-width:0; overflow-wrap:anywhere; }
  table.stack td.num { direction:rtl; text-align:start; }
  table.stack td.num::before { direction:rtl; }
  table.stack td:not([data-label])::before { display:none; }
  table.stack tr.span-row { background:none; border:none; padding:0; margin:0; }
  table.stack tr.span-row td { display:block; border:none; }
  table.stack tr.span-row td::before { display:none; }
  table.stack td:first-child { font-weight:700; }
  .pagination { flex-direction:column; gap:10px; align-items:stretch; padding:12px; text-align:center; }
  .pagination .page-btns { display:flex; gap:8px; }
  .pagination .page-btns .btn { flex:1; justify-content:center; }

  /* forms / modals / misc */
  .t-modal { width:calc(100vw - 16px); max-width:none; border-radius:18px; }
  .modal-header, .modal-body, .modal-footer { padding-inline:16px; }
  .modal-footer { flex-wrap:wrap; }
  .modal-footer .btn { flex:1; justify-content:center; }
  .grid-2, .grid-3, .grid-4, .form-row { grid-template-columns:1fr; }
  .tabs { flex-wrap:nowrap; overflow-x:auto; padding-bottom:4px; margin-inline:-12px; padding-inline:12px; scrollbar-width:none; }
  .tabs::-webkit-scrollbar { display:none; }
  .tab { white-space:nowrap; flex:0 0 auto; }
  .card-header { flex-wrap:wrap; gap:8px; }
  .legend { flex-wrap:wrap; gap:6px 12px; }
  .toast-container { inset-inline:12px; max-width:none; }
}
@media (max-width:360px) { .stats-grid, .stats-grid.six { grid-template-columns:1fr; } }

/* ===== appearance: backgrounds (html[data-bg]) ===== */
html[data-bg="plain"] body::before { background:none; }
html[data-bg="lines"] body::before { background:repeating-linear-gradient(180deg, rgba(var(--prim-rgb),.07) 0 1px, transparent 1px 9px); -webkit-mask-image:linear-gradient(180deg,#000,transparent 85%); mask-image:linear-gradient(180deg,#000,transparent 85%); }
html[data-bg="aurora"] body::before { background:radial-gradient(60% 45% at 15% 0%, rgba(var(--prim-rgb),.26), transparent 70%), radial-gradient(45% 40% at 85% 8%, rgba(34,197,94,.16), transparent 70%), radial-gradient(50% 40% at 60% 100%, rgba(139,92,246,.14), transparent 70%); }
html[data-bg="crystal"] body::before { background:conic-gradient(from 45deg at 50% 50%, rgba(var(--prim-rgb),.10) 0 25%, transparent 0 50%, rgba(var(--prim-rgb),.10) 0 75%, transparent 0) 0 0/84px 84px; -webkit-mask-image:linear-gradient(180deg,#000 10%,transparent 95%); mask-image:linear-gradient(180deg,#000 10%,transparent 95%); }
html[data-bg="glow"] body::before { background:radial-gradient(70% 55% at 50% -5%, rgba(var(--prim-rgb),.30), transparent 72%); }
html[data-bg="mist"] body::before { background:radial-gradient(40% 35% at 12% 20%, rgba(var(--prim-rgb),.20), transparent 70%), radial-gradient(38% 34% at 88% 35%, rgba(168,85,247,.16), transparent 70%), radial-gradient(45% 35% at 40% 95%, rgba(var(--prim-rgb),.14), transparent 70%); filter:blur(14px); }
html[data-bg="arcs"] body::before { background:repeating-radial-gradient(circle at 100% 0%, transparent 0 46px, rgba(var(--prim-rgb),.11) 46px 47px); -webkit-mask-image:radial-gradient(90% 70% at 100% 0%,#000,transparent 80%); mask-image:radial-gradient(90% 70% at 100% 0%,#000,transparent 80%); }
html[data-bg="tint"] body::before { background:rgba(var(--prim-rgb),.10); }
html[data-bg="grid"] body::before { background-image:linear-gradient(rgba(var(--prim-rgb),.05) 1px, transparent 1px), linear-gradient(90deg, rgba(var(--prim-rgb),.05) 1px, transparent 1px); background-size:50px 50px; }
html[data-bg="dots"] body::before { background-image:radial-gradient(rgba(var(--prim-rgb),.28) 1.2px, transparent 1.6px); background-size:26px 26px; }
html[data-bg="sunset"] body::before { background:linear-gradient(180deg, transparent 40%, rgba(249,115,22,.14) 78%, rgba(236,72,153,.18)); }
html[data-bg="geo"] body::before { background:conic-gradient(from 135deg at 0 0, rgba(var(--prim-rgb),.10) 0 25%, transparent 0) 0 0/120px 120px, conic-gradient(from -45deg at 100% 100%, rgba(var(--prim-rgb),.07) 0 25%, transparent 0) 0 0/120px 120px; }

/* ===== appearance: light modes ===== */
html[data-mode="light"] .top-header { background:rgba(255,255,255,.82); }
html[data-mode="light"] .sidebar { background:var(--bg-side); box-shadow:var(--shadow-sm); }
html[data-mode="light"] .card, html[data-mode="light"] .stat-card { box-shadow:var(--shadow-sm); }
html[data-mode="light"] .t-modal, html[data-mode="light"] .login { background:#fff; }
html[data-mode="light"] .overlay { background:rgba(20,32,51,.38); }
html[data-mode="light"] .form-control { background:#fff; }
html[data-mode="light"] ::-webkit-scrollbar-thumb { background:rgba(var(--ink-rgb),.25); }
html[data-mode="light"] .nav-item:hover, html[data-mode="light"] .nav-item.active { background:rgba(var(--prim-rgb),.12); }
html[data-mode="light"] .up-tile { background:linear-gradient(160deg, rgba(var(--prim-rgb),.08), #fff); }
html[data-mode="light"] .banner { background:rgba(168,115,10,.1); }

/* ===== appearance: pop-up option lists are always readable ===== */
select.form-control { color-scheme:inherit; }
select.form-control option, select.form-control optgroup { background-color:var(--bg-dark); color:var(--text-primary); }

/* ===== appearance: density & font size ===== */
html[data-font="small"] body { zoom:.92; }
html[data-font="large"] body { zoom:1.1; }
html[data-density="compact"] td, html[data-density="compact"] th { padding-block:7px; }
html[data-density="compact"] .card-body, html[data-density="compact"] .stat-card { padding:14px; }
html[data-density="compact"] .page-content { padding:16px; }
html[data-density="compact"] .nav-item { padding-block:8px; }
html[data-density="compact"] .stats-grid { gap:10px; }
html[data-density="cozy"] td, html[data-density="cozy"] th { padding-block:18px; }
html[data-density="cozy"] .card-body, html[data-density="cozy"] .stat-card { padding:26px; }
html[data-density="cozy"] .page-content { padding:32px; }
html[data-density="cozy"] .nav-item { padding-block:14px; }
html[data-density="cozy"] .stats-grid { gap:22px; }

/* ===== appearance panel (modal) ===== */
.ap { display:flex; flex-direction:column; gap:20px; }
.ap h3 { display:flex; align-items:baseline; justify-content:space-between; gap:8px; font-size:14px; font-weight:700; color:var(--text-primary); margin-bottom:10px; }
.ap h3 em { font-style:normal; font-size:13px; font-weight:700; color:var(--primary-light); }
html[data-mode="light"] .ap h3 em { color:var(--primary-dark); }
.ap .grp { display:flex; align-items:center; gap:8px; font-size:12px; color:var(--text-secondary); margin:2px 0 8px; }
.ap .grp::before { content:''; width:10px; height:10px; border-radius:50%; background:var(--grpc); box-shadow:0 0 0 2px rgba(var(--ink-rgb),.18); }
.ap .grp.d { --grpc:#10151c; } .ap .grp.l { --grpc:#f1f3f9; }
.modes { display:grid; grid-template-columns:repeat(3,1fr); gap:10px; margin-bottom:12px; }
.mode { position:relative; border:1.5px solid rgba(var(--ink-rgb),.14); border-radius:14px; background:transparent; padding:0; cursor:pointer; font-family:inherit; color:var(--text-primary); text-align:center; overflow:hidden; transition:transform .18s ease, border-color .18s ease, box-shadow .18s ease; }
.mode:hover { transform:translateY(-2px); }
.mode .pv { display:block; height:58px; background:var(--mb); position:relative; }
.mode .pv::before { content:''; position:absolute; inset-inline:14px; top:24px; height:7px; border-radius:4px; background:var(--mt); }
.mode .pv::after { content:''; position:absolute; inset-inline:14px; top:38px; height:7px; border-radius:4px; background:var(--mt); opacity:.28; width:60%; }
.mode .pv i { position:absolute; top:9px; inset-inline-end:10px; width:8px; height:8px; border-radius:50%; background:var(--primary); box-shadow:0 0 8px var(--primary); }
.mode > span:last-child { display:block; padding:7px 4px 8px; font-size:12px; font-weight:600; }
.mode.on { border-color:var(--primary); box-shadow:0 0 0 2px rgba(var(--prim-rgb),.35); }
.bgs { display:grid; grid-template-columns:repeat(4,1fr); gap:10px; }
.bgt { position:relative; aspect-ratio:1.35; border-radius:12px; border:1.5px solid rgba(var(--ink-rgb),.14); background:var(--bg-deep); overflow:hidden; cursor:pointer; padding:0; transition:transform .18s ease, border-color .18s ease; }
.bgt::before { content:''; position:absolute; inset:0; }
.bgt:hover { transform:translateY(-2px); }
.bgt.on { border-color:var(--primary); box-shadow:0 0 0 2px rgba(var(--prim-rgb),.35); }
.bgt[data-b="lines"]::before { background:repeating-linear-gradient(180deg, rgba(var(--prim-rgb),.5) 0 1px, transparent 1px 6px); }
.bgt[data-b="aurora"]::before { background:radial-gradient(60% 60% at 20% 0%, rgba(var(--prim-rgb),.6), transparent 70%), radial-gradient(50% 50% at 90% 10%, rgba(34,197,94,.45), transparent 70%); }
.bgt[data-b="crystal"]::before { background:conic-gradient(from 45deg at 50% 50%, rgba(var(--prim-rgb),.55) 0 25%, transparent 0 50%, rgba(var(--prim-rgb),.55) 0 75%, transparent 0) 0 0/22px 22px; }
.bgt[data-b="glow"]::before { background:radial-gradient(80% 70% at 50% 0%, rgba(var(--prim-rgb),.7), transparent 75%); }
.bgt[data-b="mist"]::before { background:radial-gradient(45% 45% at 20% 30%, rgba(var(--prim-rgb),.5), transparent 70%), radial-gradient(40% 40% at 80% 60%, rgba(168,85,247,.45), transparent 70%); filter:blur(5px); }
.bgt[data-b="arcs"]::before { background:repeating-radial-gradient(circle at 100% 0%, transparent 0 9px, rgba(var(--prim-rgb),.6) 9px 10px); }
.bgt[data-b="tint"]::before { background:rgba(var(--prim-rgb),.45); }
.bgt[data-b="grid"]::before { background-image:linear-gradient(rgba(var(--prim-rgb),.6) 1px, transparent 1px), linear-gradient(90deg, rgba(var(--prim-rgb),.6) 1px, transparent 1px); background-size:14px 14px; }
.bgt[data-b="dots"]::before { background-image:radial-gradient(rgba(var(--prim-rgb),.8) 1px, transparent 1.5px); background-size:11px 11px; }
.bgt[data-b="sunset"]::before { background:linear-gradient(180deg, transparent 20%, rgba(249,115,22,.7), rgba(236,72,153,.7)); }
.bgt[data-b="geo"]::before { background:conic-gradient(from 135deg at 0 0, rgba(var(--prim-rgb),.6) 0 25%, transparent 0) 0 0/24px 24px; }
.dots { display:grid; grid-template-columns:repeat(8,1fr); gap:10px; justify-items:center; }
.dot { width:100%; max-width:34px; aspect-ratio:1; border-radius:50%; border:2px solid transparent; background:var(--dc); cursor:pointer; padding:0; position:relative; transition:transform .16s ease; }
.dot:hover { transform:scale(1.12); }
.dot.on { box-shadow:0 0 0 2px var(--bg-dark), 0 0 0 4px var(--dc); }
.dot.custom { background:transparent; border:1.5px dashed rgba(var(--ink-rgb),.4); color:var(--text-secondary); display:flex; align-items:center; justify-content:center; font-size:16px; overflow:hidden; }
.dot.custom input { position:absolute; inset:0; opacity:0; width:100%; height:100%; cursor:pointer; }
.dot.custom.on { background:var(--dc); color:var(--on-primary); }
.seg { display:flex; gap:4px; padding:4px; border-radius:12px; background:rgba(var(--ink-rgb),.06); }
.seg button { flex:1; border:none; background:transparent; color:var(--text-secondary); font-family:inherit; font-size:13px; font-weight:600; padding:9px 6px; border-radius:9px; cursor:pointer; transition:background .16s ease, color .16s ease; }
.seg button.on { background:var(--primary); color:var(--on-primary); }
.ap .reset { border:1.5px dashed rgba(var(--ink-rgb),.25); background:transparent; color:var(--text-secondary); font-family:inherit; font-size:13px; padding:11px; border-radius:12px; cursor:pointer; }
.ap .reset:hover { border-color:var(--primary); color:var(--text-primary); }
@media (max-width:720px) { .bgs { grid-template-columns:repeat(3,1fr); } .dots { grid-template-columns:repeat(6,1fr); } .modes { gap:8px; } }

/* ===== searchable select ===== */
.combo { position:relative; width:100%; }
.combo-src { position:absolute !important; inset:auto 0 0 0; height:1px; width:1px; opacity:0; pointer-events:none; }
.combo .form-control { padding-inline-end:34px; background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238a98a8' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E"); background-repeat:no-repeat; background-size:16px; background-position:left 10px center; }
body.ltr .combo .form-control, html[dir=ltr] .combo .form-control { background-position:right 10px center; }
.combo-list { position:fixed; z-index:3000; box-sizing:border-box; max-height:260px; overflow-y:auto; margin:0; padding:6px; list-style:none; background:var(--bg-dark); border:1px solid var(--border-bright); border-radius:12px; box-shadow:var(--shadow-lg); }
html[data-mode="light"] .combo-list { background:#fff; }
.combo-list li { padding:9px 12px; border-radius:8px; cursor:pointer; font-size:13.5px; line-height:1.5; color:var(--text-primary); }
.combo-list li.act, .combo-list li:hover { background:rgba(var(--prim-rgb),.16); }
.combo-list li.sel { color:var(--primary-light); font-weight:700; }
html[data-mode="light"] .combo-list li.sel { color:var(--primary-dark); }
.combo-list li.none { color:var(--text-muted); cursor:default; }
.line-table .combo-list { min-width:260px; }
/* dates always read left-to-right, in one fixed order */
input[type=date].form-control { direction:ltr; text-align:start; font-variant-numeric:tabular-nums; }
input[type=date].form-control::-webkit-calendar-picker-indicator { filter:invert(.7); cursor:pointer; }
html[data-mode="light"] input[type=date].form-control::-webkit-calendar-picker-indicator { filter:none; opacity:.6; }

/* Urdu: Noto Sans Arabic has the full Urdu letter set */
html[lang=ur] body, html[lang=ur] .form-control, html[lang=ur] button { font-family:'Noto Sans Arabic','Cairo',sans-serif; }
html[lang=ur] body { line-height:1.75; }
.lang-btn span { font-size:13px; font-weight:800; font-family:'Cairo',sans-serif; }

/* ===== quick search palette ===== */
.qs-ov { align-items:flex-start; padding-top:12vh; }
.qs { width:min(640px, calc(100vw - 24px)); background:var(--bg-dark); border:1px solid var(--border-bright); border-radius:18px; box-shadow:var(--shadow-lg); overflow:hidden; transform:translateY(-8px); opacity:0; transition:transform .18s ease, opacity .18s ease; }
.qs-ov.is-open .qs { transform:none; opacity:1; }
html[data-mode="light"] .qs { background:#fff; }
.qs-in { display:flex; align-items:center; gap:10px; padding:14px 16px; border-bottom:1px solid var(--border); color:var(--text-secondary); }
.qs-in input { flex:1; min-width:0; background:none; border:none; outline:none; color:var(--text-primary); font-family:inherit; font-size:16px; }
.qs-in kbd { font-size:11px; padding:2px 7px; border-radius:6px; border:1px solid var(--border); color:var(--text-muted); font-family:inherit; }
.qs-res { max-height:min(60vh, 440px); overflow-y:auto; padding:6px 8px 10px; }
.qs-g { font-size:11.5px; font-weight:700; color:var(--text-muted); padding:10px 10px 4px; }
.qs-i { display:flex; align-items:center; justify-content:space-between; gap:12px; padding:10px 12px; border-radius:10px; color:var(--text-primary); text-decoration:none; font-size:14px; }
.qs-i span { min-width:0; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.qs-i em { font-style:normal; color:var(--text-secondary); font-size:12.5px; white-space:nowrap; }
.qs-i small { color:var(--text-muted); }
.qs-i.act, .qs-i:hover { background:rgba(var(--prim-rgb),.16); }
.qs-empty { padding:26px; text-align:center; color:var(--text-muted); font-size:13.5px; }
@media (max-width:720px) { .qs-ov { padding-top:8vh; } #qsBtn { margin-inline-end:auto; } }
@media print { .qs-ov { display:none !important; } }

/* ===== dashboard v3 ===== */
.today { display:grid; grid-template-columns:repeat(4,1fr); gap:0; margin-bottom:14px; border:1px solid var(--border); border-radius:var(--radius-lg); background:var(--bg-card); overflow:hidden; }
.today-i { padding:14px 18px; display:flex; flex-direction:column; gap:3px; min-width:0; }
.today-i + .today-i { border-inline-start:1px solid var(--border); }
.today-i span { font-size:12px; color:var(--text-muted); }
.today-i b { font-size:18px; font-weight:800; font-variant-numeric:tabular-nums; direction:ltr; text-align:start; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.quick { display:flex; flex-wrap:wrap; gap:8px; margin-bottom:18px; }
.spark { display:block; width:100%; height:30px; margin-top:10px; }
.seg-bar { display:flex; gap:2px; height:14px; border-radius:7px; overflow:hidden; margin-bottom:14px; }
.seg-bar i { display:block; min-width:4px; }
.seg-leg { list-style:none; margin:0; padding:0; display:flex; flex-direction:column; gap:9px; }
.seg-leg li { display:grid; grid-template-columns:1fr auto 44px; align-items:center; gap:10px; font-size:13px; }
.seg-leg li span { display:flex; align-items:center; gap:8px; color:var(--text-secondary); min-width:0; }
.seg-leg li i { width:10px; height:10px; border-radius:3px; flex:none; }
.seg-leg li b { font-weight:700; font-variant-numeric:tabular-nums; direction:ltr; }
.seg-leg li em { font-style:normal; color:var(--text-muted); font-size:12px; text-align:end; font-variant-numeric:tabular-nums; }
.deb { list-style:none; margin:0; padding:0; }
.deb li { display:flex; justify-content:space-between; align-items:center; gap:12px; padding:10px 0; border-bottom:1px dashed rgba(var(--ink-rgb),.1); font-size:13.5px; }
.deb li:last-child { border-bottom:none; }
.deb a { color:var(--text-primary); text-decoration:none; min-width:0; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.deb a:hover { color:var(--primary-light); }
.deb b { color:var(--warning); font-variant-numeric:tabular-nums; white-space:nowrap; }
@media (max-width:720px) {
  .today { grid-template-columns:1fr 1fr; }
  .today-i + .today-i { border-inline-start:none; }
  .today-i:nth-child(even) { border-inline-start:1px solid var(--border); }
  .today-i:nth-child(n+3) { border-top:1px solid var(--border); }
  .today-i b { font-size:16px; }
  .quick .btn { flex:1 1 calc(50% - 8px); justify-content:center; }
  .seg-leg li { grid-template-columns:1fr auto 38px; gap:8px; font-size:12.5px; }
}

/* ===== invoice line editor on phones ===== */
@media (max-width:720px) {
  .line-table, .line-table tbody { display:block; width:100%; }
  .line-table thead { display:none; }
  .line-table tr { display:grid; grid-template-columns:1fr 1fr; gap:8px 10px; padding:12px; margin-bottom:10px; background:var(--bg-glass); border:1px solid var(--border); border-radius:14px; position:relative; }
  .line-table td { display:block; padding:0; border:none; min-width:0; }
  .line-table td[data-l]::before { content:attr(data-l); display:block; font-size:11.5px; font-weight:600; color:var(--text-muted); margin-bottom:4px; }
  .line-table td:first-child { grid-column:1 / -1; }
  .line-table td.num { grid-column:1; align-self:end; font-weight:700; text-align:start; direction:rtl; }
  .line-table td.x { grid-column:2; justify-self:end; align-self:end; }
  .line-table .form-control { width:100%; min-height:42px; }
}
@media (max-width:720px) { .sheet table.items th, .sheet table.items td { padding:7px 5px; font-size:11px; } .sheet table.items td[dir=ltr] { white-space:nowrap; } }

/* ===== v3: brand images, invoice actions, tasks, alerts, bell, tour, settings ===== */
.login-wrap { min-height:100vh; display:flex; align-items:center; justify-content:center; padding:20px; }
.login-card { width:100%; max-width:420px; background:rgba(var(--bg-rgb),.92); border:1px solid var(--border); border-radius:24px; padding:32px 26px; box-shadow:0 24px 60px rgba(0,0,0,.35); }
.login-card h1 { font-size:21px; text-align:center; margin:0 0 8px; }
.remember { display:flex; align-items:center; gap:10px; cursor:pointer; font-size:13.5px; }
.remember input { width:18px; height:18px; accent-color:var(--primary); flex:none; }
.bars { display:block; }
.brand-logo { height:54px; max-width:130px; object-fit:contain; background:#fff; border-radius:8px; padding:4px; margin-inline-end:12px; }
.brand-signs { display:flex; gap:28px; justify-content:flex-end; padding:14px 18px 6px; }
.brand-sign { text-align:center; }
.brand-sign img { height:74px; max-width:170px; object-fit:contain; display:block; margin:0 auto 2px; }
.brand-sign small { color:#52606d; font-size:11px; }
.brand-grid { display:grid; grid-template-columns:repeat(3,1fr); gap:14px; }
.brand-tile { border:1px solid var(--border); border-radius:14px; padding:12px; display:flex; flex-direction:column; gap:6px; background:var(--bg-glass); }
.brand-prev { height:110px; border-radius:10px; background:repeating-conic-gradient(rgba(var(--ink-rgb),.06) 0 25%, transparent 0 50%) 0 0/16px 16px; display:flex; align-items:center; justify-content:center; overflow:hidden; }
.brand-prev img { max-width:100%; max-height:100%; object-fit:contain; }
.brand-tile label.btn { cursor:pointer; }
.inv-actions .card-body { padding:12px 16px; }
.task-row { display:flex; align-items:center; gap:12px; padding:12px 16px; border-bottom:1px solid var(--border); flex-wrap:wrap; }
.task-row label { flex:1 1 220px; min-width:0; }
.task-row.done b { text-decoration:line-through; opacity:.55; }
.alert-row { display:flex; gap:12px; align-items:center; padding:14px 16px; border-bottom:1px solid var(--border); color:var(--text-primary); text-decoration:none; }
.alert-row:hover { background:var(--bg-glass-hover); }
.alert-row .ico { width:20px; height:20px; flex:none; }
.alert-row.lv-danger .ico { color:var(--danger); } .alert-row.lv-warn .ico { color:var(--warning); } .alert-row.lv-info .ico { color:var(--info); }
.bell { position:relative; display:inline-flex; align-items:center; justify-content:center; text-decoration:none; color:inherit; }
.bell-n { position:absolute; top:-2px; inset-inline-end:-2px; background:var(--danger); color:#fff; border-radius:10px; font-size:10px; font-weight:800; min-width:17px; height:17px; padding:0 4px; display:flex; align-items:center; justify-content:center; }
.bell-n.hidden, .badge.hidden { display:none; }
.att-seg { display:flex; gap:6px; flex-wrap:wrap; }
.perm-box { border:1px solid var(--border); border-radius:12px; padding:10px 14px; margin:12px 0; display:grid; grid-template-columns:1fr 1fr; gap:6px 16px; }
.perm-box legend { padding:0 8px; font-size:13px; color:var(--text-secondary); }
.settings-pane > .card { margin-bottom:16px; }
.tab { display:inline-flex; align-items:center; gap:6px; text-decoration:none; }
.tab .ico { width:15px; height:15px; }
.tour-box { position:fixed; inset-inline:16px; bottom:20px; max-width:380px; margin-inline:auto; z-index:9999; background:var(--bg-dark); color:var(--text-primary); border:1px solid var(--primary); border-radius:16px; padding:16px 18px; box-shadow:0 18px 50px rgba(0,0,0,.55); }
.tour-box p { margin:6px 0 12px; font-size:13.5px; color:var(--text-secondary); }
.tour-hl { outline:3px solid var(--primary) !important; outline-offset:-3px; box-shadow:0 0 0 6px rgba(var(--prim-rgb),.35) !important; }
kbd { background:rgba(var(--ink-rgb),.08); border:1px solid var(--border); border-radius:6px; padding:2px 8px; font-family:inherit; font-size:12px; }
pre { background:rgba(var(--ink-rgb),.06); border-radius:10px; padding:12px; font-size:13px; }
code { background:rgba(var(--ink-rgb),.08); padding:2px 6px; border-radius:6px; }
.sheet .brand-logo { float:none; }
.sheet.new .n-head { align-items:center; }
.qty { display:inline-flex; align-items:center; gap:4px; }
.qty input { width:62px; text-align:center; }
.qty button { width:30px; height:30px; border-radius:8px; border:1px solid var(--border); background:var(--bg-glass); color:inherit; font-size:16px; cursor:pointer; }
.cart-row { display:grid; grid-template-columns:1fr auto auto; gap:8px; align-items:center; padding:8px 0; border-bottom:1px solid var(--border); font-size:13.5px; }
.pos-item small { display:block; margin-top:4px; }
.mb-16 { margin-bottom:16px; }
.flex.gap-8 { gap:8px; }
.skeleton { background:linear-gradient(90deg,rgba(var(--ink-rgb),.05),rgba(var(--ink-rgb),.1),rgba(var(--ink-rgb),.05)); background-size:200% 100%; animation:wf-sk 1.4s infinite; border-radius:12px; }
@keyframes wf-sk { to { background-position:-200% 0; } }
@media (prefers-reduced-motion: reduce) { .skeleton { animation:none; } }
@media (max-width:820px) { .brand-grid { grid-template-columns:1fr; } .perm-box { grid-template-columns:1fr; } .tour-box { inset-inline:10px; bottom:12px; } .brand-signs { justify-content:center; } }
@media (max-width:600px) { .page-head { flex-direction:column; align-items:stretch; gap:10px; } .page-head > .flex { flex-wrap:wrap; } .tabs { overflow-x:auto; flex-wrap:nowrap; padding-bottom:4px; -webkit-overflow-scrolling:touch; } .tab { white-space:nowrap; } .task-row { padding:12px; } .att-seg .btn { flex:1 1 40%; } }

/* ===== 80mm / 58mm thermal receipt ===== */
#thermal { display:none; }
.th-in { font-family:'Segoe UI',Tahoma,Arial,sans-serif; font-size:11px; line-height:1.45; color:#000; background:#fff; padding:2mm 0; }
.th-c { text-align:center; margin-bottom:4px; } .th-logo { max-width:40mm; max-height:16mm; display:block; margin:0 auto 3px; }
.th-l { display:flex; justify-content:space-between; gap:6px; margin:2px 0; } .th-l span:first-child { flex:1 1 auto; min-width:0; word-break:break-word; } .th-l b { white-space:nowrap; direction:ltr; }
.th-big { font-size:14px; border-top:1px dashed #000; padding-top:4px; margin-top:4px; }
.th-in hr { border:0; border-top:1px dashed #000; margin:5px 0; } .th-c svg { width:34mm; height:34mm; }
@media print {
  body.thermal-print > *:not(#thermal) { display:none !important; }
  body.thermal-print #thermal { display:block !important; }
  body.thermal-print { background:#fff !important; }
  .brand-logo { -webkit-print-color-adjust:exact; print-color-adjust:exact; }
}
@media (max-width:820px) {
  .sheet table.items { display:table !important; width:100%; table-layout:auto; overflow:visible; }
  .sheet table.items th { font-size:9.5px; line-height:1.25; padding:6px 3px; }
  .sheet table.items td { padding:6px 3px; font-size:10.5px; }
  .sheet table.items th:first-child, .sheet table.items td:first-child { width:18px; padding-inline:2px; }
}

.combo-list li { overflow-wrap:anywhere; }

.stats-grid.four { grid-template-columns:repeat(4,1fr); }
@media (max-width:980px){ .stats-grid.four { grid-template-columns:1fr 1fr; } }
.range-box { margin-bottom:8px; } .range-bar { margin-bottom:16px; } .range-chips { margin-bottom:12px; flex-wrap:wrap; padding:0; }
.range-inputs { display:flex; gap:12px; align-items:flex-end; flex-wrap:wrap; } .range-inputs .form-group { margin:0; min-width:160px; flex:1 1 160px; max-width:220px; }
.range-sub { margin:0 0 12px; font-size:13px; } .stats-grid.six + .dash-grid { margin-top:16px; }
tr.tot td { border-top:2px solid var(--border-bright); }
.chip.active { background:rgba(var(--prim-rgb),.2); border-color:var(--primary); color:var(--primary-light); }
@media (max-width:640px){ .range-inputs .form-group { max-width:none; } .range-inputs .btn { width:100%; } }

.stats-grid.five { grid-template-columns:repeat(5,1fr); } @media (max-width:1180px){ .stats-grid.five { grid-template-columns:repeat(3,1fr); } } @media (max-width:760px){ .stats-grid.five { grid-template-columns:1fr 1fr; } }

.dt-wrap { position:relative; display:block; width:100%; }
.dt-wrap .dt-text { width:100%; direction:ltr; text-align:start; font-variant-numeric:tabular-nums; padding-inline-end:40px; }
html[dir=rtl] .dt-wrap .dt-text { text-align:right; }
.dt-btn { position:absolute; inset-inline-end:6px; top:50%; transform:translateY(-50%); width:30px; height:30px; display:grid; place-items:center; border:0; background:transparent; color:var(--text-muted); border-radius:8px; cursor:pointer; }
.dt-btn:hover, .dt-btn:focus-visible { color:var(--primary-light); background:rgba(var(--prim-rgb),.12); }
.dt-btn .ico { width:17px; height:17px; }
.dt-native { position:absolute !important; inset-inline-end:6px; bottom:0; width:1px !important; height:1px !important; opacity:0; pointer-events:none; padding:0 !important; border:0 !important; }
.dt-wrap .dt-text.is-error { border-color:var(--danger, #f87171); }

.sheet { max-width:100%; box-sizing:border-box; } .sheet.new .n-head { flex-wrap:wrap; } .sheet .table-wrapper, .sheet table { max-width:100%; } .sheet img.brand-logo { flex:0 0 auto; }
@media print { .sheet { max-width:none; } }

@media print { html, body { width:210mm; margin:0 !important; padding:0 !important; overflow:visible !important; } .main-content, .page-content, #main { width:210mm !important; max-width:210mm !important; margin:0 !important; padding:0 !important; } .sheet, .sheet * { box-sizing:border-box; } .sheet { overflow:hidden; page-break-after:avoid; } .sheet table { width:100%; table-layout:auto; } }
@media print { .skip, a.skip, .sr-only, #toasts, .bell-panel, .tour-box { display:none !important; } html { background:#fff !important; } }
@media print { .page-head, .inv-actions, .tabs, .banner { display:none !important; } }

.range-tabs { display:flex; gap:6px; flex-wrap:wrap; margin:0 0 16px; padding:5px; background:var(--bg-glass); border:1px solid var(--border); border-radius:14px; width:fit-content; max-width:100%; }
.rtab { border:0; background:transparent; color:var(--text-secondary); padding:8px 18px; border-radius:10px; font:inherit; font-size:13.5px; font-weight:600; cursor:pointer; }
.rtab:hover { color:var(--text-primary); } .rtab.active { background:rgba(var(--prim-rgb),.2); color:var(--primary-light); box-shadow:inset 0 0 0 1px rgba(var(--prim-rgb),.4); }

/* ===== markdown editor ===== */
.md-editor { border:1px solid var(--border); border-radius:12px; background:var(--bg-glass); overflow:hidden; }
.md-bar { display:flex; align-items:center; gap:2px; padding:6px 8px; border-bottom:1px solid var(--border); flex-wrap:wrap; }
.md-btn { border:0; background:transparent; color:var(--text-secondary); min-width:34px; height:34px; padding:0 8px; border-radius:8px; font:inherit; font-size:14px; cursor:pointer; display:inline-flex; align-items:center; justify-content:center; }
.md-btn:hover:not(:disabled) { background:rgba(var(--prim-rgb),.14); color:var(--text-primary); } .md-btn:disabled { opacity:.35; cursor:default; }
.md-btn .ico { width:16px; height:16px; } .md-sp { flex:1; }
.md-prev { font-size:13px; font-weight:600; } .md-prev.on { background:rgba(var(--prim-rgb),.22); color:var(--primary-light); }
.md-editor .md-ta { border:0; border-radius:0; background:transparent; resize:vertical; min-height:90px; line-height:1.8; box-shadow:none; }
.md-ta::selection { background:rgba(250,204,21,.5); color:inherit; }
.md-view { padding:12px 14px; min-height:90px; }
.md p { margin:0 0 .7em; line-height:1.85; } .md blockquote { margin:.4em 0 .8em; padding:.2em 1em; border-inline-start:3px solid var(--primary-light); background:rgba(var(--prim-rgb),.08); border-radius:6px; }
.md code { background:rgba(127,127,127,.2); padding:1px 6px; border-radius:5px; font-family:ui-monospace,Consolas,monospace; font-size:.92em; direction:ltr; unicode-bidi:embed; }
.md ul, .md ol { margin:.3em 0 .8em; padding-inline-start:1.4em; } .md a { color:var(--primary-light); text-decoration:underline; } .md h4 { margin:.6em 0 .3em; }
.md-editor.md-editor .hidden { display:none; }

/* ===== attachments, uploaders ===== */
.att-row { display:flex; gap:8px; align-items:center; flex-wrap:wrap; } .att-hint { font-size:12px; }
.att-list { display:flex; gap:8px; flex-wrap:wrap; margin-top:10px; }
.att-chip { position:relative; display:inline-flex; align-items:center; gap:6px; border:1px solid var(--border); border-radius:10px; padding:6px 30px 6px 10px; background:var(--bg-glass); font-size:13px; }
.att-chip.img { padding:0; } .att-chip.img img { width:84px; height:64px; object-fit:cover; border-radius:10px; display:block; }
.att-x { position:absolute; top:-7px; inset-inline-end:-7px; width:22px; height:22px; border-radius:50%; border:0; background:var(--danger); color:#fff; font-size:14px; line-height:1; cursor:pointer; }
.att-chip:not(.img) .att-x { top:50%; transform:translateY(-50%); inset-inline-end:5px; }
.one-img { display:flex; gap:12px; align-items:center; } .one-thumb { width:84px; height:68px; border:1px dashed var(--border); border-radius:10px; display:flex; align-items:center; justify-content:center; overflow:hidden; background:var(--bg-glass); }
.one-thumb img { max-width:100%; max-height:100%; object-fit:contain; } .asset-grid { display:grid; grid-template-columns:repeat(3,1fr); gap:16px; } .asset-col { display:flex; flex-direction:column; gap:8px; }
.grid-3 { display:grid; gap:16px; }

/* ===== letters list + table builder + picker ===== */
.kind-grid { display:grid; grid-template-columns:repeat(auto-fill,minmax(150px,1fr)); gap:12px; margin-top:4px; }
.kind-tile { display:flex; flex-direction:column; align-items:center; gap:8px; padding:16px 10px; border:1px solid var(--border); border-radius:14px; background:var(--bg-glass); color:var(--text-primary); text-decoration:none; font-weight:600; text-align:center; transition:border-color .15s, transform .15s; }
.kind-tile:hover { border-color:var(--primary-light); transform:translateY(-2px); } .kind-tile .ico { width:24px; height:24px; color:var(--primary-light); }
.tb-q { display:flex; gap:18px; align-items:center; flex-wrap:wrap; margin-bottom:12px; } .tb-ctl { display:flex; gap:22px; flex-wrap:wrap; margin-bottom:10px; }
.tb-step { display:flex; align-items:center; gap:6px; } .tb-step span { font-weight:600; margin-inline-end:4px; } .tb-step .form-control { width:70px; text-align:center; padding:6px; } .tb-step .btn { min-width:34px; }
.tb-hint { font-size:12.5px; margin:0 0 8px; } .tb-scroll { overflow:auto; max-height:60vh; border:1px solid var(--border); border-radius:12px; }
.tb { border-collapse:collapse; width:100%; min-width:max-content; } .tb th, .tb td { border:1px solid var(--border); padding:0; } .tb th { background:rgba(var(--prim-rgb),.12); position:sticky; top:0; z-index:1; }
.tb input { width:100%; min-width:120px; border:0; background:transparent; color:var(--text-primary); font:inherit; font-size:13.5px; padding:10px 12px; outline:none; } .tb-h { font-weight:700; } .tb input:focus { box-shadow:inset 0 0 0 2px var(--primary-light); }
.tb-cell { position:relative; } .tb-cell .tb-in { padding-right:26px; }
.tb-dot { position:absolute; top:4px; right:4px; width:14px; height:14px; border-radius:50%; border:2px solid var(--primary-light); background:transparent; cursor:pointer; padding:0; opacity:.7; } .tb-dot:hover, .tb-dot:focus-visible { background:var(--primary-light); opacity:1; }
.pp-list { max-height:55vh; overflow:auto; display:flex; flex-direction:column; gap:6px; } .pp-item { display:flex; justify-content:space-between; align-items:center; gap:10px; padding:10px 12px; border:1px solid var(--border); border-radius:10px; background:var(--bg-glass); color:var(--text-primary); font:inherit; cursor:pointer; text-align:start; }
.pp-item:hover, .pp-item:focus-visible { border-color:var(--primary-light); } .pp-item span:first-child { display:flex; flex-direction:column; gap:2px; } .pp-item small { color:var(--text-muted); } .pp-price { font-weight:700; }
.acts { white-space:nowrap; }

/* ===== letter sheet (screen + print) ===== */
.lt-wrap { overflow:auto; padding:6px 0 20px; }
.lt-page { width:210mm; min-height:297mm; margin:0 auto; background:#fff; color:#111; position:relative; box-shadow:0 8px 30px rgba(0,0,0,.35); background-size:210mm 297mm; background-repeat:repeat-y; background-position:top center; -webkit-print-color-adjust:exact; print-color-adjust:exact; box-sizing:border-box; direction:rtl; font-family:inherit; }
.lt-inner { padding:20mm 20mm 22mm; } .lt-page.has-bg .lt-inner { padding:44mm 22mm 36mm; }
.lt-head { display:flex; gap:14px; align-items:center; border-bottom:2px solid #1b4a6b; padding-bottom:10px; margin-bottom:18px; } .lt-head img { max-height:22mm; max-width:40mm; object-fit:contain; } .lt-head b { font-size:17px; } .lt-head div { font-size:12px; line-height:1.7; }
.lt-date { text-align:left; font-size:13px; margin-bottom:10px; } .lt-to { font-size:15px; margin-bottom:12px; line-height:1.9; } .lt-subject { font-weight:800; font-size:15.5px; margin:10px 0 14px; text-decoration:underline; text-underline-offset:4px; }
.lt-body { font-size:14.5px; line-height:2; } .lt-body p { margin:0 0 .7em; } .lt-body a { color:#0b5ea8; } .lt-body blockquote { border-inline-start:3px solid #1b4a6b; background:#f1f5f9; }
.lt-table { width:100%; border-collapse:collapse; margin:12px 0 16px; font-size:13.5px; page-break-inside:auto; } .lt-table th, .lt-table td { border:1px solid #444; padding:6px 8px; text-align:center; } .lt-table th { background:#e7eef4; font-weight:800; } .lt-table tr { page-break-inside:avoid; }
.lt-imgs { display:flex; flex-wrap:wrap; gap:10px; margin:12px 0; } .lt-imgs img { max-width:100%; max-height:90mm; object-fit:contain; border-radius:4px; }
.lt-close { margin-top:22px; font-size:14.5px; page-break-inside:avoid; } .lt-sign { margin-top:6px; } .lt-sigs { display:flex; gap:20px; align-items:center; margin-top:6px; min-height:24mm; } .lt-sigs img { max-height:28mm; max-width:55mm; object-fit:contain; }

/* ===== library, notes, notices ===== */
.lib-grid { display:grid; grid-template-columns:repeat(auto-fill,minmax(300px,1fr)); gap:16px; } .lib-top { display:flex; justify-content:space-between; gap:10px; align-items:flex-start; } .lib-top h3 { margin:0; font-size:16px; } .lib-date { font-size:12.5px; margin:4px 0 10px; }
.lib-imgs { display:flex; gap:8px; flex-wrap:wrap; margin:8px 0; } .lib-imgs img { width:110px; height:84px; object-fit:cover; border-radius:10px; border:1px solid var(--border); } .lib-text { max-height:180px; overflow:auto; }
.note-card.done { opacity:.7; } .note-list { display:grid; gap:14px; } .notice { padding:12px 14px; border:1px solid var(--border); border-radius:12px; margin-bottom:10px; background:var(--bg-glass); } .notice p { margin:6px 0; }

/* ===== top bar: collapsible menu, today strip, user, calendar ===== */
.today-strip { display:flex; gap:8px; margin-inline-start:auto; } .ts-chip { display:flex; flex-direction:column; line-height:1.25; padding:4px 12px; border:1px solid var(--border); border-radius:12px; background:var(--bg-glass); } .ts-chip small { font-size:11px; color:var(--text-muted); } .ts-chip b { font-size:14px; color:var(--success); } .ts-chip.neg b { color:var(--danger); }
.hdr-day { padding:0 10px; font-size:13px; color:var(--text-secondary); white-space:nowrap; } .hdr-user { display:inline-flex; align-items:center; gap:8px; font-size:13px; font-weight:600; padding:0 6px; white-space:nowrap; max-width:180px; overflow:hidden; text-overflow:ellipsis; }
.hdr-av { width:30px; height:30px; border-radius:50%; display:inline-flex; align-items:center; justify-content:center; background:rgba(var(--prim-rgb),.25); color:var(--primary-light); font-style:normal; font-weight:800; flex:none; }
body.side-collapsed .sidebar { transform:translateX(100%); visibility:hidden; } body.ltr.side-collapsed .sidebar { transform:translateX(-100%); } body.side-collapsed .main-content { margin-right:0; } body.ltr.side-collapsed .main-content { margin-left:0; }
.sidebar { transition:transform .22s ease, visibility .22s; } .main-content { transition:margin .22s ease; }
.cal-head { display:flex; justify-content:space-between; align-items:center; margin-bottom:8px; } .cal-g { display:grid; grid-template-columns:repeat(7,1fr); gap:4px; text-align:center; } .cal-w { font-size:11px; color:var(--text-muted); padding:4px 0; }
.cal-d { padding:7px 0; border-radius:8px; font-size:13px; } .cal-d.past { color:var(--text-muted); } .cal-d.today { background:var(--primary-light); color:#04121a; font-weight:800; } .cal-h { margin:10px 0; } .cal-tt { font-size:14px; margin:12px 0 6px; }
.cal-task { display:flex; gap:10px; align-items:flex-start; padding:7px 0; border-bottom:1px solid var(--border); } .cal-task.done span { text-decoration:line-through; opacity:.6; } .cal-task .late { color:var(--danger); }
@media (max-width:900px) { .today-strip, .hdr-day { display:none; } .asset-grid { grid-template-columns:1fr; } .lt-wrap { padding-inline:0; } }
@media print {
  .lt-wrap { overflow:visible; padding:0; } .lt-page { box-shadow:none; margin:0; zoom:1 !important; width:210mm; } body.side-collapsed .main-content, .main-content { margin:0 !important; }
  .top-header, .md-bar { display:none !important; }
}

.lt-page th, .lt-page td, .lt-page .lt-table { color:#111; }
.lt-page .lt-table th { color:#111; }
.lt-table td.nw { white-space:nowrap; }
.sr-only { position:absolute !important; width:1px; height:1px; padding:0; margin:-1px; overflow:hidden; clip:rect(0,0,0,0); white-space:nowrap; border:0; }

/* ===== rich-text editor ===== */
.rt-editor { border:1px solid var(--border); border-radius:12px; background:var(--bg-glass); overflow:visible; }
.rt-menubar { display:flex; gap:2px; padding:4px 8px; border-bottom:1px solid var(--border); flex-wrap:wrap; }
.rt-m { border:0; background:transparent; color:var(--text-secondary); font:inherit; font-size:13px; padding:5px 10px; border-radius:7px; cursor:pointer; }
.rt-m:hover, .rt-m[aria-expanded=true] { background:rgba(var(--prim-rgb),.16); color:var(--text-primary); }
.rt-bar { display:flex; align-items:center; gap:2px; padding:6px 8px; flex-wrap:wrap; border-bottom:1px solid var(--border); position:relative; }
.rt-b { border:0; background:transparent; color:var(--text-secondary); min-width:32px; height:32px; padding:0 6px; border-radius:7px; font:inherit; font-size:14px; cursor:pointer; display:inline-flex; align-items:center; justify-content:center; position:relative; }
.rt-b:hover:not(:disabled), .rt-b[aria-expanded=true] { background:rgba(var(--prim-rgb),.18); color:var(--text-primary); } .rt-b:disabled, .rt-sel:disabled, .rt-m:disabled { opacity:.4; cursor:default; }
.rt-b .ico { width:16px; height:16px; } .rt-bar-c { position:absolute; bottom:3px; inset-inline:7px; height:3px; border-radius:2px; }
.rt-sep { width:1px; height:20px; background:var(--border); margin:0 4px; } .rt-sp { flex:1; }
.rt-sel { height:32px; border:1px solid var(--border); background:var(--bg-glass); color:var(--text-primary); border-radius:8px; font:inherit; font-size:12.5px; padding:0 6px; max-width:130px; }
.rt-sel option { color:#111; } .rt-tags { max-width:150px; }
.rt-pal { position:relative; display:inline-flex; }
.rt-area { padding:14px 16px; line-height:1.9; outline:none; overflow:auto; max-height:60vh; font-size:15px; }
.rt-area:focus-visible { box-shadow:inset 0 0 0 2px rgba(var(--prim-rgb),.45); } .rt-area p { margin:0 0 .6em; } .rt-area table { border-collapse:collapse; max-width:100%; } .rt-area td, .rt-area th { border:1px solid var(--border); padding:6px; min-width:40px; }
.rt-area img, .rt-prev img, .md img { max-width:100%; height:auto; } .rt-area blockquote, .md blockquote { margin:.4em 0; padding:.2em 1em; border-inline-start:3px solid var(--primary-light); background:rgba(var(--prim-rgb),.08); border-radius:6px; }
.rt-area ::selection { background:rgba(250,204,21,.5); }
.rt-src { border:0; border-radius:0; min-height:220px; font-family:ui-monospace,Consolas,monospace; font-size:13px; direction:ltr; background:transparent; }
.rt-status { display:flex; justify-content:space-between; padding:5px 12px; font-size:11.5px; color:var(--text-muted); border-top:1px solid var(--border); }
.rt-editor.rt-full { position:fixed; inset:12px; z-index:3500; background:var(--bg-dark); display:flex; flex-direction:column; } .rt-editor.rt-full .rt-area { flex:1; max-height:none; }
.rt-pop { background:var(--bg-dark); border:1px solid var(--border); border-radius:12px; box-shadow:0 16px 40px rgba(0,0,0,.45); padding:6px; min-width:150px; }
.rt-menu button { display:block; width:100%; text-align:start; border:0; background:transparent; color:var(--text-primary); font:inherit; font-size:13px; padding:8px 12px; border-radius:8px; cursor:pointer; } .rt-menu button:hover { background:rgba(var(--prim-rgb),.18); } .rt-menu hr { border:0; border-top:1px solid var(--border); margin:4px 0; }
.rt-palette { padding:10px; } .rt-grid { display:grid; grid-template-columns:repeat(10,22px); gap:4px; } .rt-sw { width:22px; height:22px; border-radius:5px; border:1px solid rgba(127,127,127,.35); cursor:pointer; padding:0; } .rt-sw:hover { transform:scale(1.18); }
.rt-pal-foot { display:flex; justify-content:space-between; align-items:center; margin-top:8px; } .rt-custom { cursor:pointer; display:inline-flex; position:relative; } .rt-custom input { position:absolute; inset:0; opacity:0; width:100%; height:100%; cursor:pointer; }
.rt-prev { line-height:1.9; } .rt-prev table { border-collapse:collapse; } .rt-prev td, .rt-prev th { border:1px solid #888; padding:6px; }

/* ===== features F: calculator, hubs, templates, labels ===== */
.hub-grid { display:grid; grid-template-columns:repeat(auto-fill,minmax(250px,1fr)); gap:14px; }
.hub-card { display:flex; gap:14px; align-items:center; padding:16px 18px; background:var(--bg-card); border:1px solid var(--border); border-radius:var(--radius-lg); color:var(--text-primary); text-decoration:none; transition:border-color .2s, transform .2s, background .2s; }
.hub-card:hover { border-color:var(--border-bright); background:var(--bg-glass-hover); transform:translateY(-2px); }
.hub-card b { display:block; font-size:15px; }
.hub-card small { color:var(--text-secondary); font-size:12px; }
.hub-ico { flex:none; width:44px; height:44px; border-radius:12px; display:grid; place-items:center; background:var(--bg-glass-hover); color:var(--primary); }
.hub-ico .ico { width:22px; height:22px; }
.filter-row { display:flex; gap:12px; flex-wrap:wrap; align-items:flex-end; }
.filter-row .form-group { margin:0; min-width:150px; }
.rx-total td { font-weight:800; border-top:2px solid var(--border-bright); background:var(--bg-glass); }
.tc { text-align:center; } .yes { color:var(--success); font-weight:800; } .no { color:var(--text-muted); }
.stat-lg { font-size:28px; font-weight:800; margin:6px 0; }
.btn-sm { padding:5px 10px; font-size:12px; }

.calc-panel { position:fixed; top:74px; inset-inline-end:18px; width:312px; max-width:calc(100vw - 24px); z-index:900; background:var(--bg-dark); border:1px solid var(--border-bright); border-radius:20px; box-shadow:var(--shadow-lg); padding:14px; color:var(--text-primary); }
.calc-panel[hidden] { display:none; }
.calc-head { display:flex; align-items:center; gap:8px; margin-bottom:10px; }
.calc-head b { flex:1; font-size:14px; }
.calc-hint { font-size:11px; color:var(--text-muted); border:1px solid var(--border); border-radius:6px; padding:1px 7px; direction:ltr; }
.calc-x { background:none; border:0; color:var(--text-secondary); font-size:22px; line-height:1; cursor:pointer; padding:0 6px; border-radius:8px; }
.calc-x:hover { color:var(--text-primary); background:var(--bg-glass-hover); }
.calc-screen { background:rgba(0,0,0,.28); border:1px solid var(--border); border-radius:14px; padding:8px 12px 6px; margin-bottom:10px; }
.calc-hist-line { min-height:18px; font-size:13px; color:var(--text-secondary); text-align:left; }
.calc-input { width:100%; background:none; border:0; outline:none; color:var(--text-primary); font-size:30px; font-weight:700; text-align:left; font-family:inherit; padding:2px 0 4px; }
.calc-input:focus-visible { outline:2px solid var(--primary); outline-offset:2px; border-radius:6px; }
.calc-vat { display:grid; grid-template-columns:repeat(3,1fr); gap:6px; margin-bottom:8px; }
.calc-vat button { background:var(--bg-glass); border:1px solid var(--border); color:var(--primary); border-radius:10px; padding:7px 4px; font-size:11.5px; font-weight:700; cursor:pointer; font-family:inherit; }
.calc-vat button:hover { background:var(--bg-glass-hover); border-color:var(--border-bright); }
.calc-keys { display:grid; grid-template-columns:repeat(4,1fr); gap:7px; direction:ltr; }
.calc-keys button { height:46px; border-radius:13px; border:1px solid var(--border); background:var(--bg-glass); color:var(--text-primary); font-size:19px; font-weight:600; cursor:pointer; font-family:inherit; transition:transform .08s, background .15s; }
.calc-keys button:hover { background:var(--bg-glass-hover); }
.calc-keys button:active { transform:scale(.95); }
.calc-keys .k-op { color:var(--primary); font-size:22px; }
.calc-keys .k-fn { color:var(--text-secondary); font-size:16px; }
.calc-keys .k-eq { background:var(--primary); color:var(--on-primary, #fff); border-color:var(--primary); }
.calc-keys .k-eq:hover { background:var(--primary-dark); }
.calc-foot { display:flex; gap:8px; margin-top:10px; }
.calc-copy { flex:1; background:none; border:1px solid var(--border); color:var(--text-secondary); border-radius:10px; padding:6px; font-size:12px; cursor:pointer; font-family:inherit; }
.calc-copy:hover { color:var(--text-primary); border-color:var(--border-bright); }
.calc-history { list-style:none; margin:10px 0 0; padding:0; max-height:130px; overflow:auto; }
.calc-history li button { width:100%; display:flex; justify-content:space-between; gap:10px; background:none; border:0; border-top:1px solid var(--border); color:var(--text-secondary); padding:6px 4px; font-size:12.5px; cursor:pointer; font-family:inherit; text-align:left; }
.calc-history li button:hover { color:var(--text-primary); background:var(--bg-glass); }
.calc-history li b { color:var(--text-primary); }
.calc-empty { color:var(--text-muted); font-size:12px; padding:6px 2px; }
@media (max-width:640px) { .calc-panel { top:auto; bottom:10px; inset-inline:10px; width:auto; } .calc-keys button { height:50px; } }

.nt-card { background:var(--bg-card); border:1px solid var(--border); border-radius:var(--radius-lg); margin-bottom:10px; overflow:hidden; }
.nt-card[open] { border-color:var(--border-bright); }
.nt-card summary { cursor:pointer; padding:14px 18px; display:flex; align-items:center; gap:12px; list-style:none; font-weight:700; }
.nt-card summary::-webkit-details-marker { display:none; }
.nt-card summary::before { content:'‹'; font-size:20px; color:var(--primary); transition:transform .2s; }
.nt-card[open] summary::before { transform:rotate(-90deg); }
.nt-name { flex:1; }
.nt-flags { display:flex; gap:6px; }
.nt-body { padding:4px 18px 18px; }
.nt-auto { display:flex; gap:18px; flex-wrap:wrap; align-items:center; padding:12px 0 4px; }
.nt-note { font-size:12px; margin:4px 0 0; }
.nt-chips { display:flex; gap:6px; flex-wrap:wrap; margin-top:8px; }
.nt-chips code { background:var(--bg-glass-hover); border:1px solid var(--border); border-radius:8px; padding:3px 8px; font-size:12px; direction:ltr; }
.nt-tag { margin-top:6px; font-size:12px; }

.lbl-sheet { display:grid; grid-template-columns:repeat(var(--lc), var(--lw)); gap:var(--lg); padding:var(--lm); justify-content:start; direction:ltr; background:#fff; color:#000; border-radius:8px; margin-top:16px; }
.lbl { width:var(--lw); height:var(--lh); box-sizing:border-box; padding:1mm 1.5mm; display:flex; flex-direction:column; align-items:center; justify-content:center; text-align:center; overflow:hidden; border:1px dashed #ccc; font-family:Arial, sans-serif; line-height:1.15; }
.lbl-n { font-size:7.5pt; font-weight:700; max-height:2.3em; overflow:hidden; }
.lbl-co { font-size:6pt; color:#444; }
.lbl-bc { width:92%; flex:1; min-height:0; display:flex; margin:.6mm 0; }
.lbl-bc svg { width:100%; height:100%; }
.lbl-sku { font-size:6.5pt; letter-spacing:.5px; }
.lbl-p { font-size:8pt; }
.bc-err { color:#b00; font-size:7pt; }
@media print {
  body.print-labels > *:not(.app-layout):not(#app) { display:none !important; }
  body.print-labels .sidebar, body.print-labels .top-header, body.print-labels .page-head, body.print-labels .no-print, body.print-labels .card.no-print { display:none !important; }
  body.print-labels .lbl-sheet { margin:0; border-radius:0; padding:0; }
  body.print-labels .lbl { border:0; page-break-inside:avoid; }
  .calc-panel { display:none !important; }
}

/* ZATCA integration page */
.banner.banner-danger { background:var(--danger-light, rgba(200,50,50,.1)); border-color:var(--danger, #c0392b); color:var(--danger, #c0392b); }
.z-envs { display:grid; grid-template-columns:repeat(auto-fit, minmax(220px, 1fr)); gap:10px; margin-bottom:14px; }
.z-env { display:flex; flex-direction:column; gap:4px; padding:12px 14px; border:1px solid var(--border, #ddd); border-radius:12px; cursor:pointer; transition:border-color .15s, background .15s; }
.z-env input { position:absolute; opacity:0; pointer-events:none; }
.z-env small { color:var(--text-muted, #777); line-height:1.6; }
.z-env.is-on { border-color:var(--primary, #0b6b4f); background:rgba(11,107,79,.06); }
.z-env:focus-within { outline:2px solid var(--primary, #0b6b4f); outline-offset:2px; }
.z-env .badge { align-self:flex-start; margin-top:4px; }
.z-msgs { list-style:none; margin:8px 0 0; padding:0; font-size:12.5px; line-height:1.8; }
.z-msgs li b { margin-inline-end:6px; }
.z-how { margin:0 0 14px; padding-inline-start:20px; line-height:1.9; color:var(--text-muted, #666); }
.wrap { flex-wrap:wrap; }

.cmp-sum{display:flex;gap:24px;flex-wrap:wrap;margin-bottom:12px}.cmp-sum div{display:flex;flex-direction:column;gap:2px}.cmp-sum b{font-size:1.25rem}.cmp-legend{display:flex;gap:16px;justify-content:center;margin-top:8px;font-size:.85rem}.cmp-legend i{display:inline-block;width:10px;height:10px;border-radius:2px;margin-inline-end:6px}.scan-inj svg{display:block}
/* password eye always sits on the right of an LTR field so it never overlaps the dots */
.pw-wrap { direction: ltr; }
.pw-wrap > input { text-align: left; }
.bell { margin-inline-end: 14px; }
.pimg{width:40px;height:40px;object-fit:cover;border-radius:8px;vertical-align:middle;margin-inline-end:8px;background:rgba(var(--ink-rgb),.06)}.pos-item .pimg{width:100%;height:84px;display:block;margin:0 0 6px}.pimg-prev{width:72px;height:72px;border-radius:12px;border:1px dashed rgba(var(--ink-rgb),.25);display:flex;align-items:center;justify-content:center;overflow:hidden;font-size:.75rem}.pimg-prev img{width:100%;height:100%;object-fit:cover}

.nav-section.collapsible > .nav-items{display:none}.nav-section.collapsible.open > .nav-items{display:block}
.nav-toggle{display:flex;align-items:center;justify-content:space-between;width:100%;background:none;border:0;cursor:pointer;font:inherit;color:inherit;text-align:start}
.nav-toggle .chev{transition:transform .2s;opacity:.7}.nav-section.open .nav-toggle .chev{transform:rotate(180deg)}
.nav-toggle{font-size:13.5px !important;padding:10px 14px !important}

/* date picker */
.wfd{position:relative;display:block;width:100%}.wfd-native{position:absolute !important;opacity:0;pointer-events:none;width:1px !important;height:1px !important;padding:0 !important;border:0 !important;inset-inline-start:0;top:0}
.wfd-disp{width:100%;padding-inline-end:44px !important}.wfd-btn{position:absolute;top:0;inset-inline-end:0;height:100%;width:42px;display:flex;align-items:center;justify-content:center;background:none;border:0;color:var(--text-secondary,inherit);cursor:pointer;border-radius:inherit}.wfd-btn:hover{color:var(--primary,inherit)}
.wfd-hint{display:block;font-size:.72rem;color:var(--text-secondary,#777);margin-top:3px;min-height:1em}.wfd-bad{outline:2px solid var(--danger,#d33) !important}
.wfd-pop{position:fixed;z-index:100000;background:var(--bg-card,#fff);color:var(--text,#222);border:1px solid rgba(var(--ink-rgb,0,0,0),.14);border-radius:16px;box-shadow:0 18px 50px rgba(0,0,0,.28);padding:12px;font-size:.9rem}
.wfd-top{display:flex;justify-content:center;margin-bottom:8px}.wfd-mode{display:inline-flex;background:rgba(var(--ink-rgb,0,0,0),.07);border-radius:999px;padding:3px}.wfd-mode button{border:0;background:none;padding:5px 16px;border-radius:999px;cursor:pointer;font:inherit;color:inherit}.wfd-mode button.on{background:var(--primary,#0b7a5a);color:#fff}
.wfd-nav{display:flex;gap:4px;align-items:center;margin-bottom:8px;direction:ltr}.wfd-nav button{border:0;background:rgba(var(--ink-rgb,0,0,0),.06);border-radius:8px;width:32px;height:32px;cursor:pointer;font-size:1.1rem;color:inherit;flex:none}.wfd-nav select{flex:1;min-width:0;height:32px;border-radius:8px;border:1px solid rgba(var(--ink-rgb,0,0,0),.15);background:transparent;color:inherit;font:inherit;padding:0 4px}
.wfd-wd,.wfd-days{display:grid;grid-template-columns:repeat(7,1fr);gap:2px}.wfd-wd span{text-align:center;font-size:.74rem;color:var(--text-secondary,#777);padding:4px 0}
.wfd-day{display:flex;flex-direction:column;align-items:center;justify-content:center;height:40px;min-width:0;border:0;border-radius:10px;background:none;cursor:pointer;color:inherit;padding:0;font:inherit;line-height:1.15}.wfd-day b{font-size:.92rem;font-weight:600}.wfd-day i{font-style:normal;font-size:.6rem;opacity:.55}
.wfd-day:hover{background:rgba(var(--ink-rgb,0,0,0),.08)}.wfd-day.fri b{color:var(--danger,#c0392b)}.wfd-day.today{box-shadow:inset 0 0 0 1.5px var(--gold,#c9a24b)}.wfd-day.focus{outline:2px solid var(--primary,#0b7a5a);outline-offset:-2px}.wfd-day.sel{background:var(--primary,#0b7a5a);color:#fff}.wfd-day.sel b{color:#fff}.wfd-day:disabled{opacity:.3;cursor:not-allowed}
.wfd-foot{display:flex;gap:8px;align-items:center;margin-top:8px;flex-wrap:wrap}.wfd-foot button{border:0;background:rgba(var(--ink-rgb,0,0,0),.07);border-radius:8px;padding:6px 12px;cursor:pointer;font:inherit;color:inherit}.wfd-sub{flex:1;font-size:.72rem;color:var(--text-secondary,#777);text-align:center}
@media (max-width:520px){.wfd-pop{left:8px !important;right:8px;width:auto !important;top:auto !important;bottom:8px;max-height:90vh;overflow:auto}}
.wfd-in{position:relative;display:block}.wfd-nav button{width:28px !important}.wfd-nav select{font-size:.85rem;padding:0 2px !important}.wfd-nav select[data-sel=m]{flex:1.7}.wfd-nav select[data-sel=y]{flex:1}.nav-toggle{padding:8px 14px !important}

/* 3.4.2: bell badge sits clear of the company name; password eye never overlaps the text */
.bell{margin-inline:6px 14px;padding:6px;border-radius:10px}.bell-n{top:-5px !important;inset-inline-end:-7px !important;box-shadow:0 0 0 2px var(--bg-card,#fff)}
.top-header{gap:12px}

/* 3.4.2: collapse = icon-only rail (like the old system), accordion groups */
@media (min-width:901px){
  body.side-collapsed{--sidebar-width:70px}
  body.side-collapsed .sidebar,body.ltr.side-collapsed .sidebar{transform:none !important;visibility:visible !important;width:70px;overflow:hidden}
  body.side-collapsed .main-content{margin-right:70px !important}body.ltr.side-collapsed .main-content{margin-right:0 !important;margin-left:70px !important}
  body.side-collapsed .sidebar .logo-text,body.side-collapsed .sidebar .nav-section-title,body.side-collapsed .sidebar .nav-item span,body.side-collapsed .sidebar .sidebar-footer .user-info>div:not(.user-avatar),body.side-collapsed .sidebar .sidebar-actions .btn span{display:none !important}
  body.side-collapsed .sidebar .nav-section.collapsible>.nav-items{display:block !important}
  body.side-collapsed .sidebar .nav-section{margin-bottom:2px;border-bottom:1px solid var(--border)}
  body.side-collapsed .sidebar .nav-item{justify-content:center;padding:10px 0;margin:1px 8px}
  body.side-collapsed .sidebar .sidebar-logo{justify-content:center;padding-inline:0}
}

.upload-boxes.single{grid-template-columns:minmax(0,260px)}

.cheque-box{margin:8px 0 14px;padding:12px 14px;border:1px dashed var(--border);border-radius:12px;background:var(--bg-glass)}.cheque-title{font-weight:700;margin-bottom:8px;color:var(--primary)}.cheque-box.hidden{display:none}
