/* ==========================================================================
   Hedwig — base.css
   Global design tokens & foundational styles.
   Ref: [UIUX] §2 (Visual Language), §10 (Accessibility)

   Redesign pass: the palette now mirrors the Hedwig Android app's
   professional slate-navy theme (values/colors.xml). Light and dark modes
   are driven by a `data-theme` attribute on <html> (see theme.js). All
   existing token names are preserved so every page keeps working — only
   the values were updated, plus the app shell, sidebar and header were
   redesigned to match the mobile look (thin glassy topbar, highlighted
   sidebar, gradient "bubble" orbs, softer surfaces).
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. CSS Custom Properties — Color System
   Per-company brand color is set at runtime (Admin → Branding, Phase 39)
   by overriding --brand-primary / --brand-primary-dark / --brand-gradient
   on :root via an inline <style> block on each page. Defaults below are the
   platform fallback so unbranded/dev pages still look correct.
   -------------------------------------------------------------------------- */
:root {
  /* ======================================================================
     Maroon & warm-white brand system (plywood / wood-trade B2B).
     Color psychology: maroon conveys strength, stability, warmth and a
     premium, established feel; warm wood-brown accents echo the product;
     clean white surfaces signal trust and craftsmanship. Light mode is a
     bright white base with maroon accents; dark mode is a warm, deep
     maroon-tinted charcoal.
     ====================================================================== */
  --brand-primary: #801a2e;
  --brand-primary-dark: #57101f;
  --brand-secondary: #a23a47;
  --brand-gradient: linear-gradient(135deg, #801a2e 0%, #a23a47 100%);

  /* Secondary accents (warm / sparing) */
  --accent-amber: #b8862e;
  --accent-coral: #b0475c;
  --accent-lime: #65a30d;
  --accent-gold: #b8862e;
  --accent-teal: #2e7d6b;
  --accent-rose: #a23a47;
  --accent-wood: #96603b;

  /* Semantic colors */
  --color-success: #1f7a45;
  --color-success-bg: #ecfdf5;
  --color-warning: #a8660a;
  --color-warning-bg: #fffbeb;
  --color-danger: #d93b3b;
  --color-danger-bg: #fef2f2;
  --color-info: #9a4a1e;
  --color-info-bg: #fdf1e7;
  --color-pending: #6d5bd0;
  --color-pending-bg: #f5f3ff;

  /* Neutral scale (warm off-white -> near-black) */
  --neutral-0: #ffffff;
  --neutral-50: #faf8f7;
  --neutral-100: #f3efed;
  --neutral-200: #e7e0db;
  --neutral-300: #cfc6c0;
  --neutral-400: #a49991;
  --neutral-500: #7e726a;
  --neutral-600: #5f554f;
  --neutral-700: #4a413c;
  --neutral-800: #332c28;
  --neutral-900: #241e1b;

  /* Surfaces & text */
  --surface-bg: #f6f2f0;
  --surface-card: #ffffff;
  --surface-card-2: #faf7f5;
  --text-primary: #241e1b;
  --text-secondary: #5f554f;
  --text-muted: #a49991;
  --border-color: #ece4df;

  /* App shell — highlighted maroon sidebar */
  --sidebar-bg: linear-gradient(180deg, #4a0e1c 0%, #681527 50%, #801a2e 130%);
  --sidebar-text: rgba(255, 255, 255, 0.74);
  --sidebar-text-strong: #ffffff;
  --sidebar-hover: rgba(255, 255, 255, 0.09);
  --sidebar-active-gradient: linear-gradient(135deg, #a23a47 0%, #c65a68 100%);
  --sidebar-glow: rgba(128, 26, 46, 0.5);

  /* Shell surfaces (light-mode punch) */
  --app-bg: linear-gradient(180deg, #faf8f7 0%, #f2eeec 55%, #f6f2f0 100%);
  --app-card-stripe: linear-gradient(90deg, #801a2e 0%, #a23a47 45%, #96603b 100%);

  /* Shape */
  --radius-sm: 10px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-pill: 9999px;

  /* Shadows (soft, layered, low-opacity) */
  --shadow-sm: 0 1px 2px rgba(36, 30, 27, 0.05), 0 1px 1px rgba(36, 30, 27, 0.03);
  --shadow-md: 0 6px 16px rgba(36, 30, 27, 0.07), 0 2px 4px rgba(36, 30, 27, 0.04);
  --shadow-lg: 0 16px 40px rgba(36, 30, 27, 0.12), 0 4px 10px rgba(36, 30, 27, 0.06);
  --shadow-glow: 0 8px 24px rgba(128, 26, 46, 0.25);

  /* Type scale */
  --fs-xs: 12px;
  --fs-sm: 14px;
  --fs-base: 16px;
  --fs-lg: 20px;
  --fs-xl: 24px;
  --fs-2xl: 32px;
  --fs-3xl: 40px;

  /* Glass */
  --glass-bg: rgba(255, 255, 255, 0.62);
  --glass-border: rgba(255, 255, 255, 0.55);
  --glass-blur: 16px;

  /* Header / layout */
  --header-bg: rgba(255, 255, 255, 0.85);
  --header-height: 52px;
  --nav-width: 240px;
  --nav-width-collapsed: 76px;

  /* Decorative orbs ("bubbles") behind the content */
  --orb-1: radial-gradient(circle, rgba(128, 26, 46, 0.14), transparent 65%);
  --orb-2: radial-gradient(circle, rgba(150, 96, 59, 0.12), transparent 62%);

  /* Focus ring tint used by inputs / selects */
  --focus-ring: rgba(128, 26, 46, 0.12);

  /* Back-compat aliases — some pages were written against these names
     before the token system above was finalized. Keeping them mapped
     here prevents invisible/broken styling wherever the older names are
     still used. */
  --color-border: var(--border-color);
  --color-muted-bg: var(--surface-bg);
  --color-primary: var(--brand-primary);
  --input-bg: var(--surface-card);
  --surface-hover: var(--neutral-100);
  --surface-table-header: var(--neutral-100);

  color-scheme: light;
}

/* --------------------------------------------------------------------------
   Dark theme — mirrors values-night/colors.xml from the mobile app
   -------------------------------------------------------------------------- */
[data-theme="dark"] {
  --brand-primary: #cf6674;
  --brand-primary-dark: #801a2e;
  --brand-secondary: #e07a86;
  --brand-gradient: linear-gradient(135deg, #801a2e 0%, #cf6674 100%);

  --accent-amber: #d0a44e;
  --accent-coral: #d16a80;
  --accent-lime: #a3e635;
  --accent-gold: #d0a44e;
  --accent-teal: #4c9e8b;
  --accent-rose: #e07a86;
  --accent-wood: #c2906b;

  --color-success: #34d399;
  --color-success-bg: rgba(52, 211, 153, 0.12);
  --color-warning: #fbbf24;
  --color-warning-bg: rgba(251, 191, 36, 0.12);
  --color-danger: #fb7185;
  --color-danger-bg: rgba(251, 113, 133, 0.12);
  --color-info: #e29a6b;
  --color-info-bg: rgba(226, 154, 107, 0.14);
  --color-pending: #a78bfa;
  --color-pending-bg: rgba(167, 139, 250, 0.12);

  --neutral-0: #120e10;
  --neutral-50: #171215;
  --neutral-100: #1e181b;
  --neutral-200: #2a2125;
  --neutral-300: #372c31;
  --neutral-400: #58493e;
  --neutral-500: #94817b;
  --neutral-600: #bfb1ab;
  --neutral-700: #d5c8c6;
  --neutral-800: #e9e0de;
  --neutral-900: #f4ecec;

  --surface-bg: #120e10;
  --surface-card: #1b1417;
  --surface-card-2: #221a1d;
  --text-primary: #f4ecec;
  --text-secondary: #d0c4c1;
  --text-muted: #9c8b88;
  --border-color: #2e2428;

  --sidebar-bg: linear-gradient(180deg, #0e070b 0%, #170c12 55%, #260f18 140%);
  --sidebar-text: rgba(255, 255, 255, 0.64);
  --sidebar-hover: rgba(255, 255, 255, 0.07);
  --sidebar-active-gradient: linear-gradient(135deg, #801a2e 0%, #a23a47 100%);
  --sidebar-glow: rgba(207, 102, 116, 0.35);

  --app-bg: linear-gradient(180deg, #120e10 0%, #0e0b0c 55%, #120e10 100%);
  --app-card-stripe: linear-gradient(90deg, #801a2e 0%, #a23a47 45%, #96603b 100%);

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.25);
  --shadow-md: 0 6px 16px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 16px 40px rgba(0, 0, 0, 0.5);
  --shadow-glow: 0 8px 24px rgba(207, 102, 116, 0.28);

  --glass-bg: rgba(27, 20, 23, 0.6);
  --glass-border: rgba(255, 255, 255, 0.1);
  --header-bg: rgba(18, 14, 16, 0.8);

  --orb-1: radial-gradient(circle, rgba(207, 102, 116, 0.16), transparent 65%);
  --orb-2: radial-gradient(circle, rgba(194, 144, 107, 0.13), transparent 62%);

  --focus-ring: rgba(207, 102, 116, 0.2);

  color-scheme: dark;
}

/* --------------------------------------------------------------------------
   2. Typography
   Latin display font with Devanagari/Tamil fallback chain so language
   switching (Hindi/Tamil) never breaks visual rhythm.
   -------------------------------------------------------------------------- */
@font-face {
  font-family: 'Plus Jakarta Sans';
  src: local('Plus Jakarta Sans');
  font-display: swap;
}

:root {
  --font-family-base:
    'Plus Jakarta Sans',
    -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto,
    'Noto Sans Devanagari', 'Noto Sans Tamil',
    Arial, sans-serif;
}

html, body {
  height: 100%;
}

body {
  margin: 0;
  font-family: var(--font-family-base);
  font-size: var(--fs-base);
  line-height: 1.5;
  color: var(--text-primary);
  background-color: var(--surface-bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  transition: background-color 0.25s ease, color 0.25s ease;
}

h1, h2, h3, h4, h5, h6 {
  margin: 0 0 0.5em 0;
  font-weight: 700;
  line-height: 1.25;
  color: var(--text-primary);
}

h1 { font-size: var(--fs-3xl); }
h2 { font-size: var(--fs-2xl); }
h3 { font-size: var(--fs-xl); }
h4 { font-size: var(--fs-lg); }

small, .text-sm { font-size: var(--fs-sm); }
.text-xs { font-size: var(--fs-xs); }
.text-muted { color: var(--text-secondary); }

a {
  color: var(--brand-primary);
  text-decoration: none;
}
a:hover { text-decoration: underline; }

/* Subtle branded scrollbars */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--neutral-300) transparent;
}
*::-webkit-scrollbar { width: 9px; height: 9px; }
*::-webkit-scrollbar-thumb {
  background: var(--neutral-300);
  border-radius: var(--radius-pill);
  border: 2px solid transparent;
  background-clip: content-box;
}
*::-webkit-scrollbar-thumb:hover { background-color: var(--neutral-400); }
*::-webkit-scrollbar-track { background: transparent; }

/* --------------------------------------------------------------------------
   3. Shape & Depth — "Curvy Structure"
   -------------------------------------------------------------------------- */
.card {
  background: var(--surface-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: 24px;
  border: 1px solid var(--border-color);
  transition: box-shadow 0.2s ease, transform 0.2s ease;
}

.card-hero {
  background: var(--brand-gradient);
  color: #fff;
  border: none;
  box-shadow: var(--shadow-glow);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: inherit;
  font-size: var(--fs-sm);
  font-weight: 600;
  padding: 10px 20px;
  border-radius: 12px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease, color 0.15s ease;
}

.btn:focus-visible {
  outline: 2px solid var(--brand-primary);
  outline-offset: 2px;
}

.btn-primary {
  background: var(--brand-gradient);
  color: #fff;
  box-shadow: var(--shadow-sm);
}
.btn-primary:hover {
  box-shadow: var(--shadow-glow);
  transform: translateY(-1px);
}

.btn-secondary {
  background: var(--surface-card);
  color: var(--text-primary);
  border-color: var(--border-color);
}
.btn-secondary:hover { background: var(--neutral-100); }

.btn-danger {
  background: var(--color-danger);
  color: #fff;
  box-shadow: var(--shadow-sm);
}
.btn-danger:hover { background: #e11d48; transform: translateY(-1px); box-shadow: var(--shadow-md); }

.btn-success {
  background: var(--color-success);
  color: #fff;
  box-shadow: var(--shadow-sm);
}
.btn-success:hover { background: #059669; transform: translateY(-1px); box-shadow: var(--shadow-md); }

.btn-warning {
  background: var(--color-warning);
  color: #fff;
  box-shadow: var(--shadow-sm);
}
.btn-warning:hover { background: #d97706; transform: translateY(-1px); box-shadow: var(--shadow-md); }

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border-color: transparent;
}
.btn-ghost:hover { background: var(--neutral-100); color: var(--text-primary); }

.btn-icon {
  padding: 10px;
  width: 40px;
  height: 40px;
}

.btn-sm { padding: 6px 12px; font-size: var(--fs-xs); border-radius: 10px; }
.btn-sm.btn-icon { width: 30px; height: 30px; padding: 6px; }
.btn-lg { padding: 13px 26px; font-size: var(--fs-base); }
.btn-block { width: 100%; }
.btn:disabled, .btn.is-disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none !important;
  box-shadow: none !important;
}
.btn .fa-spinner { animation: hedwig-spin 0.8s linear infinite; }
@keyframes hedwig-spin { to { transform: rotate(360deg); } }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border-radius: var(--radius-pill);
  font-size: var(--fs-xs);
  font-weight: 600;
}
.chip-success { background: var(--color-success-bg); color: var(--color-success); }
.chip-warning { background: var(--color-warning-bg); color: var(--color-warning); }
.chip-danger  { background: var(--color-danger-bg);  color: var(--color-danger); }
.chip-info    { background: var(--color-info-bg);    color: var(--color-info); }
.chip-pending { background: var(--color-pending-bg); color: var(--color-pending); }

.glass {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
}

input, select, textarea {
  font-family: inherit;
  font-size: var(--fs-sm);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  background: var(--surface-card);
  color: var(--text-primary);
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--brand-primary);
  outline-offset: 1px;
  border-color: var(--brand-primary);
  box-shadow: 0 0 0 4px var(--focus-ring);
}

/* Select2 re-skin so it matches the rounded/brand system */
.select2-container--default .select2-selection--single {
  height: auto;
  padding: 9px 14px;
  border-radius: var(--radius-sm);
  border-color: var(--border-color);
  background: var(--surface-card);
}
.select2-container--default .select2-selection--single .select2-selection__rendered {
  line-height: 1.4;
  padding: 0;
  color: var(--text-primary);
}
.select2-container--default .select2-selection--single .select2-selection__arrow {
  height: 100%;
}
.select2-container--default .select2-selection--single .select2-selection__arrow b {
  border-color: var(--text-secondary) transparent transparent transparent;
}
.select2-container--default.select2-container--focus .select2-selection--single,
.select2-container--default.select2-container--open .select2-selection--single {
  border-color: var(--brand-primary);
}
.select2-dropdown {
  border-radius: var(--radius-sm);
  border-color: var(--border-color);
  background: var(--surface-card);
  overflow: hidden;
}
.select2-container--default .select2-results__option[aria-selected="true"] {
  background: var(--neutral-100);
  color: var(--text-primary);
}
.select2-container--default .select2-results__option--highlighted[aria-selected] {
  background-color: var(--brand-primary);
  color: #fff;
}

/* --------------------------------------------------------------------------
   3b. Forms
   -------------------------------------------------------------------------- */
.form-group {
  margin-bottom: 18px;
}
.form-group:last-child { margin-bottom: 0; }

.form-group > label,
label.form-label {
  display: block;
  font-size: var(--fs-xs);
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 6px;
  letter-spacing: 0.01em;
}
.form-group > label .text-danger { font-weight: 700; }

.form-row {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}
.form-row > .form-group { flex: 1 1 200px; min-width: 0; }

.form-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  padding-top: 20px;
  margin-top: 4px;
  border-top: 1px solid var(--border-color);
}

.form-hint {
  display: block;
  font-size: var(--fs-xs);
  color: var(--text-secondary);
  margin-top: 5px;
}
.form-error {
  display: block;
  font-size: var(--fs-xs);
  color: var(--color-danger);
  margin-top: 5px;
}

input, select, textarea {
  width: 100%;
  box-sizing: border-box;
}
input::placeholder, textarea::placeholder { color: var(--neutral-400); }
input[type="checkbox"], input[type="radio"] { width: auto; accent-color: var(--brand-primary); cursor: pointer; }
textarea { resize: vertical; min-height: 90px; }

input.is-invalid, select.is-invalid, textarea.is-invalid {
  border-color: var(--color-danger);
}
input.is-invalid:focus, select.is-invalid:focus, textarea.is-invalid:focus {
  outline-color: var(--color-danger);
  box-shadow: 0 0 0 4px rgba(217, 59, 59, 0.08);
}

fieldset { border: none; padding: 0; margin: 0; }

.form-fieldset {
  margin-top: 20px;
  padding: 16px 18px 4px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm, 8px);
}
.form-fieldset legend {
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--text-secondary);
  padding: 0 6px;
}

.input-group {
  position: relative;
  display: flex;
  align-items: center;
}
.input-group i.input-icon {
  position: absolute;
  left: 14px;
  color: var(--text-secondary);
  pointer-events: none;
}
.input-group input { padding-left: 38px; }

/* --------------------------------------------------------------------------
   4. Layout containers
   -------------------------------------------------------------------------- */
.container {
  width: 100%;
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 24px;
}

/* --------------------------------------------------------------------------
   4b. App Shell — header, sidebar nav, responsive drawer
   -------------------------------------------------------------------------- */
html, body { height: 100%; overflow-x: hidden; }

.app-shell {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  background: var(--app-bg);
  position: relative;
}

/* Decorative gradient bubbles behind the content area */
.app-shell::before,
.app-shell::after {
  content: '';
  position: fixed;
  z-index: 0;
  border-radius: 50%;
  filter: blur(72px);
  pointer-events: none;
  will-change: transform;
}
.app-shell::before {
  width: 560px;
  height: 560px;
  top: -160px;
  right: -140px;
  background: var(--orb-1);
  animation: hedwig-orb-float 18s ease-in-out infinite alternate;
}
.app-shell::after {
  width: 480px;
  height: 480px;
  bottom: -180px;
  left: 300px;
  background: var(--orb-2);
  animation: hedwig-orb-float 22s ease-in-out infinite alternate-reverse;
}
@keyframes hedwig-orb-float {
  0%   { transform: translate(0, 0) scale(1); }
  100% { transform: translate(-30px, 24px) scale(1.06); }
}
@media (prefers-reduced-motion: reduce) {
  .app-shell::before, .app-shell::after { animation: none; }
}

.app-header {
  height: var(--header-height);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 20px;
  background: var(--header-bg);
  border-bottom: 1px solid var(--border-color);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  position: sticky;
  top: 0;
  z-index: 500;
  box-shadow: 0 10px 28px -22px rgba(27, 37, 48, 0.5);
}
/* Thin brand accent line under the topbar */
.app-header::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  bottom: -1px;
  height: 2px;
  background: var(--app-card-stripe);
  opacity: 0.9;
  pointer-events: none;
}

.app-header-left, .app-header-right {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}
.app-header-right { flex-shrink: 0; }

.app-brand {
  display: flex;
  align-items: center;
  gap: 9px;
  font-weight: 800;
  font-size: 15px;
  color: var(--text-primary);
  white-space: nowrap;
  letter-spacing: 0.01em;
}
.app-brand i.fa-dove,
.app-brand .fa-shield {
  width: 30px;
  height: 30px;
  border-radius: 10px;
  background: var(--brand-gradient);
  color: #fff !important;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  box-shadow: 0 5px 12px var(--sidebar-glow);
}
.app-brand img { height: 26px; border-radius: 8px; box-shadow: 0 4px 10px var(--sidebar-glow); }
.app-brand-logo {
  height: 32px;
  width: auto;
  max-width: 160px;
  object-fit: contain;
  /* Rectangle source image — keep it uncropped, no circular/rounded mask */
  border-radius: 0;
  box-shadow: none;
  display: block;
}
@media (max-width: 600px) {
  .app-brand-logo { height: 26px; max-width: 120px; }
}

.app-header-divider {
  width: 1px;
  height: 20px;
  background: var(--border-color);
  flex-shrink: 0;
}
@media (max-width: 640px) { .app-header-divider { display: none; } }

.app-page-title {
  font-size: 15px;
  font-weight: 700;
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text-primary);
}

.actor-name {
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--text-secondary);
  white-space: nowrap;
}

.app-nav-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 12px;
  border: 1px solid var(--border-color);
  background: var(--surface-card);
  color: var(--text-primary);
  cursor: pointer;
  font-size: 15px;
  flex-shrink: 0;
  transition: background 0.15s ease;
}
.app-nav-toggle:hover { background: var(--neutral-100); }

/* --- Header utility controls: theme, language, logout --- */
.hd-ctrl {
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: 12px;
  border: 1px solid var(--border-color);
  background: var(--surface-card);
  color: var(--text-secondary);
  font-size: 14px;
  font-family: inherit;
  cursor: pointer;
  text-decoration: none !important;
  box-shadow: var(--shadow-sm);
  transition: color 0.18s ease, border-color 0.18s ease, transform 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}
.hd-ctrl:hover {
  color: #fff;
  border-color: transparent;
  background: var(--brand-gradient);
  transform: translateY(-1px);
  box-shadow: var(--shadow-glow);
}
.hd-ctrl:focus-visible {
  outline: 2px solid var(--brand-primary);
  outline-offset: 2px;
}
.hd-logout:hover {
  color: #fff;
  border-color: transparent;
  background: var(--color-danger);
  box-shadow: 0 8px 18px rgba(217, 59, 59, 0.35);
}

/* --- Language switcher (custom dropdown) --- */
.hd-lang { position: relative; }
.hd-lang-toggle {
  width: auto;
  gap: 7px;
  padding: 0 12px;
}
.hd-lang-current {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.01em;
  max-width: 88px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.hd-lang-caret { font-size: 9px; opacity: 0.75; transition: transform 0.18s ease; }
.hd-lang.is-open .hd-lang-caret { transform: rotate(180deg); }
.hd-lang-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 1200;
  min-width: 176px;
  background: var(--surface-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  padding: 6px;
  display: none;
  flex-direction: column;
  gap: 2px;
  animation: hedwig-lang-in 0.14s ease both;
}
@keyframes hedwig-lang-in {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}
.hd-lang.is-open .hd-lang-menu { display: flex; }
.hd-lang-option {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 12px;
  border: none;
  border-radius: 10px;
  background: transparent;
  color: var(--text-primary);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  text-align: left;
  transition: background 0.12s ease, color 0.12s ease;
}
.hd-lang-option:hover { background: var(--neutral-100); }
.hd-lang-option.is-active {
  background: var(--color-info-bg);
  color: var(--color-info);
}
.hd-lang-option .lang-name { flex: 1; }
.hd-lang-option .lang-tag {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.hd-lang-option.is-active .lang-tag { color: var(--color-info); }

/* Legacy native select styling (kept for backward compat; replaced at runtime) */
.hd-lang > .fa-globe { font-size: 13px; }
.hd-lang select {
  appearance: none;
  -webkit-appearance: none;
  border: none;
  background: transparent;
  color: var(--text-primary);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  padding: 0 16px 0 0;
  width: auto;
  outline: none;
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%239aa4b0' stroke-width='1.5' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right center;
}
.hd-lang select option { background: var(--surface-card); color: var(--text-primary); }

.app-body {
  display: flex;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

/* --- Highlighted sidebar --- */
.app-nav {
  width: var(--nav-width);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 18px 14px;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border-color);
  overflow-y: auto;
  position: relative;
  z-index: 1;
}
.app-nav::before {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at 15% 0%, rgba(91, 131, 173, 0.35), transparent 45%),
    radial-gradient(circle at 95% 95%, rgba(62, 95, 132, 0.28), transparent 50%);
}
.app-nav::after {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  width: 3px;
  height: 100%;
  background: var(--app-card-stripe);
  opacity: 0.55;
  pointer-events: none;
}

/* Injected brand header (see nav-toggle.js) */
.app-nav-brand {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 2px 4px 14px;
  margin-bottom: 4px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}
.app-nav-logo {
  width: 34px;
  height: 34px;
  border-radius: 11px;
  background: linear-gradient(135deg, #c65a68 0%, #e07a86 100%);
  color: #ffffff;
  font-weight: 800;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 5px 14px rgba(0, 0, 0, 0.3);
}
.app-nav-title {
  color: #fff;
  font-weight: 800;
  font-size: 15px;
  letter-spacing: 0.01em;
  white-space: nowrap;
}
.app-nav-label {
  position: relative;
  z-index: 1;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.4);
  padding: 2px 12px 6px;
}

.nav-item {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  border-radius: 12px;
  color: var(--sidebar-text);
  font-size: var(--fs-sm);
  font-weight: 600;
  white-space: nowrap;
  text-decoration: none !important;
  transition: background 0.18s ease, color 0.18s ease, transform 0.18s ease, box-shadow 0.18s ease;
}
.nav-item i { width: 18px; text-align: center; font-size: 15px; flex-shrink: 0; color: inherit; }
.nav-item:hover {
  background: var(--sidebar-hover);
  color: var(--sidebar-text-strong);
  transform: translateX(2px);
}
.nav-item.active {
  background: var(--sidebar-active-gradient);
  color: #fff;
  box-shadow: 0 8px 20px var(--sidebar-glow);
}
.nav-item.active i { color: #fff; }

.app-content {
  flex: 1;
  min-width: 0;
  padding: 28px 28px 44px;
  position: relative;
  z-index: 1;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  animation: hedwig-content-in 0.4s ease both;
}
@keyframes hedwig-content-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
@media (prefers-reduced-motion: reduce) {
  .app-content { animation: none; }
}

.app-nav-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(11, 17, 24, 0.5);
  z-index: 899;
}

@media (max-width: 1024px) and (min-width: 769px) {
  .app-nav { width: var(--nav-width-collapsed); padding: 18px 10px; }
  .app-nav .nav-item { justify-content: center; padding: 11px 0; }
  .app-nav .nav-item i { width: auto; font-size: 17px; }
  .app-nav .nav-item .nav-label { display: none; }
  .app-nav-brand { justify-content: center; padding: 2px 0 14px; }
  .app-nav-title, .app-nav-label { display: none; }
}

@media (max-width: 768px) {
  .app-header { padding: 0 14px; }
  .app-nav-toggle { display: inline-flex; }
  .app-page-title { font-size: var(--fs-base); }
  .actor-name { display: none; }

  .app-body { position: relative; }
  .app-nav {
    position: fixed;
    top: var(--header-height);
    bottom: 0;
    left: 0;
    width: 264px;
    max-width: 82vw;
    z-index: 900;
    box-shadow: var(--shadow-lg);
    transform: translateX(-100%);
    transition: transform 0.25s ease;
  }
  .app-shell.nav-open .app-nav { transform: translateX(0); }
  .app-shell.nav-open .app-nav-overlay { display: block; }

  .app-content { padding: 18px 16px 32px; }
}

@media (max-width: 480px) {
  .app-header-right { gap: 7px; }
  .app-brand { font-size: 14px; }
}

/* --------------------------------------------------------------------------
   4c. Stat / KPI cards
   -------------------------------------------------------------------------- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--surface-card);
  border-radius: var(--radius-md);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-color);
  transition: box-shadow 0.18s ease, transform 0.18s ease;
}
.stat-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.stat-card.loading { opacity: 0.6; }

.stat-label {
  font-size: var(--fs-xs);
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 600;
  margin-bottom: 6px;
}
.stat-value {
  font-size: var(--fs-2xl);
  font-weight: 800;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
  line-height: 1.15;
}

.kpi-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  margin-bottom: 24px;
}
.kpi-card {
  background: var(--surface-card);
  border-radius: var(--radius-md);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  gap: 14px;
  transition: box-shadow 0.18s ease, transform 0.18s ease;
}
.kpi-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.kpi-icon {
  width: 44px; height: 44px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center; font-size: 18px;
  color: #fff; flex-shrink: 0;
  box-shadow: 0 6px 14px rgba(27, 37, 48, 0.18);
}
.kpi-icon.indigo { background: var(--brand-primary); }
.kpi-icon.green  { background: var(--color-success); }
.kpi-icon.amber  { background: var(--color-warning); }
.kpi-icon.rose   { background: var(--color-danger); }
.kpi-icon.sky    { background: var(--color-info); }
.kpi-icon.purple { background: var(--brand-secondary); }
.kpi-value { font-size: var(--fs-xl); font-weight: 700; line-height: 1.2; color: var(--text-primary); font-variant-numeric: tabular-nums; }
.kpi-label { font-size: var(--fs-xs); color: var(--text-secondary); text-transform: uppercase; letter-spacing: .03em; }

/* --------------------------------------------------------------------------
   4d. Cards, section titles
   -------------------------------------------------------------------------- */
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-color);
}
.card-header h3, .card-header h4 { margin: 0; }
.card-body { padding: 20px; }
.card > .card-header:first-child { margin: -24px -24px 0; padding: 18px 24px; }
.card > .card-body:only-of-type,
.card > .card-body:last-child { margin: 0 -24px -24px; padding: 20px 24px; }
.card > .card-body:first-child { margin-top: -24px; padding-top: 24px; }

.section-title {
  font-size: var(--fs-sm); font-weight: 700; text-transform: uppercase;
  letter-spacing: .04em; color: var(--text-secondary); margin: 0 0 12px;
}

/* Content-level action toolbar (relocated from the old header) */
.page-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}
.page-toolbar-title { font-size: var(--fs-lg); font-weight: 700; margin: 0; }
.page-toolbar-sub { font-size: var(--fs-sm); color: var(--text-secondary); margin: 2px 0 0; }
.page-toolbar-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* --------------------------------------------------------------------------
   4e. Tables
   -------------------------------------------------------------------------- */
.table-responsive { overflow-x: auto; -webkit-overflow-scrolling: touch; }

table.table, .recent-table, table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--fs-sm);
}
table.table th, .recent-table th, table th {
  text-align: left;
  padding: 12px 16px;
  font-weight: 600;
  color: var(--text-secondary);
  font-size: var(--fs-xs);
  text-transform: uppercase;
  letter-spacing: .03em;
  background: var(--surface-table-header);
  border-bottom: 1px solid var(--border-color);
  white-space: nowrap;
}
table.table td, .recent-table td, table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--neutral-100);
  vertical-align: middle;
}
table.table tbody tr:hover, .recent-table tbody tr:hover { background: var(--surface-hover); }
table.table tbody tr:last-child td, .recent-table tbody tr:last-child td { border-bottom: none; }

.card > .table-responsive:only-child,
.card-body > .table-responsive { margin: 0 -4px; }

/* --------------------------------------------------------------------------
   4f. Badges / status chips
   -------------------------------------------------------------------------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: var(--radius-pill);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.02em;
  white-space: nowrap;
}
.badge-success, .badge-Closed, .badge-approved { background: var(--color-success-bg); color: var(--color-success); }
.badge-warning, .badge-Confirmed, .badge-pending { background: var(--color-warning-bg); color: var(--color-warning); }
.badge-danger, .badge-rejected  { background: var(--color-danger-bg); color: var(--color-danger); }
.badge-info, .badge-New { background: var(--color-info-bg); color: var(--color-info); }
.badge-primary, .badge-Edited { background: var(--color-pending-bg); color: var(--color-pending); }
.badge-secondary { background: var(--neutral-100); color: var(--neutral-600); }

/* --------------------------------------------------------------------------
   4g. Detail views
   -------------------------------------------------------------------------- */
.detail-wrap { max-width: 760px; margin: 0 auto; }
.detail-card {
  background: var(--surface-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-color);
  overflow: hidden;
}
.detail-header {
  padding: 24px 24px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.detail-header h2 { margin: 0; }
.detail-body {
  padding: 24px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 18px 24px;
}
.detail-field { margin-bottom: 0; }
.detail-label {
  font-size: 11px; font-weight: 700; color: var(--text-secondary);
  text-transform: uppercase; letter-spacing: .05em; margin-bottom: 4px;
}
.detail-value { font-size: var(--fs-base); color: var(--text-primary); word-break: break-word; }
.detail-row { display: flex; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--neutral-100); }
.detail-row:last-child { border-bottom: none; }
.rd-row { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; }
.rd-label { color: var(--text-secondary); font-size: var(--fs-sm); }
.rd-value { font-weight: 600; font-size: var(--fs-sm); }
.action-bar {
  display: flex; gap: 8px; flex-wrap: wrap;
  margin-top: 16px; padding: 16px 24px; border-top: 1px solid var(--border-color);
}

/* --------------------------------------------------------------------------
   4h. Alerts
   -------------------------------------------------------------------------- */
.alert {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: var(--fs-sm);
  margin-bottom: 16px;
  border: 1px solid transparent;
}
.alert-danger  { background: var(--color-danger-bg);  color: var(--color-danger); border-color: rgba(217,59,59,.2); }
.alert-success { background: var(--color-success-bg); color: var(--color-success); border-color: rgba(31,122,69,.2); }
.alert-warning { background: var(--color-warning-bg); color: var(--color-warning); border-color: rgba(168,102,10,.2); }
.alert-info    { background: var(--color-info-bg);    color: var(--color-info); border-color: rgba(3,105,161,.2); }

/* --------------------------------------------------------------------------
   4i. Pagination
   -------------------------------------------------------------------------- */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 16px 0 0;
  flex-wrap: wrap;
}
.pagination button, .pagination a {
  min-width: 34px;
  height: 34px;
  padding: 0 8px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  background: var(--surface-card);
  color: var(--text-primary);
  font-size: var(--fs-sm);
  cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
}
.pagination button:hover, .pagination a:hover { background: var(--neutral-100); }
.pagination button.active, .pagination a.active { background: var(--brand-primary); color: #fff; border-color: var(--brand-primary); }
.pagination button:disabled { opacity: 0.4; cursor: not-allowed; }

/* --------------------------------------------------------------------------
   4j. Status tabs
   -------------------------------------------------------------------------- */
.status-tabs {
  display: flex; gap: 4px; margin-bottom: 16px; background: var(--surface-card);
  padding: 6px; border-radius: var(--radius-lg); box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-color);
  overflow-x: auto;
}
.status-tab {
  padding: 9px 18px; border: none; border-radius: var(--radius-md);
  background: transparent; color: var(--text-secondary); cursor: pointer;
  font-size: var(--fs-sm); font-weight: 600; white-space: nowrap;
  transition: all .15s;
}
.status-tab:hover { background: var(--neutral-100); }
.status-tab.active { background: var(--brand-gradient); color: #fff; box-shadow: var(--shadow-sm); }

/* --------------------------------------------------------------------------
   4k. OTP input boxes
   -------------------------------------------------------------------------- */
.otp-box-row { display: flex; gap: 10px; justify-content: center; margin: 8px 0 4px; }
.otp-box {
  width: 44px; height: 52px;
  text-align: center;
  font-size: 20px;
  font-weight: 700;
  padding: 0;
}

/* --------------------------------------------------------------------------
   5. Accessibility base
   -------------------------------------------------------------------------- */
:focus-visible {
  outline: 2px solid var(--brand-primary);
  outline-offset: 2px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Reduced-motion respect */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
