/* ═══════════════════════════════════════════════════════════════════
   MAGAIES / AL-SAJANA ERP — Professional Design System v7.0
   Design Philosophy: Spatial · Rhythmic · Alive
   Built to match: SAP Fiori + Salesforce Lightning + Linear.app
   ═══════════════════════════════════════════════════════════════════ */

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

/* ═══════════════════════════════════════════════════════════════════
   1. DESIGN TOKENS — Single source of truth
   ═══════════════════════════════════════════════════════════════════ */
:root {
  /* ── Color Primitives ── */
  --hue-brand:    210;
  --hue-success:  160;
  --hue-warning:  38;
  --hue-danger:   355;
  --hue-purple:   265;

  /* ── Semantic Colors ── */
  --color-brand-50:   hsl(210, 100%, 95%);
  --color-brand-100:  hsl(210, 95%,  88%);
  --color-brand-400:  hsl(210, 90%,  65%);
  --color-brand-500:  hsl(210, 85%,  56%);  /* primary */
  --color-brand-600:  hsl(210, 80%,  48%);

  --color-success-400: hsl(160, 75%, 55%);
  --color-success-500: hsl(160, 70%, 45%);
  --color-warning-400: hsl(38,  90%, 62%);
  --color-warning-500: hsl(38,  85%, 52%);
  --color-danger-400:  hsl(355, 85%, 68%);
  --color-danger-500:  hsl(355, 80%, 58%);
  --color-purple-400:  hsl(265, 75%, 72%);
  --color-purple-500:  hsl(265, 70%, 62%);

  /* ── Surface Colors (Dark) ── */
  --surface-base:     hsl(222, 47%, 6%);    /* deepest bg */
  --surface-raised:   hsl(220, 40%, 9%);    /* cards */
  --surface-overlay:  hsl(218, 35%, 12%);   /* modals / panels */
  --surface-floating: hsl(215, 30%, 16%);   /* dropdowns */
  --surface-sunken:   hsl(224, 50%, 4%);    /* inputs */
  --surface-hover:    hsl(215, 30%, 18%);

  /* ── Text Colors ── */
  --text-base:        hsl(210, 40%, 98%);
  --text-secondary:   hsl(215, 25%, 65%);
  --text-tertiary:    hsl(215, 20%, 45%);
  --text-disabled:    hsl(215, 15%, 32%);
  --text-inverse:     hsl(220, 47%, 8%);

  /* ── Border Colors ── */
  --border-subtle:    hsla(210, 30%, 80%, 0.07);
  --border-default:   hsla(210, 30%, 80%, 0.12);
  --border-strong:    hsla(210, 30%, 80%, 0.22);
  --border-brand:     hsla(210, 85%, 56%, 0.40);
  --border-success:   hsla(160, 70%, 45%, 0.35);
  --border-warning:   hsla(38,  85%, 52%, 0.35);
  --border-danger:    hsla(355, 80%, 58%, 0.35);

  /* ── Glow / Shadow ── */
  --glow-brand:    0 0 24px hsla(210, 85%, 56%, 0.25), 0 0 60px hsla(210, 85%, 56%, 0.10);
  --glow-success:  0 0 20px hsla(160, 70%, 45%, 0.25);
  --glow-warning:  0 0 20px hsla(38,  85%, 52%, 0.25);
  --glow-danger:   0 0 20px hsla(355, 80%, 58%, 0.25);

  --shadow-xs:  0 1px 2px  rgba(0,0,0,0.25);
  --shadow-sm:  0 2px 6px  rgba(0,0,0,0.35), 0 1px 2px rgba(0,0,0,0.25);
  --shadow-md:  0 4px 16px rgba(0,0,0,0.45), 0 2px 4px rgba(0,0,0,0.30);
  --shadow-lg:  0 12px 40px rgba(0,0,0,0.55), 0 4px 12px rgba(0,0,0,0.35);
  --shadow-xl:  0 24px 80px rgba(0,0,0,0.65), 0 8px 24px rgba(0,0,0,0.40);

  /* ── Spacing Scale (4px base) ── */
  --space-1:  4px;
  --space-2:  8px;
  --space-3:  12px;
  --space-4:  16px;
  --space-5:  20px;
  --space-6:  24px;
  --space-8:  32px;
  --space-10: 40px;
  --space-12: 48px;
  --space-16: 64px;

  /* ── Typography Scale ── */
  --font-family:   'Cairo', system-ui, -apple-system, sans-serif;
  --font-mono:     'IBM Plex Mono', 'Courier New', monospace;

  --text-xs:   0.70rem;   /* 11.2px */
  --text-sm:   0.78rem;   /* 12.5px */
  --text-base: 0.875rem;  /* 14px   */
  --text-lg:   1.00rem;   /* 16px   */
  --text-xl:   1.15rem;   /* 18.4px */
  --text-2xl:  1.35rem;   /* 21.6px */
  --text-3xl:  1.65rem;   /* 26.4px */

  --font-normal:   400;
  --font-medium:   500;
  --font-semibold: 600;
  --font-bold:     700;
  --font-extrabold:800;
  --font-black:    900;

  --line-tight:  1.25;
  --line-normal: 1.5;
  --line-relaxed:1.7;

  --tracking-tight:  -0.02em;
  --tracking-normal:  0em;
  --tracking-wide:    0.04em;
  --tracking-wider:   0.08em;
  --tracking-widest:  0.12em;

  /* ── Border Radius ── */
  --radius-sm:  6px;
  --radius-md:  10px;
  --radius-lg:  16px;
  --radius-xl:  22px;
  --radius-2xl: 28px;
  --radius-full:9999px;

  /* ── Transitions ── */
  --ease-default:  cubic-bezier(0.4, 0, 0.2, 1);
  --ease-spring:   cubic-bezier(0.34, 1.56, 0.64, 1);
  --ease-in-out:   cubic-bezier(0.65, 0, 0.35, 1);
  --ease-out:      cubic-bezier(0.16, 1, 0.3, 1);

  --duration-fast:   150ms;
  --duration-normal: 250ms;
  --duration-slow:   400ms;

  --transition-fast:   all var(--duration-fast)   var(--ease-default);
  --transition-normal: all var(--duration-normal) var(--ease-default);
  --transition-spring: all var(--duration-normal) var(--ease-spring);

  /* ── Sidebar ── */
  --sb-collapsed: 64px;
  --sb-expanded:  252px;

  /* ── Z-Index Scale ── */
  --z-base:    0;
  --z-raised:  10;
  --z-overlay: 100;
  --z-modal:   1000;
  --z-toast:   9999;
  --z-sidebar: 9998;
}

/* ═══════════════════════════════════════════════════════════════════
   2. GLOBAL RESET & BASE
   ═══════════════════════════════════════════════════════════════════ */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-family);
  font-size: var(--text-base);
  line-height: var(--line-normal);
  color: var(--text-base);
  background-color: var(--surface-base);
  direction: rtl;
  min-height: 100vh;
  overflow-x: hidden;
  overscroll-behavior-y: contain;
  background-image:
    radial-gradient(ellipse 80% 60% at 10% 10%, hsla(210, 80%, 50%, 0.06) 0%, transparent 60%),
    radial-gradient(ellipse 70% 50% at 90% 90%, hsla(265, 70%, 55%, 0.06) 0%, transparent 60%),
    radial-gradient(ellipse 60% 40% at 50% 0%,  hsla(160, 60%, 45%, 0.04) 0%, transparent 50%);
  background-attachment: fixed;
}

/* ═══════════════════════════════════════════════════════════════════
   3. SCROLLBAR — Subtle & Refined
   ═══════════════════════════════════════════════════════════════════ */
::-webkit-scrollbar              { width: 5px; height: 5px; }
::-webkit-scrollbar-track        { background: transparent; }
::-webkit-scrollbar-thumb        {
  background: hsla(210, 30%, 70%, 0.15);
  border-radius: var(--radius-full);
  transition: background var(--duration-normal);
}
::-webkit-scrollbar-thumb:hover  { background: hsla(210, 85%, 56%, 0.4); }
::-webkit-scrollbar-corner       { background: transparent; }

/* ═══════════════════════════════════════════════════════════════════
   4. SIDEBAR — Polished RTL Navigation
   ═══════════════════════════════════════════════════════════════════ */
body.has-sidebar {
  margin-right: var(--sb-collapsed);
  transition: margin-right var(--duration-slow) var(--ease-in-out);
}
body.has-sidebar.sidebar-open {
  margin-right: var(--sb-expanded);
}

.global-sidebar {
  position: fixed;
  top: 0;
  right: 0;
  width: var(--sb-collapsed);
  height: 100vh;
  background: rgba(6, 9, 20, 0.97);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border-left: 1px solid var(--border-subtle);
  z-index: var(--z-sidebar);
  display: flex;
  flex-direction: column;
  box-shadow: -8px 0 40px rgba(0,0,0,0.6);
  transition: width var(--duration-slow) var(--ease-in-out);
  will-change: width;
}

.global-sidebar:hover {
  width: var(--sb-expanded);
  border-left-color: var(--border-brand);
}

/* Sidebar Header */
.sidebar-header {
  position: relative;
  height: 68px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  border-bottom: 1px solid var(--border-subtle);
  overflow: hidden;
}

.sidebar-header::after {
  content: '';
  position: absolute;
  bottom: 0;
  right: 0;
  left: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, hsla(210, 85%, 56%, 0.3), transparent);
}

.sidebar-logo-icon {
  position: absolute;
  right: 0;
  top: 0;
  width: var(--sb-collapsed);
  height: 68px;
  display: flex;
  align-items: center;
  justify-content: center;
  filter: drop-shadow(0 0 10px hsla(210, 85%, 56%, 0.8));
  z-index: 1;
  transition: filter var(--duration-normal);
}
.global-sidebar:hover .sidebar-logo-icon {
  filter: drop-shadow(0 0 14px hsla(210, 85%, 56%, 1));
}

.sidebar-logo-text {
  font-size: var(--text-sm);
  font-weight: var(--font-extrabold);
  color: var(--text-base);
  padding-right: var(--space-2);
  opacity: 0;
  max-width: 0;
  overflow: hidden;
  white-space: nowrap;
  letter-spacing: var(--tracking-tight);
  transition: max-width var(--duration-slow) var(--ease-out),
              opacity var(--duration-normal) var(--ease-out);
}

.global-sidebar:hover .sidebar-logo-text {
  max-width: 200px;
  opacity: 1;
  transition-delay: 60ms;
}

/* Sidebar Nav */
.sidebar-nav {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: var(--space-2) 0;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: none;
}
.sidebar-nav::-webkit-scrollbar { display: none; }

/* Sidebar Items */
.sidebar-item {
  position: relative;
  display: block;
  height: 52px;
  text-decoration: none;
  color: var(--text-secondary);
  transition: color var(--duration-fast) var(--ease-default),
              background var(--duration-fast) var(--ease-default);
  outline: none;
}

.sidebar-item::before {
  content: '';
  position: absolute;
  inset: 4px 6px;
  border-radius: var(--radius-md);
  background: transparent;
  transition: background var(--duration-fast) var(--ease-default);
  z-index: 0;
}

.sidebar-item:hover::before {
  background: hsla(210, 30%, 80%, 0.04);
}

.sidebar-item:hover {
  color: var(--text-base);
}

.sidebar-item.active {
  color: #fff;
}
.sidebar-item.active::before {
  background: hsla(210, 85%, 56%, 0.10);
}

/* Active indicator bar */
.sidebar-item.active::after {
  content: '';
  position: absolute;
  right: 0;
  top: 10px;
  bottom: 10px;
  width: 3px;
  background: linear-gradient(180deg, var(--color-brand-400), var(--color-brand-600));
  border-radius: 2px 0 0 2px;
  box-shadow: var(--glow-brand);
}

/* Sidebar Icon */
.sidebar-icon {
  position: absolute;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  width: var(--sb-collapsed);
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1;
  transition: transform var(--duration-normal) var(--ease-spring),
              filter var(--duration-normal);
}

.sidebar-item:hover .sidebar-icon {
  transform: translateY(-50%) scale(1.15);
  filter: brightness(1.3);
}

.sidebar-item.active .sidebar-icon {
  filter: brightness(1.2) drop-shadow(0 0 8px currentColor);
}

/* Sidebar Text */
.sidebar-text {
  position: absolute;
  right: var(--sb-collapsed);
  top: 50%;
  transform: translateY(-50%);
  font-size: var(--text-sm);
  font-weight: var(--font-semibold);
  white-space: nowrap;
  overflow: hidden;
  max-width: 0;
  opacity: 0;
  letter-spacing: var(--tracking-normal);
  transition: max-width var(--duration-slow) var(--ease-out),
              opacity var(--duration-normal) var(--ease-out);
  z-index: 1;
}

.global-sidebar:hover .sidebar-text {
  max-width: 180px;
  opacity: 1;
  transition-delay: 60ms;
}

/* Sidebar Footer */
.sidebar-footer {
  flex-shrink: 0;
  padding: var(--space-2) 0;
  border-top: 1px solid var(--border-subtle);
}

.sidebar-logout { color: var(--color-danger-400); }
.sidebar-logout:hover::before {
  background: hsla(355, 80%, 58%, 0.06);
}

/* ═══════════════════════════════════════════════════════════════════
   5. GLASSMORPHISM PANELS — Refined
   ═══════════════════════════════════════════════════════════════════ */
.glass-panel {
  background: hsla(218, 35%, 10%, 0.75);
  backdrop-filter: blur(20px) saturate(1.4);
  -webkit-backdrop-filter: blur(20px) saturate(1.4);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md),
              inset 0 1px 0 hsla(210, 30%, 100%, 0.06);
  position: relative;
}

/* Top shine line */
.glass-panel::before {
  content: '';
  position: absolute;
  top: 0; left: 12%; right: 12%;
  height: 1px;
  background: linear-gradient(90deg,
    transparent,
    hsla(210, 85%, 85%, 0.12) 40%,
    hsla(210, 85%, 85%, 0.18) 50%,
    hsla(210, 85%, 85%, 0.12) 60%,
    transparent
  );
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  pointer-events: none;
}

/* ── Panel component ── */
.panel {
  background: var(--surface-raised);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  margin-bottom: var(--space-4);
  box-shadow: var(--shadow-sm),
              inset 0 1px 0 hsla(210, 30%, 100%, 0.04);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  position: relative;
  overflow: visible;
  transition: border-color var(--duration-normal) var(--ease-default),
              box-shadow var(--duration-normal) var(--ease-default);
}

.panel::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--border-brand), transparent);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  opacity: 0;
  transition: opacity var(--duration-normal);
  pointer-events: none;
}

.panel:hover {
  border-color: var(--border-default);
  box-shadow: var(--shadow-md);
}

.panel:hover::before {
  opacity: 1;
}

/* Panel Title */
.panel-title {
  font-size: var(--text-sm);
  font-weight: var(--font-bold);
  color: var(--text-base);
  margin-bottom: var(--space-4);
  display: flex;
  align-items: center;
  gap: var(--space-2);
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
}

.panel-title > *:first-child {
  display: inline-block;
  transition: transform var(--duration-normal) var(--ease-spring);
}
.panel:hover .panel-title > *:first-child {
  transform: scale(1.2) rotate(-5deg);
}

/* ═══════════════════════════════════════════════════════════════════
   6. FORM ELEMENTS — Premium Feel
   ═══════════════════════════════════════════════════════════════════ */
.ctrl-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  position: relative;
}

/* Left border focus indicator (RTL = right side is leading) */
.ctrl-group::before {
  content: '';
  position: absolute;
  right: -1px;
  top: 28px;
  bottom: 0;
  width: 2px;
  background: var(--color-brand-500);
  border-radius: var(--radius-full);
  transform: scaleY(0);
  transform-origin: bottom;
  transition: transform var(--duration-normal) var(--ease-spring);
  opacity: 0;
}

.ctrl-group:focus-within::before {
  transform: scaleY(1);
  opacity: 1;
}

.label {
  font-size: var(--text-xs);
  font-weight: var(--font-bold);
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: var(--tracking-widest);
  transition: color var(--duration-fast) var(--ease-default);
  user-select: none;
}

.ctrl-group:focus-within .label {
  color: var(--color-brand-400);
}

.ctrl-input {
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-default);
  background: var(--surface-sunken);
  color: var(--text-base);
  font-family: var(--font-family);
  font-size: var(--text-base);
  font-weight: var(--font-medium);
  outline: none;
  transition: border-color var(--duration-fast) var(--ease-default),
              box-shadow var(--duration-fast) var(--ease-default),
              background var(--duration-fast) var(--ease-default);
  width: 100%;
  -webkit-appearance: none;
  appearance: none;
}

.ctrl-input::placeholder {
  color: var(--text-disabled);
  font-weight: var(--font-normal);
}

.ctrl-input:hover {
  border-color: var(--border-strong);
  background: hsla(224, 50%, 5%, 0.9);
}

.ctrl-input:focus {
  border-color: var(--color-brand-500);
  background: hsla(224, 50%, 5%, 0.95);
  box-shadow: 0 0 0 3px hsla(210, 85%, 56%, 0.12),
              inset 0 1px 3px rgba(0,0,0,0.2);
}

.ctrl-input:disabled, .ctrl-input[disabled] {
  opacity: 0.4;
  cursor: not-allowed;
}

/* Select arrow */
select.ctrl-input {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' fill='none' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: left 12px center;
  padding-left: 32px;
  cursor: pointer;
}

select.ctrl-input option {
  background: var(--surface-floating);
  color: var(--text-base);
  padding: var(--space-2);
}

/* Grid input */
.g-input {
  width: 100%;
  padding: 5px var(--space-2);
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-base);
  font-family: var(--font-family);
  font-size: var(--text-sm);
  font-weight: var(--font-semibold);
  text-align: center;
  outline: none;
  transition: var(--transition-fast);
}

.g-input:hover {
  border-color: var(--border-default);
  background: var(--surface-sunken);
}

.g-input:focus {
  border-color: var(--color-brand-500);
  background: var(--surface-sunken);
  box-shadow: 0 0 0 2px hsla(210, 85%, 56%, 0.12);
}

/* ═══════════════════════════════════════════════════════════════════
   7. BUTTONS — Systematic & Expressive
   ═══════════════════════════════════════════════════════════════════ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  font-family: var(--font-family);
  font-size: var(--text-sm);
  font-weight: var(--font-bold);
  cursor: pointer;
  white-space: nowrap;
  position: relative;
  overflow: hidden;
  transition: transform var(--duration-normal) var(--ease-spring),
              box-shadow var(--duration-normal) var(--ease-default),
              background var(--duration-fast) var(--ease-default),
              border-color var(--duration-fast) var(--ease-default);
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

/* Ripple */
.btn::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: radial-gradient(circle at center, rgba(255,255,255,0.15) 0%, transparent 70%);
  opacity: 0;
  transform: scale(0);
  transition: opacity 0.4s, transform 0.4s;
}
.btn:active::after {
  opacity: 1;
  transform: scale(2.5);
  transition: opacity 0s, transform 0s;
}

.btn:active {
  transform: scale(0.96) !important;
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none !important;
}

/* Button Sizes */
.btn-sm  { padding: 5px var(--space-3); font-size: var(--text-xs); border-radius: var(--radius-sm); }
.btn-lg  { padding: var(--space-3) var(--space-6); font-size: var(--text-lg); border-radius: var(--radius-lg); }

/* Primary Button */
.btn-primary {
  background: linear-gradient(145deg,
    hsla(210, 85%, 60%, 0.20),
    hsla(225, 80%, 55%, 0.12)
  );
  border-color: hsla(210, 85%, 56%, 0.45);
  color: var(--color-brand-400);
  box-shadow: var(--shadow-xs), inset 0 1px 0 hsla(210, 85%, 85%, 0.08);
}
.btn-primary:hover {
  background: linear-gradient(145deg,
    hsla(210, 85%, 60%, 0.30),
    hsla(225, 80%, 55%, 0.20)
  );
  border-color: hsla(210, 85%, 56%, 0.65);
  box-shadow: var(--shadow-sm), var(--glow-brand);
  transform: translateY(-2px);
}

/* Success Button */
.btn-success {
  background: linear-gradient(145deg,
    hsla(160, 70%, 45%, 0.20),
    hsla(160, 70%, 40%, 0.12)
  );
  border-color: hsla(160, 70%, 45%, 0.45);
  color: var(--color-success-400);
  box-shadow: var(--shadow-xs), inset 0 1px 0 hsla(160, 70%, 85%, 0.06);
}
.btn-success:hover {
  background: linear-gradient(145deg,
    hsla(160, 70%, 45%, 0.30),
    hsla(160, 70%, 40%, 0.20)
  );
  border-color: hsla(160, 70%, 45%, 0.65);
  box-shadow: var(--shadow-sm), var(--glow-success);
  transform: translateY(-2px);
}

/* Danger Button */
.btn-danger {
  background: linear-gradient(145deg,
    hsla(355, 80%, 58%, 0.15),
    hsla(355, 80%, 55%, 0.08)
  );
  border-color: hsla(355, 80%, 58%, 0.40);
  color: var(--color-danger-400);
}
.btn-danger:hover {
  background: linear-gradient(145deg,
    hsla(355, 80%, 58%, 0.25),
    hsla(355, 80%, 55%, 0.16)
  );
  border-color: hsla(355, 80%, 58%, 0.60);
  box-shadow: var(--shadow-sm), var(--glow-danger);
  transform: translateY(-2px);
}

/* Ghost Button */
.btn-ghost {
  background: transparent;
  border-color: var(--border-subtle);
  color: var(--text-secondary);
}
.btn-ghost:hover {
  background: hsla(210, 30%, 80%, 0.04);
  border-color: var(--border-default);
  color: var(--text-base);
}

/* ═══════════════════════════════════════════════════════════════════
   8. TOP ACTION BAR — Navigation & Context
   ═══════════════════════════════════════════════════════════════════ */
.top-action-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
  flex-wrap: wrap;
  padding: var(--space-2) 0;
}

.action-tabs {
  display: flex;
  gap: var(--space-1);
  background: var(--surface-raised);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: var(--space-1);
  flex-wrap: wrap;
}

.action-tab {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-tertiary);
  font-family: var(--font-family);
  font-size: var(--text-sm);
  font-weight: var(--font-semibold);
  cursor: pointer;
  transition: var(--transition-spring);
  white-space: nowrap;
  position: relative;
}

.action-tab:hover {
  background: hsla(210, 30%, 80%, 0.04);
  color: var(--text-secondary);
}

.action-tab.active {
  background: hsla(210, 85%, 56%, 0.12);
  border-color: hsla(210, 85%, 56%, 0.30);
  color: var(--color-brand-400);
  box-shadow: inset 0 1px 0 hsla(210, 85%, 85%, 0.06);
}

/* Glowing dot for active tab */
.action-tab.active::before {
  content: '';
  position: absolute;
  bottom: -1px;
  left: 25%;
  right: 25%;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--color-brand-400), transparent);
  border-radius: var(--radius-full);
  box-shadow: 0 0 8px var(--color-brand-400);
  animation: tabGlow 2.5s ease-in-out infinite;
}

@keyframes tabGlow {
  0%, 100% { opacity: 0.6; }
  50%       { opacity: 1; }
}

/* Invoice number badge */
.inv-badge {
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-weight: var(--font-extrabold);
  font-family: var(--font-mono);
  color: var(--color-brand-400);
  letter-spacing: var(--tracking-wider);
  background: hsla(210, 85%, 56%, 0.08);
  border: 1px solid hsla(210, 85%, 56%, 0.25);
  animation: badgePulse 4s ease-in-out infinite;
}

@keyframes badgePulse {
  0%, 100% { box-shadow: 0 0 0 transparent; }
  50%       { box-shadow: 0 0 12px hsla(210, 85%, 56%, 0.20); }
}

/* ═══════════════════════════════════════════════════════════════════
   9. DATA GRID TABLE — Enterprise Grade
   ═══════════════════════════════════════════════════════════════════ */
.pos-grid {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  table-layout: auto;
}

.pos-grid thead tr {
  position: sticky;
  top: 0;
  z-index: 10;
}

.pos-grid thead th {
  background: hsla(222, 47%, 7%, 0.95);
  padding: var(--space-2) var(--space-2);
  font-size: var(--text-xs);
  font-weight: var(--font-bold);
  color: var(--text-tertiary);
  text-align: center;
  white-space: nowrap;
  border-bottom: 1px solid var(--border-default);
  text-transform: uppercase;
  letter-spacing: var(--tracking-widest);
  backdrop-filter: blur(8px);
}

.pos-grid thead th:first-child { border-radius: var(--radius-sm) 0 0 0; }
.pos-grid thead th:last-child  { border-radius: 0 var(--radius-sm) 0 0; }

.pos-grid tbody tr {
  border-bottom: 1px solid var(--border-subtle);
  transition: background var(--duration-fast) var(--ease-default);
  animation: rowEnter var(--duration-slow) var(--ease-out) both;
}

.pos-grid tbody tr:nth-child(1)  { animation-delay: 0ms; }
.pos-grid tbody tr:nth-child(2)  { animation-delay: 30ms; }
.pos-grid tbody tr:nth-child(3)  { animation-delay: 60ms; }
.pos-grid tbody tr:nth-child(4)  { animation-delay: 90ms; }
.pos-grid tbody tr:nth-child(5)  { animation-delay: 120ms; }
.pos-grid tbody tr:nth-child(6)  { animation-delay: 150ms; }
.pos-grid tbody tr:nth-child(n+7){ animation-delay: 180ms; }

@keyframes rowEnter {
  from { opacity: 0; transform: translateX(8px); }
  to   { opacity: 1; transform: translateX(0); }
}

.pos-grid tbody tr:hover {
  background: hsla(210, 85%, 56%, 0.04);
}

.pos-grid tbody td {
  padding: var(--space-1);
  vertical-align: middle;
  text-align: center;
}

/* Total value cell */
.g-readonly.total-val {
  color: var(--color-success-400);
  font-weight: var(--font-extrabold);
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  text-shadow: 0 0 8px hsla(160, 70%, 55%, 0.3);
}

.g-readonly.avail-val {
  color: var(--color-brand-400);
  font-family: var(--font-mono);
}

.g-readonly.warn-val {
  color: var(--color-warning-400);
  font-family: var(--font-mono);
}

/* Delete button */
.del-btn {
  width: 28px; height: 28px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-disabled);
  font-size: var(--text-base);
  cursor: pointer;
  transition: var(--transition-spring);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.del-btn:hover {
  background: hsla(355, 80%, 58%, 0.12);
  border-color: hsla(355, 80%, 58%, 0.30);
  color: var(--color-danger-400);
  transform: scale(1.15);
  box-shadow: var(--glow-danger);
}

/* ═══════════════════════════════════════════════════════════════════
   10. TOTALS SECTION — Financial Focus
   ═══════════════════════════════════════════════════════════════════ */
.totals-stack {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.total-line {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  background: hsla(222, 47%, 8%, 0.6);
  font-size: var(--text-sm);
  transition: background var(--duration-fast);
}

.total-line:hover {
  background: hsla(222, 47%, 10%, 0.8);
}

.total-line .tl-label {
  color: var(--text-secondary);
  font-weight: var(--font-semibold);
}

.total-line .tl-value {
  color: var(--text-base);
  font-weight: var(--font-extrabold);
  font-family: var(--font-mono);
  letter-spacing: var(--tracking-wide);
}

.total-line .tl-value.plus     { color: var(--color-success-400); }
.total-line .tl-value.tax      { color: var(--color-warning-400); }
.total-line .tl-value.discount { color: var(--color-danger-400); }

.total-line.editable { background: hsla(222, 47%, 7%, 0.4); }

.total-line.sub {
  background: transparent;
  padding-top: var(--space-1);
  padding-bottom: var(--space-1);
  font-size: var(--text-xs);
  opacity: 0.85;
}

/* Grand Total */
.total-line.grand {
  margin-top: var(--space-2);
  background: linear-gradient(135deg,
    hsla(160, 70%, 45%, 0.12),
    hsla(160, 70%, 40%, 0.06)
  );
  border: 1px solid hsla(160, 70%, 45%, 0.25);
  padding: var(--space-3) var(--space-4);
  animation: grandBreath 3.5s ease-in-out infinite;
}

@keyframes grandBreath {
  0%, 100% { box-shadow: 0 0 0 transparent; }
  50%       { box-shadow: 0 0 20px hsla(160, 70%, 45%, 0.15), inset 0 0 20px hsla(160, 70%, 45%, 0.04); }
}

.total-line.grand .tl-label {
  color: var(--color-success-400);
  font-weight: var(--font-bold);
  font-size: var(--text-base);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wide);
}

.total-line.grand .tl-value {
  color: var(--color-success-400);
  font-size: var(--text-2xl);
  font-weight: var(--font-black);
  text-shadow: 0 0 16px hsla(160, 70%, 55%, 0.5);
}

/* ═══════════════════════════════════════════════════════════════════
   11. STICKY FOOTER — Command Bar
   ═══════════════════════════════════════════════════════════════════ */
.sticky-footer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-3) var(--space-6);
  background: hsla(220, 40%, 8%, 0.92);
  backdrop-filter: blur(24px) saturate(1.5);
  -webkit-backdrop-filter: blur(24px) saturate(1.5);
  border-top: 1px solid var(--border-subtle);
  z-index: var(--z-overlay);
  transition: right var(--duration-slow) var(--ease-in-out);
}

/* Top gradient glow */
.sticky-footer::before {
  content: '';
  position: absolute;
  top: 0; left: 15%; right: 15%;
  height: 1px;
  background: linear-gradient(90deg,
    transparent,
    var(--color-brand-400) 30%,
    var(--color-success-400) 70%,
    transparent
  );
  border-radius: var(--radius-full);
  opacity: 0.4;
  animation: footerGlow 4s ease-in-out infinite;
}

@keyframes footerGlow {
  0%, 100% { opacity: 0.3; }
  50%       { opacity: 0.7; }
}

body.has-sidebar .sticky-footer       { right: var(--sb-collapsed); }
body.has-sidebar.sidebar-open .sticky-footer { right: var(--sb-expanded); }

.footer-total {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.ft-label {
  font-size: var(--text-sm);
  font-weight: var(--font-semibold);
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wider);
}

.ft-value {
  font-size: var(--text-xl);
  font-weight: var(--font-black);
  color: var(--color-success-400);
  font-family: var(--font-mono);
  text-shadow: 0 0 12px hsla(160, 70%, 55%, 0.4);
  letter-spacing: var(--tracking-normal);
}

.footer-actions {
  display: flex;
  gap: var(--space-2);
}

/* ═══════════════════════════════════════════════════════════════════
   12. BREADCRUMB — Contextual Navigation
   ═══════════════════════════════════════════════════════════════════ */
.page-breadcrumb {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) 0 var(--space-3);
  font-size: var(--text-xs);
  font-weight: var(--font-semibold);
  text-transform: uppercase;
  letter-spacing: var(--tracking-widest);
}

.bc-link {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  color: var(--text-tertiary);
  text-decoration: none;
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-sm);
  transition: var(--transition-fast);
}

.bc-link:hover {
  color: var(--color-brand-400);
  background: hsla(210, 85%, 56%, 0.06);
}

.bc-sep {
  color: var(--text-disabled);
  font-size: 1rem;
  line-height: 1;
}

.bc-current {
  color: var(--text-base);
  font-weight: var(--font-bold);
  position: relative;
  padding-bottom: 2px;
}

.bc-current::after {
  content: '';
  position: absolute;
  bottom: 0; right: 0;
  width: 0; height: 1px;
  background: linear-gradient(90deg, transparent, var(--color-brand-400));
  border-radius: var(--radius-full);
  transition: width var(--duration-slow) var(--ease-out);
}

.page-breadcrumb:hover .bc-current::after {
  width: 100%;
}

/* ═══════════════════════════════════════════════════════════════════
   13. FINANCIAL STATUS CARDS — KPI Display
   ═══════════════════════════════════════════════════════════════════ */
.fin-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-2);
}

.fin-card {
  padding: var(--space-3);
  border-radius: var(--radius-md);
  background: hsla(222, 47%, 7%, 0.6);
  border: 1px solid var(--border-subtle);
  text-align: center;
  transition: var(--transition-normal);
}

.fin-card:hover {
  border-color: var(--border-default);
  background: hsla(222, 47%, 9%, 0.8);
  transform: translateY(-1px);
}

.fin-label {
  font-size: var(--text-xs);
  font-weight: var(--font-bold);
  color: var(--text-tertiary);
  margin-bottom: var(--space-1);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wide);
}

.fin-value {
  font-size: var(--text-lg);
  font-weight: var(--font-black);
  color: var(--text-base);
  font-family: var(--font-mono);
}

.fin-card.warn   .fin-value { color: var(--color-warning-400); }
.fin-card.success .fin-value { color: var(--color-success-400); }
.fin-card.highlight {
  grid-column: 1 / -1;
  background: linear-gradient(135deg,
    hsla(160, 70%, 45%, 0.10),
    hsla(160, 70%, 40%, 0.05)
  );
  border-color: hsla(160, 70%, 45%, 0.20);
}
.fin-card.highlight .fin-value {
  font-size: var(--text-2xl);
  color: var(--color-success-400);
  text-shadow: 0 0 12px hsla(160, 70%, 55%, 0.35);
}

/* ═══════════════════════════════════════════════════════════════════
   14. MODALS — Layered Depth
   ═══════════════════════════════════════════════════════════════════ */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: hsla(220, 47%, 4%, 0.75);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: var(--z-modal);
  align-items: center;
  justify-content: center;
  padding: var(--space-5);
}

.modal-overlay.visible { display: flex; }

.modal-card {
  background: var(--surface-overlay);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-2xl);
  width: 100%;
  max-width: 460px;
  box-shadow: var(--shadow-xl);
  animation: modalIn var(--duration-slow) var(--ease-out) both;
}

@keyframes modalIn {
  from {
    opacity: 0;
    transform: scale(0.92) translateY(16px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--border-subtle);
}

.modal-header h3 {
  font-size: var(--text-lg);
  font-weight: var(--font-extrabold);
  color: var(--text-base);
}

.modal-close {
  width: 30px; height: 30px;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-tertiary);
  font-size: 1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition-spring);
}

.modal-close:hover {
  background: hsla(355, 80%, 58%, 0.10);
  border-color: hsla(355, 80%, 58%, 0.25);
  color: var(--color-danger-400);
  transform: scale(1.1) rotate(90deg);
}

.modal-body {
  padding: var(--space-5);
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.modal-footer {
  padding: var(--space-4) var(--space-5);
  border-top: 1px solid var(--border-subtle);
  display: flex;
  gap: var(--space-2);
  justify-content: flex-end;
}

/* ═══════════════════════════════════════════════════════════════════
   15. TOAST NOTIFICATIONS — Elegant Feedback
   ═══════════════════════════════════════════════════════════════════ */
.toast-container {
  position: fixed;
  top: var(--space-5);
  left: 50%;
  transform: translateX(-50%);
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  pointer-events: none;
  min-width: 280px;
  max-width: 90vw;
}

.toast {
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-lg);
  font-weight: var(--font-semibold);
  font-size: var(--text-sm);
  display: flex;
  align-items: center;
  gap: var(--space-2);
  pointer-events: auto;
  backdrop-filter: blur(20px);
  box-shadow: var(--shadow-lg);
  animation: toastIn var(--duration-slow) var(--ease-out) both;
  border: 1px solid;
}

@keyframes toastIn {
  from { opacity: 0; transform: translateY(-12px) scale(0.95); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.toast.success {
  background: hsla(160, 70%, 45%, 0.12);
  border-color: hsla(160, 70%, 45%, 0.35);
  color: var(--color-success-400);
}
.toast.error {
  background: hsla(355, 80%, 58%, 0.12);
  border-color: hsla(355, 80%, 58%, 0.35);
  color: var(--color-danger-400);
}
.toast.warning {
  background: hsla(38, 85%, 52%, 0.12);
  border-color: hsla(38, 85%, 52%, 0.35);
  color: var(--color-warning-400);
}
.toast.hide {
  animation: toastOut var(--duration-normal) var(--ease-in-out) forwards;
}
@keyframes toastOut {
  to { opacity: 0; transform: translateY(-12px) scale(0.95); }
}

/* ═══════════════════════════════════════════════════════════════════
   16. EMPTY STATE — Delightful Zero Data
   ═══════════════════════════════════════════════════════════════════ */
.empty-state {
  text-align: center;
  padding: var(--space-10) var(--space-5);
  color: var(--text-tertiary);
}

.empty-icon {
  font-size: 3rem;
  margin-bottom: var(--space-4);
  opacity: 0.35;
  display: block;
  animation: emptyFloat 3s ease-in-out infinite;
  filter: grayscale(0.3);
}

@keyframes emptyFloat {
  0%, 100% { transform: translateY(0) rotate(-2deg); }
  50%       { transform: translateY(-10px) rotate(2deg); }
}

.empty-state p {
  font-size: var(--text-base);
  font-weight: var(--font-semibold);
  color: var(--text-tertiary);
  margin-bottom: var(--space-2);
}

.empty-hint {
  font-size: var(--text-sm);
  color: var(--text-disabled);
}

.empty-hint kbd {
  background: hsla(210, 30%, 80%, 0.06);
  border: 1px solid var(--border-default);
  padding: 2px var(--space-2);
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
}

/* ═══════════════════════════════════════════════════════════════════
   17. PAGE WRAPPER ANIMATION
   ═══════════════════════════════════════════════════════════════════ */
.pos-wrapper {
  max-width: 1440px;
  margin: 0 auto;
  padding: var(--space-3) var(--space-4) 100px;
  animation: pageEnter 0.6s var(--ease-out) both;
}

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

/* ═══════════════════════════════════════════════════════════════════
   18. BACK ARROW BUTTON
   ═══════════════════════════════════════════════════════════════════ */
.back-arrow-btn {
  width: 38px; height: 38px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  background: var(--surface-raised);
  color: var(--text-tertiary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition-spring);
}

.back-arrow-btn:hover {
  background: hsla(210, 85%, 56%, 0.08);
  border-color: var(--border-brand);
  color: var(--color-brand-400);
  transform: translateX(-3px);
  box-shadow: var(--glow-brand);
}

/* ═══════════════════════════════════════════════════════════════════
   19. HEADER FORM GRID — Structured Layout
   ═══════════════════════════════════════════════════════════════════ */
.header-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-4);
  margin-bottom: var(--space-4);
}

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

.header-form {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-3);
}

.ctrl-full { grid-column: 1 / -1; }

/* ═══════════════════════════════════════════════════════════════════
   20. ICON BUTTONS
   ═══════════════════════════════════════════════════════════════════ */
.btn-icon {
  width: 36px; height: 36px;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-tertiary);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition-spring);
  flex-shrink: 0;
}

.btn-icon:hover {
  background: hsla(210, 30%, 80%, 0.06);
  border-color: var(--border-default);
  color: var(--text-base);
  transform: scale(1.1);
}

.btn-icon:active { transform: scale(0.92) !important; }

.btn-icon-add {
  width: 36px; height: 36px;
  border-radius: var(--radius-md);
  border: 1px dashed hsla(210, 85%, 56%, 0.35);
  background: hsla(210, 85%, 56%, 0.06);
  color: var(--color-brand-400);
  font-size: 1.25rem;
  font-weight: var(--font-black);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition-spring);
  flex-shrink: 0;
}

.btn-icon-add:hover {
  background: hsla(210, 85%, 56%, 0.15);
  border-style: solid;
  border-color: var(--color-brand-500);
  transform: scale(1.08);
  box-shadow: var(--glow-brand);
}

/* ═══════════════════════════════════════════════════════════════════
   21. RESPONSIVE ADJUSTMENTS
   ═══════════════════════════════════════════════════════════════════ */
@media (max-width: 768px) {
  .top-action-bar { flex-direction: column; align-items: stretch; }
  .action-tabs { overflow-x: auto; flex-wrap: nowrap; }
  .sticky-footer { padding: var(--space-2) var(--space-4); flex-wrap: wrap; gap: var(--space-2); }
  .footer-actions { flex: 1; justify-content: flex-end; }
  .header-form { grid-template-columns: 1fr; }
  .fin-grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 480px) {
  .pos-wrapper { padding: var(--space-2) var(--space-3) 90px; }
  .panel { padding: var(--space-4); }
  .ft-value { font-size: var(--text-lg); }
}

/* ═══════════════════════════════════════════════════════════════════
   22. PRINT — Clean Output
   ═══════════════════════════════════════════════════════════════════ */
@media print {
  body { background: #fff !important; color: #000 !important; }
  .top-action-bar, .sticky-footer, .btn, .del-btn,
  .btn-icon, .global-sidebar, .page-breadcrumb { display: none !important; }
  .panel {
    border: 1px solid #e2e8f0;
    box-shadow: none;
    background: #fff !important;
    backdrop-filter: none;
  }
  .pos-grid thead th { background: #f8fafc !important; color: #475569 !important; border: 1px solid #e2e8f0; }
  .pos-grid tbody td { border: 1px solid #e2e8f0; color: #1e293b; }
  .g-input, .ctrl-input { background: transparent; border: 1px solid #cbd5e1; color: #1e293b; }
  .pos-wrapper { padding: 0; max-width: 100%; }
}
