/* ===== ORCA Agency Dashboard styles (modified) ===== */
:root {
  --orca-blue: #1E5EFF;
  --orca-blue-dark: #1849cc;
  --orca-navy: #0D1B2A;
  --bg: #f5f7fb;
  --card: #ffffff;
  --border: #e4e7ec;
  --text: #0D1B2A;
  --muted: #6b7280;
  --muted-soft: #9aa0a6;
  --danger: #dc2626;
  --success: #16a34a;
  --warning: #f59e0b;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(0,0,0,.04), 0 4px 14px rgba(13,27,42,.06);
  --shadow-lg: 0 8px 30px rgba(13,27,42,.12);
  --font-en: "Inter", system-ui, -apple-system, sans-serif;
  --font-ar: "Tajawal", system-ui, sans-serif;
  --transition: 180ms cubic-bezier(.4,.0,.2,1);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  font-family: var(--font-ar);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  font-size: 14px;
  line-height: 1.5;
  overflow-x: hidden; /* prevent horizontal scroll on mobile */
}
html[lang="en"] body { font-family: var(--font-en); }

a { color: var(--orca-blue); text-decoration: none; transition: color var(--transition); }
a:hover { text-decoration: underline; }
button { font-family: inherit; cursor: pointer; transition: background var(--transition), color var(--transition), transform var(--transition), box-shadow var(--transition); }
button:active { transform: scale(.97); }

/* Splash — large prominent logo at the top of the page on first load */
.splash {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  min-height: 100vh;
  background: var(--bg);
  padding-top: 12vh;
}
.splash-logo {
  width: 220px;
  height: 220px;
  object-fit: contain;
  opacity: .95;
  transform: none;
  will-change: opacity;
  animation: pulse 1.5s ease-in-out infinite;
}
@keyframes pulse { 0%,100%{opacity:.72;} 50%{opacity:1;} }

/* ===== Layout shell — RTL FIX =====
   The DOM order is <sidebar> then <main>. We use logical grid columns in BOTH
   directions; the browser flips them visually for RTL. The previous version
   re-flipped them in RTL which made the sidebar stretch and cover the screen.
*/
.shell {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr); /* minmax prevents content overflow */
  min-height: 100vh;
}
/* No RTL override — let CSS Grid + dir="rtl" handle the flip naturally. */

.sidebar {
  background: var(--orca-navy);
  color: #fff;
  padding: 22px 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  z-index: 40;
  transition: transform var(--transition);
}
.sidebar-brand { display:flex; align-items:center; gap:14px; padding: 6px 6px 22px; }
.sidebar-brand img { width: 80px; height: 80px; object-fit: contain; }
.sidebar-brand .title { font-weight: 800; font-size: 17px; line-height: 1.1; }
.sidebar-brand .subtitle { font-size: 12px; opacity: .7; margin-top: 3px; }
.nav-link {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border-radius: 8px;
  color: rgba(255,255,255,.78); font-weight: 500;
  cursor: pointer; transition: background var(--transition), color var(--transition), transform var(--transition);
  font-size: 14px; position: relative;
}
.nav-link:hover { background: rgba(255,255,255,.06); color: #fff; text-decoration: none; transform: translateX(2px); }
html[dir="rtl"] .nav-link:hover { transform: translateX(-2px); }
.nav-link.active { background: var(--orca-blue); color: #fff; }
.nav-link svg { width: 18px; height: 18px; flex-shrink: 0; }
.nav-link .badge { margin-inline-start: auto; }
.sidebar-footer { margin-top: auto; padding-top: 14px; border-top: 1px solid rgba(255,255,255,.08); font-size: 12px; opacity: .65; }

.main {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-width: 0; /* critical: prevents grid blowout when content is wide */
}
.topbar {
  background: #fff; border-bottom: 1px solid var(--border);
  padding: 14px 28px; display:flex; align-items:center; justify-content: space-between;
  position: sticky; top: 0; z-index: 30;
  gap: 12px;
}
.topbar-left { display:flex; align-items:center; gap: 12px; min-width: 0; }
.topbar-left h2 { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-actions { display:flex; align-items:center; gap: 6px; flex-wrap: nowrap; }
.icon-btn {
  background: transparent; border: 1px solid transparent; border-radius: 8px;
  width: 36px; height: 36px; display:inline-flex; align-items:center; justify-content:center;
  color: var(--muted); transition: background var(--transition), color var(--transition); position: relative;
}
.icon-btn:hover { background: var(--bg); color: var(--text); }
.icon-btn svg { width: 18px; height: 18px; }
.icon-btn .dot {
  position: absolute; top: 6px; inset-inline-end: 6px;
  min-width: 16px; height: 16px; border-radius: 999px; background: var(--danger);
  color: #fff; font-size: 10px; font-weight: 700; display:inline-flex; align-items:center; justify-content:center;
  padding: 0 4px;
}
.menu-btn { display: none; }
.user-pill { display:flex; align-items:center; gap: 8px; padding: 6px 12px; background: var(--bg); border-radius: 999px; font-size: 13px; }
.user-avatar { width: 28px; height: 28px; border-radius: 50%; background: var(--orca-blue); color: #fff; display:inline-flex; align-items:center; justify-content:center; font-weight:600; font-size:12px; }

.content {
  padding: 28px; flex: 1;
  max-width: 100%;
  min-width: 0;
  animation: pageEnter .25s ease;
}
@keyframes pageEnter { from { opacity:0; transform: translateY(6px); } to { opacity:1; transform: translateY(0); } }

/* Cards */
.card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
  transition: box-shadow var(--transition), transform var(--transition);
}
.card-hover:hover { box-shadow: var(--shadow-lg); transform: translateY(-1px); }
.card-header { padding: 18px 22px; border-bottom: 1px solid var(--border); display:flex; align-items:center; justify-content:space-between; gap:12px; flex-wrap: wrap; }
.card-title { font-size: 16px; font-weight: 600; margin:0; }
.card-body { padding: 22px; }
.card-body.compact { padding: 0; }

/* Typography */
h1, h2, h3, h4 { margin: 0; color: var(--text); font-weight: 700; line-height: 1.25; }
h1 { font-size: 28px; }
h2 { font-size: 20px; }
h3 { font-size: 16px; }
.muted { color: var(--muted); }
.text-sm { font-size: 13px; }
.text-xs { font-size: 12px; }
.font-medium { font-weight: 500; }
.font-bold { font-weight: 700; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; gap: 8px; padding: 9px 16px;
  border-radius: 8px; border: 1px solid transparent; font-weight: 500;
  font-size: 14px; transition: background var(--transition), border-color var(--transition), color var(--transition), transform var(--transition), box-shadow var(--transition);
  background: var(--orca-blue); color: #fff;
  white-space: nowrap;
}
.btn:hover { background: var(--orca-blue-dark); box-shadow: 0 4px 12px rgba(30,94,255,.25); }
.btn.outline { background: transparent; color: var(--text); border-color: var(--border); box-shadow: none; }
.btn.outline:hover { background: var(--bg); border-color: var(--orca-blue); color: var(--orca-blue); }
.btn.ghost { background: transparent; color: var(--text); box-shadow: none; }
.btn.ghost:hover { background: var(--bg); }
.btn.danger { background: var(--danger); }
.btn.danger:hover { background: #b91c1c; box-shadow: 0 4px 12px rgba(220,38,38,.25); }
.btn.success { background: var(--success); }
.btn.success:hover { background: #15803d; box-shadow: 0 4px 12px rgba(22,163,74,.25); }
.btn.warning { background: var(--warning); color: #fff; }
.btn.warning:hover { background: #d97706; }
.btn.sm { padding: 6px 12px; font-size: 13px; }
.btn.lg { padding: 12px 22px; font-size: 15px; }
.btn.block { width: 100%; justify-content: center; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn svg { width: 16px; height: 16px; }

/* Inputs */
.input, .select, .textarea {
  width: 100%; padding: 9px 12px; border-radius: 8px; border: 1px solid var(--border);
  font-family: inherit; font-size: 14px; background: #fff; color: var(--text);
  transition: border-color var(--transition), box-shadow var(--transition);
}
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--orca-blue); box-shadow: 0 0 0 3px rgba(30,94,255,.12); }
.input.with-icon { padding-inline-start: 36px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 13px; font-weight: 500; color: var(--text); }
.input-icon-wrap { position: relative; display: inline-block; max-width: 100%; }
.input-icon-wrap > .input { width: 240px; max-width: 100%; }
.input-icon-wrap svg { position: absolute; inset-inline-start: 12px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--muted); pointer-events: none; }
.textarea { min-height: 100px; resize: vertical; font-family: inherit; }

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

/* Stack utility */
.stack { display: flex; flex-direction: column; gap: 22px; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.row.nowrap { flex-wrap: nowrap; }
.spacer { flex: 1; }

/* Badge */
.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 500; background: var(--bg); color: var(--text); border: 1px solid var(--border); }
.badge.primary { background: rgba(30,94,255,.12); color: var(--orca-blue); border-color: transparent; }
.badge.success { background: rgba(22,163,74,.12); color: var(--success); border-color: transparent; }
.badge.warning { background: rgba(245,158,11,.14); color: #b45309; border-color: transparent; }
.badge.danger  { background: rgba(220,38,38,.12); color: var(--danger); border-color: transparent; }
.badge.muted   { background: var(--bg); color: var(--muted); border-color: transparent; }

/* Table */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: 12px 18px; text-align: start; border-bottom: 1px solid var(--border); font-size: 14px; vertical-align: middle; }
.table th { background: #fafbfd; font-weight: 600; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; white-space: nowrap; }
.table tbody tr { transition: background var(--transition); }
.table tbody tr:hover { background: rgba(30,94,255,.03); }
.table tbody tr:last-child td { border-bottom: 0; }
.row-actions { display: inline-flex; gap: 4px; }

/* Tabs */
.tabs { display:flex; gap: 2px; padding: 4px; background: var(--bg); border-radius: 10px; width: fit-content; max-width: 100%; overflow-x: auto; }
.tab { padding: 8px 18px; border-radius: 8px; cursor: pointer; font-size: 14px; font-weight: 500; color: var(--muted); background: transparent; border: 0; white-space: nowrap; }
.tab.active { background: #fff; color: var(--text); box-shadow: var(--shadow); }

/* KPI cards */
.kpi {
  background: #fff; border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px 20px; box-shadow: var(--shadow);
  transition: transform var(--transition), box-shadow var(--transition);
}
.kpi:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.kpi-head { display:flex; align-items:center; justify-content:space-between; margin-bottom: 14px; }
.kpi-head .title { font-size: 13px; color: var(--muted); font-weight: 500; }
.kpi-head svg { width: 20px; height: 20px; }
.kpi-value { font-size: 26px; font-weight: 700; }
.kpi-blue svg { color: var(--orca-blue); }
.kpi-green svg { color: #10b981; }
.kpi-purple svg { color: #8b5cf6; }
.kpi-rose svg { color: #f43f5e; }
.kpi-amber svg { color: #f59e0b; }
.kpi-indigo svg { color: #6366f1; }

/* Toast */
.toast-host { position: fixed; bottom: 20px; inset-inline-end: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 99; pointer-events: none; }
.toast { background: #fff; border: 1px solid var(--border); padding: 12px 16px; border-radius: 8px; box-shadow: var(--shadow-lg); min-width: 240px; max-width: calc(100vw - 40px); pointer-events: auto; animation: slideIn .25s cubic-bezier(.4,.0,.2,1); }
.toast.error { border-color: var(--danger); }
.toast.success { border-color: var(--success); }
.toast .t-title { font-weight: 600; font-size: 14px; }
.toast .t-desc { font-size: 13px; color: var(--muted); margin-top: 2px; }
@keyframes slideIn { from { opacity:0; transform: translateY(8px); } to { opacity:1; transform: translateY(0); } }

/* Modal */
.modal-backdrop { position: fixed; inset: 0; background: rgba(13,27,42,.45); z-index: 60; display:flex; align-items:center; justify-content:center; padding: 20px; animation: fade .15s ease; }
@keyframes fade { from {opacity:0} to {opacity:1} }
.modal { background: #fff; border-radius: 12px; max-width: 520px; width: 100%; box-shadow: 0 20px 50px rgba(0,0,0,.2); max-height: 90vh; overflow-y: auto; animation: modalIn .2s cubic-bezier(.4,.0,.2,1); }
.modal.lg { max-width: 720px; }
@keyframes modalIn { from { opacity: 0; transform: translateY(12px) scale(.98); } to { opacity:1; transform: translateY(0) scale(1); } }
.modal-header { padding: 18px 22px; border-bottom: 1px solid var(--border); display:flex; align-items:center; justify-content:space-between; }
.modal-title { font-size: 17px; font-weight: 600; margin: 0; }
.modal-body { padding: 22px; }
.modal-footer { padding: 14px 22px; border-top: 1px solid var(--border); display:flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }

/* Auth */
.auth-screen { min-height: 100vh; display:flex; align-items:center; justify-content:center; padding: 24px; background: linear-gradient(135deg, #f5f7fb, #eef1fa); }
.auth-card { background: #fff; padding: 36px; border-radius: 16px; max-width: 440px; width: 100%; box-shadow: 0 12px 40px rgba(13,27,42,.10); animation: modalIn .3s cubic-bezier(.4,.0,.2,1); }
.auth-logo { width: 148px; height: 148px; display:flex; align-items:center; justify-content:center; margin: 0 auto 22px; }
.auth-logo img { width: 100%; height: 100%; object-fit: contain; }
.auth-card h1 { text-align: center; margin: 0 0 6px; font-size: 19px; }
.auth-sub { text-align: center; color: var(--muted); margin-bottom: 22px; }
.auth-foot { text-align: center; margin-top: 18px; font-size: 13px; color: var(--muted); }

/* RTL fix-ups */
html[dir="rtl"] .input.with-icon { padding-inline-start: 12px; padding-inline-end: 36px; }

/* Dashboard editor */
.section-wrap { position: relative; }
.section-wrap.editing { border: 2px dashed rgba(30,94,255,.4); border-radius: 12px; padding: 12px; }
.section-toolbar { display:flex; align-items:center; gap: 4px; margin-bottom: 8px; padding: 4px 8px; background: rgba(30,94,255,.06); border: 1px solid rgba(30,94,255,.2); border-radius: 8px; }
.section-toolbar .label { font-size: 12px; font-weight: 500; color: var(--orca-blue); padding: 0 6px; }

/* Rich text editor */
.rt-wrap { border: 1px solid var(--border); border-radius: 8px; overflow: hidden; background: #fff; }
.rt-toolbar { display: flex; flex-wrap: wrap; gap: 4px; padding: 8px; background: #fafbfd; border-bottom: 1px solid var(--border); align-items: center; }
.rt-toolbar select { height: 32px; padding: 0 8px; border-radius: 6px; border: 1px solid var(--border); background: #fff; font-size: 13px; }
.rt-btn { width: 30px; height: 30px; display:inline-flex; align-items:center; justify-content:center; border: 0; border-radius: 6px; background: transparent; color: var(--text); }
.rt-btn:hover { background: var(--bg); }
.rt-btn svg { width: 16px; height: 16px; }
.rt-divider { width: 1px; height: 22px; background: var(--border); margin: 0 4px; }
.rt-color-swatch { width: 22px; height: 22px; border-radius: 4px; border: 1px solid var(--border); cursor: pointer; padding: 0; }
.rt-area { padding: 16px; min-height: 180px; outline: none; font-size: 14px; line-height: 1.6; }
.rt-area[data-placeholder]:empty:before { content: attr(data-placeholder); color: var(--muted); }

/* Task board */
.kanban { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 16px; }
.kanban-col { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; min-height: 360px; }
.kanban-col h3 { display:flex; align-items:center; justify-content:space-between; margin-bottom: 12px; font-size: 14px; }
.kanban-card { background: #fafbfd; border: 1px solid var(--border); border-radius: 8px; padding: 12px; margin-bottom: 8px; cursor: pointer; transition: transform var(--transition), box-shadow var(--transition); }
.kanban-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); border-color: var(--orca-blue); }
.kanban-card .title { font-weight: 500; font-size: 14px; }
.kanban-card .meta { display:flex; justify-content:space-between; margin-top: 8px; font-size: 12px; color: var(--muted); flex-wrap: wrap; gap: 4px; }
.kanban-col.pending h3::before { color: var(--muted); }

/* Inbox */
.inbox-shell { display: grid; grid-template-columns: minmax(280px, 360px) minmax(0,1fr); gap: 16px; min-height: 60vh; }
.inbox-list { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.inbox-item { display: flex; flex-direction: column; gap: 4px; padding: 12px 16px; border-bottom: 1px solid var(--border); cursor: pointer; transition: background var(--transition); position: relative; }
.inbox-item:hover { background: var(--bg); }
.inbox-item.active { background: rgba(30,94,255,.08); }
.inbox-item.unread { background: rgba(30,94,255,.04); }
.inbox-item.unread::before { content:""; position:absolute; inset-block:0; inset-inline-start:0; width:3px; background: var(--orca-blue); }
.inbox-item .ttl { font-weight: 600; font-size: 14px; }
.inbox-item .preview { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.inbox-item .when { font-size: 11px; color: var(--muted); }
.inbox-pane { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); padding: 22px; }
.inbox-empty { text-align: center; padding: 60px 20px; color: var(--muted); }
.notif-icon { width: 32px; height: 32px; border-radius: 8px; display: inline-flex; align-items:center; justify-content:center; flex-shrink: 0; }
.notif-icon.task_assigned    { background: rgba(30,94,255,.12); color: var(--orca-blue); }
.notif-icon.task_submitted   { background: rgba(245,158,11,.14); color: #b45309; }
.notif-icon.task_approved    { background: rgba(22,163,74,.12); color: var(--success); }
.notif-icon.task_rejected    { background: rgba(220,38,38,.12); color: var(--danger); }
.notif-icon.task_needs_changes { background: rgba(245,158,11,.14); color: #b45309; }
.notif-icon.system           { background: var(--bg); color: var(--muted); }

/* Printable document */
.doc-actions { display:flex; gap: 8px; flex-wrap: wrap; }
.printable-doc {
  background: #fff; color: #000; width: 210mm; max-width: 100%; min-height: 297mm; margin: 0 auto;
  position: relative; box-shadow: 0 8px 30px rgba(13,27,42,.12); overflow: hidden;
}
/* Brand corners — supplied design uses two diagonal accents:
   ‣ navy block in the top-start (logical) corner
   ‣ blue block in the bottom-end (logical) corner
   Old single .doc-corner kept for backwards compatibility. */
.doc-corner { position: absolute; width: 220px; height: 220px; pointer-events: none; overflow: hidden; }
.doc-corner::before, .doc-corner::after {
  content: ""; position: absolute; width: 140%; height: 140%;
}
.doc-corner-tl { top: 0; inset-inline-start: 0; }
.doc-corner-tl::before {
  top: -55%; inset-inline-start: -45%;
  background: var(--orca-navy);
  transform: rotate(-22deg);
}
.doc-corner-tl::after {
  top: -65%; inset-inline-start: -25%;
  background: var(--orca-blue);
  transform: rotate(-22deg);
  opacity: .85;
}
.doc-corner-br { bottom: 0; inset-inline-end: 0; }
.doc-corner-br::before {
  bottom: -55%; inset-inline-end: -45%;
  background: var(--orca-blue);
  transform: rotate(-22deg);
}
.doc-corner-br::after {
  bottom: -65%; inset-inline-end: -25%;
  background: var(--orca-navy);
  transform: rotate(-22deg);
  opacity: .85;
}
/* Legacy single corner still works (top-end) */
.doc-corner:not(.doc-corner-tl):not(.doc-corner-br) { top: 0; inset-inline-end: 0; }
.doc-corner:not(.doc-corner-tl):not(.doc-corner-br)::before {
  top: -55%; inset-inline-end: -45%;
  background: var(--orca-navy); transform: rotate(22deg);
}
.doc-corner:not(.doc-corner-tl):not(.doc-corner-br)::after {
  top: -65%; inset-inline-end: -25%;
  background: var(--orca-blue); transform: rotate(22deg); opacity: .85;
}
.doc-brand-name {
  font-size: 12px; letter-spacing: 3px;
  color: var(--orca-blue); font-weight: 700; margin-top: 8px;
}
.doc-page { position: relative; padding: 48px; z-index: 2; }
.doc-header { display:flex; justify-content: space-between; align-items: flex-start; margin-bottom: 36px; gap: 20px; flex-wrap: wrap; }
.doc-header-left img { height: 56px; margin-bottom: 14px; }
.doc-header-left h2 { font-size: 26px; color: var(--orca-navy); letter-spacing: 2px; margin: 0; }
.doc-header-left .accent-line { width: 60px; height: 5px; background: var(--orca-blue); margin-top: 8px; }
.doc-meta { background: #f8f9fa; padding: 16px; border-bottom: 2px solid var(--orca-blue); border-inline-end: 2px solid var(--orca-blue); border-radius: 0 0 0 14px; font-size: 12px; }
html[dir="rtl"] .doc-meta { border-radius: 0 0 14px 0; }
.doc-meta table { border-collapse: collapse; }
.doc-meta td { padding: 3px 8px; }
.doc-meta td.k { font-weight: 600; color: var(--orca-navy); }
.doc-parties { display: grid; grid-template-columns: 1fr 1fr; gap: 28px; margin-bottom: 36px; }
.doc-parties h3 { font-size: 11px; color: var(--orca-blue); letter-spacing: 1.4px; text-transform: uppercase; margin-bottom: 8px; }
.doc-parties .name { font-size: 17px; font-weight: 700; color: var(--orca-navy); margin-bottom: 4px; }
.doc-parties p { margin: 2px 0; color: #555; font-size: 13px; }
.doc-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.doc-table thead { background: var(--orca-navy); color: #fff; }
.doc-table th, .doc-table td { padding: 10px 14px; text-align: start; }
.doc-table tbody tr:nth-child(even) { background: #f8f9fa; }
.doc-table tbody { border-bottom: 2px solid var(--orca-navy); }
.doc-totals { display: flex; justify-content: flex-end; margin-top: 18px; }
.doc-totals table { width: 280px; max-width: 100%; font-size: 13px; }
.doc-totals td { padding: 6px 4px; }
.doc-totals tr.total { background: var(--orca-blue); color: #fff; font-weight: 700; }
.doc-totals tr.total td { padding: 12px 14px; font-size: 16px; }
.doc-section { margin: 24px 0; }
.doc-section h3 { font-size: 11px; color: var(--orca-blue); letter-spacing: 1.4px; text-transform: uppercase; margin-bottom: 8px; }
.doc-section .body { border-inline-start: 4px solid var(--orca-blue); padding-inline-start: 14px; font-size: 14px; line-height: 1.7; }
.doc-signatures { display: grid; grid-template-columns: 1fr 1fr; gap: 60px; margin: 60px 0 30px; }
.doc-signatures .sig { text-align: center; padding-top: 50px; border-top: 2px solid var(--orca-navy); }
.doc-signatures .sig-label { font-size: 11px; color: #777; }
.doc-signatures .sig-name { font-weight: 700; color: var(--orca-navy); margin-top: 4px; }
.doc-footer { padding-top: 16px; border-top: 2px solid var(--orca-navy); margin-top: 28px; text-align: center; font-size: 11px; color: var(--muted); }
.doc-footer .thanks { font-weight: 700; color: var(--orca-navy); margin-bottom: 4px; }

/* Print */
@media print {
  body { background: #fff; }
  .no-print, .topbar, .sidebar, #toast-host { display: none !important; }
  .content { padding: 0; }
  .printable-doc { box-shadow: none; width: 100%; min-height: auto; }
}

/* Dropdown menu */
.dropdown { position: relative; }
.dropdown-menu {
  position: absolute; top: calc(100% + 6px); inset-inline-end: 0;
  background: #fff; border: 1px solid var(--border); border-radius: 8px;
  box-shadow: 0 8px 24px rgba(13,27,42,.10); min-width: 220px; padding: 6px;
  z-index: 50; max-height: 360px; overflow-y: auto;
  animation: modalIn .15s ease;
}
.dropdown-item { display: block; width: 100%; padding: 8px 12px; border-radius: 6px; background: transparent; border: 0; text-align: start; font-size: 14px; color: var(--text); cursor: pointer; }
.dropdown-item:hover { background: var(--bg); }
.dropdown-label { padding: 6px 12px; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.dropdown-sep { height: 1px; background: var(--border); margin: 4px 0; }

/* Empty state */
.empty { text-align: center; padding: 48px 24px; color: var(--muted); }

/* Notice block */
.notice-info    { background: #eff6ff; border: 1px solid #bfdbfe; border-radius: 12px; padding: 16px; color: #1e3a8a; }
.notice-warn    { background: #fffbeb; border: 1px solid #fde68a; border-radius: 12px; padding: 16px; color: #92400e; }
.notice-success { background: #ecfdf5; border: 1px solid #a7f3d0; border-radius: 12px; padding: 16px; color: #065f46; }
.notice-default { background: var(--bg); border: 1px solid var(--border); border-radius: 12px; padding: 16px; }

/* Misc */
hr.sep { border: 0; border-top: 1px solid var(--border); margin: 18px 0; }
.invoice-prose { line-height: 1.7; }
.invoice-prose p { margin: 8px 0; }

/* Drawer */
.drawer-backdrop { position: fixed; inset: 0; background: rgba(13,27,42,.45); z-index: 60; animation: fade .15s ease; }
.drawer { position: fixed; top: 0; bottom: 0; inset-inline-end: 0; background: #fff; width: 420px; max-width: 95vw; z-index: 61; padding: 22px; overflow-y: auto; box-shadow: -10px 0 30px rgba(0,0,0,.1); animation: drawerIn .25s cubic-bezier(.4,.0,.2,1); }
@keyframes drawerIn { from { transform: translateX(100%); } to { transform: translateX(0); } }
html[dir="rtl"] .drawer { animation-name: drawerInRtl; }
@keyframes drawerInRtl { from { transform: translateX(-100%); } to { transform: translateX(0); } }
.drawer h2 { margin-bottom: 18px; }

/* Status pills used by tasks */
.pill-status { display:inline-block; padding: 3px 10px; border-radius: 999px; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.pill-pending { background: #f1f5f9; color: #475569; }
.pill-in_progress { background: #fef3c7; color: #92400e; }
.pill-blocked { background: #fee2e2; color: #b91c1c; }
.pill-done, .pill-approved { background: #dcfce7; color: #166534; }
.pill-submitted { background: #dbeafe; color: #1e40af; }
.pill-rejected { background: #fee2e2; color: #b91c1c; }
.pill-needs_changes { background: #ffedd5; color: #9a3412; }

/* Skeleton loader */
.skeleton { background: linear-gradient(90deg, #eef2f7 0%, #f7f9fc 50%, #eef2f7 100%); background-size: 200% 100%; animation: shimmer 1.4s infinite linear; border-radius: 6px; height: 14px; }
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* ===== Responsive layout ===== */

/* Tablet: shrink the sidebar */
@media (max-width: 1100px) {
  .shell { grid-template-columns: 200px minmax(0, 1fr); }
  .grid-4 { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .kanban { grid-template-columns: repeat(2, minmax(0,1fr)); }
}

/* Phone: collapse sidebar to off-canvas drawer + show hamburger */
@media (max-width: 820px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar {
    position: fixed; top: 0; bottom: 0; inset-inline-start: 0; width: 260px; height: 100vh;
    transform: translateX(-100%);
    box-shadow: 4px 0 20px rgba(0,0,0,.12);
  }
  html[dir="rtl"] .sidebar { transform: translateX(100%); inset-inline-start: auto; inset-inline-end: 0; box-shadow: -4px 0 20px rgba(0,0,0,.12); }
  .sidebar.open { transform: translateX(0); }
  .menu-btn { display: inline-flex; }
  .topbar { padding: 12px 16px; }
  .content { padding: 18px; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .user-pill span:not(.user-avatar):not(.badge) { display: none; }
  .inbox-shell { grid-template-columns: 1fr; }
  .doc-parties { grid-template-columns: 1fr; }
  h1 { font-size: 22px; }
  .topbar-left h2 { display: none; }
}

@media (max-width: 600px) {
  .kanban { grid-template-columns: 1fr; }
  .grid-4 { grid-template-columns: 1fr; }
  .modal { max-height: 95vh; }
  .toast-host { inset-inline-end: 10px; bottom: 10px; }
  .toast { min-width: 200px; }
}

/* Mobile sidebar backdrop */
.sidebar-backdrop { display: none; }
@media (max-width: 820px) {
  .sidebar-backdrop.open {
    display: block; position: fixed; inset: 0; background: rgba(13,27,42,.45); z-index: 39;
    animation: fade .15s ease;
  }
}

/* ============================================================
   Inline content editor (WordPress-like)
   ============================================================ */
body.edit-mode { padding-bottom: 64px; }
.cms-editable {
  outline: 1.5px dashed rgba(13, 110, 253, 0.55) !important;
  outline-offset: 2px;
  cursor: text;
  transition: background-color .12s ease;
  border-radius: 4px;
  min-height: 1em;
}
.cms-editable:hover { background-color: rgba(13, 110, 253, 0.07); }
.cms-editable:focus {
  outline-color: rgba(13, 110, 253, 1) !important;
  background-color: rgba(13, 110, 253, 0.10);
}
#cms-bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 80;
  background: linear-gradient(180deg, #0d1b2a, #1b2a3d);
  color: #fff; padding: 10px 16px;
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  box-shadow: 0 -6px 20px rgba(0,0,0,.25);
}
#cms-bar .cms-bar-title { font-weight: 600; }
#cms-bar .cms-bar-status { color: #ffd166; font-size: 13px; flex: 1; }
#cms-bar .btn { padding: 6px 12px; }

/* ============================================================
   Task private message thread
   ============================================================ */
.thread-item { padding: 12px 0; border-bottom: 1px solid var(--border); }
.thread-item:last-child { border-bottom: 0; }
.attachment-chip {
  display: inline-flex; align-items: center; gap: 6px; margin-top: 6px;
  background: var(--surface-2, #f1f5f9); border-radius: 6px; padding: 4px 10px;
  font-size: 13px;
}
.attachment-chip a { color: inherit; text-decoration: none; }
.msg-thread {
  display: flex; flex-direction: column; gap: 10px;
  max-height: 360px; overflow-y: auto; padding: 4px;
  background: var(--surface-2, #f8fafc); border-radius: 8px;
  border: 1px solid var(--border);
}
.msg-bubble {
  background: #fff; border: 1px solid var(--border);
  padding: 10px 12px; border-radius: 10px; max-width: 80%;
  align-self: flex-start;
}
.msg-bubble.mine {
  align-self: flex-end;
  background: #e7f1ff; border-color: #bdd6fa;
}
.msg-bubble.role-admin { border-color: #ffd6a5; background: #fff7e8; }
.msg-bubble.mine.role-admin { background: #ffe6c2; }
.msg-bubble .msg-meta {
  display: flex; justify-content: space-between; gap: 8px;
  font-size: 12px; margin-bottom: 4px; color: var(--muted);
}
.msg-bubble .msg-body { font-size: 14px; }
.msg-composer { margin-top: 12px; display: flex; flex-direction: column; gap: 8px; }

/* Larger task status pill in detail view */
.pill-status.lg { font-size: 13px; padding: 4px 10px; }

/* Two-column task detail layout */
.task-detail-grid {
  grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr);
  gap: 18px;
}
@media (max-width: 900px) {
  .task-detail-grid { grid-template-columns: 1fr; }
  .msg-bubble { max-width: 95%; }
}

/* ============================================================
   Settings page (tabs + help boxes)
   ============================================================ */
.tabs { display: flex; gap: 4px; border-bottom: 2px solid var(--border); margin-bottom: 16px; }
.tab {
  background: transparent; border: 0; padding: 10px 16px;
  border-bottom: 2px solid transparent; margin-bottom: -2px;
  cursor: pointer; font: inherit; color: var(--muted);
  transition: color .15s, border-color .15s;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--primary, #0d6efd); border-bottom-color: var(--primary, #0d6efd); }
.tab-pane { animation: fade .2s ease; }
.help-box {
  background: var(--surface-2, #f8fafc); border: 1px solid var(--border);
  border-radius: 8px; padding: 10px 14px; margin-bottom: 10px;
}
.help-box summary { cursor: pointer; font-weight: 500; }
.help-box ol { margin: 8px 0 0 0; padding-inline-start: 22px; }
.help-box code {
  background: rgba(13,110,253,.08); padding: 1px 6px; border-radius: 4px;
  font-family: ui-monospace, monospace; font-size: 13px;
}
.override-row {
  display: flex; flex-direction: column; gap: 6px;
  padding: 10px; border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface-2, #f8fafc);
}

/* Top-bar settings dropdown menu */
.popover-menu {
  background: #fff; border: 1px solid var(--border);
  border-radius: 8px; box-shadow: 0 8px 24px rgba(13,27,42,.18);
  padding: 4px; z-index: 60; min-width: 220px;
}
.popover-menu button {
  display: block; width: 100%; text-align: inherit;
  background: transparent; border: 0; padding: 8px 12px; border-radius: 6px;
  cursor: pointer; font: inherit; color: var(--text);
}
.popover-menu button:hover { background: var(--surface-2, #f1f5f9); }
html[dir="rtl"] .popover-menu { text-align: right; }

/* When body is in edit mode, prevent navigation through editable links */
body.edit-mode .nav-link.cms-editable,
body.edit-mode a.cms-editable { pointer-events: auto; }
body.edit-mode a.cms-editable { text-decoration: none; }

/* ============================================================
   THEME TOGGLE BUTTON (sun / moon in the topbar)
   ============================================================ */
.theme-toggle {
  display: inline-flex; align-items: center; justify-content: center;
  width: 38px; height: 38px; border-radius: 10px;
  background: transparent; color: var(--text);
  border: 1px solid var(--border);
  cursor: pointer; transition: background var(--transition), color var(--transition), transform var(--transition);
}
.theme-toggle:hover { background: var(--surface-2, #f1f5f9); transform: rotate(-12deg); }
.theme-toggle svg { width: 20px; height: 20px; }

/* Back-button in the topbar */
.topbar-back {
  display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; border-radius: 8px;
  background: transparent; color: var(--text);
  border: 1px solid var(--border); cursor: pointer;
  transition: background var(--transition), transform var(--transition);
}
.topbar-back:hover { background: var(--surface-2, #f1f5f9); }
.topbar-back svg { width: 18px; height: 18px; }
html[dir="rtl"] .topbar-back svg { transform: scaleX(-1); }

/* ============================================================
   PROFESSIONAL DARK MODE
   Activated by `data-theme="dark"` on <html>. Stored in localStorage
   so it persists between visits. The sidebar logo is swapped to
   /assets/orca-white.png by sidebar.js when this flag is on.
   ============================================================ */
html { transition: background-color var(--transition), color var(--transition); }

html[data-theme="dark"] {
  --orca-blue: #4d8bff;
  --orca-blue-dark: #3a72e6;
  --orca-navy: #060d18;       /* even deeper navy for the side-rail   */
  --bg: #0a1320;              /* page background                      */
  --card: #131e2e;            /* card / panel background              */
  --border: #1f2a3c;          /* subtle borders between elements      */
  --text: #e8edf5;
  --muted: #8b94a3;
  --muted-soft: #6b7280;
  --danger: #ef4444;
  --success: #22c55e;
  --warning: #fbbf24;
  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 4px 14px rgba(0,0,0,.45);
  --shadow-lg: 0 10px 36px rgba(0,0,0,.55);
  --surface-2: #1a2638;       /* hover / secondary surface            */
}

html[data-theme="dark"] body { background: var(--bg); color: var(--text); }

html[data-theme="dark"] .splash { background: var(--bg); }
html[data-theme="dark"] .splash-logo { filter: drop-shadow(0 4px 18px rgba(77,139,255,.35)); }

html[data-theme="dark"] .topbar,
html[data-theme="dark"] .card,
html[data-theme="dark"] .modal,
html[data-theme="dark"] .drawer,
html[data-theme="dark"] .popover-menu {
  background: var(--card);
  border-color: var(--border);
  color: var(--text);
}

html[data-theme="dark"] .input,
html[data-theme="dark"] .textarea,
html[data-theme="dark"] .select {
  background: #0f1827;
  color: var(--text);
  border-color: var(--border);
}
html[data-theme="dark"] .input::placeholder,
html[data-theme="dark"] .textarea::placeholder { color: var(--muted-soft); }
html[data-theme="dark"] .input:focus,
html[data-theme="dark"] .textarea:focus,
html[data-theme="dark"] .select:focus {
  outline: 2px solid rgba(77,139,255,.35); outline-offset: 1px;
  border-color: var(--orca-blue);
}

html[data-theme="dark"] .btn.outline,
html[data-theme="dark"] .btn.ghost {
  color: var(--text); border-color: var(--border); background: transparent;
}
html[data-theme="dark"] .btn.ghost:hover,
html[data-theme="dark"] .btn.outline:hover { background: var(--surface-2); }

html[data-theme="dark"] .badge.muted,
html[data-theme="dark"] .pill-status.pill-pending { background: #1f2a3c; color: #cbd5e1; }

/* Dark-mode status pills — keep them legible (was white-on-white before).
   We pair each tinted background with a bright readable foreground so the
   "in progress / blocked / done / submitted / rejected / needs changes"
   chips stay distinguishable in either theme. */
html[data-theme="dark"] .pill-status.pill-in_progress  { background: rgba(251,191,36,.18); color: #fcd34d; }
html[data-theme="dark"] .pill-status.pill-blocked      { background: rgba(239,68,68,.20);  color: #fca5a5; }
html[data-theme="dark"] .pill-status.pill-done,
html[data-theme="dark"] .pill-status.pill-approved     { background: rgba(34,197,94,.18);  color: #86efac; }
html[data-theme="dark"] .pill-status.pill-submitted    { background: rgba(59,130,246,.20); color: #93c5fd; }
html[data-theme="dark"] .pill-status.pill-rejected     { background: rgba(239,68,68,.20);  color: #fca5a5; }
html[data-theme="dark"] .pill-status.pill-needs_changes{ background: rgba(249,115,22,.20); color: #fdba74; }
html[data-theme="dark"] .nav-link { color: rgba(255,255,255,.78); }
html[data-theme="dark"] .nav-link:hover { background: rgba(255,255,255,.07); color: #fff; }

html[data-theme="dark"] table.table thead th { background: #0f1827; color: var(--muted); border-color: var(--border); }
html[data-theme="dark"] table.table td,
html[data-theme="dark"] table.table th { border-color: var(--border); }
html[data-theme="dark"] table.table tr:hover { background: var(--surface-2); }

html[data-theme="dark"] .help-box {
  background: #0f1827; border-color: var(--border); color: var(--text);
}
html[data-theme="dark"] .help-box code { background: rgba(77,139,255,.18); color: #cfe0ff; }

html[data-theme="dark"] .override-row { background: #0f1827; border-color: var(--border); }

html[data-theme="dark"] .toast { background: #131e2e; color: var(--text); border: 1px solid var(--border); }

html[data-theme="dark"] .theme-toggle { color: #ffd76b; }
html[data-theme="dark"] .theme-toggle:hover { background: rgba(255,215,107,.10); }

/* Smooth global colour transitions when toggling */
body, .topbar, .card, .modal, .drawer, .input, .textarea, .select,
.btn, .nav-link, .badge, .pill-status, table.table {
  transition: background-color var(--transition), color var(--transition), border-color var(--transition);
}

/* ============================================================
   ROUND 3 — Comprehensive dark-mode polish
   The previous theme only covered cards and form controls. Many
   surfaces hard-coded `background:#fff` or `#fafbfd`, which produced
   the unreadable "black-on-black" pages the user reported. The block
   below gives every surface a sensible dark counterpart.
   ============================================================ */

/* Auth screens (login / register) */
html[data-theme="dark"] .auth-screen {
  background: radial-gradient(1200px 700px at 50% -10%, #15233a 0%, #0a1320 60%, #060d18 100%);
  color: var(--text);
}
html[data-theme="dark"] .auth-card {
  background: var(--card);
  border: 1px solid var(--border);
  color: var(--text);
  box-shadow: var(--shadow-lg);
}
html[data-theme="dark"] .auth-card h1,
html[data-theme="dark"] .auth-card h2,
html[data-theme="dark"] .auth-card label { color: var(--text); }
html[data-theme="dark"] .auth-card .muted,
html[data-theme="dark"] .auth-card .hint { color: var(--muted); }

/* KPI / dashboard cards */
html[data-theme="dark"] .kpi,
html[data-theme="dark"] .stat-card,
html[data-theme="dark"] .summary-card {
  background: var(--card);
  border: 1px solid var(--border);
  color: var(--text);
}
html[data-theme="dark"] .kpi .label,
html[data-theme="dark"] .kpi small,
html[data-theme="dark"] .stat-card small { color: var(--muted); }
html[data-theme="dark"] .kpi .value,
html[data-theme="dark"] .stat-card .value { color: var(--text); }

/* Kanban board (tasks) */
html[data-theme="dark"] .kanban,
html[data-theme="dark"] .kanban-board { background: transparent; }
html[data-theme="dark"] .kanban-col {
  background: #101a2a;
  border: 1px solid var(--border);
}
html[data-theme="dark"] .kanban-col h3,
html[data-theme="dark"] .kanban-col header { color: var(--text); }
html[data-theme="dark"] .kanban-card,
html[data-theme="dark"] .task-card {
  background: var(--card);
  border: 1px solid var(--border);
  color: var(--text);
  box-shadow: 0 1px 2px rgba(0,0,0,.4);
}
html[data-theme="dark"] .kanban-card:hover,
html[data-theme="dark"] .task-card:hover {
  background: var(--surface-2);
  border-color: rgba(77,139,255,.4);
}
html[data-theme="dark"] .kanban-card .muted,
html[data-theme="dark"] .task-card .muted { color: var(--muted); }

/* Tabs */
html[data-theme="dark"] .tabs { border-bottom-color: var(--border); }
html[data-theme="dark"] .tab { color: var(--muted); }
html[data-theme="dark"] .tab:hover { color: var(--text); }
html[data-theme="dark"] .tab.active {
  background: var(--card);
  color: var(--orca-blue);
  border-color: var(--border);
  border-bottom-color: var(--card);
}

/* Generic table headers (extra rules for non-".table" tables in detail pages) */
html[data-theme="dark"] table th,
html[data-theme="dark"] .table-wrap thead th,
html[data-theme="dark"] .table thead th { background: #0f1827; color: var(--muted); }

/* Dropdown / popover menus (notifications, employee picker, etc.) */
html[data-theme="dark"] .dropdown-menu,
html[data-theme="dark"] .menu,
html[data-theme="dark"] .ctx-menu {
  background: var(--card);
  border: 1px solid var(--border);
  color: var(--text);
  box-shadow: var(--shadow-lg);
}
html[data-theme="dark"] .dropdown-menu .item:hover,
html[data-theme="dark"] .menu .item:hover,
html[data-theme="dark"] .ctx-menu .item:hover { background: var(--surface-2); }
html[data-theme="dark"] .dropdown-menu .divider,
html[data-theme="dark"] .menu .divider { background: var(--border); }

/* Inbox (notifications page) */
html[data-theme="dark"] .inbox-list,
html[data-theme="dark"] .inbox-pane {
  background: var(--card);
  border: 1px solid var(--border);
  color: var(--text);
}
html[data-theme="dark"] .inbox-item { border-bottom-color: var(--border); color: var(--text); }
html[data-theme="dark"] .inbox-item:hover { background: var(--surface-2); }
html[data-theme="dark"] .inbox-item.active,
html[data-theme="dark"] .inbox-item.selected { background: rgba(77,139,255,.12); }
html[data-theme="dark"] .inbox-item.unread { border-inline-start: 3px solid var(--orca-blue); }
html[data-theme="dark"] .inbox-empty,
html[data-theme="dark"] .inbox-pane .muted { color: var(--muted); }

/* Rich-text editor (documents) */
html[data-theme="dark"] .rt-wrap,
html[data-theme="dark"] .rt-editor {
  background: #0f1827;
  border: 1px solid var(--border);
  color: var(--text);
}
html[data-theme="dark"] .rt-toolbar {
  background: var(--card);
  border-bottom: 1px solid var(--border);
}
html[data-theme="dark"] .rt-toolbar button { color: var(--text); background: transparent; }
html[data-theme="dark"] .rt-toolbar button:hover { background: var(--surface-2); }

/* Task chat / message bubbles */
html[data-theme="dark"] .msg,
html[data-theme="dark"] .chat-msg { color: var(--text); }
html[data-theme="dark"] .msg-bubble {
  background: #1a2638;
  color: var(--text);
  border: 1px solid var(--border);
}
html[data-theme="dark"] .msg-bubble.role-admin,
html[data-theme="dark"] .msg-bubble.from-admin {
  background: rgba(77,139,255,.18);
  border-color: rgba(77,139,255,.35);
}
html[data-theme="dark"] .msg-meta,
html[data-theme="dark"] .msg-time { color: var(--muted); }

/* Empty / placeholder states */
html[data-theme="dark"] .empty,
html[data-theme="dark"] .placeholder,
html[data-theme="dark"] .no-data {
  background: #0f1827;
  border: 1px dashed var(--border);
  color: var(--muted);
}

/* Notice banners (info / warning / success) */
html[data-theme="dark"] .notice,
html[data-theme="dark"] .notice-info {
  background: rgba(77,139,255,.10);
  border: 1px solid rgba(77,139,255,.30);
  color: #cfe0ff;
}
html[data-theme="dark"] .notice-success {
  background: rgba(34,197,94,.10);
  border-color: rgba(34,197,94,.30);
  color: #bbf7d0;
}
html[data-theme="dark"] .notice-warning {
  background: rgba(251,191,36,.10);
  border-color: rgba(251,191,36,.30);
  color: #fde68a;
}
html[data-theme="dark"] .notice-danger,
html[data-theme="dark"] .notice-error {
  background: rgba(239,68,68,.10);
  border-color: rgba(239,68,68,.30);
  color: #fecaca;
}

/* Skeleton shimmer (loading state) */
html[data-theme="dark"] .skeleton {
  background: linear-gradient(90deg, #131e2e 0%, #1a2638 50%, #131e2e 100%);
}

/* The printable document preview keeps a white surface even in dark mode
   — printed PDFs/Word exports must stay legible on paper. Force this
   regardless of theme so the user can preview what the export will look
   like. */
html[data-theme="dark"] .printable-doc,
html[data-theme="dark"] .doc-page {
  background: #ffffff;
  color: #111827;
}
html[data-theme="dark"] .printable-doc table,
html[data-theme="dark"] .printable-doc th,
html[data-theme="dark"] .printable-doc td {
  background: transparent;
  color: inherit;
  border-color: #e5e7eb;
}

/* Sidebar always stays dark navy regardless of theme — the white logo
   in components/sidebar.js depends on this. Re-assert here so any
   future tweaks to the light-mode sidebar styling don't accidentally
   bleed white into dark mode. */
.sidebar { background: var(--orca-navy); color: #fff; }
html[data-theme="dark"] .sidebar { background: var(--orca-navy); }
html[data-theme="dark"] .sidebar .nav-link.active {
  background: rgba(77,139,255,.18);
  color: #fff;
}

/* ============================================================
   ROUND 3 — Smoother page navigation
   Cross-fade + subtle slide-in for #page when its content changes.
   The router replaces the inner HTML on every route change; adding a
   short animation makes navigation feel instant rather than jumpy.
   ============================================================ */
@keyframes orca-page-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}
#page > * { animation: orca-page-in 220ms cubic-bezier(.2,.8,.2,1) both; }

/* Nav links get a softer hover transition */
.nav-link, .topbar a, .topbar button { transition: background-color var(--transition), color var(--transition); }

/* ============================================================
   ROUND 3 — Print typography (PDF / Word export)
   The browser's "Print → Save as PDF" path is what the export
   buttons rely on. Set a proper @page size, embed the Tajawal font
   so Arabic stays consistent, and tighten the layout.
   ============================================================ */
@page {
  size: A4;
  margin: 14mm 12mm;
}
@media print {
  html, body {
    background: #ffffff !important;
    color: #111827 !important;
    font-family: "Tajawal", "Segoe UI", Tahoma, Arial, sans-serif !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
  .printable-doc, .doc-page {
    background: #ffffff !important;
    color: #111827 !important;
    box-shadow: none !important;
    border: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
  }
  .printable-doc h1, .printable-doc h2, .printable-doc h3 {
    color: #0b1730 !important;
    page-break-after: avoid;
  }
  .printable-doc table { border-collapse: collapse; width: 100%; font-size: 11pt; }
  .printable-doc table th {
    background: #f3f4f6 !important;
    color: #0b1730 !important;
    font-weight: 700;
    padding: 6pt 8pt;
    border-bottom: 1pt solid #cbd5e1 !important;
  }
  .printable-doc table td {
    padding: 5pt 8pt;
    border-bottom: 1pt solid #e5e7eb !important;
  }
  .printable-doc tr { page-break-inside: avoid; }
  .printable-doc .accent-line { background: #0b1730 !important; }
  /* Keep brand corners visible in PDF/print exports — the previous
     rule hid them, which dropped the ORCA branding from PDFs. */
  .printable-doc .doc-corner { display: block !important; }
  .no-print, .sidebar, .topbar, .toast, .modal-backdrop { display: none !important; }
}

/* ============================================================
   ROUND 4 — Dashboard task-overview KPI status pills
   The dashboard renders 5 KPI cards summarising tasks by status
   (pending, in_progress, blocked, submitted, done). Previously
   each card had a hard-coded pale background colour set inline,
   which made them look like white blocks in dark mode.
   We now expose the theme-aware variables here so both light and
   dark backgrounds get a tint that matches the status colour.
   ============================================================ */
.kpi-status {
  border-left: 4px solid transparent;
  background: var(--surface, #ffffff);
  transition: background .2s ease, border-color .2s ease;
}
.kpi-status[data-status="pending"]     { border-left-color: #f59e0b; background: #fff7ed; }
.kpi-status[data-status="in_progress"] { border-left-color: #fbbf24; background: #fffbeb; }
.kpi-status[data-status="blocked"]     { border-left-color: #ef4444; background: #fef2f2; }
.kpi-status[data-status="submitted"]   { border-left-color: #3b82f6; background: #eff6ff; }
.kpi-status[data-status="done"]        { border-left-color: #22c55e; background: #ecfdf5; }

/* Dark-mode tints — keep the colour cue but match the navy palette */
html[data-theme="dark"] .kpi-status                            { background: var(--surface, #1a2335); color: var(--text, #e2e8f0); }
html[data-theme="dark"] .kpi-status[data-status="pending"]     { background: rgba(245,158,11,.10); }
html[data-theme="dark"] .kpi-status[data-status="in_progress"] { background: rgba(251,191,36,.12); }
html[data-theme="dark"] .kpi-status[data-status="blocked"]     { background: rgba(239,68,68,.12);  }
html[data-theme="dark"] .kpi-status[data-status="submitted"]   { background: rgba(59,130,246,.12); }
html[data-theme="dark"] .kpi-status[data-status="done"]        { background: rgba(34,197,94,.12);  }
html[data-theme="dark"] .kpi-status .kpi-head .title           { color: var(--muted-soft, #94a3b8); }
html[data-theme="dark"] .kpi-status .kpi-value                 { color: var(--text, #e2e8f0); }

/* ============================================================
   ROUND 4 — Document templates (contract + invoice redesign)
   Larger 110px logo, dark-navy / blue diagonal corner bands,
   bismillah cover sheet, party cards, signature boxes, dark
   "BILLED TO" card and a payment-methods grid.
   ============================================================ */
.doc-logo-xl {
  width: 110px !important;
  height: 110px !important;
  object-fit: contain;
  margin-bottom: 8px;
  filter: drop-shadow(0 4px 14px rgba(13,27,42,.12));
}
.doc-brand-tag {
  display: inline-block;
  background: #0D1B2A;
  color: #fff;
  padding: 6px 14px;
  border-radius: 6px;
  font-weight: 700;
  letter-spacing: 1px;
  font-size: 12px;
}
.doc-meta-table {
  width: 100%;
  border-collapse: collapse;
  margin: 12px 0 18px;
  font-size: 13px;
}
.doc-meta-table .k {
  background: #f1f5f9;
  color: #334155;
  font-weight: 600;
  width: 130px;
  padding: 6px 10px;
}
.doc-meta-table td {
  padding: 6px 10px;
  border-bottom: 1px solid #e2e8f0;
}

/* ----- Party cards (used on the cover + quote layouts) ----- */
.doc-party-card {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-inline-start: 4px solid #1E5EFF;
  padding: 14px 16px;
  border-radius: 8px;
}
.doc-party-card h3 {
  margin: 0 0 8px;
  color: #0D1B2A;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 1px;
}
.doc-party-card .name { font-weight: 700; color: #0D1B2A; font-size: 15px; }
.doc-party-card p { margin: 4px 0; color: #475569; font-size: 13px; }

/* ----- Contract: cover sheet ----- */
.doc-template-contract .doc-page { page-break-after: always; min-height: 297mm; position: relative; }
.doc-template-contract .doc-page:last-child { page-break-after: auto; }
.doc-cover {
  text-align: center;
  padding: 60px 40px 40px;
}
.doc-cover-logo {
  width: 160px;
  height: 160px;
  object-fit: contain;
  margin: 0 auto 18px;
  display: block;
  filter: drop-shadow(0 6px 20px rgba(13,27,42,.18));
}
.doc-bismillah {
  font-family: "Tajawal", "Amiri", serif;
  font-size: 22px;
  color: #0D1B2A;
  margin: 8px 0 24px;
  letter-spacing: 1px;
}
.doc-cover-title {
  font-size: 38px;
  color: #0D1B2A;
  margin: 12px 0 6px;
  letter-spacing: 2px;
  font-weight: 800;
}
.doc-cover-serial {
  display: inline-block;
  font-family: monospace;
  background: #1E5EFF;
  color: #fff;
  padding: 6px 16px;
  border-radius: 999px;
  font-size: 14px;
  margin-bottom: 26px;
}
.doc-cover-meta { max-width: 520px; margin: 0 auto 26px; text-align: start; }
.doc-cover .doc-parties { max-width: 720px; margin: 24px auto 0; }

/* ----- Contract: last (signature) page ----- */
.doc-last { text-align: center; padding: 50px 40px; }
.doc-last-title {
  color: #0D1B2A;
  font-size: 26px;
  letter-spacing: 1px;
  margin: 12px 0 32px;
}
.doc-signature-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 28px;
  max-width: 720px;
  margin: 0 auto;
}
.doc-signature-box {
  background: #f8fafc;
  border: 2px solid #cbd5e1;
  border-radius: 10px;
  padding: 22px 18px;
  text-align: center;
  min-height: 200px;
}
.doc-signature-box .sig-label {
  text-transform: uppercase;
  letter-spacing: 2px;
  color: #1E5EFF;
  font-weight: 700;
  font-size: 12px;
  margin-bottom: 12px;
}
.doc-signature-box .sig-name {
  font-size: 16px;
  font-weight: 700;
  color: #0D1B2A;
  margin-bottom: 60px;
}
.doc-signature-box .sig-line {
  border-top: 2px solid #0D1B2A;
  margin: 0 12px 8px;
}
.doc-signature-box .sig-meta { color: #64748b; font-size: 12px; }

/* ----- Invoice template (matches invoice.jpeg) ----- */
.doc-template-invoice .invoice-head-grid {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 18px;
  margin: 12px 0 22px;
}
.invoice-billed-to {
  background: #0D1B2A;
  color: #fff;
  padding: 22px 22px;
  border-radius: 10px;
  position: relative;
  overflow: hidden;
}
.invoice-billed-to::before {
  content: "";
  position: absolute;
  inset: auto -30px -30px auto;
  width: 120px;
  height: 120px;
  background: linear-gradient(135deg, #1E5EFF, transparent);
  border-radius: 50%;
  opacity: .35;
}
.invoice-billed-to .bt-label {
  text-transform: uppercase;
  letter-spacing: 3px;
  font-size: 11px;
  color: #93c5fd;
  margin-bottom: 8px;
}
.invoice-billed-to .bt-name {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 8px;
}
.invoice-billed-to .bt-line {
  font-size: 13px;
  color: #cbd5e1;
  margin: 2px 0;
  position: relative;
  z-index: 1;
}
.invoice-meta-card {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 14px 16px;
}
.invoice-meta-card .doc-meta-table { margin: 0; }

/* ----- Invoice: payment methods grid ----- */
.invoice-payment-block { margin: 24px 0 12px; }
.invoice-payment-block h3 {
  color: #0D1B2A;
  border-inline-start: 4px solid #1E5EFF;
  padding-inline-start: 10px;
  margin: 0 0 12px;
  font-size: 16px;
}
.invoice-payment-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}
.pm-card {
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 16px;
  text-align: center;
  background: #ffffff;
  transition: transform .15s ease, box-shadow .15s ease;
}
.pm-card:hover { transform: translateY(-2px); box-shadow: 0 6px 18px rgba(13,27,42,.08); }
.pm-card .pm-icon { font-size: 26px; margin-bottom: 8px; }
.pm-card .pm-title { font-weight: 700; color: #0D1B2A; margin-bottom: 6px; font-size: 14px; }
.pm-card .pm-line { color: #475569; font-size: 12px; margin: 2px 0; word-break: break-all; }

/* ----- Footer band shared by all templates ----- */
.doc-footer-band {
  margin-top: 28px;
  background: linear-gradient(135deg, #0D1B2A 0%, #1E5EFF 100%);
  color: #fff;
  padding: 16px 22px;
  border-radius: 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}
.doc-footer-band .thanks { font-weight: 700; font-size: 15px; letter-spacing: 1px; }
.doc-footer-band .iban-line { font-size: 12px; opacity: .9; font-family: monospace; }

/* ----- Dark-mode adjustments for document preview only -----
   The on-screen preview uses the dashboard surfaces, but the
   printable document itself must always look like white paper. */
html[data-theme="dark"] .printable-doc { background: #ffffff; color: #0f172a; }
html[data-theme="dark"] .doc-party-card { background: #f8fafc; color: #0f172a; }
html[data-theme="dark"] .invoice-meta-card { background: #f8fafc; color: #0f172a; }
html[data-theme="dark"] .pm-card { background: #ffffff; color: #0f172a; }

/* ----- Responsive (preview only — print always uses 2-up) ---- */
@media (max-width: 720px) {
  .doc-template-invoice .invoice-head-grid { grid-template-columns: 1fr; }
  .invoice-payment-grid { grid-template-columns: 1fr; }
  .doc-signature-grid   { grid-template-columns: 1fr; }
}

/* Print rules for the new templates — make sure dark-navy survives */
@media print {
  .doc-template-contract .doc-page,
  .doc-template-invoice  .doc-page { page-break-after: always; }
  .doc-template-contract .doc-page:last-child,
  .doc-template-invoice  .doc-page:last-child { page-break-after: auto; }
  .invoice-billed-to    { background: #0D1B2A !important; color: #ffffff !important; }
  .invoice-billed-to .bt-line { color: #cbd5e1 !important; }
  .doc-footer-band      { background: #0D1B2A !important; color: #ffffff !important; }
  .doc-cover-serial     { background: #1E5EFF !important; color: #ffffff !important; }
  .doc-brand-tag        { background: #0D1B2A !important; color: #ffffff !important; }
  .doc-signature-box    { border: 2px solid #cbd5e1 !important; }
}


  /* ============================================================
     CONTRACT LETTERHEAD TEMPLATE  (ctr-* prefix)
     ============================================================ */
  @import url('https://fonts.googleapis.com/css2?family=Amiri:ital,wght@0,400;0,700;1,400&display=swap');
  .ctr-printable { display:flex; flex-direction:column; gap:32px; margin:0 auto; max-width:210mm; }
  .ctr-page { background:#ffffff; width:210mm; min-height:297mm; max-width:100%; position:relative; box-shadow:0 8px 30px rgba(13,27,42,.12); overflow:hidden; display:flex; flex-direction:column; font-family:"Tajawal",system-ui,sans-serif; }
  .ctr-top-band { width:100%; height:72px; background:#1E5EFF; flex-shrink:0; position:relative; overflow:hidden; }
  .ctr-top-corner { position:absolute; top:-28px; inset-inline-end:-28px; width:130px; height:130px; background:#0a0a0a; transform:rotate(22deg); }
  .ctr-logo-row { display:flex; align-items:center; gap:20px; padding:14px 32px 6px; flex-shrink:0; }
  .ctr-logo { width:88px; height:88px; object-fit:contain; filter:drop-shadow(0 2px 8px rgba(13,27,42,.10)); }
  .ctr-title-wrap { display:flex; flex-direction:column; }
  .ctr-title-ar { font-size:28px; font-weight:700; color:#0D1B2A; letter-spacing:1px; font-family:"Tajawal",sans-serif; }
  .ctr-title-underline { width:72px; height:3px; background:#1E5EFF; margin-top:5px; }
  .ctr-body { flex:1; padding:10px 32px 18px; display:flex; flex-direction:column; gap:12px; }
  .ctr-bismillah { text-align:center; font-family:"Amiri","Tajawal",serif; font-size:24px; color:#0D1B2A; padding:6px 0 2px; letter-spacing:1px; }
  .ctr-fields-row { display:flex; gap:16px; }
  .ctr-labeled-field { flex:1; display:flex; border:1px solid #c5cde0; border-radius:3px; overflow:hidden; }
  .ctr-field-label { background:#1E4ECC; color:#fff; padding:8px 14px; font-weight:700; font-size:13px; white-space:nowrap; display:flex; align-items:center; order:2; }
  [dir="ltr"] .ctr-field-label { order:1; }
  .ctr-field-value { flex:1; padding:8px 12px; font-size:13px; color:#1a1a1a; order:1; }
  [dir="ltr"] .ctr-field-value { order:2; }
  .ctr-section-box { border:1px solid #c5cde0; border-radius:3px; overflow:hidden; }
  .ctr-section-header { background:#0D1B2A; color:#fff; padding:9px 18px; font-weight:700; font-size:14px; text-align:center; letter-spacing:.5px; }
  .ctr-subject-content,.ctr-terms-content { padding:10px 18px; font-size:13px; line-height:1.75; min-height:60px; }
  .ctr-subject-lines,.ctr-terms-lines { padding:10px 18px 6px; }
  .ctr-line { border-bottom:1px solid #d1d9e8; height:24px; margin-bottom:8px; }
  .ctr-quran-verse { text-align:center; font-family:"Amiri","Tajawal",serif; font-size:22px; color:#1E5EFF; padding:10px 18px; line-height:1.8; letter-spacing:.5px; }
  .ctr-intro-section { display:flex; flex-direction:column; align-items:center; gap:12px; padding:4px 0 8px; width:100%; }
  .ctr-intro-btn { background:#1E5EFF; color:#fff; padding:10px 36px; font-size:15px; font-weight:700; border-radius:5px; letter-spacing:.5px; }
  .ctr-intro-content { width:100%; min-height:40px; font-size:13px; line-height:1.9; }
  .ctr-blank-body { padding-top:20px; }
  .ctr-blank-lines { display:flex; flex-direction:column; flex:1; gap:6px; }
  .ctr-parties-grid { display:grid; grid-template-columns:1fr 1fr; gap:14px; }
  .ctr-party-box { border:1.5px solid #1E5EFF; border-radius:5px; overflow:hidden; }
  .ctr-party-header { background:#0D1B2A; color:#fff; padding:9px 14px; font-weight:700; font-size:14px; display:flex; align-items:center; gap:8px; }
  .ctr-party-field { display:flex; align-items:flex-end; gap:8px; padding:5px 14px; border-bottom:1px solid #edf0f7; }
  .ctr-party-field:last-child { border-bottom:0; }
  .ctr-party-field-label { font-size:12px; color:#334155; white-space:nowrap; font-weight:500; }
  .ctr-party-field-line { flex:1; border-bottom:1px solid #b0bad0; min-height:18px; font-size:13px; color:#1a1a1a; padding-bottom:1px; }
  .ctr-sig-grid { display:grid; grid-template-columns:1fr 1fr; gap:14px; margin-top:4px; }
  .ctr-sig-box { border:1.5px solid #1E5EFF; border-radius:5px; overflow:hidden; }
  .ctr-sig-header { background:#0D1B2A; color:#fff; padding:9px 14px; font-weight:700; font-size:14px; display:flex; align-items:center; gap:8px; }
  .ctr-sig-area { padding:12px 14px 10px; }
  .ctr-sig-line-area { height:50px; border-bottom:1px dashed #b0bad0; margin-bottom:12px; }
  .ctr-footer-band { background:#1E5EFF; color:#fff; padding:13px 28px; flex-shrink:0; position:relative; overflow:hidden; margin-top:auto; }
  .ctr-bottom-corner { position:absolute; bottom:-28px; inset-inline-start:-28px; width:110px; height:110px; background:#0a0a0a; transform:rotate(22deg); }
  .ctr-footer-items { display:flex; justify-content:space-around; align-items:center; gap:16px; font-size:13px; position:relative; z-index:1; }
  .ctr-footer-item { display:flex; align-items:center; gap:6px; white-space:nowrap; }
  .ctr-footer-item svg { flex-shrink:0; opacity:.9; }
  html[data-theme="dark"] .ctr-page, html[data-theme="dark"] .ctr-party-field-line, html[data-theme="dark"] .ctr-sig-line-area { background:#ffffff !important; color:#0f172a !important; }
  html[data-theme="dark"] .ctr-party-field-label, html[data-theme="dark"] .ctr-title-ar { color:#1a1a1a !important; }
  @media print {
    .ctr-printable { gap:0; max-width:100%; }
    .ctr-page { page-break-after:always; box-shadow:none; width:100%; min-height:auto; }
    .ctr-page:last-child { page-break-after:auto; }
    .ctr-top-band { background:#1E5EFF !important; }
    .ctr-field-label { background:#1E4ECC !important; color:#fff !important; }
    .ctr-section-header { background:#0D1B2A !important; color:#fff !important; }
    .ctr-party-header, .ctr-sig-header { background:#0D1B2A !important; color:#fff !important; }
    .ctr-footer-band { background:#1E5EFF !important; color:#fff !important; }
    .ctr-intro-btn { background:#1E5EFF !important; color:#fff !important; }
    .ctr-quran-verse { color:#1E5EFF !important; }
    .ctr-top-corner, .ctr-bottom-corner { background:#000 !important; }
  }
  @media (max-width:760px) {
    .ctr-page { width:100%; min-height:auto; }
    .ctr-parties-grid, .ctr-sig-grid { grid-template-columns:1fr; }
    .ctr-fields-row { flex-direction:column; }
  }
  
/* ============================================================
   FEATURE BATCH 3 — COMPREHENSIVE RESPONSIVE DESIGN
   Supplements the existing breakpoints with deeper mobile polish
   ============================================================ */

/* ── Auth screens: full-width card on small phones ── */
@media (max-width: 500px) {
  .auth-screen { padding: 12px; align-items: flex-start; padding-top: 24px; }
  .auth-card {
    width: 100%;
    max-width: 100%;
    border-radius: 16px;
    padding: 24px 18px;
  }
  .auth-logo img { width: 148px; height: 148px; }
  .auth-card h1 { font-size: 19px; }
  .auth-card .grid.grid-2 { grid-template-columns: 1fr; }
}

/* ── Topbar: tighter on small phones ── */
@media (max-width: 480px) {
  .topbar-actions .btn.ghost.sm span { display: none; }
  .topbar-actions .btn.ghost.sm { min-width: 36px; justify-content: center; }
  .user-pill .badge { display: none; }
  .content { padding: 14px; }
  h1 { font-size: 20px; }
}

/* ── Tables: always scrollable inside a .table-wrap ── */
.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: 0 0 var(--radius) var(--radius);
}
@media (max-width: 820px) {
  .table th, .table td { padding: 10px 12px; font-size: 13px; }
}
@media (max-width: 600px) {
  .table th, .table td { padding: 8px 10px; font-size: 12px; }
  .row-actions { flex-direction: column; gap: 4px; }
  .row-actions .btn { width: 100%; }
}

/* ── KPI cards: 2-up on phone instead of 4-up ── */
@media (max-width: 600px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi { padding: 14px 10px; }
  .kpi-value { font-size: 28px; }
}

/* ── Modal: full-screen on small phones ── */
@media (max-width: 600px) {
  .modal {
    width: 100%;
    max-width: 100%;
    margin: 0;
    border-radius: 16px 16px 0 0;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    max-height: 92vh;
    overflow-y: auto;
  }
  .modal-backdrop { align-items: flex-end; }
}

/* ── Cards: reduce padding on small phones ── */
@media (max-width: 600px) {
  .card-body { padding: 14px; }
  .card-header { padding: 12px 14px; }
  .card-body.compact { padding: 0; }
}

/* ── Document preview: full-width on mobile ── */
@media (max-width: 820px) {
  .printable-doc,
  .doc-page,
  .ctr-page {
    width: 100% !important;
    min-height: auto !important;
    border-radius: 8px;
  }
  .document-view-shell {
    flex-direction: column;
    gap: 12px;
  }
  .doc-actions-bar {
    flex-wrap: wrap;
    gap: 8px;
  }
  .doc-actions-bar .btn { flex: 1 1 auto; }
}

/* ── Employee detail: stack on mobile ── */
@media (max-width: 820px) {
  .grid[style*="minmax(280px"] {
    grid-template-columns: 1fr !important;
  }
}

/* ── Settings tabs: wrap on mobile ── */
@media (max-width: 600px) {
  .tabs { flex-wrap: wrap; width: 100%; }
  .tab { flex: 1 1 auto; text-align: center; font-size: 12px; padding: 7px 8px; }
}

/* ── Stack spacing: tighter on phones ── */
@media (max-width: 600px) {
  .stack { gap: 12px; }
}

/* ── Row actions: always visible on mobile ── */
@media (max-width: 820px) {
  .row-actions { display: flex; flex-wrap: wrap; gap: 6px; }
}

/* ── Sidebar: ensure z-index above content ── */
@media (max-width: 820px) {
  .sidebar { z-index: 40; transition: transform .25s cubic-bezier(.4,0,.2,1); }
}

/* ── Prevent text overflow in table cells on mobile ── */
@media (max-width: 820px) {
  .table td { word-break: break-word; }
  .table .font-medium { word-break: break-word; }
}

/* ── Permissions toggle in employee modal ── */
.perm-toggle input:focus-visible + span {
  outline: 2px solid var(--orca-blue);
  outline-offset: 2px;
  border-radius: 24px;
}

/* ── Pending-users badge on tab ── */
#pending-badge {
  font-weight: 700;
  line-height: 1;
  border-radius: 999px;
  padding: 2px 7px;
  font-size: 11px;
  vertical-align: middle;
  margin-inline-start: 6px;
}
