/* =====================================================================
   ORION ACCOUNTS ERP - Modern UI 2026
   Clean, modern light/dark theme with full LTR + RTL support.
   --------------------------------------------------------------------- */

/* -------------------- Tokens -------------------- */
:root {
  --bg: #f4f6fb;
  --bg-soft: #eef1f7;
  --surface: #ffffff;
  --surface-soft: #f8fafc;
  --surface-strong: #ffffff;
  --surface-muted: #f1f4f9;

  --ink: #0f172a;
  --ink-soft: #1e293b;
  --muted: #64748b;
  --muted-2: #94a3b8;

  --border: #e5e9f1;
  --border-strong: #d6dbe6;
  --border-soft: #eef1f7;

  --primary: #4f46e5;
  --primary-strong: #4338ca;
  --primary-soft: #eef2ff;
  --primary-2: #6366f1;

  --accent: #0ea5e9;
  --accent-soft: #e0f2fe;
  --accent-2: #14b8a6;
  --accent-2-soft: #ccfbf1;

  --good: #10b981;
  --good-soft: #d1fae5;
  --warn: #f59e0b;
  --warn-soft: #fef3c7;
  --danger: #ef4444;
  --danger-soft: #fee2e2;

  --shadow-xs: 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.05), 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow: 0 6px 18px rgba(15, 23, 42, 0.06), 0 2px 4px rgba(15, 23, 42, 0.04);
  --shadow-lg: 0 16px 40px rgba(15, 23, 42, 0.10), 0 4px 12px rgba(15, 23, 42, 0.05);
  --shadow-glow: 0 14px 32px rgba(79, 70, 229, 0.18);

  --radius-xl: 22px;
  --radius-lg: 16px;
  --radius-md: 12px;
  --radius-sm: 10px;
  --radius-xs: 8px;

  --grad-primary: linear-gradient(135deg, #6366f1 0%, #4f46e5 50%, #4338ca 100%);
  --grad-accent: linear-gradient(135deg, #14b8a6 0%, #0ea5e9 100%);
  --grad-hero: linear-gradient(135deg, #1e1b4b 0%, #4338ca 50%, #4f46e5 100%);
  --grad-soft: linear-gradient(135deg, #eef2ff 0%, #f8fafc 100%);

  --topbar-h: 64px;
  --sidebar-w: 264px;
  --sidebar-w-collapsed: 78px;

  /* Legacy aliases used by portal.php inline styles. */
  --card: var(--surface-soft);
  --card2: var(--surface-muted);
  --border2: var(--border-strong);
  --gold: #b07c10;
  --gold2: #d49a1a;
  --gold-dim: rgba(176, 124, 16, 0.12);
  --red: #ef4444;
  --red-dim: rgba(239, 68, 68, 0.12);
  --green: #10b981;
  --green-dim: rgba(16, 185, 129, 0.12);
  --blue: #2563eb;
  --blue-dim: rgba(37, 99, 235, 0.12);
  --teal: #14b8a6;
  --teal-dim: rgba(20, 184, 166, 0.12);
  --amber: #f59e0b;

  color-scheme: light;
}

html[data-theme="dark"] {
  --bg: #0a0f1d;
  --bg-soft: #0f1525;
  --surface: #111827;
  --surface-soft: #161d31;
  --surface-strong: #0f172a;
  --surface-muted: #1a2238;

  --ink: #e2e8f0;
  --ink-soft: #f1f5f9;
  --muted: #94a3b8;
  --muted-2: #64748b;

  --border: rgba(148, 163, 184, 0.16);
  --border-strong: rgba(148, 163, 184, 0.28);
  --border-soft: rgba(148, 163, 184, 0.10);

  --primary: #818cf8;
  --primary-strong: #6366f1;
  --primary-soft: rgba(129, 140, 248, 0.14);
  --primary-2: #a5b4fc;

  --accent: #38bdf8;
  --accent-soft: rgba(56, 189, 248, 0.14);
  --accent-2: #2dd4bf;
  --accent-2-soft: rgba(45, 212, 191, 0.14);

  --good: #34d399;
  --good-soft: rgba(52, 211, 153, 0.14);
  --warn: #fbbf24;
  --warn-soft: rgba(251, 191, 36, 0.14);
  --danger: #f87171;
  --danger-soft: rgba(248, 113, 113, 0.14);

  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.4), 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.44), 0 2px 6px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 22px 50px rgba(0, 0, 0, 0.55), 0 6px 14px rgba(0, 0, 0, 0.35);
  --shadow-glow: 0 16px 40px rgba(99, 102, 241, 0.32);

  --grad-primary: linear-gradient(135deg, #818cf8 0%, #6366f1 50%, #4f46e5 100%);
  --grad-hero: linear-gradient(135deg, #1e1b4b 0%, #312e81 60%, #1e3a8a 100%);
  --grad-soft: linear-gradient(135deg, #1a2238 0%, #111827 100%);

  /* Legacy aliases (dark) */
  --card: var(--surface-soft);
  --card2: var(--surface-muted);
  --border2: var(--border-strong);
  --gold: #d49a1a;
  --gold2: #f0c96a;
  --gold-dim: rgba(212, 154, 26, 0.16);
  --red: #f87171;
  --red-dim: rgba(248, 113, 113, 0.16);
  --green: #34d399;
  --green-dim: rgba(52, 211, 153, 0.16);
  --blue: #60a5fa;
  --blue-dim: rgba(96, 165, 250, 0.16);
  --teal: #2dd4bf;
  --teal-dim: rgba(45, 212, 191, 0.16);
  --amber: #fbbf24;

  color-scheme: dark;
}

/* -------------------- Reset -------------------- */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

html {
  font-family: "Inter", "Cairo", "Tajawal", "Segoe UI", system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

body {
  margin: 0;
  background: var(--bg);
  background-image:
    radial-gradient(circle at 8% 0%, rgba(79, 70, 229, 0.07), transparent 32%),
    radial-gradient(circle at 92% 4%, rgba(14, 165, 233, 0.05), transparent 30%);
  background-attachment: fixed;
  color: var(--ink);
  font-size: 14px;
  line-height: 1.5;
  letter-spacing: -0.005em;
}

html[data-theme="dark"] body {
  background-image:
    radial-gradient(circle at 8% 0%, rgba(99, 102, 241, 0.13), transparent 32%),
    radial-gradient(circle at 92% 4%, rgba(56, 189, 248, 0.10), transparent 30%);
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

img,
svg {
  max-width: 100%;
  display: block;
}

* {
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
}
*::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}
*::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 999px;
  border: 2px solid transparent;
  background-clip: padding-box;
}
*::-webkit-scrollbar-thumb:hover {
  background: var(--muted-2);
  background-clip: padding-box;
  border: 2px solid transparent;
}

/* -------------------- App shell -------------------- */
.app-shell {
  position: relative;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.app-shell.has-sidebar {
  min-height: 100vh;
}

.container {
  width: 100%;
  max-width: 1480px;
  margin: 0 auto;
  padding: 22px 24px 36px;
}

.workspace-page {
  width: 100%;
  max-width: 1480px;
  margin: 0 auto;
  padding: 24px 28px 48px;
  display: grid;
  gap: 22px;
}

.dashboard-content {
  width: 100%;
  max-width: 1480px;
  margin: 0 auto;
  padding: 22px 24px 36px;
  display: grid;
  gap: 20px;
}

.print-only {
  display: none;
}
.screen-only {
  display: revert;
}

/* -------------------- Top mega nav -------------------- */
.site-sidebar.top-mega-nav {
  position: sticky;
  top: 0;
  z-index: 1000;
  display: flex;
  align-items: stretch;
  gap: 6px;
  padding: 0 16px;
  height: var(--topbar-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-xs);
  backdrop-filter: saturate(140%) blur(6px);
  -webkit-backdrop-filter: saturate(140%) blur(6px);
}

html[data-theme="dark"] .site-sidebar.top-mega-nav {
  background: rgba(15, 23, 42, 0.86);
}

.top-mega-nav__brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 0 14px;
  font-size: 17px;
  font-weight: 700;
  color: var(--ink);
  letter-spacing: -0.01em;
  white-space: nowrap;
}

.top-mega-nav__brand::before {
  content: "";
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: var(--grad-primary);
  box-shadow: 0 6px 14px rgba(79, 70, 229, 0.32);
}

.top-mega-nav__quick {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 10px 6px;
}

.top-mega-nav__menus {
  display: inline-flex;
  align-items: stretch;
  flex: 1 1 auto;
  min-width: 0;
  gap: 2px;
  padding: 8px 4px;
  overflow: visible;
}

.top-mega-nav__controls {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 0;
  margin-inline-start: auto;
}

.top-mega-nav__user {
  position: relative;
  display: inline-flex;
  align-items: center;
  padding: 8px 4px;
}

.top-mega-nav__user-button {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 6px 10px 6px 6px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-soft);
  color: var(--ink);
  cursor: pointer;
  font-weight: 600;
  font-size: 13px;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
}

.top-mega-nav__user-button:hover {
  background: var(--primary-soft);
  border-color: var(--primary);
}

.top-mega-nav__user-button img {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: #fff;
  padding: 3px;
  border: 1px solid var(--border);
  object-fit: contain;
}

.top-mega-nav__user-caret {
  font-size: 11px;
  color: var(--muted);
}

.top-mega-nav__user-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  inset-inline-end: 0;
  min-width: 220px;
  display: none;
  flex-direction: column;
  gap: 2px;
  padding: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  z-index: 1100;
}

.top-mega-nav__user:hover .top-mega-nav__user-dropdown,
.top-mega-nav__user:focus-within .top-mega-nav__user-dropdown {
  display: flex;
}

.top-mega-nav__user-dropdown strong {
  display: block;
  padding: 6px 10px 8px;
  font-size: 12px;
  color: var(--muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-bottom: 1px solid var(--border-soft);
  margin-bottom: 4px;
}

.top-mega-nav__user-dropdown a {
  display: block;
  padding: 8px 10px;
  border-radius: var(--radius-xs);
  font-size: 13px;
  font-weight: 500;
  color: var(--ink);
  transition: background 0.12s ease;
}

.top-mega-nav__user-dropdown a:hover {
  background: var(--surface-muted);
}

.top-mega-nav__user-dropdown a.is-danger {
  color: var(--danger);
}

.top-mega-nav__user-dropdown a.is-danger:hover {
  background: var(--danger-soft);
}

.top-mega-nav__quick-link,
.top-mega-nav__group-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 42px;
  padding: 0 14px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--ink);
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.top-mega-nav__quick-link:hover,
.top-mega-nav__group-button:hover {
  background: var(--surface-muted);
  color: var(--primary);
}

.top-mega-nav__quick-link.is-active {
  background: var(--primary-soft);
  color: var(--primary);
  border-color: var(--primary-soft);
}

.top-mega-nav__group {
  position: relative;
  display: inline-flex;
}

.top-mega-nav__group.is-active .top-mega-nav__group-button,
.top-mega-nav__group:hover .top-mega-nav__group-button,
.top-mega-nav__group:focus-within .top-mega-nav__group-button {
  background: var(--primary-soft);
  color: var(--primary);
}

.top-mega-nav__quick-link .site-sidebar__icon,
.top-mega-nav__group-button .site-sidebar__icon {
  width: 24px;
  height: 24px;
  border-radius: 7px;
  background: var(--surface-muted);
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.top-mega-nav__quick-link.is-active .site-sidebar__icon,
.top-mega-nav__group-button.is-active .site-sidebar__icon {
  background: var(--primary);
  color: #fff;
}

.top-mega-nav__group .site-sidebar__caret {
  margin-inline-start: 2px;
  font-size: 10px;
  color: var(--muted);
}

.top-mega-nav__dropdown {
  position: absolute;
  top: calc(100% + 6px);
  inset-inline-start: 0;
  z-index: 1100;
  display: grid;
  grid-template-columns: repeat(2, minmax(220px, 1fr));
  gap: 4px;
  min-width: 460px;
  max-width: min(720px, calc(100vw - 40px));
  max-height: min(70vh, 560px);
  overflow: auto;
  padding: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-6px);
  transition: opacity 0.16s ease, transform 0.16s ease, visibility 0.16s ease;
  pointer-events: none;
}

.top-mega-nav__group:hover .top-mega-nav__dropdown,
.top-mega-nav__group:focus-within .top-mega-nav__dropdown {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
  pointer-events: auto;
}

.top-mega-nav__dropdown .site-sidebar__sublink {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-xs);
  font-size: 13px;
  font-weight: 500;
  color: var(--ink);
  transition: background 0.12s ease, color 0.12s ease;
}

.top-mega-nav__dropdown .site-sidebar__sublink:hover {
  background: var(--surface-muted);
  color: var(--primary);
}

.top-mega-nav__dropdown .site-sidebar__sublink.is-active {
  background: var(--primary-soft);
  color: var(--primary);
}

.site-sidebar__subicon {
  width: 22px;
  height: 22px;
  border-radius: 6px;
  background: var(--surface-muted);
  color: var(--muted);
  font-size: 9px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.site-sidebar__sublink.is-active .site-sidebar__subicon {
  background: var(--primary);
  color: #fff;
}

.site-sidebar__sublabel {
  font-weight: 500;
}

.site-sidebar__label {
  font-weight: 600;
}

/* UI controls (theme/language) */
.ui-switcher {
  display: inline-flex;
  gap: 6px;
}

.ui-switcher--auth {
  position: fixed;
  top: 18px;
  inset-inline-end: 22px;
  z-index: 100;
}

.ui-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  height: 38px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
}

.ui-toggle:hover {
  background: var(--primary-soft);
  border-color: var(--primary);
  color: var(--primary);
}

.ui-toggle.is-active {
  background: var(--primary-soft);
  border-color: var(--primary);
  color: var(--primary);
}

.ui-toggle__icon {
  width: 22px;
  height: 22px;
  border-radius: 6px;
  background: var(--grad-primary);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.top-mega-nav__controls .ui-toggle__text {
  display: none;
}

@media (min-width: 1280px) {
  .top-mega-nav__controls .ui-toggle__text {
    display: inline;
  }
}

/* -------------------- Header (sub-header for inner pages) -------------------- */
.header {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 16px;
  padding: 18px 28px;
  background: var(--surface);
  color: var(--ink);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-xs);
}

.header-side {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.header-side.left {
  align-items: flex-start;
  text-align: start;
}

.header-side.right {
  align-items: flex-end;
  text-align: end;
}

.header-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--ink);
  letter-spacing: -0.01em;
}

.header-subtitle {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.5;
}

.header-subtitle a {
  color: var(--primary);
  font-weight: 600;
}

.header-center {
  display: flex;
  align-items: center;
  justify-content: center;
}

.school-logo {
  width: auto;
  height: 44px;
  max-width: 140px;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  background: #fff;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-xs);
  object-fit: contain;
}

/* -------------------- Date / context bar -------------------- */
.date-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 18px;
  padding: 10px 28px;
  background: var(--surface-soft);
  border-bottom: 1px solid var(--border);
  font-size: 12px;
  color: var(--muted);
}

.date-item span {
  font-weight: 600;
  color: var(--ink);
  margin-inline-start: 6px;
}

.date-author {
  margin-inline-start: auto;
  font-weight: 600;
  color: var(--primary);
  white-space: nowrap;
}

/* -------------------- Flash / Alerts -------------------- */
.flash-stack {
  display: grid;
  gap: 10px;
  margin-bottom: 16px;
}

.alert {
  padding: 12px 16px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font-size: 13px;
  line-height: 1.55;
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.alert::before {
  content: "";
  width: 6px;
  align-self: stretch;
  border-radius: 999px;
  flex-shrink: 0;
}

.alert.success {
  background: var(--good-soft);
  border-color: rgba(16, 185, 129, 0.28);
  color: #047857;
}
.alert.success::before { background: var(--good); }

.alert.error {
  background: var(--danger-soft);
  border-color: rgba(239, 68, 68, 0.28);
  color: #b91c1c;
}
.alert.error::before { background: var(--danger); }

.alert.warning {
  background: var(--warn-soft);
  border-color: rgba(245, 158, 11, 0.28);
  color: #b45309;
}
.alert.warning::before { background: var(--warn); }

.alert.info {
  background: var(--accent-soft);
  border-color: rgba(14, 165, 233, 0.28);
  color: #075985;
}
.alert.info::before { background: var(--accent); }

html[data-theme="dark"] .alert.success { color: #6ee7b7; }
html[data-theme="dark"] .alert.error { color: #fca5a5; }
html[data-theme="dark"] .alert.warning { color: #fcd34d; }
html[data-theme="dark"] .alert.info { color: #7dd3fc; }

/* -------------------- Cards / Panels -------------------- */
.panel,
.panel-card,
.filters-card,
.table-card,
.chart-card,
.summary-card,
.report-cover-card,
.erp-control-panel,
.odoo-move-card,
.journal-list-card,
.invoice-print-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

.panel,
.panel-card {
  padding: 20px;
  margin-bottom: 16px;
}

.panel-grid {
  display: grid;
  grid-template-columns: 1fr 1.15fr;
  gap: 18px;
}

.panel-intro {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 14px;
}

.panel-title {
  margin: 0 0 6px;
  font-size: 16px;
  font-weight: 700;
  color: var(--ink);
}

.panel-subtitle {
  margin: 0;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.7;
}

.panel-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.mini-badge,
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary);
  border: 1px solid transparent;
  font-size: 11px;
  font-weight: 600;
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 14px;
}

.section-heading h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  color: var(--ink);
}

.section-heading span {
  font-size: 12px;
  color: var(--muted);
}

/* -------------------- Tabs -------------------- */
.tabs {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px;
  background: var(--surface-muted);
  border-radius: 999px;
  border: 1px solid var(--border);
}

.tab-btn {
  border: 0;
  padding: 8px 16px;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.tab-btn:hover {
  color: var(--ink);
}

.tab-btn.is-active {
  background: var(--surface);
  color: var(--primary);
  box-shadow: var(--shadow-xs);
}

.tab-panel {
  display: none;
  margin-top: 16px;
}

.tab-panel.is-active {
  display: block;
}

/* -------------------- Forms -------------------- */
.form-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.form-grid.two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.form-grid.four {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.field-wide,
.journal-field-wide {
  grid-column: 1 / -1;
}

.field label {
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-soft);
  letter-spacing: 0.005em;
}

.field-help,
.helper,
.hint {
  font-size: 11px;
  color: var(--muted);
  line-height: 1.55;
}

input[type="text"],
input[type="number"],
input[type="date"],
input[type="datetime-local"],
input[type="time"],
input[type="month"],
input[type="email"],
input[type="search"],
input[type="tel"],
input[type="url"],
input[type="password"],
select,
textarea {
  width: 100%;
  min-height: 38px;
  padding: 9px 12px;
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-xs);
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

input::placeholder,
textarea::placeholder {
  color: var(--muted-2);
}

textarea {
  min-height: 96px;
  resize: vertical;
  line-height: 1.6;
}

input:focus,
select:focus,
textarea:focus {
  outline: 0;
  border-color: var(--primary);
  background: var(--surface);
  box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.14);
}

input[readonly],
select[readonly],
textarea[readonly] {
  background: var(--surface-muted);
  color: var(--muted);
  cursor: not-allowed;
}

input[disabled],
select[disabled],
textarea[disabled] {
  opacity: 0.7;
  cursor: not-allowed;
}

select {
  appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12' fill='none'><path d='M3 4.5L6 7.5L9 4.5' stroke='%2364748b' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/></svg>");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-inline-end: 32px;
}

html[dir="rtl"] select {
  background-position: left 10px center;
  padding-inline-end: 12px;
  padding-inline-start: 32px;
}

input[type="checkbox"],
input[type="radio"] {
  width: 18px;
  height: 18px;
  min-height: 0;
  accent-color: var(--primary);
  cursor: pointer;
}

.checkbox-field {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--ink);
  cursor: pointer;
}

.password-control {
  position: relative;
  display: flex;
  align-items: center;
}

.password-control input {
  padding-inline-end: 70px;
}

.password-toggle {
  position: absolute;
  inset-inline-end: 6px;
  top: 50%;
  transform: translateY(-50%);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 28px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  background: var(--surface-muted);
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.password-toggle:hover {
  background: var(--primary-soft);
  color: var(--primary);
}

.stacked {
  display: grid;
  gap: 14px;
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 16px;
}

/* -------------------- Buttons -------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 38px;
  padding: 8px 16px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.005em;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
  text-decoration: none;
  white-space: nowrap;
}

.btn:disabled,
.btn[disabled] {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

.btn-primary {
  background: var(--grad-primary);
  border-color: transparent;
  color: #fff;
  box-shadow: var(--shadow-glow);
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 18px 36px rgba(79, 70, 229, 0.26);
}

.btn-secondary {
  background: var(--surface);
  border-color: var(--border-strong);
  color: var(--ink);
}

.btn-secondary:hover {
  background: var(--primary-soft);
  border-color: var(--primary);
  color: var(--primary);
}

.btn-ghost {
  background: transparent;
  border-color: var(--border);
  color: var(--muted);
}

.btn-ghost:hover {
  background: var(--surface-muted);
  color: var(--ink);
}

.btn-danger {
  background: var(--danger-soft);
  border-color: rgba(239, 68, 68, 0.32);
  color: var(--danger);
}

.btn-danger:hover {
  background: var(--danger);
  color: #fff;
  border-color: var(--danger);
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 32px;
  padding: 6px 11px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  color: var(--ink);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease, transform 0.15s ease;
}

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

.icon-btn.danger {
  background: var(--danger-soft);
  border-color: rgba(239, 68, 68, 0.32);
  color: var(--danger);
}

.icon-btn.danger:hover {
  background: var(--danger);
  border-color: var(--danger);
  color: #fff;
}

.actions {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 6px;
}

.bulk-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.bulk-count {
  display: inline-flex;
  align-items: center;
  height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 11px;
  font-weight: 700;
}

.bulk-delete-form {
  margin: 0;
}

.inline-workflow-form {
  display: inline-flex;
  margin: 0;
}

/* -------------------- Tables -------------------- */
.table-card {
  padding: 0;
  overflow: hidden;
}

.table-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--border-soft);
}

.table-header h3 {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  color: var(--ink);
}

.table-header .hint {
  font-size: 12px;
  color: var(--muted);
}

.table-wrap {
  overflow: auto;
  max-width: 100%;
}

.data-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

.data-table thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--surface-soft);
  color: var(--muted);
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  text-align: start;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.data-table tbody td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--border-soft);
  color: var(--ink);
  vertical-align: middle;
}

.data-table tbody tr:last-child td {
  border-bottom: 0;
}

.data-table tbody tr:hover td {
  background: var(--primary-soft);
}

.data-table tbody tr.is-row-selected td {
  background: var(--accent-soft);
}

.data-table tfoot th,
.data-table tfoot td {
  background: var(--surface-soft);
  color: var(--ink);
  font-weight: 700;
  padding: 10px 14px;
  border-top: 1px solid var(--border);
}

.data-table .bulk-select-cell,
.data-table .centered-cell {
  text-align: center;
}

.data-table .amount-col {
  text-align: end;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.amount-input {
  text-align: end;
  font-variant-numeric: tabular-nums;
}

.muted { color: var(--muted); }
.nowrap { white-space: nowrap; }
.text-ellipsis {
  max-width: 240px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.danger { color: var(--danger); }
.primary { color: var(--primary); }
.warning { color: var(--warn); }
.info { color: var(--accent); }

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  border: 1px solid transparent;
  white-space: nowrap;
}

.badge-soft {
  background: var(--primary-soft);
  color: var(--primary);
}

.badge-green {
  background: var(--good-soft);
  color: #047857;
  border-color: rgba(16, 185, 129, 0.32);
}

.badge-red {
  background: var(--danger-soft);
  color: #b91c1c;
  border-color: rgba(239, 68, 68, 0.32);
}

.badge-yellow {
  background: var(--warn-soft);
  color: #92400e;
  border-color: rgba(245, 158, 11, 0.32);
}

html[data-theme="dark"] .badge-green { color: #6ee7b7; }
html[data-theme="dark"] .badge-red { color: #fca5a5; }
html[data-theme="dark"] .badge-yellow { color: #fcd34d; }

/* -------------------- Pagination -------------------- */
.pagination {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 16px;
  padding: 0 18px 16px;
  font-size: 12px;
  color: var(--muted);
}

.page-links {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 4px;
}

.page-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 34px;
  height: 34px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  background: var(--surface);
  color: var(--ink);
  font-weight: 600;
  font-size: 12px;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.page-link:hover {
  background: var(--primary-soft);
  color: var(--primary);
  border-color: var(--primary);
}

.page-link.is-active {
  background: var(--grad-primary);
  border-color: transparent;
  color: #fff;
  box-shadow: var(--shadow-glow);
}

/* -------------------- Empty state -------------------- */
.empty-state {
  padding: 28px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-md);
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 13px;
  text-align: center;
  line-height: 1.7;
}

/* -------------------- Auth pages -------------------- */
.auth-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 28px;
  background:
    radial-gradient(circle at 14% 18%, rgba(99, 102, 241, 0.18), transparent 28%),
    radial-gradient(circle at 86% 14%, rgba(14, 165, 233, 0.14), transparent 28%),
    linear-gradient(135deg, #f6f8fb 0%, #eef2ff 50%, #f0f9ff 100%);
}

html[data-theme="dark"] .auth-shell {
  background:
    radial-gradient(circle at 14% 18%, rgba(99, 102, 241, 0.22), transparent 28%),
    radial-gradient(circle at 86% 14%, rgba(56, 189, 248, 0.16), transparent 28%),
    linear-gradient(135deg, #0a0f1d 0%, #161d31 50%, #0f172a 100%);
}

.auth-card {
  width: min(100%, 880px);
  display: grid;
  grid-template-columns: 1.05fr 0.95fr;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

.company-select-card {
  width: min(100%, 1040px);
}

.auth-hero {
  position: relative;
  padding: 36px;
  color: #fff;
  background: var(--grad-hero);
  overflow: hidden;
}

.auth-hero::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 20% 20%, rgba(255, 255, 255, 0.18), transparent 28%),
    radial-gradient(circle at 80% 80%, rgba(255, 255, 255, 0.10), transparent 30%);
  pointer-events: none;
}

.auth-hero > * {
  position: relative;
}

.auth-hero h1 {
  margin: 18px 0 10px;
  font-size: 28px;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.01em;
  color: #fff;
}

.auth-hero p {
  margin: 0;
  font-size: 13px;
  line-height: 1.8;
  color: rgba(255, 255, 255, 0.78);
}

.auth-logo {
  width: 96px;
  height: 96px;
  padding: 8px;
  border-radius: 22px;
  background: #fff;
  box-shadow: 0 14px 28px rgba(0, 0, 0, 0.2);
  object-fit: contain;
}

.auth-meta {
  display: grid;
  gap: 10px;
  margin-top: 26px;
}

.auth-meta .chip {
  background: rgba(255, 255, 255, 0.14);
  border: 1px solid rgba(255, 255, 255, 0.22);
  color: #fff;
  width: fit-content;
}

.auth-form {
  padding: 36px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 18px;
  background: var(--surface);
}

.auth-form h2 {
  margin: 0;
  font-size: 22px;
  font-weight: 700;
  color: var(--ink);
  letter-spacing: -0.01em;
}

.auth-form .helper {
  margin: 0;
  font-size: 12px;
  line-height: 1.7;
  color: var(--muted);
}

/* Company picker */
.company-picker-grid,
.company-access-grid {
  display: grid;
  gap: 10px;
}

.company-picker-card,
.company-access-option {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
}

.company-picker-card:hover,
.company-access-option:hover {
  border-color: var(--primary);
  background: var(--primary-soft);
  transform: translateY(-1px);
  box-shadow: var(--shadow);
}

.company-picker-card.is-current,
.company-access-option:has(input:checked) {
  border-color: var(--primary);
  background: var(--primary-soft);
}

.company-picker-card input,
.company-access-option input {
  width: 18px;
  height: 18px;
  accent-color: var(--primary);
}

.company-picker-card__logo {
  width: 52px;
  height: 52px;
  border-radius: var(--radius-sm);
  background: #fff;
  border: 1px solid var(--border);
  display: grid;
  place-items: center;
  overflow: hidden;
  flex-shrink: 0;
}

.company-picker-card__logo img {
  width: 100%;
  height: 100%;
  padding: 4px;
  object-fit: contain;
}

.company-picker-card__content,
.company-access-option span {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.company-picker-card strong,
.company-access-option strong {
  color: var(--ink);
  font-size: 14px;
  font-weight: 600;
}

.company-picker-card small,
.company-access-option small {
  color: var(--muted);
  font-size: 11px;
  font-weight: 500;
}

/* -------------------- Portal home (home.php) -------------------- */
.portal-body {
  background:
    radial-gradient(circle at 18% 12%, rgba(99, 102, 241, 0.14), transparent 30%),
    radial-gradient(circle at 80% 88%, rgba(14, 165, 233, 0.12), transparent 32%),
    linear-gradient(180deg, #f6f8fb 0%, #eef2ff 100%);
  min-height: 100vh;
}

html[data-theme="dark"] .portal-body {
  background:
    radial-gradient(circle at 18% 12%, rgba(99, 102, 241, 0.20), transparent 30%),
    radial-gradient(circle at 80% 88%, rgba(56, 189, 248, 0.16), transparent 32%),
    linear-gradient(180deg, #0a0f1d 0%, #111827 100%);
}

.portal-shell {
  position: relative;
  min-height: 100vh;
  padding: 28px 32px 60px;
  display: flex;
  flex-direction: column;
  gap: 32px;
}

.portal-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.portal-user {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  font-size: 13px;
}

.portal-power {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--danger-soft);
  color: var(--danger);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.05em;
  border: 1px solid rgba(239, 68, 68, 0.24);
  transition: background 0.15s ease, color 0.15s ease;
}

.portal-power:hover {
  background: var(--danger);
  color: #fff;
}

.portal-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: #fff;
  border: 1px solid var(--border);
  overflow: hidden;
}

.portal-avatar img {
  width: 100%;
  height: 100%;
  padding: 4px;
  object-fit: contain;
}

.portal-user span {
  display: grid;
  gap: 2px;
  line-height: 1.3;
}

.portal-user strong {
  color: var(--ink);
  font-size: 14px;
  font-weight: 700;
}

.portal-user small {
  color: var(--muted);
  font-size: 12px;
}

.portal-actions {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.portal-actions a {
  display: inline-flex;
  align-items: center;
  height: 36px;
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
  font-size: 12px;
  font-weight: 600;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.portal-actions a:hover {
  background: var(--primary-soft);
  border-color: var(--primary);
  color: var(--primary);
}

.portal-actions a.is-home {
  background: var(--grad-primary);
  border-color: transparent;
  color: #fff;
  box-shadow: var(--shadow-glow);
}

.portal-actions a.is-home:hover {
  transform: translateY(-1px);
}

.portal-map {
  flex: 1 1 auto;
  display: grid;
  grid-template-columns: 1fr minmax(360px, 460px) 1fr;
  align-items: center;
  gap: 32px;
  min-height: calc(100vh - 200px);
}

.portal-center {
  display: grid;
  place-items: center;
}

.portal-center-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  padding: 40px 28px;
  width: 100%;
  max-width: 420px;
  border: 1px solid var(--border);
  border-radius: 32px;
  background:
    radial-gradient(circle at 30% 0%, rgba(99, 102, 241, 0.1), transparent 50%),
    var(--surface);
  box-shadow: var(--shadow-lg);
  text-align: center;
}

.portal-center-kicker {
  display: inline-flex;
  align-items: center;
  padding: 6px 14px;
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.portal-center-card h1 {
  margin: 0;
  font-size: 42px;
  font-weight: 800;
  letter-spacing: -0.04em;
  background: var(--grad-primary);
  -webkit-background-clip: text;
          background-clip: text;
  -webkit-text-fill-color: transparent;
}

.portal-center-card h2 {
  margin: 0;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--ink);
}

.portal-orbit-logo {
  position: relative;
  width: 140px;
  height: 140px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  padding: 18px;
}

.portal-orbit-logo::before,
.portal-orbit-logo::after {
  content: "";
  position: absolute;
  inset: -10px;
  border-radius: 50%;
  border: 1px dashed rgba(99, 102, 241, 0.3);
  animation: portal-spin 18s linear infinite;
}

.portal-orbit-logo::after {
  inset: -22px;
  border: 1px dashed rgba(14, 165, 233, 0.22);
  animation-duration: 28s;
  animation-direction: reverse;
}

.portal-orbit-logo img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

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

.portal-module-list {
  display: grid;
  gap: 14px;
}

.portal-module-list--left {
  justify-self: end;
  width: 100%;
  max-width: 360px;
}

.portal-module-list--right {
  justify-self: start;
  width: 100%;
  max-width: 360px;
}

.portal-module-card {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 14px;
  padding: 18px 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
  --portal-accent: #4f46e5;
}

.portal-module-list--right .portal-module-card {
  grid-template-columns: auto 1fr;
}

.portal-module-card:hover {
  transform: translateY(-2px);
  border-color: var(--portal-accent);
  box-shadow: 0 16px 30px rgba(15, 23, 42, 0.08);
}

.portal-module-card.is-disabled {
  opacity: 0.6;
  pointer-events: none;
}

.portal-module-text {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.portal-module-list--left .portal-module-text {
  text-align: end;
}

.portal-module-text strong {
  font-size: 15px;
  font-weight: 700;
  color: var(--ink);
}

.portal-module-text small {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.6;
}

.portal-module-icon {
  width: 50px;
  height: 50px;
  border-radius: var(--radius-sm);
  display: grid;
  place-items: center;
  background: rgba(79, 70, 229, 0.12);
  color: var(--portal-accent);
  font-weight: 700;
  font-size: 14px;
  letter-spacing: 0.04em;
  border: 1px solid rgba(79, 70, 229, 0.18);
}

/* -------------------- Workspace pages -------------------- */
.workspace-back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.18);
  border: 1px solid rgba(255, 255, 255, 0.28);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  margin-bottom: 14px;
  width: fit-content;
  transition: background 0.15s ease, transform 0.15s ease;
}

.workspace-back::before {
  content: "←";
  font-size: 14px;
}

html[dir="rtl"] .workspace-back::before {
  content: "→";
}

.workspace-back:hover {
  background: rgba(255, 255, 255, 0.28);
  transform: translateX(-2px);
}

.workspace-hero {
  position: relative;
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 24px;
  padding: 32px 36px;
  border-radius: var(--radius-xl);
  color: #fff;
  background: var(--grad-hero);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

.workspace-hero::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 20% 30%, rgba(255, 255, 255, 0.16), transparent 30%),
    radial-gradient(circle at 80% 80%, rgba(255, 255, 255, 0.08), transparent 32%);
  pointer-events: none;
}

.workspace-hero > * {
  position: relative;
}

.workspace-hero h1 {
  margin: 0 0 8px;
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: #fff;
}

.workspace-hero p {
  margin: 0;
  max-width: 720px;
  font-size: 14px;
  line-height: 1.7;
  color: rgba(255, 255, 255, 0.82);
}

.workspace-hero img {
  width: 88px;
  height: 88px;
  padding: 10px;
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.95);
  object-fit: contain;
  box-shadow: 0 18px 30px rgba(0, 0, 0, 0.16);
}

.workspace-hero--accounting {
  background: linear-gradient(135deg, #1e1b4b 0%, #4338ca 50%, #4f46e5 100%);
}

.workspace-hero--hr {
  background: linear-gradient(135deg, #831843 0%, #be123c 50%, #ef4444 100%);
}

.workspace-hero--students {
  background: linear-gradient(135deg, #0f766e 0%, #0891b2 50%, #2563eb 100%);
}

.workspace-kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
}

.workspace-kpi {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 16px 18px;
  border-radius: var(--radius-lg);
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

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

.workspace-kpi span {
  font-size: 11px;
  color: var(--muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.workspace-kpi strong {
  font-size: 26px;
  font-weight: 700;
  color: var(--ink);
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

.workspace-section {
  padding: 24px;
  border-radius: var(--radius-lg);
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}

.workspace-section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 16px;
}

.workspace-section-head h2 {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
  color: var(--ink);
  letter-spacing: -0.01em;
}

.workspace-section-head span {
  font-size: 12px;
  color: var(--muted);
}

.workspace-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
}

.workspace-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 20px 18px;
  border-radius: var(--radius-md);
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-xs);
  text-decoration: none;
  color: inherit;
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
  --workspace-accent: #4f46e5;
  overflow: hidden;
}

.workspace-card::before {
  content: "";
  position: absolute;
  top: 0;
  inset-inline-start: 0;
  width: 100%;
  height: 3px;
  background: var(--workspace-accent);
  opacity: 0.85;
}

.workspace-card:hover {
  transform: translateY(-2px);
  border-color: var(--workspace-accent);
  box-shadow: 0 16px 32px rgba(15, 23, 42, 0.08);
}

.workspace-card-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: var(--radius-xs);
  background: rgba(79, 70, 229, 0.12);
  color: var(--workspace-accent);
  font-weight: 700;
  font-size: 12px;
  letter-spacing: 0.04em;
  margin-bottom: 6px;
}

.workspace-card strong {
  font-size: 14px;
  font-weight: 700;
  color: var(--ink);
  letter-spacing: -0.005em;
}

.workspace-card small {
  font-size: 12px;
  color: var(--muted);
  font-weight: 500;
}

/* -------------------- KPI tiles -------------------- */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 16px;
}

.kpi-card {
  position: relative;
  overflow: hidden;
  padding: 18px 18px;
  border-radius: var(--radius-lg);
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  display: grid;
  gap: 4px;
  min-height: 116px;
  color: var(--ink);
}

.kpi-card::before {
  content: "";
  position: absolute;
  top: 0;
  inset-inline-start: 0;
  width: 100%;
  height: 4px;
  background: var(--grad-primary);
  opacity: 0.85;
}

.kpi-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: var(--radius-xs);
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 6px;
}

.kpi-value {
  font-size: 26px;
  font-weight: 700;
  color: var(--ink);
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

.kpi-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.kpi-note {
  margin-top: 6px;
  font-size: 11px;
  color: var(--muted);
}

.kpi-card.c-purple::before { background: linear-gradient(135deg, #6d28d9, #a855f7); }
.kpi-card.c-pink::before { background: linear-gradient(135deg, #be185d, #ec4899); }
.kpi-card.c-blue::before { background: linear-gradient(135deg, #1e40af, #3b82f6); }
.kpi-card.c-green::before { background: linear-gradient(135deg, #047857, #10b981); }
.kpi-card.c-orange::before { background: linear-gradient(135deg, #c2410c, #f97316); }
.kpi-card.c-cyan::before { background: linear-gradient(135deg, #0e7490, #06b6d4); }
.kpi-card.c-rose::before { background: linear-gradient(135deg, #9f1239, #f43f5e); }
.kpi-card.c-indigo::before { background: linear-gradient(135deg, #312e81, #6366f1); }

/* -------------------- Charts -------------------- */
.charts-grid {
  display: grid;
  gap: 18px;
  margin-bottom: 18px;
}

.charts-grid.two {
  grid-template-columns: 1fr 1fr;
}

.charts-grid.three {
  grid-template-columns: 1.15fr 0.95fr 1fr;
}

.chart-card {
  padding: 22px;
}

.chart-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  padding-bottom: 14px;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--border);
  color: var(--ink);
  font-size: 15px;
  font-weight: 700;
}

.chart-badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.chart-empty {
  padding: 28px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-md);
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 12px;
  text-align: center;
  line-height: 1.7;
}

.chart-subnote {
  margin-top: -2px;
  margin-bottom: 14px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.6;
}

/* Donut */
.donut-wrap {
  display: grid;
  grid-template-columns: 180px 1fr;
  gap: 22px;
  align-items: center;
}

.donut {
  position: relative;
  width: 168px;
  aspect-ratio: 1 / 1;
  border-radius: 50%;
  background: conic-gradient(from 0deg, var(--primary) 0deg, var(--accent) 120deg, var(--accent-2) 210deg, var(--warn) 300deg, var(--primary) 360deg);
  margin-inline: auto;
}

.donut::after {
  content: "";
  position: absolute;
  inset: 22%;
  border-radius: 50%;
  background: var(--surface);
  box-shadow: inset 0 0 0 1px var(--border);
}

.donut-center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  z-index: 1;
  padding: 0 16px;
}

.donut-center .big {
  font-size: 26px;
  font-weight: 700;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}

.donut-center .small {
  margin-top: 4px;
  font-size: 11px;
  color: var(--muted);
  line-height: 1.5;
}

/* Bars */
.bar-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.bar-row {
  display: grid;
  grid-template-columns: 130px 1fr 80px;
  align-items: center;
  gap: 12px;
  font-size: 12px;
}

.bar-label {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  color: var(--ink);
  font-weight: 600;
}

.bar-track {
  height: 10px;
  background: var(--surface-muted);
  border-radius: 999px;
  overflow: hidden;
}

.bar-fill {
  display: block;
  height: 100%;
  background: var(--grad-primary);
  border-radius: inherit;
}

.bar-value {
  text-align: end;
  color: var(--primary);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.legend-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 12px;
  font-size: 11px;
  color: var(--muted);
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 3px;
  flex-shrink: 0;
}

/* Section donuts (template sections) */
.section-summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.section-summary-tile {
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface-soft);
}

.section-summary-tile .summary-label {
  font-size: 11px;
  color: var(--muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.section-summary-tile .summary-value {
  margin-top: 4px;
  font-size: 16px;
  font-weight: 700;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
}

.section-donut-wrap {
  display: grid;
  grid-template-columns: 190px 1fr;
  gap: 16px;
  align-items: center;
  margin-bottom: 14px;
}

.section-donut {
  position: relative;
  width: 174px;
  aspect-ratio: 1 / 1;
  border-radius: 50%;
  margin-inline: auto;
}

.section-donut::after {
  content: "";
  position: absolute;
  inset: 24%;
  border-radius: 50%;
  background: var(--surface);
  box-shadow: inset 0 0 0 1px var(--border);
}

.section-donut.as-pie::after {
  display: none;
}

.section-donut-center {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 0 14px;
}

.section-donut-center .big {
  font-size: 20px;
  font-weight: 700;
  color: var(--ink);
  letter-spacing: -0.01em;
  font-variant-numeric: tabular-nums;
}

.section-donut-center .small {
  margin-top: 4px;
  font-size: 10px;
  color: var(--muted);
  line-height: 1.5;
}

.section-detail-table {
  margin-top: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
}

/* Comparison rows */
.comparison-legend { margin-bottom: 12px; }

.comparison-list {
  display: grid;
  gap: 10px;
}

.comparison-row {
  display: grid;
  grid-template-columns: 160px 1fr;
  gap: 14px;
  align-items: start;
  padding: 14px;
  border-radius: var(--radius-md);
  background: var(--surface-soft);
  border: 1px solid var(--border);
}

.comparison-row-label {
  font-weight: 600;
  color: var(--ink);
  line-height: 1.5;
  padding-top: 4px;
}

.comparison-bars {
  display: grid;
  gap: 10px;
}

.comparison-bar-row {
  display: grid;
  grid-template-columns: 1fr 84px;
  gap: 10px;
  align-items: center;
}

.comparison-track {
  height: 10px;
  border-radius: 999px;
  background: var(--surface-muted);
  overflow: hidden;
}

.comparison-fill {
  display: block;
  height: 100%;
  border-radius: inherit;
}

.comparison-value {
  text-align: end;
  color: var(--primary);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  font-size: 12px;
}

/* Line chart */
.line-chart-wrap {
  margin-bottom: 14px;
  padding: 12px 14px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface-soft);
}

.line-chart-svg {
  width: 100%;
  height: auto;
  display: block;
}

.line-axis-labels {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  margin-top: 8px;
  padding-bottom: 2px;
}

.line-axis-labels span {
  font-size: 10px;
  color: var(--muted);
  white-space: nowrap;
  min-width: 70px;
}

/* -------------------- ERP control panel -------------------- */
.erp-control-panel {
  margin-bottom: 16px;
  overflow: hidden;
}

.erp-breadcrumbs {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  border-bottom: 1px solid var(--border-soft);
  color: var(--muted);
  font-size: 12px;
}

.erp-breadcrumbs a {
  color: var(--primary);
  font-weight: 600;
}

.erp-breadcrumbs strong {
  color: var(--ink);
  font-weight: 700;
}

.erp-control-main {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 18px 22px;
}

.erp-control-main h1 {
  margin: 0;
  font-size: 22px;
  font-weight: 700;
  color: var(--ink);
  letter-spacing: -0.02em;
}

.erp-control-main p {
  margin: 4px 0 0;
  font-size: 13px;
  color: var(--muted);
  line-height: 1.6;
}

.erp-search {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1 1 460px;
  min-width: 0;
  max-width: 760px;
}

.erp-search input[type="search"],
.erp-search input[type="date"] {
  min-height: 38px;
}

.erp-search input[type="search"] {
  flex: 1 1 240px;
}

.erp-search input[type="date"] {
  flex: 0 0 150px;
}

.erp-document-toolbar {
  display: grid;
  grid-template-columns: minmax(180px, auto) minmax(260px, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 14px 22px;
  border-top: 1px solid var(--border-soft);
  background: var(--surface-soft);
}

.erp-document-actions {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

/* Smart buttons */
.erp-smart-buttons {
  display: inline-flex;
  align-items: stretch;
  gap: 6px;
}

.erp-smart-button {
  min-width: 116px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 2px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
  text-decoration: none;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
}

.erp-smart-button:hover {
  background: var(--primary-soft);
  border-color: var(--primary);
  transform: translateY(-1px);
}

.erp-smart-value {
  color: var(--primary);
  font-size: 14px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.erp-smart-label {
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* Status bar */
.erp-statusbar {
  display: inline-flex;
  align-items: center;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
}

.erp-status-step {
  position: relative;
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 6px 14px;
  border-inline-end: 1px solid var(--border);
  color: var(--muted);
  background: var(--surface);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.erp-status-step:last-child { border-inline-end: 0; }

.erp-status-step.is-current {
  background: var(--grad-primary);
  color: #fff;
}

.erp-status-step.is-done:not(.is-current) {
  color: var(--good);
  background: var(--good-soft);
}

.erp-status-step.is-progress:not(.is-current) {
  color: var(--warn);
  background: var(--warn-soft);
}

.erp-status-step.is-cancelled:not(.is-current) {
  color: var(--danger);
  background: var(--danger-soft);
}

/* Form heads */
.erp-form-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
}

.erp-form-head h3 {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
  color: var(--ink);
  letter-spacing: -0.01em;
}

.erp-form-head span {
  display: block;
  margin-top: 4px;
  font-size: 12px;
  color: var(--muted);
}

/* Budget strip */
.erp-budget-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 10px;
  margin-bottom: 16px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
}

.erp-budget-tile {
  min-height: 76px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 6px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-soft);
}

.erp-budget-tile span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.erp-budget-tile strong {
  color: var(--ink);
  font-size: 15px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  word-break: break-all;
}

.erp-budget-tile.is-ok strong { color: var(--good); }

.erp-budget-tile.is-over {
  border-color: rgba(239, 68, 68, 0.32);
  background: var(--danger-soft);
}

.erp-budget-tile.is-over strong { color: var(--danger); }

/* -------------------- Document/Journal editors -------------------- */
.document-lines-editor,
.journal-editor {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  overflow: hidden;
}

.document-lines-head,
.journal-lines-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border-soft);
  background: var(--surface-soft);
}

.document-lines-head h3,
.journal-lines-head h3 {
  margin: 0;
  font-size: 14px;
  font-weight: 700;
  color: var(--ink);
}

.document-lines-wrap,
.journal-lines-wrap {
  overflow-x: auto;
}

.document-lines-table,
.journal-lines-table,
.invoice-lines-table,
.odoo-journal-table,
.journal-list-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

.document-lines-table thead th,
.journal-lines-table thead th,
.invoice-lines-table thead th,
.odoo-journal-table thead th,
.journal-list-table thead th {
  padding: 10px 12px;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  text-align: start;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.document-lines-table tbody td,
.journal-lines-table tbody td,
.invoice-lines-table tbody td,
.odoo-journal-table tbody td,
.journal-list-table tbody td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border-soft);
  color: var(--ink);
  vertical-align: middle;
}

.document-lines-table tbody tr:last-child td,
.journal-lines-table tbody tr:last-child td {
  border-bottom: 0;
}

.document-lines-table input,
.document-lines-table select,
.journal-lines-table input,
.journal-lines-table select {
  min-height: 34px;
  font-size: 12px;
  padding: 6px 10px;
}

.document-line-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 10px;
  padding: 14px;
  border-top: 1px solid var(--border);
  background: var(--surface-soft);
}

.tax-live-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface-soft);
  margin-top: 10px;
}

.tax-live-summary > div,
.document-line-summary > div {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 10px 12px;
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
}

.tax-live-summary span,
.document-line-summary span {
  font-size: 11px;
  color: var(--muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.tax-live-summary strong,
.document-line-summary strong {
  font-size: 14px;
  color: var(--ink);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.journal-remove-line {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border: 1px solid rgba(239, 68, 68, 0.32);
  border-radius: var(--radius-xs);
  background: var(--danger-soft);
  color: var(--danger);
  cursor: pointer;
  font-size: 14px;
  font-weight: 700;
  transition: background 0.15s ease, color 0.15s ease;
}

.journal-remove-line:hover {
  background: var(--danger);
  color: #fff;
}

.journal-line-number {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 11px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

/* Journal sheet */
.journal-sheet {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  overflow: hidden;
}

.journal-sheet-header {
  padding: 16px 20px;
  background: var(--surface-soft);
  border-bottom: 1px solid var(--border);
}

.journal-title-block {
  display: grid;
  gap: 4px;
}

.journal-title-block h3 {
  margin: 0;
  font-size: 17px;
  font-weight: 700;
  color: var(--ink);
}

.journal-header-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  padding: 16px 20px;
}

.journal-list-actions,
.report-actions,
.invoice-print-actions {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.journal-list-card {
  padding: 0;
  margin-bottom: 16px;
}

.journal-list-card .table-header {
  border-bottom: 1px solid var(--border-soft);
}

.journal-total-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 12px;
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  background: var(--surface-soft);
}

.journal-total-strip > div {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.journal-total-strip span {
  font-size: 11px;
  color: var(--muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.journal-total-strip strong {
  font-size: 16px;
  color: var(--ink);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
}

.journal-difference {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}

.journal-difference.is-balanced {
  background: var(--good-soft);
  color: var(--good);
}

.journal-difference.is-unbalanced {
  background: var(--danger-soft);
  color: var(--danger);
}

/* Odoo-style move card */
.odoo-move-card {
  margin-bottom: 14px;
  overflow: hidden;
}

.odoo-move-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-soft);
  background: var(--surface-soft);
}

.odoo-move-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--ink);
  letter-spacing: -0.005em;
}

.odoo-move-subtitle {
  margin-top: 4px;
  font-size: 12px;
  color: var(--muted);
}

.odoo-move-head-actions {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.odoo-move-meta-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
  padding: 14px 16px;
}

.odoo-meta-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-soft);
}

.odoo-meta-item span {
  font-size: 11px;
  color: var(--muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.odoo-meta-item strong {
  font-size: 13px;
  color: var(--ink);
  font-weight: 700;
}

/* -------------------- Invoice print -------------------- */
.invoice-print-card {
  padding: 30px;
  margin-bottom: 16px;
}

.invoice-print-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  flex-wrap: wrap;
  padding-bottom: 18px;
  border-bottom: 2px solid var(--primary);
  margin-bottom: 18px;
}

.invoice-brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.invoice-brand img {
  width: 64px;
  height: 64px;
  padding: 6px;
  border-radius: var(--radius-sm);
  background: #fff;
  border: 1px solid var(--border);
  object-fit: contain;
}

.invoice-brand strong {
  font-size: 18px;
  font-weight: 700;
  color: var(--ink);
}

.invoice-brand small {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
}

.invoice-title-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.invoice-title-row h1 {
  margin: 0;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--ink);
}

.invoice-status-chip {
  display: inline-flex;
  align-items: center;
  padding: 4px 12px;
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.invoice-meta-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
  margin-bottom: 18px;
}

.invoice-meta-grid > div {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-soft);
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.invoice-meta-grid span {
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 600;
}

.invoice-meta-grid strong {
  font-size: 13px;
  color: var(--ink);
  font-weight: 700;
}

.invoice-print-body {
  display: grid;
  grid-template-columns: 1fr;
  gap: 18px;
}

.invoice-lines-table {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.invoice-summary-panel {
  display: grid;
  grid-template-columns: minmax(160px, 220px) 1fr;
  gap: 18px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface-soft);
}

.invoice-summary-panel dl {
  margin: 0;
  display: grid;
  gap: 8px;
}

.invoice-summary-panel dl > div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-xs);
}

.invoice-summary-panel dl > div.is-total {
  background: var(--grad-primary);
  border-color: transparent;
  color: #fff;
}

.invoice-summary-panel dl > div.is-total dt,
.invoice-summary-panel dl > div.is-total dd {
  color: #fff;
  font-weight: 700;
}

.invoice-summary-panel dt {
  margin: 0;
  font-size: 12px;
  color: var(--muted);
  font-weight: 600;
}

.invoice-summary-panel dd {
  margin: 0;
  font-size: 14px;
  color: var(--ink);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.invoice-qr-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
}

.invoice-qr-box small {
  font-size: 10px;
  color: var(--muted);
}

.zatca-qr {
  width: 132px;
  height: 132px;
  display: grid;
  place-items: center;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  padding: 6px;
  overflow: hidden;
}

.zatca-qr canvas,
.zatca-qr img,
.zatca-qr__img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

/* -------------------- Floating buttons -------------------- */
.floating-print-btn,
.floating-back-btn {
  position: fixed;
  bottom: 22px;
  z-index: 1100;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 18px;
  border: 0;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.floating-print-btn {
  inset-inline-start: 22px;
  background: var(--grad-primary);
  color: #fff;
  box-shadow: var(--shadow-glow);
}

.floating-back-btn {
  inset-inline-end: 22px;
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.floating-print-btn:hover,
.floating-back-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 18px 36px rgba(15, 23, 42, 0.16);
}

/* -------------------- Searchable select -------------------- */
.select-search {
  position: relative;
  display: block;
}

.select-search__input {
  width: 100%;
  min-height: 38px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
}

.select-search select {
  position: absolute !important;
  inset: auto auto 0 0;
  width: 1px !important;
  height: 1px !important;
  opacity: 0 !important;
  pointer-events: none !important;
}

.select-search__menu {
  position: absolute;
  z-index: 2600;
  inset-inline: 0;
  top: calc(100% + 6px);
  display: none;
  max-height: 280px;
  overflow: auto;
  padding: 6px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  box-shadow: var(--shadow-lg);
}

.select-search__menu.is-open {
  display: grid;
  gap: 2px;
}

.select-search__option {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 36px;
  padding: 8px 10px;
  border: 0;
  border-radius: var(--radius-xs);
  background: transparent;
  color: var(--ink);
  text-align: inherit;
  cursor: pointer;
  font-size: 13px;
}

.select-search__option small {
  color: var(--muted);
  font-size: 11px;
  font-weight: 500;
}

.select-search__option:hover,
.select-search__option.is-active {
  background: var(--primary-soft);
  color: var(--primary);
}

/* -------------------- Footer -------------------- */
.footer {
  margin-top: 22px;
  padding: 14px 18px;
  border-radius: var(--radius-md);
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--muted);
  text-align: center;
  font-size: 12px;
}

/* -------------------- Bulk select cell -------------------- */
.bulk-select-cell { width: 44px; }
.centered-cell { text-align: center; }
.is-total { font-weight: 700; }

.journal-entry-form,
.print-scope {
  display: contents;
}

/* Stand-alone print-scope wrapper used elsewhere as a section. */
section.print-scope,
div.print-scope,
.print-scope[data-print-scope] {
  display: block;
}

.ui-toggle--lang,
.ui-toggle--theme {
  /* both toggles share the base .ui-toggle look */
}

.site-sidebar__sublinks:not(.top-mega-nav__dropdown) {
  display: grid;
  gap: 4px;
  margin: 6px 0;
}

/* -------------------- Design builder (reports) -------------------- */
.design-builder-grid {
  display: grid;
  gap: 14px;
  margin-top: 8px;
}

.design-section-card {
  padding: 16px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-md);
  background: var(--surface-soft);
}

.design-style-classic { border-color: var(--border-strong); background: var(--surface-soft); }
.design-style-glass { border-color: rgba(14, 165, 233, 0.32); background: var(--accent-soft); }
.design-style-sunset { border-color: rgba(239, 68, 68, 0.32); background: rgba(254, 226, 226, 0.5); }
.design-style-forest { border-color: rgba(16, 185, 129, 0.32); background: var(--good-soft); }
.design-style-royal { border-color: rgba(99, 102, 241, 0.32); background: var(--primary-soft); }

html[data-theme="dark"] .design-style-glass,
html[data-theme="dark"] .design-style-sunset,
html[data-theme="dark"] .design-style-forest,
html[data-theme="dark"] .design-style-royal {
  background: var(--surface-soft);
}

.design-compare-grid {
  display: grid;
  gap: 10px;
  margin-top: 6px;
}

.design-compare-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
}

.context-switch-panel .form-grid {
  align-items: end;
}

/* -------------------- Print clone -------------------- */
.print-clone-root {
  position: relative;
  z-index: 0;
}

@media not print {
  .print-clone-root { display: none; }
}

body.is-printing-selection > *:not(.print-clone-root) {
  display: none !important;
}

/* -------------------- Print stylesheet (A4 landscape) -------------------- */
@media print {
  @page {
    size: A4 landscape;
    margin: 8mm;
  }

  html,
  body {
    background: #fff !important;
  }

  body { background-image: none !important; }

  .site-sidebar,
  .top-mega-nav,
  .floating-print-btn,
  .floating-back-btn,
  .ui-switcher,
  .panel.screen-only,
  .filters-card,
  .actions,
  .bulk-actions,
  .page-links,
  .screen-only,
  .print-hide {
    display: none !important;
  }

  .container,
  .workspace-page,
  .dashboard-content {
    max-width: none !important;
    padding: 0 !important;
  }

  .header,
  .date-bar,
  .panel,
  .table-card,
  .chart-card,
  .invoice-print-card,
  .workspace-section,
  .erp-control-panel {
    box-shadow: none !important;
    border-radius: 6px !important;
  }

  .header {
    border-radius: 0 !important;
    border-bottom: 1px solid #d6dbe6 !important;
    page-break-after: avoid;
  }

  .header,
  .date-bar {
    background: #fff !important;
  }

  .workspace-hero {
    background: #1e1b4b !important;
    -webkit-print-color-adjust: exact;
            print-color-adjust: exact;
    color: #fff !important;
    page-break-inside: avoid;
  }

  .kpi-grid,
  .charts-grid,
  .table-card,
  .invoice-print-card {
    break-inside: avoid;
    page-break-inside: avoid;
  }

  .data-table {
    min-width: 0 !important;
    width: 100% !important;
  }

  .data-table th,
  .data-table td {
    font-size: 10px !important;
    padding: 6px 8px !important;
  }

  .data-table th {
    position: static !important;
  }

  .print-only { display: revert !important; }
}

/* -------------------- Responsive -------------------- */
@media (max-width: 1280px) {
  .panel-grid,
  .charts-grid.three {
    grid-template-columns: 1fr;
  }

  .top-mega-nav__menus {
    overflow-x: auto;
  }
}

@media (max-width: 1100px) {
  .top-mega-nav__brand {
    font-size: 15px;
    padding-inline: 8px;
  }

  .form-grid,
  .form-grid.four {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .charts-grid.two {
    grid-template-columns: 1fr;
  }

  .donut-wrap,
  .section-donut-wrap {
    grid-template-columns: 1fr;
    justify-items: center;
  }

  .kpi-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .auth-card {
    grid-template-columns: 1fr;
  }

  .portal-map {
    grid-template-columns: 1fr;
    gap: 24px;
  }

  .portal-module-list--left,
  .portal-module-list--right {
    justify-self: stretch;
    max-width: none;
  }

  .portal-module-list--left .portal-module-card {
    grid-template-columns: auto 1fr;
  }

  .portal-module-list--left .portal-module-text {
    text-align: start;
  }

  .erp-document-toolbar {
    grid-template-columns: 1fr;
  }

  .invoice-summary-panel {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  .container,
  .workspace-page,
  .dashboard-content {
    padding: 16px 14px 32px;
  }

  .top-mega-nav {
    height: auto;
    flex-wrap: wrap;
    gap: 4px;
    padding: 8px;
  }

  .top-mega-nav__brand {
    order: 0;
    flex: 1 1 auto;
    font-size: 15px;
  }

  .top-mega-nav__quick { order: 1; padding: 0; }
  .top-mega-nav__user { order: 2; }
  .top-mega-nav__menus {
    order: 5;
    width: 100%;
    overflow-x: auto;
    padding: 4px 0;
  }
  .top-mega-nav__controls {
    order: 4;
    margin-inline-start: 0;
    padding: 0;
  }

  .top-mega-nav__group-button,
  .top-mega-nav__quick-link {
    height: 38px;
  }

  .top-mega-nav__dropdown {
    grid-template-columns: 1fr;
    min-width: auto;
    inset-inline-start: 0;
    inset-inline-end: 0;
    width: 100%;
  }

  .header {
    grid-template-columns: 1fr;
    gap: 8px;
    padding: 16px;
    text-align: start;
  }

  .header-side.right,
  .header-side.left {
    align-items: flex-start;
    text-align: start;
  }

  .header-center { justify-content: flex-start; }

  .date-bar { padding: 10px 16px; }
  .date-author { margin-inline-start: 0; }

  .form-grid,
  .form-grid.two,
  .form-grid.four {
    grid-template-columns: 1fr;
  }

  .kpi-grid { grid-template-columns: 1fr; }

  .workspace-hero {
    grid-template-columns: 1fr;
    text-align: start;
    padding: 24px;
  }

  .workspace-hero img {
    width: 64px;
    height: 64px;
  }

  .erp-control-main {
    flex-direction: column;
    align-items: stretch;
  }

  .erp-search { flex-wrap: wrap; }
  .erp-search input[type="date"] { flex: 1 1 140px; }
  .erp-budget-strip { grid-template-columns: 1fr; }
  .erp-statusbar { overflow-x: auto; }

  .floating-print-btn,
  .floating-back-btn {
    bottom: 16px;
    padding: 10px 14px;
    font-size: 12px;
  }

  .portal-shell {
    padding: 18px 16px 40px;
    gap: 20px;
  }

  .portal-topbar {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }

  .portal-actions {
    flex-wrap: wrap;
    width: 100%;
  }

  .portal-actions a {
    flex: 1 1 100px;
    justify-content: center;
  }

  .portal-center-card h1 { font-size: 32px; }

  .auth-shell { padding: 16px; }

  .auth-hero,
  .auth-form { padding: 24px; }

  .comparison-row { grid-template-columns: 1fr; }

  .bar-row { grid-template-columns: 100px 1fr 70px; }
}

/* -------------------- RTL polish -------------------- */
html[dir="rtl"] .header-side.left {
  align-items: flex-end;
  text-align: end;
}

html[dir="rtl"] .header-side.right {
  align-items: flex-start;
  text-align: start;
}

html[dir="rtl"] .data-table thead th {
  text-align: start;
}

html[dir="rtl"] .portal-module-list--left .portal-module-card {
  grid-template-columns: auto 1fr;
}

html[dir="rtl"] .portal-module-list--left .portal-module-text {
  text-align: start;
}

html[dir="rtl"] .portal-module-list--right .portal-module-card {
  grid-template-columns: 1fr auto;
}

html[dir="rtl"] .portal-module-list--right .portal-module-text {
  text-align: end;
}
