:root {
  --bg: #f8fafc;
  --surface: #ffffff;
  --surface-2: #f1f5f9;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --text: #0f172a;
  --text-2: #475569;
  --muted: #94a3b8;
  --primary: #4f46e5;
  --primary-dark: #4338ca;
  --primary-soft: #eef2ff;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --danger-soft: #fef2f2;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow: 0 1px 3px rgba(15, 23, 42, 0.06), 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-md: 0 4px 6px -1px rgba(15, 23, 42, 0.07), 0 2px 4px -2px rgba(15, 23, 42, 0.04);
  --shadow-lg: 0 10px 15px -3px rgba(15, 23, 42, 0.08), 0 4px 6px -4px rgba(15, 23, 42, 0.04);
  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 14px;
  --sidebar-w: 260px;
  --topbar-h: 60px;
  --transition: 0.18s cubic-bezier(0.4, 0, 0.2, 1);
}

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

html, body { width: 100%; }

body {
  font-family: 'Cairo', -apple-system, BlinkMacSystemFont, 'Segoe UI', Tahoma, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
  min-height: 100vh;
  font-size: 15px;
}

.hidden { display: none !important; }

.screen { width: 100%; min-height: 100vh; }
#main-screen { display: block; width: 100%; }

button { font-family: inherit; cursor: pointer; }

input, textarea, select {
  font-family: inherit; font-size: 15px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  transition: border-color var(--transition), box-shadow var(--transition);
  width: 100%;
}
input:focus, textarea:focus, select:focus {
  outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.12);
}
textarea { resize: vertical; min-height: 100px; line-height: 1.6; }

/* ────────────────── Buttons ────────────────── */
.btn { font-size: 14px; font-weight: 600; padding: 9px 16px;
  border: 1px solid transparent; border-radius: var(--radius-sm);
  display: inline-flex; align-items: center; gap: 6px;
  transition: all var(--transition); white-space: nowrap;
}
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-primary:disabled { background: var(--muted); cursor: not-allowed; }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn-secondary:hover { background: var(--surface-2); border-color: var(--border-strong); }
.btn-ghost { background: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.btn-danger { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.btn-danger:hover { background: var(--danger); color: white; }
.btn-lg { padding: 12px 22px; font-size: 15px; }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-icon { padding: 8px; }

/* ────────────────── Layout ────────────────── */
:root {
  --topnav-h: 64px;
}

.app-shell {
  display: grid;
  grid-template-columns: 1fr;
  grid-template-rows: var(--topnav-h) 1fr;
  grid-template-areas: "topnav" "main";
  min-height: 100vh;
  width: 100%;
}
.app-shell.no-sidebar {
  grid-template-columns: 1fr;
  grid-template-areas: "topbar" "main";
  grid-template-rows: var(--topbar-h) 1fr;
}

/* ────────────────── TOP NAVIGATION (refined Stripe/Vercel style) ────────────────── */
.topnav {
  grid-area: topnav;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 50;
  box-shadow: var(--shadow-sm);
}
.topnav-inner {
  max-width: 1400px; margin: 0 auto;
  padding: 0 28px;
  height: var(--topnav-h);
  display: flex; align-items: center;
  gap: 24px;
}
.topnav-brand {
  display: flex; align-items: center; gap: 10px;
  font-size: 16px; font-weight: 800;
  color: var(--text);
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 8px;
  transition: background var(--transition);
}
.topnav-brand:hover { background: var(--surface-2); }
.topnav-brand .brand-icon { font-size: 22px; }

.topnav-items {
  display: flex; align-items: center; gap: 2px;
  flex: 1;
}
.topnav-item {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 7px 12px;
  background: transparent; border: none;
  font-family: inherit; font-size: 13.5px; font-weight: 600;
  color: var(--text-2);
  cursor: pointer;
  border-radius: 8px;
  transition: all var(--transition);
  white-space: nowrap;
}
.topnav-item:hover { background: var(--surface-2); color: var(--text); }
.topnav-item.active { background: var(--primary-soft); color: var(--primary); }
.topnav-item .tni-icon { font-size: 16px; }
.topnav-item .tni-count {
  font-size: 11px; font-weight: 700;
  background: var(--surface-2);
  color: var(--text-2);
  padding: 1px 7px; border-radius: 99px;
}
.topnav-item:hover .tni-count, .topnav-item.active .tni-count {
  background: white; color: var(--primary);
}

.topnav-cta {
  background: var(--primary) !important;
  color: white !important;
  padding: 8px 14px !important;
  font-weight: 700 !important;
  margin-right: 6px;
}
.topnav-cta:hover { background: var(--primary-dark) !important; transform: translateY(-1px); }

.topnav-right {
  display: flex; align-items: center; gap: 6px;
}
.topnav-icon {
  background: transparent; border: none;
  width: 38px; height: 38px; border-radius: 8px;
  font-size: 18px; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  transition: background var(--transition);
}
.topnav-icon:hover { background: var(--surface-2); }

@media (max-width: 1100px) {
  .topnav-item .tni-label { display: none; }
}
@media (max-width: 720px) {
  .topnav-inner { padding: 0 14px; gap: 8px; }
  .topnav-brand .brand-text { display: none; }
}

/* ────────────────── Categories as horizontal chips ────────────────── */
.cats-chips-wrap {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid rgba(255,255,255,0.18);
}
.cats-chips-head {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 10px;
}
.cats-chips-title {
  font-size: 13px; font-weight: 700;
  color: rgba(255,255,255,0.9);
}
.cats-add-btn {
  background: rgba(255,255,255,0.12);
  color: white;
  border: none;
  padding: 4px 10px;
  border-radius: 99px;
  font-size: 12px; font-weight: 700;
  cursor: pointer;
  transition: background var(--transition);
}
.cats-add-btn:hover { background: rgba(255,255,255,0.22); }

.cats-chips {
  display: flex; gap: 6px;
  flex-wrap: wrap;
}
.cats-chip-item {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px;
  background: rgba(255,255,255,0.1);
  color: white;
  border: 1px solid rgba(255,255,255,0.18);
  border-radius: 99px;
  font-size: 12px; font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  font-family: inherit;
}
.cats-chip-item:hover { background: rgba(255,255,255,0.2); border-color: rgba(255,255,255,0.4); }
.cats-chip-item.active {
  background: white; color: var(--primary);
  border-color: white;
  font-weight: 800;
}
.cats-chip-item .chip-icon { font-size: 13px; }
.cats-chip-item .chip-count {
  font-size: 10px; font-weight: 700;
  background: rgba(255,255,255,0.25);
  padding: 1px 6px; border-radius: 99px;
  color: white;
}
.cats-chip-item.active .chip-count {
  background: var(--primary-soft); color: var(--primary);
}

/* ────────────────── Main Navigation Sidebar ────────────────── */
.main-nav {
  grid-area: main-nav;
  background: var(--ink);
  color: white;
  padding: 18px 12px;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}
.main-nav-brand {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px 18px;
  margin-bottom: 14px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  font-size: 16px; font-weight: 800;
}
.main-nav-brand .brand-icon { font-size: 22px; }

.main-nav-items {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.main-nav-footer {
  border-top: 1px solid rgba(255,255,255,0.1);
  padding-top: 8px;
  margin-top: 8px;
}

.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 14px;
  background: transparent; border: none;
  color: rgba(255,255,255,0.75);
  font-family: inherit; font-size: 14px; font-weight: 600;
  text-align: right; cursor: pointer;
  border-radius: var(--radius-sm);
  transition: all var(--transition);
  width: 100%;
}
.nav-item:hover { background: rgba(255,255,255,0.08); color: white; }
.nav-item.active { background: var(--primary); color: white; }
.nav-item .ni-icon { font-size: 18px; width: 24px; text-align: center; }
.nav-item .ni-label { flex: 1; }
.nav-item .ni-count {
  font-size: 11px; font-weight: 700;
  background: rgba(255,255,255,0.15);
  padding: 2px 8px; border-radius: 99px;
  color: white;
}
.nav-item.active .ni-count { background: rgba(255,255,255,0.25); }

.nav-item-primary {
  background: var(--primary);
  color: white !important;
  font-weight: 700;
  margin-bottom: 4px;
}
.nav-item-primary:hover { background: var(--primary-dark); color: white; }
.nav-item-primary .ni-icon { font-size: 20px; }

.nav-divider {
  height: 1px;
  background: rgba(255,255,255,0.1);
  margin: 8px 4px;
}

/* ════════════════ Quotation View Page (read-only) ════════════════ */
#quote-view { padding-bottom: 60px; }

.qv-toolbar {
  position: sticky; top: var(--topnav-h); z-index: 30;
  background: var(--bg);
  padding: 14px 0;
  margin-bottom: 18px;
  display: flex; justify-content: space-between; align-items: center;
  gap: 12px; flex-wrap: wrap;
  border-bottom: 1px solid var(--border);
}
.qv-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.qv-doc {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 32px;
  box-shadow: var(--shadow-md);
  animation: fadeInUp 0.3s ease;
}

.qv-head {
  display: flex; justify-content: space-between; align-items: flex-start;
  gap: 20px; flex-wrap: wrap;
  padding-bottom: 24px;
  margin-bottom: 24px;
  border-bottom: 2px solid var(--ink);
}
.qv-type {
  font-size: 12px; font-weight: 700;
  color: var(--primary);
  text-transform: uppercase; letter-spacing: 0.08em;
  margin-bottom: 4px;
}
.qv-number {
  font-size: 28px; font-weight: 800;
  color: var(--text); letter-spacing: -0.02em;
  font-family: 'Consolas', monospace;
}
.qv-meta {
  font-size: 13px; color: var(--text-2);
  margin-top: 6px;
}

.qv-totals-summary {
  text-align: left; min-width: 200px;
}
.qv-total-label {
  font-size: 12px; font-weight: 600;
  color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em;
}
.qv-total-value {
  font-size: 30px; font-weight: 800;
  color: var(--primary); letter-spacing: -0.02em;
  direction: ltr; text-align: left;
  margin: 4px 0 8px;
  font-feature-settings: "tnum";
}
.qv-status-badge {
  display: inline-block; padding: 4px 12px;
  border-radius: 99px; font-size: 12px; font-weight: 700;
}
.qv-status-badge.draft { background: #f3f4f6; color: #4b5563; }
.qv-status-badge.sent { background: #dbeafe; color: #1e40af; }
.qv-status-badge.accepted { background: #d1fae5; color: #065f46; }
.qv-status-badge.rejected { background: #fee2e2; color: #991b1b; }
.qv-status-badge.imported { background: #fef3c7; color: #92400e; }
.qv-status-badge.issued { background: #fef3c7; color: #92400e; }

.qv-section {
  margin-bottom: 28px;
}
.qv-section:last-child { margin-bottom: 0; }
.qv-section-title {
  font-size: 14px; font-weight: 800;
  color: var(--text);
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

.qv-client-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px 24px;
}
.qv-client-field {
  display: flex; flex-direction: column; gap: 2px;
  font-size: 13px;
}
.qv-client-field .qv-cf-label {
  font-size: 11px; color: var(--muted); font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.04em;
}
.qv-client-field .qv-cf-value {
  color: var(--text); font-weight: 700;
}
.qv-client-field.name .qv-cf-value {
  color: var(--primary); font-size: 16px; font-weight: 800;
}

.qv-totals-section {
  background: var(--surface-2);
  border-radius: var(--radius);
  padding: 18px 22px;
  margin-top: 12px;
}
.qv-totals-rows { display: flex; flex-direction: column; gap: 8px; max-width: 380px; margin-right: auto; }
.qv-totals-row {
  display: flex; justify-content: space-between;
  padding: 6px 0; font-size: 14px;
  color: var(--text-2); font-weight: 600;
}
.qv-totals-row.final {
  border-top: 2px solid var(--text);
  padding-top: 12px; margin-top: 4px;
  font-size: 16px; font-weight: 800; color: var(--text);
}
.qv-totals-row.discount .val { color: var(--danger); }
.qv-totals-row .val { font-family: 'Consolas', monospace; direction: ltr; }

/* ────────────────── Home content (full width) ────────────────── */
.home-content { min-width: 0; }
#home-view, #newquote-view, #products-view, #quote-view {
  max-width: 1400px;
  margin: 0 auto;
  padding: 28px 28px 60px;
}
.main { grid-area: main; }

/* New quotation page header */
.newquote-page-head {
  display: flex; justify-content: space-between; align-items: flex-start;
  gap: 14px; margin-bottom: 24px;
}
.newquote-page-head .page-title {
  font-size: 24px; font-weight: 800;
  letter-spacing: -0.02em;
}
.newquote-page-head .page-subtitle {
  font-size: 14px; color: var(--text-2);
  margin-top: 4px;
}

@media (max-width: 720px) {
  #home-view, #newquote-view, #products-view { padding: 18px 14px; }
}

.topbar {
  grid-area: topbar;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; z-index: 50;
}
.brand {
  font-size: 18px; font-weight: 800; color: var(--primary);
  display: flex; align-items: center; gap: 8px;
}
.brand-icon { font-size: 22px; }
.topbar-actions { display: flex; gap: 8px; align-items: center; }

/* ────────────────── Sidebar ────────────────── */
.sidebar {
  grid-area: sidebar;
  background: var(--surface);
  border-left: 1px solid var(--border);
  padding: 18px 12px;
  overflow-y: auto;
  position: sticky;
  top: var(--topbar-h);
  height: calc(100vh - var(--topbar-h));
}
.sidebar-title {
  font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.05em;
  color: var(--muted); padding: 0 10px 8px;
}
.sidebar-list { display: flex; flex-direction: column; gap: 2px; }
.cat-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--transition);
  border: none; background: transparent;
  text-align: right; width: 100%;
  font-size: 14px; color: var(--text-2);
}
.cat-item:hover { background: var(--surface-2); color: var(--text); }
.cat-item.active {
  background: var(--primary-soft);
  color: var(--primary);
  font-weight: 700;
}
.cat-icon {
  width: 28px; height: 28px;
  border-radius: 7px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 15px;
  flex-shrink: 0;
}
.cat-name { flex: 1; }
.cat-count {
  font-size: 12px; color: var(--muted);
  background: var(--surface-2);
  padding: 2px 8px; border-radius: 99px;
  font-weight: 600;
}
.cat-item.active .cat-count { background: white; color: var(--primary); }

.sidebar-divider {
  height: 1px; background: var(--border);
  margin: 12px 8px;
}

/* ────────────────── Main ────────────────── */
.main {
  grid-area: main;
  padding: 28px 32px;
  overflow-x: hidden;
  width: 100%;
  min-width: 0;
}
.container { max-width: 1100px; margin: 0 auto; width: 100%; }

.page-header {
  display: flex; justify-content: space-between; align-items: flex-start;
  margin-bottom: 24px; gap: 16px; flex-wrap: wrap;
}
.page-title { font-size: 24px; font-weight: 800; margin-bottom: 4px; }
.page-subtitle { color: var(--text-2); font-size: 14px; }

/* ────────────────── Cards ────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 20px;
}
.card h2 { font-size: 17px; font-weight: 700; margin-bottom: 14px; color: var(--text); }
.card .hint { font-size: 13px; color: var(--text-2); margin: 6px 0; }
.card pre {
  background: #0f172a; color: #e2e8f0; padding: 12px;
  border-radius: var(--radius-sm); font-size: 13px; overflow-x: auto;
  direction: ltr; text-align: left; font-family: 'Consolas', monospace;
}
.card code {
  background: var(--surface-2); padding: 2px 6px; border-radius: 4px;
  font-size: 13px; direction: ltr; display: inline-block;
  font-family: 'Consolas', monospace;
}

/* ════════════════════════════════════════════════════
   MODERN DASHBOARD — 2026 design standard
   ════════════════════════════════════════════════════ */
#dashboard {
  margin-bottom: 32px;
  display: flex; flex-direction: column;
  gap: 22px;
  animation: fadeInUp 0.3s ease;
}

@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

/* ─── Welcome header ─── */
.dash-welcome {
  display: flex; justify-content: space-between; align-items: flex-end;
  flex-wrap: wrap; gap: 14px;
  padding: 4px 4px;
}
.dash-greeting {
  font-size: 28px; font-weight: 800;
  color: var(--text); letter-spacing: -0.02em;
  line-height: 1.1;
}
.dash-greeting-sub {
  font-size: 14px; color: var(--text-2);
  margin-top: 6px; font-weight: 500;
}
.dash-date {
  font-size: 13px; font-weight: 600; color: var(--muted);
  padding: 6px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 99px;
}

/* ─── Primary CTA card ─── */
.dash-cta {
  position: relative;
  background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 50%, #a855f7 100%);
  color: white;
  border: none;
  border-radius: 16px;
  padding: 26px 28px;
  display: flex; align-items: center; justify-content: space-between;
  cursor: pointer;
  overflow: hidden;
  font-family: inherit;
  text-align: right;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 10px 30px -10px rgba(79, 70, 229, 0.4);
}
.dash-cta::before {
  content: ""; position: absolute; inset: 0;
  background: radial-gradient(circle at 0% 100%, rgba(255,255,255,0.15) 0%, transparent 50%);
  pointer-events: none;
}
.dash-cta:hover {
  transform: translateY(-2px);
  box-shadow: 0 14px 40px -10px rgba(79, 70, 229, 0.55);
}
.dash-cta:active { transform: translateY(0); }

.dash-cta-content {
  display: flex; align-items: center; gap: 18px;
  position: relative; z-index: 1;
}
.dash-cta-icon {
  width: 56px; height: 56px;
  background: rgba(255,255,255,0.15);
  border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  font-size: 28px;
  backdrop-filter: blur(8px);
}
.dash-cta-text h2 {
  font-size: 20px; font-weight: 800;
  margin-bottom: 4px; letter-spacing: -0.01em;
}
.dash-cta-text p {
  font-size: 13px; opacity: 0.85; font-weight: 500;
}
.dash-cta-arrow {
  font-size: 32px; font-weight: 300;
  opacity: 0.7;
  transition: transform var(--transition);
  position: relative; z-index: 1;
}
.dash-cta:hover .dash-cta-arrow { transform: translateX(-6px); opacity: 1; }

/* ─── KPI Stats ─── */
.dash-kpis {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
}
.kpi {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 18px 18px 16px;
  position: relative;
  overflow: hidden;
  transition: all var(--transition);
}
.kpi::after {
  content: ""; position: absolute;
  top: 0; right: 0; width: 80px; height: 80px;
  border-radius: 50%;
  opacity: 0.08;
  transform: translate(40%, -40%);
  pointer-events: none;
}
.kpi[data-tone="indigo"]::after { background: #4f46e5; }
.kpi[data-tone="amber"]::after { background: #f59e0b; }
.kpi[data-tone="emerald"]::after { background: #10b981; }
.kpi[data-tone="rose"]::after { background: #f43f5e; }

.kpi:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }

.kpi-top {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 12px;
}
.kpi-icon {
  width: 36px; height: 36px; border-radius: 10px;
  background: var(--surface-2);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 18px;
}
.kpi[data-tone="indigo"] .kpi-icon { background: #eef2ff; }
.kpi[data-tone="amber"] .kpi-icon { background: #fef3c7; }
.kpi[data-tone="emerald"] .kpi-icon { background: #d1fae5; }
.kpi[data-tone="rose"] .kpi-icon { background: #fee2e2; }

.kpi-pill {
  font-size: 11px; font-weight: 700;
  padding: 3px 10px; border-radius: 99px;
  background: var(--surface-2); color: var(--text-2);
}
.kpi-pill.up { background: #d1fae5; color: #065f46; }
.kpi-pill.down { background: #fee2e2; color: #991b1b; }

.kpi-value {
  font-size: 28px; font-weight: 800;
  color: var(--text); letter-spacing: -0.02em;
  line-height: 1.1;
  font-feature-settings: "tnum";
}
.kpi-label {
  font-size: 12px; color: var(--text-2);
  margin-top: 6px; font-weight: 600;
}

/* ─── Two-column grid ─── */
.dash-grid {
  display: grid;
  grid-template-columns: 1.6fr 1fr;
  gap: 18px;
  align-items: start;
}

.dash-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 20px 22px;
  box-shadow: var(--shadow-sm);
}
.dash-card-head {
  display: flex; justify-content: space-between; align-items: flex-start;
  margin-bottom: 16px;
  gap: 10px;
}
.dash-card-head h3 {
  font-size: 16px; font-weight: 800; color: var(--text);
  letter-spacing: -0.01em;
}
.dash-card-sub {
  font-size: 12px; color: var(--text-2);
  margin-top: 2px; font-weight: 500;
}
.dash-card-action {
  background: transparent; border: none;
  font-family: inherit; font-size: 12px; font-weight: 700;
  color: var(--primary); cursor: pointer;
  padding: 6px 10px; border-radius: 6px;
  transition: all var(--transition);
}
.dash-card-action:hover { background: var(--primary-soft); }

/* ─── Activity Feed ─── */
.activity-feed { display: flex; flex-direction: column; }
.activity-item {
  display: grid;
  grid-template-columns: 36px 1fr auto;
  gap: 12px; align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: all var(--transition);
}
.activity-item:last-child { border-bottom: none; }
.activity-item:hover { background: var(--surface-2); margin: 0 -10px; padding-left: 10px; padding-right: 10px; border-radius: 6px; }

.activity-icon {
  width: 36px; height: 36px; border-radius: 10px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 16px;
}
.activity-icon.quote { background: #eef2ff; color: #4f46e5; }
.activity-icon.invoice { background: #fef3c7; color: #d97706; }
.activity-icon.po { background: #eff6ff; color: #1e40af; }

.activity-text { min-width: 0; }
.activity-title {
  font-size: 14px; font-weight: 700; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.activity-meta {
  font-size: 12px; color: var(--text-2);
  margin-top: 2px;
  display: flex; gap: 8px; flex-wrap: wrap;
}
.activity-meta .sep { color: var(--line-strong); }

.activity-right {
  text-align: left; direction: ltr;
  font-size: 13px; font-weight: 700; color: var(--text);
  font-feature-settings: "tnum";
}

/* ─── Quick Links ─── */
.dash-side { display: flex; flex-direction: column; gap: 18px; }
.quick-link-list { display: flex; flex-direction: column; gap: 4px; }
.quick-link {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px;
  background: transparent; border: none;
  font-family: inherit; text-align: right;
  cursor: pointer; width: 100%;
  border-radius: 10px;
  transition: all var(--transition);
}
.quick-link:hover { background: var(--surface-2); }
.ql-icon {
  width: 36px; height: 36px; border-radius: 10px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 16px;
}
.ql-text { flex: 1; font-size: 13px; font-weight: 700; color: var(--text); }
.ql-count {
  font-size: 12px; font-weight: 700; color: var(--text-2);
  background: var(--surface-2);
  padding: 2px 10px; border-radius: 99px;
}

/* ─── Status Overview ─── */
.status-rows { display: flex; flex-direction: column; gap: 10px; }
.status-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 8px 0;
  font-size: 13px;
}
.status-row .sr-label { color: var(--text-2); font-weight: 600; }
.status-row .sr-value {
  font-weight: 800; color: var(--text);
}

.activity-empty {
  text-align: center; padding: 32px 16px;
  color: var(--text-2); font-size: 13px;
}

@media (max-width: 1200px) {
  .dash-kpis { grid-template-columns: repeat(2, 1fr); }
  .dash-grid { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .dash-kpis { grid-template-columns: 1fr; }
  .dash-greeting { font-size: 22px; }
  .dash-cta { padding: 20px; }
  .dash-cta-text h2 { font-size: 17px; }
}

/* ────────────────── Hero / search ────────────────── */
.hero-card {
  background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
  color: white;
  border-radius: var(--radius-lg);
  padding: 32px;
  margin-bottom: 24px;
  box-shadow: var(--shadow-lg);
}
.hero-card h1 { font-size: 24px; font-weight: 800; margin-bottom: 6px; }
.hero-card .subtitle { color: rgba(255, 255, 255, 0.85); font-size: 14px; margin-bottom: 18px; }

.search-shell {
  background: white;
  border-radius: var(--radius);
  padding: 14px;
  box-shadow: var(--shadow-md);
}
.search-shell textarea {
  border: none; padding: 8px 6px; min-height: 70px;
  font-size: 15px;
}
.search-shell textarea:focus { box-shadow: none; }
.search-row {
  display: flex; gap: 10px; align-items: center;
  padding-top: 10px; border-top: 1px solid var(--border);
  flex-wrap: wrap;
}
.search-row .scope-chip {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--primary-soft); color: var(--primary);
  padding: 6px 10px; border-radius: 99px; font-size: 13px; font-weight: 600;
}
.search-row .scope-chip button {
  border: none; background: transparent; color: inherit;
  cursor: pointer; padding: 0 2px; font-size: 14px;
}
.search-row .client-input {
  flex: 1; min-width: 180px;
  display: flex; align-items: center; gap: 8px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 0 10px;
}
.search-row .client-input span { color: var(--muted); font-size: 13px; }
.search-row .client-input input {
  border: none; padding: 8px 0; background: transparent;
}
.search-row .client-input input:focus { box-shadow: none; }

/* ────────────────── Image attach previews ────────────────── */
.image-previews {
  display: flex; gap: 8px; flex-wrap: wrap;
  padding: 8px 0;
  border-top: 1px solid var(--border);
  margin-top: 4px;
}
.image-thumb {
  position: relative; width: 70px; height: 70px;
  border-radius: 6px; overflow: hidden;
  border: 1px solid var(--border);
  background: var(--surface-2);
}
.image-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.image-thumb button {
  position: absolute; top: 2px; left: 2px;
  width: 22px; height: 22px; border-radius: 50%;
  background: rgba(220, 38, 38, 0.92); color: white;
  border: none; cursor: pointer; font-size: 13px; line-height: 1;
  display: flex; align-items: center; justify-content: center;
}

/* ────────────────── Status messages ────────────────── */
.status { margin-top: 12px; padding: 10px 14px; border-radius: var(--radius-sm); font-size: 13px; font-weight: 600; }
.status-ok { background: #d1fae5; color: #065f46; }
.status-err { background: var(--danger-soft); color: #991b1b; }
.status-info { background: #dbeafe; color: #1e40af; }

/* ────────────────── Tables ────────────────── */
.table-wrap { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--border); background: white; }
table.data-table { width: 100%; border-collapse: collapse; font-size: 14px; }
table.data-table th, table.data-table td {
  padding: 11px 12px;
  text-align: right;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
table.data-table thead th {
  background: var(--surface-2);
  font-weight: 700;
  color: var(--text-2);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
table.data-table tbody tr:last-child td { border-bottom: none; }
table.data-table tbody tr:hover { background: var(--surface-2); }
table.data-table input {
  padding: 6px 8px; font-size: 13px; border-radius: 5px;
}
table.data-table input[type="number"] { text-align: center; }
.col-narrow { width: 95px; }
.col-mid { width: 115px; }
.input-warn {
  border-color: var(--danger) !important;
  background: #fef2f2 !important;
  color: var(--danger) !important;
  font-weight: 700;
}
.row-no-price td:nth-child(7) strong { color: var(--danger); }

.zero-price-warn {
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-right: 4px solid var(--danger);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  margin-bottom: 12px;
  font-size: 13px;
  color: #991b1b;
}
.cell-icon-btn {
  border: none; background: transparent; color: var(--danger);
  cursor: pointer; font-size: 16px; padding: 4px 8px;
  border-radius: 4px;
}
.cell-icon-btn:hover { background: var(--danger-soft); }

/* ────────────────── Totals ────────────────── */
.totals {
  margin-top: 20px; padding: 16px 20px;
  background: var(--surface-2); border-radius: var(--radius);
  max-width: 400px; margin-right: auto;
}
.totals-row {
  display: flex; justify-content: space-between;
  padding: 6px 0; font-weight: 600; font-size: 14px; color: var(--text-2);
}
.total-final {
  border-top: 2px solid var(--text); margin-top: 8px; padding-top: 12px;
  font-size: 16px; font-weight: 800; color: var(--text);
}

/* ────────────────── Modal ────────────────── */
.modal {
  position: fixed; inset: 0;
  background: rgba(15, 23, 42, 0.5);
  backdrop-filter: blur(2px);
  display: flex; align-items: center; justify-content: center;
  z-index: 200; padding: 20px;
  animation: fadeIn 0.15s;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal-content {
  background: white; border-radius: var(--radius-lg);
  width: 100%; max-width: 720px; max-height: 88vh;
  display: flex; flex-direction: column;
  box-shadow: var(--shadow-lg);
  animation: slideUp 0.2s;
}
@keyframes slideUp { from { transform: translateY(20px); opacity: 0; } to { transform: none; opacity: 1; } }
.modal-head {
  padding: 18px 24px;
  border-bottom: 1px solid var(--border);
  display: flex; justify-content: space-between; align-items: center;
}
.modal-head h2 { font-size: 17px; font-weight: 700; }
.modal-body { padding: 24px; overflow-y: auto; }
.modal-foot {
  padding: 14px 24px; border-top: 1px solid var(--border);
  display: flex; justify-content: flex-end; gap: 10px;
}
.btn-close {
  background: transparent; border: none; font-size: 22px;
  cursor: pointer; color: var(--muted); line-height: 1;
  padding: 4px 8px; border-radius: 4px;
}
.btn-close:hover { background: var(--surface-2); color: var(--text); }

/* ────────────────── Forms ────────────────── */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
.form-grid label { display: flex; flex-direction: column; gap: 5px; font-size: 13px; font-weight: 600; color: var(--text-2); }
.form-grid label.full { grid-column: 1 / -1; }

/* ────────────────── Upload area ────────────────── */
.upload-card {
  background: var(--surface-2);
  border: 2px dashed var(--border-strong);
  border-radius: var(--radius);
  padding: 20px;
  margin-top: 12px;
  display: flex; flex-direction: column; gap: 12px;
}
.upload-card .row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.upload-card input[type="file"] {
  flex: 1; min-width: 200px; padding: 7px;
  background: white;
}
.upload-card select { max-width: 280px; }

/* ────────────────── Multi-select chips ────────────────── */
.chips-input {
  display: flex; flex-wrap: wrap; gap: 6px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 6px; background: white; min-height: 42px;
}
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--primary-soft); color: var(--primary);
  padding: 4px 10px; border-radius: 99px; font-size: 13px; font-weight: 600;
}
.chip button { border: none; background: transparent; color: inherit; cursor: pointer; font-size: 13px; padding: 0; }
.chips-input .chip-add {
  border: none; background: transparent; outline: none;
  padding: 4px 8px; font-size: 13px; flex: 1; min-width: 120px;
}

/* ────────────────── Client info section ────────────────── */
.client-section {
  background: var(--surface-2);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 18px;
}
.client-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 12px;
}
.client-grid label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; }
.client-grid .lbl { font-weight: 700; color: var(--text-2); }
.client-grid label.full { grid-column: 1 / -1; }
.client-grid label.client-name-full { grid-column: 1 / -1; }
.client-grid input { padding: 8px 10px; font-size: 14px; background: white; }

@media (max-width: 720px) {
  .client-grid { grid-template-columns: 1fr; }
}

/* ────────────────── Products page ────────────────── */
.products-toolbar {
  display: flex; gap: 10px; margin-bottom: 14px; flex-wrap: wrap;
  align-items: center;
}
.products-toolbar .prod-search-input { flex: 1; min-width: 240px; }
.products-toolbar select {
  width: auto; min-width: 160px; padding: 9px 12px;
}

.bulk-bar {
  display: flex; justify-content: space-between; align-items: center;
  background: var(--primary-soft); color: var(--primary);
  padding: 10px 14px; border-radius: var(--radius-sm);
  margin-bottom: 12px;
  font-size: 14px; font-weight: 600;
  gap: 12px; flex-wrap: wrap;
}
.bulk-bar select { background: white; padding: 6px 10px; font-size: 13px; }

.products-table tbody tr.row-selected { background: #eef2ff !important; }
.products-table .desc-col {
  max-width: 480px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.products-table .price-zero { color: var(--danger); font-weight: 700; }
.products-table .price-zero::after { content: ' (بدون سعر)'; font-size: 11px; font-weight: 500; }

.nav-active {
  background: var(--primary-soft) !important;
  color: var(--primary) !important;
}

/* ────────────────── Client suggestions dropdown ────────────────── */
.client-suggestions {
  position: absolute; top: 100%; right: 0; left: 0;
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
  z-index: 50;
  max-height: 240px;
  overflow-y: auto;
  margin-top: 4px;
}
.client-suggestion-item {
  padding: 10px 12px;
  cursor: pointer;
  display: flex; flex-direction: column; gap: 2px;
  border-bottom: 1px solid var(--border);
  transition: background var(--transition);
}
.client-suggestion-item:last-child { border-bottom: none; }
.client-suggestion-item:hover { background: var(--primary-soft); }
.client-suggestion-item .cs-name {
  font-weight: 700; font-size: 13px; color: var(--text);
}
.client-suggestion-item .cs-meta {
  font-size: 11px; color: var(--text-2);
  display: flex; gap: 10px;
}

/* ────────────────── Quotation status badges ────────────────── */
.quote-status {
  display: inline-block; padding: 2px 8px; border-radius: 99px;
  font-size: 11px; font-weight: 700;
}
.quote-status.draft { background: #f3f4f6; color: #4b5563; }
.quote-status.sent { background: #dbeafe; color: #1e40af; }
.quote-status.accepted { background: #d1fae5; color: #065f46; }
.quote-status.rejected { background: #fee2e2; color: #991b1b; }
.quote-status.imported { background: #fef3c7; color: #92400e; }

/* ────────────────── PO Status badges ────────────────── */
.po-status {
  display: inline-block; padding: 2px 8px; border-radius: 99px;
  font-size: 11px; font-weight: 700;
}
.po-status.draft { background: #f3f4f6; color: #4b5563; }
.po-status.sent { background: #dbeafe; color: #1e40af; }
.po-status.acknowledged { background: #e0e7ff; color: #4338ca; }
.po-status.in_transit { background: #fef3c7; color: #92400e; }
.po-status.partial { background: #fed7aa; color: #c2410c; }
.po-status.received { background: #d1fae5; color: #065f46; }
.po-status.closed { background: #e5e7eb; color: #1f2937; }
.po-status.cancelled { background: #fee2e2; color: #991b1b; }

/* ────────────────── Supplier contacts (multi) ────────────────── */
.contacts-section {
  margin-top: 18px; padding-top: 14px;
  border-top: 2px solid var(--border);
}
.contacts-head {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 12px;
}
.contacts-head h3 {
  font-size: 15px; font-weight: 700;
}
.contact-card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
  margin-bottom: 10px;
  position: relative;
}
.contact-card .contact-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 10px;
}
.contact-card .contact-number {
  font-size: 12px; font-weight: 700; color: var(--primary);
}
.contact-card .contact-remove {
  background: transparent; border: none; cursor: pointer;
  color: var(--danger); font-size: 16px; padding: 2px 6px;
  border-radius: 4px;
}
.contact-card .contact-remove:hover { background: var(--danger-soft); }
.contact-card .contact-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.contact-card .contact-grid label {
  display: flex; flex-direction: column; gap: 3px;
  font-size: 12px; font-weight: 600; color: var(--text-2);
}
.contact-card .contact-grid label.full { grid-column: 1 / -1; }
.contact-card .contact-grid input {
  padding: 7px 10px; font-size: 13px;
}

.contacts-empty {
  text-align: center; padding: 16px; color: var(--text-2);
  font-size: 13px; font-style: italic;
  background: var(--surface-2); border-radius: 6px;
}

/* ────────────────── Supplier rating stars ────────────────── */
.supplier-rating { color: #f59e0b; font-size: 14px; letter-spacing: 1px; }

/* ────────────────── WhatsApp setup guide ────────────────── */
.wa-guide {
  margin-top: 12px; padding-top: 12px;
  border-top: 1px solid var(--border);
  font-size: 13px; line-height: 1.7;
}
.wa-guide h4 {
  font-size: 13px; font-weight: 800;
  color: var(--primary);
  margin: 14px 0 6px;
}
.wa-guide h4:first-child { margin-top: 0; }
.wa-guide ol, .wa-guide ul {
  margin: 4px 22px 8px; padding: 0;
}
.wa-guide li { margin-bottom: 3px; }
.wa-guide code {
  background: var(--surface); padding: 2px 6px; border-radius: 4px;
  font-size: 12px; direction: ltr; display: inline-block;
}
.wa-guide a { color: var(--primary); text-decoration: underline; }
.wa-guide p { margin: 4px 0; color: var(--text-2); }

/* ────────────────── Attachments grid ────────────────── */
.attachments-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  margin-top: 8px;
}
.att-slot {
  display: flex; align-items: center; gap: 14px;
  padding: 12px 14px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.att-slot.has-file { background: #ecfdf5; border-color: #a7f3d0; }
.att-icon { font-size: 22px; flex-shrink: 0; }
.att-info { flex: 1; min-width: 0; }
.att-info strong { display: block; font-size: 14px; font-weight: 700; color: var(--text); }
.att-status { font-size: 12px; color: var(--muted); margin-top: 2px; }
.att-status.has { color: var(--success); }
.att-actions { display: flex; gap: 6px; flex-shrink: 0; }

/* ────────────────── Phone WhatsApp button ────────────────── */
.phone-wa-btn {
  background: #25D366; color: white;
  border: none; cursor: pointer;
  width: 22px; height: 22px; border-radius: 50%;
  font-size: 12px; line-height: 1;
  display: inline-flex; align-items: center; justify-content: center;
  margin-right: 6px;
  vertical-align: middle;
}
.phone-wa-btn:hover { background: #128C7E; }

/* ────────────────── WhatsApp modal ────────────────── */
.wa-steps {
  list-style: none; padding: 0; margin: 12px 0 6px;
  counter-reset: wa-step;
}
.wa-steps li {
  counter-increment: wa-step;
  font-size: 13px; color: var(--text);
  padding: 6px 0;
  display: flex; gap: 10px; align-items: flex-start;
}
.wa-steps li::before {
  content: counter(wa-step);
  display: inline-flex; align-items: center; justify-content: center;
  width: 22px; height: 22px; border-radius: 50%;
  background: #25D366; color: white;
  font-size: 12px; font-weight: 700;
  flex-shrink: 0;
}
.wa-downloads {
  display: flex; flex-direction: column; gap: 6px;
  padding: 10px;
  background: var(--surface-2);
  border-radius: var(--radius-sm);
}
.wa-info {
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-right: 3px solid #f59e0b;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: #78350f;
}
.wa-dl-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 8px 12px; background: white;
  border-radius: 6px; font-size: 13px;
  border: 1px solid var(--border);
}
.wa-dl-row.missing {
  background: #fef2f2; border-color: #fecaca; color: #991b1b;
  font-size: 12px;
}
.wa-dl-row .file-name { flex: 1; font-weight: 600; }
.wa-dl-row .file-size { color: var(--muted); font-size: 11px; margin: 0 8px; }

/* ────────────────── Language tabs ────────────────── */
.lang-tabs {
  display: flex; gap: 4px; margin-bottom: 10px;
  border-bottom: 1px solid var(--border);
}
.lang-tab {
  background: transparent; border: none;
  padding: 8px 14px; font-family: inherit;
  font-size: 13px; font-weight: 600; color: var(--text-2);
  cursor: pointer; border-radius: 6px 6px 0 0;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.lang-tab:hover { color: var(--text); background: var(--surface-2); }
.lang-tab.active {
  color: var(--primary); border-bottom-color: var(--primary);
  background: var(--primary-soft);
}

.terms-type-tab {
  background: transparent; border: 1px solid var(--border);
  padding: 8px 14px; font-family: inherit;
  font-size: 13px; font-weight: 700; color: var(--text-2);
  cursor: pointer; border-radius: var(--radius-sm);
  margin-right: 4px; margin-left: 4px;
}
.terms-type-tab:hover { color: var(--text); background: var(--surface-2); }
.terms-type-tab.active {
  background: var(--ink); color: white; border-color: var(--ink);
}

/* ────────────────── Template selector ────────────────── */
.template-pick {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 6px 12px; background: var(--surface-2);
  border-radius: 6px; font-size: 13px; font-weight: 600;
  border: 1px solid var(--border);
}
.template-pick select {
  border: none; background: transparent; padding: 2px 4px;
  font-weight: 700; color: var(--primary);
  cursor: pointer; font-size: 13px;
  width: auto;
}

/* ────────────────── Notes box ────────────────── */
.notes {
  background: #fffbeb;
  border-right: 3px solid var(--warning);
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  margin-bottom: 16px; font-size: 13px;
  color: #78350f;
}

/* ────────────────── Not-found warning box ────────────────── */
.not-found {
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-right: 4px solid var(--danger);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 16px;
}
.not-found.not-found-warn {
  background: #fffbeb;
  border-color: #fde68a;
  border-right-color: var(--warning);
}
.not-found-head {
  display: flex; flex-direction: column; gap: 2px;
  font-size: 14px; font-weight: 700; color: #991b1b;
  margin-bottom: 12px;
}
.not-found.not-found-warn .not-found-head { color: #92400e; }
.not-found-list {
  list-style: none; display: flex; flex-direction: column; gap: 10px;
}
.nf-item {
  background: white; padding: 12px;
  border-radius: var(--radius-sm);
  border: 1px solid #fecaca;
  display: flex; flex-direction: column; gap: 10px;
}
.not-found.not-found-warn .nf-item { border-color: #fde68a; }
.nf-desc { font-size: 13px; color: var(--text); }
.nf-suggestions {
  background: #ecfdf5;
  border-right: 3px solid var(--success);
  padding: 10px 12px; border-radius: 6px;
}
.nf-suggestions-title { font-size: 12px; font-weight: 700; color: #065f46; margin-bottom: 8px; }
.nf-suggestion {
  display: flex; justify-content: space-between; align-items: center;
  padding: 8px 10px; background: white; border-radius: 5px;
  font-size: 13px; gap: 10px; margin-bottom: 4px;
  border: 1px solid #d1fae5;
}
.nf-suggestion:last-child { margin-bottom: 0; }
.nf-actions {
  display: flex; gap: 6px; justify-content: flex-end;
  padding-top: 4px;
  border-top: 1px dashed var(--border);
}

/* ────────────────── Empty states ────────────────── */
.empty {
  text-align: center; padding: 40px 20px;
  color: var(--text-2);
}
.empty-icon { font-size: 42px; margin-bottom: 10px; opacity: 0.5; }
.empty h3 { font-size: 16px; margin-bottom: 4px; color: var(--text); }
.empty p { font-size: 13px; }

/* ────────────────── Pills/badges ────────────────── */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px;
  border-radius: 99px;
  font-size: 11px; font-weight: 700;
  background: var(--surface-2); color: var(--text-2);
}
.cat-badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px; border-radius: 99px;
  font-size: 11px; font-weight: 600;
  margin: 2px;
}

/* ────────────────── Color swatch picker ────────────────── */
.color-picker { display: flex; flex-wrap: wrap; gap: 6px; }
.color-swatch {
  width: 28px; height: 28px; border-radius: 50%;
  border: 2px solid white; cursor: pointer;
  box-shadow: 0 0 0 1px var(--border);
}
.color-swatch.selected { box-shadow: 0 0 0 2px var(--text); }

/* ────────────────── Icon picker ────────────────── */
.icon-picker { display: flex; flex-wrap: wrap; gap: 4px; max-height: 140px; overflow-y: auto; }
.icon-option {
  width: 34px; height: 34px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 6px; cursor: pointer;
  font-size: 17px;
  border: 1px solid transparent;
}
.icon-option:hover { background: var(--surface-2); }
.icon-option.selected { background: var(--primary-soft); border-color: var(--primary); }

@media (max-width: 900px) {
  .app-shell { grid-template-columns: 1fr; grid-template-areas: "topbar" "main"; }
  .sidebar { display: none; }
}

/* ─────────── Auth screen (login + first-admin setup) ─────────── */
#auth-screen { min-height: 100vh; background: linear-gradient(135deg, #eef2ff 0%, #f0f9ff 50%, #fdf2f8 100%); display: flex; align-items: center; justify-content: center; padding: 24px; }
.auth-wrap { width: 100%; max-width: 440px; }
.auth-card { background: #fff; border-radius: 20px; padding: 36px 32px; box-shadow: 0 20px 60px rgba(15, 23, 42, 0.12), 0 4px 12px rgba(15, 23, 42, 0.04); border: 1px solid rgba(15, 23, 42, 0.06); }
.auth-brand { text-align: center; margin-bottom: 28px; }
.auth-logo { width: 64px; height: 64px; border-radius: 16px; margin: 0 auto 14px; display: flex; align-items: center; justify-content: center; font-size: 30px; background: linear-gradient(135deg, var(--primary, #4f46e5), #7c3aed); color: #fff; box-shadow: 0 8px 24px rgba(79, 70, 229, 0.3); overflow: hidden; }
.auth-logo img { width: 100%; height: 100%; object-fit: contain; background: #fff; padding: 6px; }
.auth-title { font-size: 22px; font-weight: 800; color: var(--text, #0f172a); margin-bottom: 4px; }
.auth-sub { font-size: 14px; color: var(--muted, #64748b); }
.auth-form { display: flex; flex-direction: column; gap: 14px; }
.auth-form label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 600; color: var(--text-2, #334155); }
.auth-form input { padding: 11px 14px; border: 1.5px solid #e2e8f0; border-radius: 10px; font-size: 15px; font-family: inherit; transition: border-color .15s, box-shadow .15s; }
.auth-form input:focus { outline: none; border-color: var(--primary, #4f46e5); box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.12); }
.auth-info { background: #eff6ff; color: #1e40af; padding: 12px 14px; border-radius: 10px; font-size: 13px; line-height: 1.6; border: 1px solid #bfdbfe; }
.auth-error { background: #fef2f2; color: #b91c1c; padding: 10px 14px; border-radius: 10px; font-size: 13px; border: 1px solid #fecaca; }
.auth-submit { margin-top: 6px; padding: 12px; font-size: 15px; font-weight: 700; }
.auth-foot { margin-top: 22px; text-align: center; font-size: 12px; color: var(--muted, #94a3b8); }

/* ─────────── User menu in topnav ─────────── */
.user-menu { position: relative; }
.user-menu-btn { display: flex; align-items: center; gap: 8px; padding: 6px 10px 6px 6px; background: #f1f5f9; border: 1px solid #e2e8f0; border-radius: 999px; cursor: pointer; font-family: inherit; transition: background .15s, border-color .15s; }
.user-menu-btn:hover { background: #e2e8f0; }
.user-avatar { width: 30px; height: 30px; border-radius: 50%; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, var(--primary, #4f46e5), #7c3aed); color: #fff; font-weight: 700; font-size: 13px; flex-shrink: 0; }
.user-name { font-size: 13px; font-weight: 600; color: var(--text, #0f172a); max-width: 110px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-caret { font-size: 10px; color: var(--muted, #64748b); }
.user-menu-dropdown { position: absolute; top: calc(100% + 6px); inset-inline-end: 0; min-width: 240px; background: #fff; border: 1px solid #e2e8f0; border-radius: 12px; box-shadow: 0 12px 36px rgba(15, 23, 42, 0.12); padding: 8px; z-index: 200; }
.umd-head { padding: 10px 12px 12px; border-bottom: 1px solid #f1f5f9; margin-bottom: 6px; }
.umd-name { font-weight: 700; font-size: 14px; color: var(--text, #0f172a); }
.umd-role { font-size: 12px; color: var(--muted, #64748b); margin-top: 2px; }
.umd-item { width: 100%; text-align: start; padding: 10px 12px; background: transparent; border: none; border-radius: 8px; cursor: pointer; font-family: inherit; font-size: 13px; font-weight: 600; color: var(--text-2, #334155); display: flex; align-items: center; gap: 8px; transition: background .12s; }
.umd-item:hover { background: #f8fafc; }
.umd-danger { color: #b91c1c; }
.umd-danger:hover { background: #fef2f2; }

/* ─────────── Users management ─────────── */
.ue-role-perms { background: #f8fafc; border: 1px solid #e2e8f0; border-radius: 10px; padding: 12px 14px; font-size: 12px; color: var(--text-2, #334155); line-height: 1.7; }
.ue-role-perms b { color: var(--text, #0f172a); }
.user-status-pill { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 11px; font-weight: 700; }
.user-status-pill.active { background: #dcfce7; color: #166534; }
.user-status-pill.inactive { background: #f1f5f9; color: #64748b; }

/* ─────────── AI draft review modal ─────────── */
.ai-review-content { max-width: 98vw; width: 1500px; height: 92vh; display: flex; flex-direction: column; padding: 0; }
.ai-review-content .modal-head { flex-shrink: 0; padding: 14px 18px; border-bottom: 1px solid #e2e8f0; }
.ai-review-body { flex: 1; display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 0; overflow: hidden; min-height: 0; }
.ai-review-pane { padding: 14px 16px; overflow-y: auto; border-inline-end: 1px solid #e2e8f0; min-width: 0; }
.ai-review-pane:last-child { border-inline-end: none; }
.ai-pane-title { font-size: 14px; font-weight: 700; color: #4338ca; margin: 0 0 12px; padding-bottom: 8px; border-bottom: 1px solid #e2e8f0; }
.ai-original { font-size: 13px; line-height: 1.7; }
.ai-original .ai-from { background: #eef2ff; padding: 6px 10px; border-radius: 6px; font-size: 12px; margin-bottom: 6px; color: #4338ca; }
.ai-original .ai-subject { font-weight: 700; margin-bottom: 6px; }
.ai-original .ai-body { background: #f8fafc; padding: 10px 12px; border-radius: 8px; white-space: pre-wrap; max-height: 60vh; overflow-y: auto; font-size: 12px; }
.ai-classification { background: #fef9c3; padding: 8px 12px; border-radius: 6px; font-size: 12px; margin-bottom: 10px; line-height: 1.6; color: #713f12; }

#adr-quote-fields label { display: block; font-size: 11px; color: #475569; font-weight: 600; margin-bottom: 6px; }
#adr-quote-fields input { padding: 5px 8px; font-size: 13px; border: 1px solid #e2e8f0; border-radius: 6px; width: 100%; font-family: inherit; }
#adr-quote-items input { width: 100%; padding: 4px 6px; font-size: 12px; border: 1px solid #e2e8f0; border-radius: 4px; }
#adr-quote-items td { padding: 4px; }

@media (max-width: 1100px) {
  .ai-review-body { grid-template-columns: 1fr; overflow-y: auto; }
  .ai-review-pane { border-inline-end: none; border-bottom: 1px solid #e2e8f0; }
}

/* ─────────── Inbox (email) modal ─────────── */
.inbox-modal-content { max-width: 98vw; width: 1480px; height: 92vh; display: flex; flex-direction: column; padding: 0; }
.inbox-modal-content .modal-head { flex-shrink: 0; padding: 14px 18px; border-bottom: 1px solid #e2e8f0; }
.inbox-body { flex: 1; display: grid; grid-template-columns: var(--folders-w, 200px) 4px var(--list-w, 340px) 4px 1fr; gap: 0; overflow: hidden; min-height: 0; }
.inbox-body.reader-max { grid-template-columns: 0 0 0 0 1fr; }
.inbox-body.reader-max .inbox-folders,
.inbox-body.reader-max .inbox-list,
.inbox-body.reader-max .inbox-resizer { display: none; }
.inbox-resizer { background: transparent; cursor: col-resize; transition: background .15s; position: relative; }
.inbox-resizer::before { content: ''; position: absolute; inset: 0 1px; background: #e2e8f0; transition: background .15s; }
.inbox-resizer:hover::before, .inbox-resizer.dragging::before { background: #4f46e5; }
.inbox-folders { background: #f8fafc; overflow-y: auto; padding: 8px 0; min-width: 0; }
.inbox-back-btn { display: none; }
.inbox-folder { padding: 9px 16px; cursor: pointer; font-size: 13px; color: var(--text-2, #334155); display: flex; justify-content: space-between; align-items: center; gap: 6px; }
.inbox-folder:hover { background: #f1f5f9; }
.inbox-folder.active { background: #eef2ff; color: #4338ca; font-weight: 700; border-inline-end: 3px solid #4338ca; }
.inbox-folder .unread-pill { background: #4f46e5; color: #fff; border-radius: 999px; padding: 1px 8px; font-size: 11px; font-weight: 700; }
.inbox-folder.active .unread-pill { background: #4338ca; }

.inbox-list { background: #fff; overflow-y: auto; min-width: 0; }
.msg-row { padding: 12px 16px; border-bottom: 1px solid #f1f5f9; cursor: pointer; transition: background .12s; }
.msg-row:hover { background: #f8fafc; }
.msg-row.active { background: #eef2ff; }
.msg-row.unread { background: #fff; }
.msg-row.unread .msg-from, .msg-row.unread .msg-subject { font-weight: 700; color: var(--text, #0f172a); }
.msg-from { font-size: 13px; color: var(--text-2); margin-bottom: 3px; display: flex; justify-content: space-between; align-items: center; }
.msg-date { font-size: 11px; color: var(--muted); }
.msg-subject { font-size: 13px; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msg-preview { font-size: 11px; color: var(--muted); margin-top: 2px; }

.inbox-reader { background: #fff; overflow-y: auto; padding: 20px 24px; min-width: 0; display: flex; flex-direction: column; }
.reader-head { padding-bottom: 14px; border-bottom: 1px solid #e2e8f0; margin-bottom: 14px; flex-shrink: 0; }
.reader-subject { font-size: 19px; font-weight: 800; color: var(--text); margin-bottom: 10px; }
.reader-meta { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--text-2); }
.reader-meta b { color: var(--muted); font-weight: 600; min-width: 50px; display: inline-block; }
.reader-actions { display: flex; gap: 6px; margin-top: 12px; }
.reader-body { font-size: 14px; line-height: 1.8; color: var(--text); flex: 1; width: 100%; min-height: 400px; border: none; }
iframe.reader-body { background: #fff; }
.reader-body img { max-width: 100%; height: auto; }
.reader-attachments { margin-top: 16px; padding-top: 14px; border-top: 1px solid #e2e8f0; }
.attach-item { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; background: #f1f5f9; border-radius: 8px; font-size: 12px; margin-inline-end: 6px; margin-bottom: 6px; text-decoration: none; color: var(--text); }
.attach-item:hover { background: #e2e8f0; }

@media (max-width: 1100px) {
  .inbox-body { grid-template-columns: 180px 280px 1fr; }
}
@media (max-width: 800px) {
  .inbox-body { grid-template-columns: 1fr; }
  .inbox-folders, .inbox-list { display: none; }
  .inbox-body.show-folders .inbox-folders { display: block; }
  .inbox-body.show-list .inbox-list { display: block; }
}

/* ─────────── Code autocomplete (quote item rows) ─────────── */
.code-suggest { position: fixed; min-width: 320px; max-width: 460px; max-height: 320px; overflow-y: auto; background: #fff; border: 1px solid #e2e8f0; border-radius: 10px; box-shadow: 0 16px 48px rgba(15, 23, 42, 0.22); z-index: 9999; padding: 4px; }
.cs-item { display: grid; grid-template-columns: auto 1fr auto; gap: 10px; align-items: center; padding: 8px 10px; border-radius: 7px; cursor: pointer; transition: background .1s; }
.cs-item:hover, .cs-item.active { background: #eef2ff; }
.cs-code { font-family: 'SF Mono', Consolas, monospace; font-size: 12px; font-weight: 700; color: #4338ca; background: #eef2ff; padding: 2px 8px; border-radius: 5px; white-space: nowrap; }
.cs-item:hover .cs-code, .cs-item.active .cs-code { background: #c7d2fe; }
.cs-desc { font-size: 12px; color: var(--text, #0f172a); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cs-price { font-size: 12px; font-weight: 700; color: #059669; white-space: nowrap; }

/* ─────────── Project detail view ─────────── */
.pv-doc { background: #fff; border: 1px solid var(--border, #e2e8f0); border-radius: 14px; padding: 20px 24px; box-shadow: 0 2px 8px rgba(15,23,42,0.04); }
.pv-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 24px; padding-bottom: 16px; border-bottom: 1px solid #e2e8f0; }
.pv-head-main { flex: 1; min-width: 0; }
.pv-num-row { display: flex; align-items: center; gap: 12px; margin-bottom: 6px; flex-wrap: wrap; }
.pv-num { background: linear-gradient(135deg, #4f46e5, #7c3aed); color: #fff; padding: 4px 12px; border-radius: 999px; font-weight: 700; font-size: 12px; letter-spacing: .5px; font-family: 'SF Mono', monospace; }
.pv-status-select { padding: 4px 10px; border-radius: 8px; border: 1px solid #e2e8f0; background: #f8fafc; font-size: 12px; font-weight: 700; cursor: pointer; }
.pv-name { font-size: 24px; font-weight: 800; color: var(--text, #0f172a); margin: 0 0 4px; }
.pv-meta { font-size: 13px; color: var(--muted, #64748b); }
.pv-progress-wrap { min-width: 160px; text-align: center; }
.pv-progress-label { font-size: 11px; color: var(--muted); font-weight: 600; margin-bottom: 6px; }
.pv-progress-bar { width: 160px; height: 8px; background: #f1f5f9; border-radius: 999px; overflow: hidden; margin: 0 auto 6px; }
.pv-progress-fill { height: 100%; background: linear-gradient(90deg, #10b981, #06b6d4); transition: width .25s; }
.pv-progress-pct { font-size: 22px; font-weight: 800; color: var(--text); }

.pv-kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin: 16px 0; }
.pv-kpi { background: #f8fafc; border: 1px solid #e2e8f0; border-radius: 10px; padding: 12px 14px; }
.pv-kpi-label { font-size: 11px; color: var(--muted); font-weight: 600; margin-bottom: 4px; }
.pv-kpi-value { font-size: 18px; font-weight: 800; color: var(--text); }

.pv-tabs { display: flex; gap: 4px; border-bottom: 1px solid #e2e8f0; margin: 8px 0 16px; overflow-x: auto; }
.pv-tab { padding: 10px 16px; background: transparent; border: none; border-bottom: 2px solid transparent; cursor: pointer; font-family: inherit; font-size: 13px; font-weight: 600; color: var(--muted); white-space: nowrap; transition: color .15s, border-color .15s; }
.pv-tab:hover { color: var(--text); }
.pv-tab.active { color: var(--primary, #4f46e5); border-bottom-color: var(--primary, #4f46e5); }

.pv-tab-panel { animation: fadeIn .15s ease-out; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.pv-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 12px; }
.pv-card { background: #fff; border: 1px solid #e2e8f0; border-radius: 10px; padding: 14px 16px; margin-bottom: 12px; }
.pv-card h3 { margin: 0 0 10px; font-size: 14px; font-weight: 700; color: var(--text); }
.pv-card .row { display: flex; gap: 8px; align-items: center; }

.pv-toolbar-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.pv-toolbar-row h3 { margin: 0; font-size: 15px; font-weight: 700; }

/* Material status pills */
.mat-status { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 11px; font-weight: 700; }
.mat-status.required { background: #fef3c7; color: #92400e; }
.mat-status.received { background: #dbeafe; color: #1e40af; }
.mat-status.on_site { background: #ede9fe; color: #5b21b6; }
.mat-status.installed { background: #dcfce7; color: #166534; }

/* Task cards */
.pv-tasks-list { display: flex; flex-direction: column; gap: 8px; }
.task-card { background: #fff; border: 1px solid #e2e8f0; border-radius: 10px; padding: 12px 14px; display: flex; gap: 12px; align-items: flex-start; }
.task-card[data-status="done"] { background: #f0fdf4; border-color: #bbf7d0; }
.task-card[data-status="blocked"] { background: #fef2f2; border-color: #fecaca; }
.task-card[data-status="in_progress"] { background: #eff6ff; border-color: #bfdbfe; }
.task-body { flex: 1; min-width: 0; }
.task-title { font-weight: 700; color: var(--text); margin-bottom: 3px; }
.task-meta { font-size: 11px; color: var(--muted); }
.task-actions { display: flex; gap: 4px; flex-shrink: 0; }
.task-status-pill { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 10px; font-weight: 700; margin-inline-end: 6px; }
.task-status-pill.todo { background: #f1f5f9; color: #475569; }
.task-status-pill.in_progress { background: #dbeafe; color: #1e40af; }
.task-status-pill.done { background: #dcfce7; color: #166534; }
.task-status-pill.blocked { background: #fee2e2; color: #991b1b; }

/* Costs */
.pv-cost-summary { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 14px; }
.pv-cost-card { background: #fff; border: 1px solid #e2e8f0; border-radius: 10px; padding: 14px 16px; }
.pv-cost-card .label { font-size: 11px; color: var(--muted); font-weight: 600; margin-bottom: 6px; }
.pv-cost-card .value { font-size: 20px; font-weight: 800; color: var(--text); }
.pv-cost-card.profit-pos .value { color: #059669; }
.pv-cost-card.profit-neg .value { color: #dc2626; }
.pv-cost-list { display: flex; flex-direction: column; gap: 6px; max-height: 240px; overflow-y: auto; padding-bottom: 4px; }
.pv-cost-row { display: flex; justify-content: space-between; align-items: center; padding: 8px 12px; background: #f8fafc; border-radius: 8px; font-size: 13px; }
.pv-cost-row .row-desc { flex: 1; }
.pv-cost-row .row-amt { font-weight: 700; margin-inline: 12px; }
.pv-cost-row button { background: transparent; border: none; color: #b91c1c; cursor: pointer; font-size: 16px; padding: 2px 6px; }

/* Timeline */
.pv-timeline-list { display: flex; flex-direction: column; gap: 6px; }
.tl-item { display: flex; gap: 12px; padding: 10px 12px; background: #f8fafc; border-radius: 8px; font-size: 13px; }
.tl-item .tl-when { color: var(--muted); font-size: 11px; min-width: 90px; }
.tl-item .tl-msg { flex: 1; }
.tl-item .tl-actor { font-size: 11px; color: var(--muted); }

/* Project status pills (used in list table) */
.proj-status { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 11px; font-weight: 700; }
.proj-status.planning { background: #fef9c3; color: #854d0e; }
.proj-status.procurement { background: #dbeafe; color: #1e40af; }
.proj-status.logistics { background: #ccfbf1; color: #115e59; }
.proj-status.installation { background: #ede9fe; color: #5b21b6; }
.proj-status.commissioning { background: #fce7f3; color: #9d174d; }
.proj-status.handover { background: #ffedd5; color: #9a3412; }
.proj-status.closed { background: #dcfce7; color: #166534; }
.proj-status.on_hold { background: #f1f5f9; color: #475569; }
.proj-status.cancelled { background: #fee2e2; color: #991b1b; }

/* My tasks (technician landing) */
.mytasks-list { display: flex; flex-direction: column; gap: 12px; }
.mt-card { background: #fff; border: 1px solid #e2e8f0; border-radius: 12px; padding: 16px; box-shadow: 0 1px 3px rgba(15,23,42,.04); }
.mt-card-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.mt-project { font-size: 11px; color: var(--muted); font-weight: 600; }
.mt-title { font-size: 16px; font-weight: 700; color: var(--text); margin-bottom: 4px; }
.mt-desc { font-size: 13px; color: var(--text-2); margin-bottom: 8px; }
.mt-due { font-size: 12px; color: var(--muted); }
.mt-actions { display: flex; gap: 6px; margin-top: 10px; flex-wrap: wrap; }
.mt-actions .btn { font-size: 13px; padding: 8px 14px; }

@media (max-width: 760px) {
  .pv-head { flex-direction: column; }
  .pv-progress-wrap { width: 100%; }
  .pv-kpis { grid-template-columns: repeat(2, 1fr); }
  .pv-grid-2 { grid-template-columns: 1fr; }
  .pv-cost-summary { grid-template-columns: 1fr; }
  .mt-card { padding: 14px; }
}

/* ────────────────── iOS-style Bottom Navigation ────────────────── */
.bottom-nav { display: none; }
@media (max-width: 768px) {
  .bottom-nav {
    display: flex !important;
    align-items: flex-end;
    justify-content: space-around;
    position: fixed; bottom: 0; left: 0; right: 0;
    background: rgba(255, 255, 255, 0.82);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
    backdrop-filter: saturate(180%) blur(20px);
    border-top: 0.5px solid rgba(0, 0, 0, 0.18);
    padding: 6px 8px calc(6px + env(safe-area-inset-bottom)) 8px;
    z-index: 7000;
    height: calc(56px + env(safe-area-inset-bottom));
    box-sizing: border-box;
  }
  .bn-item {
    flex: 1;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 2px;
    background: transparent; border: none;
    padding: 6px 4px 4px;
    font-family: inherit;
    color: #8e8e93;
    cursor: pointer;
    position: relative;
    transition: color .15s;
    -webkit-tap-highlight-color: transparent;
  }
  .bn-item .bn-icon { font-size: 22px; line-height: 1; transition: transform .15s; }
  .bn-item .bn-label { font-size: 10px; font-weight: 600; letter-spacing: 0.1px; }
  .bn-item:active .bn-icon { transform: scale(0.88); }
  .bn-item.active { color: #4f46e5; }
  .bn-item.active .bn-icon { filter: none; }
  .bn-badge {
    position: absolute;
    top: 2px;
    inset-inline-end: calc(50% - 22px);
    background: #ff3b30;
    color: #fff;
    font-size: 10px; font-weight: 700;
    padding: 1px 6px; min-width: 16px;
    border-radius: 999px;
    text-align: center;
    border: 1.5px solid rgba(255,255,255,0.92);
  }

  /* Center floating "+" button */
  .bn-fab { position: relative; padding-top: 0 !important; }
  .bn-fab .bn-fab-circle {
    width: 48px; height: 48px; border-radius: 50%;
    background: linear-gradient(135deg, #4f46e5, #7c3aed);
    color: #fff;
    font-size: 28px; font-weight: 300; line-height: 48px;
    display: inline-block;
    box-shadow: 0 6px 18px rgba(79, 70, 229, 0.45);
    transform: translateY(-14px);
    transition: transform .15s, box-shadow .15s;
  }
  .bn-fab:active .bn-fab-circle { transform: translateY(-14px) scale(0.92); }

  /* Reserve space at bottom for nav so content doesn't hide under it */
  body { padding-bottom: calc(56px + env(safe-area-inset-bottom)) !important; }

  /* iOS standalone (PWA installed): tighter top safe area */
  @supports (-webkit-touch-callout: none) {
    body { padding-top: env(safe-area-inset-top); }
  }
}

/* ────────────────── "More" Sheet (iOS-style, slides up from very bottom) ────────────────── */
.more-sheet {
  position: fixed;
  left: 0; right: 0;
  bottom: 0;
  background: rgba(255, 255, 255, 0.98);
  -webkit-backdrop-filter: blur(30px);
  backdrop-filter: blur(30px);
  border-radius: 18px 18px 0 0;
  box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.2);
  z-index: 9500;
  padding: 8px 16px calc(20px + env(safe-area-inset-bottom));
  max-height: 80vh;
  overflow-y: auto;
  transform: translateY(105%);
  transition: transform .3s cubic-bezier(0.32, 0.72, 0, 1);
  display: none;
}
@media (max-width: 768px) {
  .more-sheet { display: block; }
  .more-sheet.open { transform: translateY(0); }
  body.more-sheet-open::before {
    content: '';
    position: fixed; inset: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 9400;
    animation: fadeIn .2s;
  }
}
.ms-handle {
  width: 36px; height: 5px;
  background: rgba(60, 60, 67, 0.3);
  border-radius: 999px;
  margin: 6px auto 12px;
}
.ms-title { font-size: 17px; font-weight: 700; text-align: center; margin: 0 0 16px; color: #1c1c1e; }
.ms-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}
.ms-tile {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  background: rgba(118, 118, 128, 0.08);
  border: none; border-radius: 14px;
  padding: 14px 8px;
  cursor: pointer;
  font-family: inherit; font-size: 12px; font-weight: 600;
  color: #1c1c1e;
  transition: background .15s, transform .12s;
  -webkit-tap-highlight-color: transparent;
}
.ms-tile:active { background: rgba(118, 118, 128, 0.18); transform: scale(0.96); }
.ms-tile .ms-emoji { font-size: 26px; }
.ms-tile.ms-danger { color: #ff3b30; }

/* ────────────────── Bottom-sheet style for modals on mobile ────────────────── */
@media (max-width: 768px) {
  .modal {
    align-items: flex-end !important;
    padding: 0 !important;
    background: rgba(0, 0, 0, 0.4) !important;
    backdrop-filter: blur(2px) !important;
  }
  .modal-content {
    width: 100% !important;
    max-width: 100% !important;
    max-height: 92vh !important;
    margin: 0 !important;
    border-radius: 18px 18px 0 0 !important;
    animation: slideUpSheet .28s cubic-bezier(0.32, 0.72, 0, 1) !important;
    padding-bottom: env(safe-area-inset-bottom) !important;
  }
  @keyframes slideUpSheet {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
  }
  .modal-content::before {
    content: '';
    display: block;
    width: 36px; height: 5px;
    background: rgba(60, 60, 67, 0.3);
    border-radius: 999px;
    margin: 8px auto 0;
  }
  .modal-head {
    padding: 14px 16px !important;
    border-bottom: 0.5px solid rgba(0, 0, 0, 0.1) !important;
  }
  .modal-head h2 { font-size: 16px !important; font-weight: 700 !important; }
}

/* ────────────────── Quick Nav (Instagram-style horizontal strip on home) ────────────────── */
.quick-nav {
  display: flex;
  gap: 14px;
  overflow-x: auto;
  padding: 16px 4px 18px;
  margin-bottom: 8px;
  scroll-snap-type: x proximity;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.quick-nav::-webkit-scrollbar { display: none; }
.qn-item {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 4px;
  font-family: inherit;
  position: relative;
  min-width: 72px;
  transition: transform .15s;
}
.qn-item:active { transform: scale(0.95); }
.qn-icon {
  width: 60px; height: 60px;
  border-radius: 18px;
  background: #f1f5f9;
  display: flex; align-items: center; justify-content: center;
  font-size: 28px;
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.08);
  transition: all .15s;
}
.qn-item:hover .qn-icon { box-shadow: 0 6px 18px rgba(15, 23, 42, 0.14); transform: translateY(-2px); }
.qn-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text, #0f172a);
  white-space: nowrap;
}
.qn-count {
  position: absolute;
  top: -2px; inset-inline-end: 2px;
  background: #ef4444;
  color: #fff;
  font-size: 10px;
  font-weight: 800;
  padding: 2px 7px;
  border-radius: 999px;
  min-width: 18px;
  text-align: center;
  border: 2px solid #fff;
}
.qn-count:empty, .qn-count[data-zero] { display: none; }
.qn-cta .qn-icon {
  background: linear-gradient(135deg, #4f46e5, #7c3aed);
  color: #fff;
}

/* ════════════════════════════════════════════════════════════════════
   RESPONSIVE LAYER — phones, tablets, desktops
   ════════════════════════════════════════════════════════════════════ */

/* Mobile hamburger button — hidden on desktop */
.mobile-menu-btn {
  display: none;
  background: transparent;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  width: 40px;
  height: 40px;
  font-size: 20px;
  cursor: pointer;
  color: var(--text, #0f172a);
  flex-shrink: 0;
}
.mobile-menu-btn:hover { background: #f1f5f9; }

/* ─────────── Tablet (≤ 1024px) ─────────── */
@media (max-width: 1024px) {
  .topnav-items { gap: 4px; }
  .topnav-item { padding: 6px 10px; font-size: 12px; }
  .tni-label { font-size: 11px; }
  .container { padding: 14px; }
  .page-header { flex-direction: column; align-items: stretch; gap: 12px; }
  .dash-kpis { grid-template-columns: repeat(2, 1fr); }
  .dash-grid { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr 1fr; }
  .ai-review-body { grid-template-columns: 1fr; overflow-y: auto; }
  .ai-review-pane { border-inline-end: none; border-bottom: 1px solid #e2e8f0; max-height: none; }
}

/* ─────────── Mobile (≤ 768px) ─────────── */
@media (max-width: 768px) {
  /* Force full-width layout on mobile (defeat any inherited width constraint) */
  html, body { width: 100%; max-width: 100vw; overflow-x: hidden; }
  body > section, .screen, .app-shell, .main,
  #home-view, #newquote-view, #products-view, #quote-view, #project-view, #mytasks-view,
  .container, .home-content, #dashboard {
    width: 100% !important;
    max-width: 100% !important;
    margin-inline: 0 !important;
    box-sizing: border-box;
  }
  .app-shell { display: block !important; }
  #home-view, #newquote-view, #products-view, #quote-view, #project-view, #mytasks-view { padding: 14px !important; }
  .main { padding: 0 !important; }

  /* Hamburger + slide-out menu HIDDEN — replaced by bottom nav */
  .mobile-menu-btn { display: none !important; }
  .topnav-items { display: none !important; }
  .quick-nav { display: none !important; }
  /* Topnav becomes a clean header with logo centered */
  .topnav { min-height: 84px; }
  .topnav-inner {
    padding: 8px 14px !important;
    max-width: 100% !important;
    height: auto;
    min-height: 84px;
    position: relative;
    justify-content: center;
  }
  .topnav-brand {
    padding: 0 !important;
    margin: 0 auto !important;
    background: transparent !important;
    display: flex;
    align-items: center;
    justify-content: center;
  }
  .topnav-brand .brand-icon { font-size: 36px; line-height: 1; }
  .topnav-brand .brand-icon img {
    height: 68px !important;
    max-width: 260px !important;
    width: auto !important;
    object-fit: contain;
    display: block;
  }
  .topnav-brand .brand-text {
    font-size: 17px;
    font-weight: 800;
    max-width: 260px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    text-align: center;
  }
  /* Right side compact (positioned absolutely so it doesn't push the logo off-center) */
  .topnav-right {
    position: absolute;
    inset-inline-end: 14px;
    top: 50%;
    transform: translateY(-50%);
    gap: 6px;
  }
  .user-name, .user-caret { display: none; }
  #open-setup-btn, #user-menu-btn { display: none !important; }
  /* Modals appear above the bottom nav */
  .modal { z-index: 10000 !important; }

  /* ─── Mobile slide-out menu (premium design) ─── */
  .topnav-items {
    position: fixed;
    top: 0;
    inset-inline-end: -100%;
    width: 320px;
    max-width: 85vw;
    height: 100vh;
    background: linear-gradient(180deg, #1e1b4b 0%, #312e81 100%);
    box-shadow: -12px 0 40px rgba(15, 23, 42, 0.35);
    display: flex !important;
    flex-direction: column;
    align-items: stretch;
    padding: 0;
    gap: 0;
    overflow-y: auto;
    transition: inset-inline-end .28s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 9000;
  }
  body.mobile-menu-open .topnav-items { inset-inline-end: 0; }

  /* Backdrop overlay */
  body.mobile-menu-open::after {
    content: '';
    position: fixed; inset: 0;
    background: rgba(0, 0, 0, 0.55);
    z-index: 8500;
    animation: fadeIn .2s ease;
  }
  @keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

  /* User profile header at top of menu */
  .topnav-items::before {
    content: '';
    display: none;
  }
  .mobile-menu-profile {
    display: flex !important;
    align-items: center;
    gap: 12px;
    padding: 24px 20px 20px;
    background: rgba(255, 255, 255, 0.08);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    color: #fff;
  }
  .mobile-menu-profile .mm-avatar {
    width: 48px; height: 48px; border-radius: 50%;
    background: linear-gradient(135deg, #fbbf24, #f59e0b);
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 18px; color: #fff;
    flex-shrink: 0;
    box-shadow: 0 4px 12px rgba(251, 191, 36, 0.35);
  }
  .mobile-menu-profile .mm-info { flex: 1; min-width: 0; }
  .mobile-menu-profile .mm-name { font-weight: 700; font-size: 15px; }
  .mobile-menu-profile .mm-role { font-size: 12px; opacity: 0.75; margin-top: 2px; }

  /* Nav items section */
  .mobile-menu-section {
    padding: 12px 12px;
  }
  .mobile-menu-label {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.4);
    letter-spacing: 1px;
    padding: 8px 14px 8px;
    display: block;
  }

  /* Nav items inside the slide-out menu */
  .topnav-item {
    display: flex !important;
    width: 100%;
    padding: 13px 16px !important;
    font-size: 15px !important;
    font-weight: 600 !important;
    align-items: center;
    justify-content: flex-start;
    gap: 14px !important;
    border-radius: 12px;
    color: rgba(255, 255, 255, 0.9) !important;
    background: transparent !important;
    margin-bottom: 2px;
    transition: background .15s, transform .12s;
  }
  .topnav-item:hover, .topnav-item:active {
    background: rgba(255, 255, 255, 0.1) !important;
    color: #fff !important;
  }
  .topnav-item.active {
    background: rgba(255, 255, 255, 0.15) !important;
    color: #fff !important;
  }
  .topnav-item .tni-icon {
    font-size: 22px !important;
    width: 28px; text-align: center;
    flex-shrink: 0;
  }
  .topnav-item .tni-label {
    display: inline !important;
    font-size: 15px !important;
    flex: 1;
    text-align: start;
  }
  .topnav-item .tni-count {
    background: rgba(255, 255, 255, 0.15) !important;
    color: #fff !important;
    font-size: 11px; font-weight: 700;
    padding: 3px 9px; border-radius: 99px;
    min-width: 24px; text-align: center;
  }
  .topnav-item:hover .tni-count, .topnav-item.active .tni-count {
    background: rgba(255, 255, 255, 0.25) !important;
    color: #fff !important;
  }

  /* CTA item — accent gold */
  .topnav-cta {
    background: linear-gradient(135deg, #fbbf24, #f59e0b) !important;
    color: #422006 !important;
    box-shadow: 0 4px 14px rgba(251, 191, 36, 0.3);
    margin: 4px 0 8px !important;
  }
  .topnav-cta .tni-label { color: #422006 !important; font-weight: 800 !important; }
  .topnav-cta .tni-icon { color: #422006 !important; }
  .topnav-cta:hover, .topnav-cta:active {
    background: linear-gradient(135deg, #fcd34d, #fbbf24) !important;
    transform: translateY(-1px);
  }

  /* Bottom section for settings + logout */
  .mobile-menu-bottom {
    margin-top: auto;
    padding: 12px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
  }
  .mobile-menu-bottom .mm-item {
    display: flex;
    align-items: center;
    gap: 14px;
    width: 100%;
    padding: 13px 16px;
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.9);
    font-size: 15px; font-weight: 600;
    border-radius: 12px;
    cursor: pointer;
    font-family: inherit;
    margin-bottom: 2px;
    transition: background .15s;
  }
  .mobile-menu-bottom .mm-item:hover, .mobile-menu-bottom .mm-item:active {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
  }
  .mobile-menu-bottom .mm-item.mm-danger {
    color: #fca5a5;
  }
  .mobile-menu-bottom .mm-item.mm-danger:hover {
    background: rgba(239, 68, 68, 0.15);
    color: #fff;
  }
  .mobile-menu-bottom .mm-item .mm-icon { font-size: 20px; width: 28px; text-align: center; }

  /* Dashboard */
  .container { padding: 12px; }
  .dash-welcome { flex-direction: column; align-items: flex-start; gap: 6px; }
  .dash-greeting { font-size: 18px; }
  .dash-cta { padding: 20px 16px; }
  .dash-cta-content h2 { font-size: 18px; }
  .dash-cta-content p { font-size: 13px; }
  .dash-cta-arrow { font-size: 28px; }
  .dash-kpis { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .kpi { padding: 12px; }
  .kpi-value { font-size: 22px; }
  .kpi-label { font-size: 11px; }
  .dash-grid { grid-template-columns: 1fr; gap: 12px; }

  /* Page header */
  .page-title { font-size: 20px; }

  /* Forms stack */
  .form-grid { grid-template-columns: 1fr; gap: 12px; }
  .form-grid label.full { grid-column: 1; }
  .form-grid input, .form-grid select, .form-grid textarea { font-size: 16px; /* prevent iOS zoom */ }

  /* Modals: take most of the screen */
  .modal-content {
    max-width: 96vw !important;
    width: 96vw !important;
    max-height: 92vh;
    margin: 4vh auto;
    border-radius: 14px;
  }
  .modal-head { padding: 12px 14px; }
  .modal-head h2 { font-size: 15px; }
  .modal-body { padding: 14px; max-height: calc(92vh - 60px); }

  /* Tables → Card layout on mobile (each row becomes a vertical card) */
  .table-wrap { overflow: visible !important; border: none !important; padding: 0; }
  .data-table { display: block !important; min-width: 0 !important; width: 100% !important; border: none; }
  .data-table thead { display: none !important; }
  .data-table tbody { display: block; }
  .data-table tr {
    display: block;
    background: #fff;
    border: 1px solid rgba(0,0,0,0.06);
    border-radius: 14px;
    margin-bottom: 10px;
    padding: 14px 16px;
    box-shadow: 0 1px 3px rgba(15,23,42,0.04);
    cursor: pointer;
    transition: background .15s;
  }
  .data-table tr:active { background: #f8fafc; }
  .data-table td {
    display: flex !important;
    justify-content: space-between;
    align-items: center;
    padding: 6px 0 !important;
    border: none !important;
    font-size: 14px;
    text-align: start;
    gap: 12px;
    min-height: 24px;
  }
  .data-table td:not(:last-child) {
    border-bottom: 1px solid rgba(0,0,0,0.05) !important;
  }
  .data-table td::before {
    content: attr(data-label);
    font-weight: 600;
    color: #64748b;
    font-size: 12px;
    flex-shrink: 0;
    text-align: start;
  }
  /* First cell is the "title" of the card — bigger, no label */
  .data-table td:first-child {
    font-size: 15px;
    font-weight: 700;
    color: var(--text, #0f172a);
    border-bottom: 1px solid rgba(0,0,0,0.08) !important;
    padding-bottom: 10px !important;
    margin-bottom: 4px;
    display: block !important;
  }
  .data-table td:first-child::before {
    display: none;
  }
  /* Last cell (usually action buttons) — full-width, centered */
  .data-table td:last-child {
    justify-content: center !important;
    padding-top: 10px !important;
    margin-top: 4px;
    border-top: 1px solid rgba(0,0,0,0.05);
    flex-wrap: wrap;
  }
  .data-table td:last-child::before { display: none; }
  /* Empty cells: hide entirely on mobile to avoid noise */
  .data-table td:empty { display: none !important; }
  /* Buttons inside table cells: comfortable touch */
  .data-table td .btn-sm { padding: 8px 14px; font-size: 13px; min-height: 36px; }

  /* Products table special: small checkbox top-right corner, small inline category badges */
  .products-table tr {
    position: relative;
    padding-top: 18px !important;
  }
  .products-table td:has(.row-check) {
    position: absolute;
    top: 8px;
    inset-inline-end: 10px;
    padding: 0 !important;
    border: none !important;
    width: auto;
    min-height: 0 !important;
  }
  .products-table td:has(.row-check)::before { display: none; }
  .products-table .row-check {
    width: 18px; height: 18px;
    accent-color: #4f46e5;
    cursor: pointer;
  }
  .products-table .desc-col {
    font-size: 13px !important;
    line-height: 1.5;
  }
  .products-table td .cat-badge {
    font-size: 10px !important;
    padding: 3px 8px !important;
    border-radius: 8px !important;
    font-weight: 600;
    white-space: nowrap;
  }
  .products-table td:has(.cat-badge) {
    flex-wrap: wrap !important;
    align-items: center !important;
    gap: 6px !important;
  }

  /* Buttons & inputs sized for touch */
  .btn { padding: 10px 14px; font-size: 14px; min-height: 40px; }
  .btn-sm { padding: 8px 12px; font-size: 13px; min-height: 36px; }
  input, select, textarea { font-size: 16px; min-height: 40px; }
  .row { flex-wrap: wrap; gap: 8px; }

  /* Quote editor items table — already inside table-wrap will scroll horizontally */
  #items-tbody input { font-size: 14px; min-height: 34px; padding: 4px 6px; }

  /* Quote view */
  .qv-toolbar { flex-direction: column; align-items: stretch; gap: 8px; }
  .qv-actions { flex-wrap: wrap; }
  .qv-actions .btn { flex: 1; min-width: calc(50% - 4px); }
  .qv-doc { padding: 14px; }
  .qv-head { flex-direction: column; gap: 12px; }
  .qv-totals-summary { width: 100%; align-items: flex-start; }
  .qv-client-grid { grid-template-columns: 1fr; }

  /* Project view */
  .pv-doc { padding: 14px; }
  .pv-kpis { grid-template-columns: repeat(2, 1fr); }
  .pv-tabs { font-size: 12px; }
  .pv-tab { padding: 8px 12px; font-size: 12px; }

  /* Inbox: stack everything */
  .inbox-modal-content { width: 100vw !important; max-width: 100vw !important; height: 100vh !important; max-height: 100vh; margin: 0; border-radius: 0; }
  .inbox-body { grid-template-columns: 1fr !important; }
  .inbox-resizer { display: none !important; }
  .inbox-folders, .inbox-list, .inbox-reader { display: none; height: 100%; }
  .inbox-body[data-pane="folders"] .inbox-folders { display: block; }
  .inbox-body[data-pane="list"] .inbox-list { display: block; }
  .inbox-body[data-pane="reader"] .inbox-reader { display: block; }
  /* default: show list when nothing selected */
  .inbox-body:not([data-pane]) .inbox-list { display: block; }
  /* Real back buttons inside list/reader panes (shown only on mobile) */
  .inbox-back-btn { display: block; width: 100%; text-align: start; padding: 12px 14px; background: #eef2ff; cursor: pointer; font-size: 13px; font-weight: 700; color: #4338ca; border: none; border-bottom: 1px solid #c7d2fe; position: sticky; top: 0; z-index: 5; font-family: inherit; }
  .inbox-back-btn:hover { background: #c7d2fe; }

  /* AI draft review: stacked already at ≤1100px */

  /* Auth screen */
  .auth-card { padding: 24px 18px; }
  .auth-title { font-size: 18px; }

  /* Tasks/my-tasks: bigger cards */
  .mt-card { padding: 14px; }
  .mt-title { font-size: 17px; }
  .mt-actions .btn { font-size: 14px; padding: 10px 14px; }

  /* Hide elements that are noise on mobile */
  .topnav-item .tni-count { display: inline-flex; }
}

/* ─────────── Small phone (≤ 480px) ─────────── */
@media (max-width: 480px) {
  .topnav-brand .brand-text { display: none; }
  .dash-kpis { grid-template-columns: 1fr; }
  .pv-kpis { grid-template-columns: 1fr; }
  .qv-actions .btn { min-width: 100%; }
  .modal-content { border-radius: 10px; margin: 2vh auto; max-height: 96vh; }
  .modal-body { padding: 12px; }
}

/* ─────────── Landscape phone ─────────── */
@media (max-height: 500px) and (orientation: landscape) {
  .dash-cta { padding: 14px; }
  .modal-content { max-height: 95vh; }
}
