/* ================================================================
   SPARK ENGINEERING EPMS — Design System v2
   Theme: Deep slate base · Emerald accent · Amber highlights
   ================================================================ */

/* ----------------------------------------------------------------
   1. CUSTOM PROPERTIES
   ---------------------------------------------------------------- */
:root {
  /* Brand */
  --c-brand:        #10b981;   /* emerald-500  */
  --c-brand-dark:   #059669;   /* emerald-600  */
  --c-brand-xdark:  #047857;   /* emerald-700  */
  --c-brand-light:  #d1fae5;   /* emerald-100  */
  --c-brand-faint:  #ecfdf5;   /* emerald-50   */

  /* Accent */
  --c-amber:        #f59e0b;
  --c-amber-light:  #fef3c7;
  --c-red:          #ef4444;
  --c-red-light:    #fee2e2;
  --c-blue:         #3b82f6;
  --c-blue-light:   #dbeafe;
  --c-purple:       #8b5cf6;
  --c-purple-light: #ede9fe;
  --c-sky:          #0ea5e9;
  --c-sky-light:    #e0f2fe;

  /* Surface: Dimmed Light / Slate Default (Low glare, eye-friendly, Android & OLED optimized) */
  --bg:             #0f172a;
  --bg-2:           #1e293b;
  --surface:        #1e293b;
  --surface-2:      #273549;
  --surface-3:      #334155;
  --border:         #334155;
  --border-2:       #475569;

  /* Text */
  --text:           #f8fafc;
  --text-2:         #cbd5e1;
  --text-3:         #94a3b8;
  --text-4:         #64748b;
  --text-inv:       #0f172a;

  /* Shadows */
  --shadow-xs: 0 1px 2px 0 rgb(0 0 0 / .3);
  --shadow-sm: 0 1px 3px 0 rgb(0 0 0 / .4), 0 1px 2px -1px rgb(0 0 0 / .4);
  --shadow:    0 4px 6px -1px rgb(0 0 0 / .4), 0 2px 4px -2px rgb(0 0 0 / .4);
  --shadow-md: 0 10px 15px -3px rgb(0 0 0 / .5), 0 4px 6px -4px rgb(0 0 0 / .5);
  --shadow-lg: 0 20px 25px -5px rgb(0 0 0 / .6), 0 8px 10px -6px rgb(0 0 0 / .6);
  --shadow-xl: 0 25px 50px -12px rgb(0 0 0 / .7);

  /* Border radius */
  --r-xs:  4px;
  --r-sm:  6px;
  --r:     8px;
  --r-md:  10px;
  --r-lg:  14px;
  --r-xl:  18px;
  --r-2xl: 24px;
  --r-full:9999px;

  /* Transitions */
  --ease:      cubic-bezier(.4, 0, .2, 1);
  --t-fast:    120ms;
  --t:         220ms;
  --t-slow:    380ms;

  /* Sidebar */
  --sidebar-w: 240px;

  /* Z-index scale */
  --z-dropdown: 40;
  --z-sticky:   50;
  --z-overlay:  100;
  --z-modal:    200;
  --z-confirm:  300;
  --z-toast:    400;
}

/* Dimmed dark palette (matches default :root) */
body.dark {
  --bg:        #0f172a;
  --bg-2:      #1e293b;
  --surface:   #1e2a3a;
  --surface-2: #243040;
  --surface-3: #2c3a4e;
  --border:    #2e3d52;
  --border-2:  #3d5068;
  --text:      #f1f5f9;
  --text-2:    #cbd5e1;
  --text-3:    #94a3b8;
  --text-4:    #64748b;
  --text-inv:  #0f172a;
}

/* Optional high-brightness Light Mode */
body.light {
  --bg:             #f1f5f9;
  --bg-2:           #e8eef5;
  --surface:        #ffffff;
  --surface-2:      #f8fafc;
  --surface-3:      #f1f5f9;
  --border:         #e2e8f0;
  --border-2:       #cbd5e1;
  --text:           #0f172a;
  --text-2:         #334155;
  --text-3:         #64748b;
  --text-4:         #94a3b8;
  --text-inv:       #ffffff;
  --shadow-xs: 0 1px 2px 0 rgb(0 0 0 / .05);
  --shadow-sm: 0 1px 3px 0 rgb(0 0 0 / .10), 0 1px 2px -1px rgb(0 0 0 / .10);
  --shadow:    0 4px 6px -1px rgb(0 0 0 / .10), 0 2px 4px -2px rgb(0 0 0 / .10);
  --shadow-md: 0 10px 15px -3px rgb(0 0 0 / .10), 0 4px 6px -4px rgb(0 0 0 / .10);
  --shadow-lg: 0 20px 25px -5px rgb(0 0 0 / .10), 0 8px 10px -6px rgb(0 0 0 / .10);
  --shadow-xl: 0 25px 50px -12px rgb(0 0 0 / .25);
}

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

html, body {
  -webkit-font-smoothing: antialiased;
  scroll-behavior: smooth;
  max-width: 100vw;
  overflow-x: hidden;
}

body {
  font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  max-width: 100vw;
  overflow-x: hidden;
  transition: background var(--t) var(--ease), color var(--t) var(--ease);
}

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

/* Accessibility focus ring */
:focus-visible {
  outline: 2px solid var(--c-brand);
  outline-offset: 2px;
}

/* ----------------------------------------------------------------
   3. SCROLLBARS
   ---------------------------------------------------------------- */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--border-2);
  border-radius: var(--r-full);
}
::-webkit-scrollbar-thumb:hover { background: var(--text-4); }

/* ----------------------------------------------------------------
   4. TYPOGRAPHY HELPERS
   ---------------------------------------------------------------- */
.text-xs   { font-size: 11px; }
.text-sm   { font-size: 12px; }
.text-base { font-size: 14px; }
.text-lg   { font-size: 16px; }
.text-xl   { font-size: 18px; }
.text-2xl  { font-size: 22px; }

.font-medium { font-weight: 500; }
.font-semibold { font-weight: 600; }
.font-bold   { font-weight: 700; }
.font-black  { font-weight: 800; }

.text-muted  { color: var(--text-3); }
.text-faint  { color: var(--text-4); }
.text-green  { color: var(--c-brand); }
.text-red    { color: var(--c-red); }
.text-amber  { color: var(--c-amber); }
.text-blue   { color: var(--c-blue); }

.tabular-nums { font-variant-numeric: tabular-nums; }
.text-balance { text-wrap: balance; }
.text-pretty  { text-wrap: pretty; }

.truncate { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ----------------------------------------------------------------
   5. PAGE TRANSITIONS
   ---------------------------------------------------------------- */
.page { display: none; }
.page.active { display: block; }

.module-wrap {
  animation: fadeUp .3s var(--ease) both;
}

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

@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes slideDown {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}

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

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

@keyframes shimmer {
  0%   { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}

/* ----------------------------------------------------------------
   6. LAYOUT — SIDEBAR + MAIN
   ---------------------------------------------------------------- */
#app-shell {
  display: flex;
  min-height: 100vh;
  min-height: 100dvh;
}

/* ── Sidebar ── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  height: 100dvh;
  z-index: var(--z-sticky);
  transition: transform var(--t) var(--ease), width var(--t) var(--ease);
  overflow: hidden;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 16px 14px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.sidebar-brand-icon {
  width: 34px;
  height: 34px;
  background: linear-gradient(135deg, var(--c-brand), var(--c-brand-dark));
  border-radius: var(--r-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  box-shadow: 0 4px 12px rgb(16 185 129 / .3);
  flex-shrink: 0;
}

.sidebar-brand-logo {
  width: 38px;
  height: 38px;
  object-fit: contain;
  flex-shrink: 0;
}

.sidebar-brand-text {
  font-size: 13.5px;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -.2px;
  line-height: 1.25;
}

.sidebar-brand-sub {
  font-size: 10px;
  color: var(--text-3);
  font-weight: 600;
  letter-spacing: .02em;
  margin-top: 2px;
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 12px 8px;
}

.nav-section { margin-bottom: 20px; }

.nav-section-title {
  font-size: 10px;
  font-weight: 700;
  color: var(--text-4);
  text-transform: uppercase;
  letter-spacing: .08em;
  padding: 0 8px;
  margin-bottom: 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: var(--r);
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-3);
  background: none;
  border: none;
  width: 100%;
  text-align: left;
  transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
  margin-bottom: 1px;
  white-space: nowrap;
}

.nav-item .nav-icon {
  font-size: 16px;
  width: 20px;
  text-align: center;
  flex-shrink: 0;
}

.nav-item:hover {
  background: var(--surface-2);
  color: var(--text);
}

.nav-item.active {
  background: var(--c-brand-faint);
  color: var(--c-brand-dark);
  font-weight: 700;
}
body.dark .nav-item.active {
  background: rgb(16 185 129 / .12);
  color: var(--c-brand);
}

.sidebar-footer {
  padding: 12px 8px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

/* Sidebar overlay (mobile) */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgb(0 0 0 / .5);
  z-index: calc(var(--z-sticky) - 1);
  backdrop-filter: blur(2px);
  animation: fadeIn var(--t-fast) var(--ease);
}
.sidebar-overlay.open { display: block; }

/* ── Main ── */
.main {
  flex: 1;
  margin-left: var(--sidebar-w);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
  min-width: 0;
  max-width: 100%;
  overflow-x: hidden;
  transition: margin-left var(--t) var(--ease);
}

/* Offline Test Banner coordination */
#offline-test-strip {
  position: sticky;
  top: 0;
  z-index: calc(var(--z-sticky) + 1);
}
#offline-test-strip + .topbar {
  top: 35px;
}

/* ── Topbar ── */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 20px;
  height: 56px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: var(--z-sticky);
  flex-shrink: 0;
}

.topbar-left { display: flex; align-items: center; gap: 12px; }
.topbar-right { display: flex; align-items: center; gap: 10px; }
.topbar-center { display: flex; align-items: center; gap: 8px; }

.hamburger {
  display: none;
  width: 38px;
  height: 38px;
  border-radius: var(--r);
  background: var(--surface-2);
  border: 1px solid var(--border);
  cursor: pointer;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}

/* Notice bar */
.notice-bar {
  padding: 6px 0;
  background: linear-gradient(90deg, var(--c-amber-light), #fffdf0, var(--c-amber-light));
  border-bottom: 1px solid #fde68a;
  overflow: hidden;
  white-space: nowrap;
}
.notice-bar-inner {
  display: inline-block;
  padding-left: 100%;
  animation: scrollNotice 35s linear infinite;
}
@keyframes scrollNotice {
  from { transform: translateX(0); }
  to   { transform: translateX(-100%); }
}
.notice-label { font-weight: 800; color: var(--c-amber); margin-right: 8px; }
.notice-text  { font-size: 12px; font-weight: 600; color: #78350f; }

/* ── Content ── */
.content {
  flex: 1;
  padding: 24px 20px;
  padding-bottom: max(24px, env(safe-area-inset-bottom, 24px));
  max-width: 100%;
  min-width: 0;
  width: 100%;
  margin: 0 auto;
  box-sizing: border-box;
}

.panel, .card, .stat-card, .tab-panel {
  min-width: 0;
  max-width: 100%;
  box-sizing: border-box;
}

/* ----------------------------------------------------------------
   7. PAGE HEADER
   ---------------------------------------------------------------- */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.page-header-left h1 {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -.3px;
}

.page-header-left p {
  font-size: 12px;
  color: var(--text-3);
  margin-top: 2px;
}

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

/* ----------------------------------------------------------------
   8. BUTTONS
   ---------------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 16px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  border-radius: var(--r);
  cursor: pointer;
  border: 1.5px solid transparent;
  transition:
    background var(--t-fast) var(--ease),
    border-color var(--t-fast) var(--ease),
    box-shadow var(--t-fast) var(--ease),
    transform var(--t-fast) var(--ease);
  white-space: nowrap;
  user-select: none;
  background: var(--surface-2);
  color: var(--text);
  border-color: var(--border);
}

.btn:hover:not(:disabled) {
  background: var(--surface-3);
  transform: translateY(-1px);
  box-shadow: var(--shadow-xs);
}

.btn:active:not(:disabled) {
  transform: translateY(0) scale(.98);
  box-shadow: none;
}

.btn:disabled { opacity: .45; cursor: not-allowed; }

/* Variants */
.btn-primary {
  background: linear-gradient(135deg, var(--c-brand), var(--c-brand-dark));
  color: #fff;
  border-color: transparent;
  box-shadow: 0 4px 12px rgb(16 185 129 / .25);
}
.btn-primary:hover:not(:disabled) {
  background: linear-gradient(135deg, var(--c-brand-dark), var(--c-brand-xdark));
  box-shadow: 0 6px 20px rgb(16 185 129 / .35);
}

.btn-danger {
  background: var(--c-red-light);
  color: var(--c-red);
  border-color: #fca5a5;
}
.btn-danger:hover:not(:disabled) {
  background: var(--c-red);
  color: #fff;
  border-color: var(--c-red);
}

.btn-amber {
  background: var(--c-amber-light);
  color: #92400e;
  border-color: #fcd34d;
}
.btn-amber:hover:not(:disabled) {
  background: var(--c-amber);
  color: #fff;
  border-color: var(--c-amber);
}

.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--text-3);
}
.btn-ghost:hover:not(:disabled) {
  background: var(--surface-2);
  color: var(--text);
}

/* Sizes */
.btn-xs { padding: 4px 10px; font-size: 11px; border-radius: var(--r-sm); gap: 4px; }
.btn-sm { padding: 6px 12px; font-size: 12px; border-radius: var(--r-sm); }
.btn-lg { padding: 12px 24px; font-size: 15px; border-radius: var(--r-md); }

.btn-icon {
  padding: 7px;
  border-radius: var(--r);
  background: transparent;
  border: 1px solid var(--border);
}

/* ----------------------------------------------------------------
   9. FORM ELEMENTS
   ---------------------------------------------------------------- */
label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: .05em;
  margin-bottom: 5px;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="date"],
input[type="time"],
input[type="search"],
input[type="url"],
input[type="tel"],
select,
textarea {
  width: 100%;
  padding: 9px 12px;
  font-family: inherit;
  font-size: 13px;
  color: var(--text);
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--r);
  transition:
    border-color var(--t-fast) var(--ease),
    box-shadow   var(--t-fast) var(--ease);
  outline: none;
  appearance: none;
}

input:hover, select:hover, textarea:hover { border-color: var(--border-2); }

input:focus, select:focus, textarea:focus {
  border-color: var(--c-brand);
  box-shadow: 0 0 0 3px rgb(16 185 129 / .15);
}

input::placeholder, textarea::placeholder { color: var(--text-4); }

select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2.5'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 32px;
}

textarea { resize: vertical; min-height: 72px; }

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

.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
}

/* Search input with icon */
.search-wrap { position: relative; }
.search-wrap input {
  padding-left: 36px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='15' height='15' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cpath d='m21 21-4.35-4.35'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: 11px center;
}

/* File input */
input[type="file"] {
  padding: 6px 10px;
  font-size: 12px;
  cursor: pointer;
}
input[type="file"]::file-selector-button {
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 600;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  cursor: pointer;
  margin-right: 8px;
  color: var(--text);
}

/* Toggle switch */
.toggle-wrap { display: flex; align-items: center; gap: 10px; }
.toggle {
  position: relative;
  display: inline-block;
  width: 40px;
  height: 22px;
  flex-shrink: 0;
}
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute;
  inset: 0;
  background: var(--border-2);
  border-radius: var(--r-full);
  transition: background var(--t-fast) var(--ease);
  cursor: pointer;
}
.toggle-slider::before {
  content: '';
  position: absolute;
  width: 16px;
  height: 16px;
  background: #fff;
  border-radius: 50%;
  left: 3px;
  top: 3px;
  transition: transform var(--t-fast) var(--ease);
  box-shadow: var(--shadow-xs);
}
.toggle input:checked + .toggle-slider { background: var(--c-brand); }
.toggle input:checked + .toggle-slider::before { transform: translateX(18px); }

/* Tag input */
.tags-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  padding: 7px 10px;
  border: 1.5px solid var(--border);
  border-radius: var(--r);
  min-height: 42px;
  background: var(--surface);
  cursor: text;
  transition: border-color var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease);
}
.tags-wrap:focus-within {
  border-color: var(--c-brand);
  box-shadow: 0 0 0 3px rgb(16 185 129 / .15);
}
.tag-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--c-brand-light);
  color: var(--c-brand-xdark);
  font-size: 11px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: var(--r-full);
}
.tag-chip button {
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  color: inherit;
  opacity: .6;
  font-size: 14px;
  line-height: 1;
  display: inline-flex;
}
.tag-chip button:hover { opacity: 1; }
.tag-input {
  flex: 1;
  min-width: 80px;
  border: none !important;
  box-shadow: none !important;
  background: transparent !important;
  padding: 3px 4px;
  font-size: 13px;
}

/* ----------------------------------------------------------------
   10. PANELS & CARDS
   ---------------------------------------------------------------- */
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 18px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-xs);
  transition: box-shadow var(--t-fast) var(--ease);
}

.panel-title {
  font-size: 14px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

.panel-subtitle {
  font-size: 12px;
  color: var(--text-3);
  margin-top: -10px;
  margin-bottom: 14px;
}

/* Stat cards */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 16px;
  position: relative;
  overflow: hidden;
  min-width: 0; /* required so ellipsis can work — grid items don't shrink below content by default */
  transition: box-shadow var(--t-fast) var(--ease), transform var(--t-fast) var(--ease);
}
.stat-card:hover {
  box-shadow: var(--shadow);
  transform: translateY(-2px);
}

.stat-card-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--r-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  margin-bottom: 12px;
}
.stat-icon-green  { background: var(--c-brand-light);  color: var(--c-brand-xdark); }
.stat-icon-amber  { background: var(--c-amber-light);  color: #92400e; }
.stat-icon-red    { background: var(--c-red-light);    color: #991b1b; }
.stat-icon-blue   { background: var(--c-blue-light);   color: #1e40af; }
.stat-icon-purple { background: var(--c-purple-light); color: #5b21b6; }
.stat-icon-sky    { background: var(--c-sky-light);    color: #075985; }

.stat-value {
  font-size: clamp(16px, 5vw, 24px);
  font-weight: 800;
  letter-spacing: -.5px;
  line-height: 1.15;
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-variant-numeric: tabular-nums;
}

.stat-label {
  font-size: 12px;
  color: var(--text-3);
  font-weight: 500;
}

.stat-trend {
  position: absolute;
  top: 14px;
  right: 14px;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 7px;
  border-radius: var(--r-full);
}
.stat-trend.up   { background: var(--c-brand-light); color: var(--c-brand-xdark); }
.stat-trend.down { background: var(--c-red-light);   color: #991b1b; }

/* Info cards (small key-value) */
.info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}

.icard {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 14px;
  position: relative;
  transition: box-shadow var(--t-fast) var(--ease);
}
.icard:hover { box-shadow: var(--shadow-sm); }
.icard .lbl { font-size: 10px; color: var(--text-4); font-weight: 700; text-transform: uppercase; letter-spacing: .05em; margin-bottom: 5px; }
.icard .val { font-size: 18px; font-weight: 800; line-height: 1.2; }

/* ----------------------------------------------------------------
   11. TABLES
   ---------------------------------------------------------------- */
.tbl-wrap, .table-responsive, .table-wrap {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-x pan-y;
  overscroll-behavior-x: contain;
  border-radius: var(--r-md);
  border: 1px solid var(--border);
  position: relative;
  margin-bottom: 16px;
}

.tbl, .table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  min-width: 500px;
}

.tbl thead th, .table thead th, .table th {
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: .04em;
  padding: 11px 12px;
  background: var(--surface-2);
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
  position: sticky;
  top: 0;
  z-index: 2;
}

.tbl tbody td, .table tbody td, .table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.tbl tbody tr, .table tbody tr { transition: background var(--t-fast) var(--ease); }
.tbl tbody tr:hover td, .table tbody tr:hover td { background: var(--surface-2); }
.tbl tbody tr:last-child td, .table tbody tr:last-child td { border-bottom: none; }
.tbl tbody tr.clickable, .table tbody tr.clickable { cursor: pointer; }

/* Table inline inputs */
.tbl input, .table input,
.tbl select, .table select,
.tbl textarea, .table textarea {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--r-xs);
  padding: 6px 8px;
  font-size: 13px;
  box-sizing: border-box;
}

.tbl input:focus, .table input:focus,
.tbl select:focus, .table select:focus,
.tbl textarea:focus, .table textarea:focus {
  border-color: var(--c-brand);
  outline: none;
}

.tbl .sel-col { width: 38px; text-align: center; }
.tbl .num-col { text-align: right; }

/* Row checkbox batch */
.batch-bar {
  display: none;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: var(--c-red-light);
  border-radius: var(--r);
  margin-bottom: 8px;
  animation: slideDown var(--t-fast) var(--ease);
}
.batch-bar.visible { display: flex; }

/* Expandable sub-row */
.sub-wrap {
  display: none;
  padding: 12px;
  background: var(--surface-2);
  border-top: 1px solid var(--border);
}
.sub-wrap.open { display: block; animation: slideDown var(--t-fast) var(--ease); }

/* Items sub-table */
.items-tbl { width: 100%; border-collapse: collapse; font-size: 12px; margin-top: 6px; }
.items-tbl th { font-size: 10px; font-weight: 700; color: var(--text-3); text-transform: uppercase; padding: 6px 8px; background: var(--surface-3); border-bottom: 1px solid var(--border); }
.items-tbl td { padding: 5px 8px; border-bottom: 1px solid var(--border); }
.items-tbl tr:last-child td { border-bottom: none; }
.items-tbl tfoot td { font-weight: 800; background: var(--c-brand-faint); color: var(--c-brand-xdark); border-top: 2px solid var(--c-brand-light); }

/* ----------------------------------------------------------------
   12. BADGES
   ---------------------------------------------------------------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: var(--r-full);
  line-height: 1;
  white-space: nowrap;
}

.b-green   { background: var(--c-brand-light);  color: #065f46; }
.b-amber   { background: var(--c-amber-light);  color: #92400e; }
.b-red     { background: var(--c-red-light);    color: #991b1b; }
.b-blue    { background: var(--c-blue-light);   color: #1e40af; }
.b-purple  { background: var(--c-purple-light); color: #5b21b6; }
.b-sky     { background: var(--c-sky-light);    color: #075985; }
.b-gray    { background: var(--surface-3);      color: var(--text-3); border: 1px solid var(--border); }
.b-admin   { background: var(--c-purple-light); color: #5b21b6; }
.b-manager { background: var(--c-brand-light);  color: #065f46; }
.b-viewer  { background: var(--surface-3);      color: var(--text-3); }

/* ----------------------------------------------------------------
   13. TABS
   ---------------------------------------------------------------- */
.tab-bar, .tabs-bar, .tabs-nav {
  display: flex;
  gap: 4px;
  border-bottom: 2px solid var(--border);
  margin-bottom: 18px;
  overflow-x: auto;
  max-width: 100%;
  white-space: nowrap;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.tab-bar::-webkit-scrollbar, .tabs-bar::-webkit-scrollbar, .tabs-nav::-webkit-scrollbar { display: none; }

.tab-btn {
  padding: 10px 18px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-3);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  cursor: pointer;
  white-space: nowrap;
  transition: color var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease);
}
.tab-btn:hover:not(.active) { color: var(--text); }
.tab-btn.active { color: var(--c-brand); border-bottom-color: var(--c-brand); }

.tab-panel { display: none; }
.tab-panel.active { display: block; animation: fadeIn var(--t-fast) var(--ease); }

/* Settings tabs */
.settings-tab { display: none; }
.settings-tab.active { display: block; animation: fadeIn var(--t-fast) var(--ease); }

/* ----------------------------------------------------------------
   14. ADD / EDIT ROWS (inline forms)
   ---------------------------------------------------------------- */
.add-row, .edit-row {
  display: none;
  padding: 16px;
  border-radius: var(--r-lg);
  margin-top: 10px;
  border: 1.5px solid var(--c-brand-light);
  background: linear-gradient(135deg, var(--c-brand-faint), #f0fdf4);
  animation: slideDown var(--t) var(--ease);
}
.add-row.open, .edit-row.open { display: block; }
.edit-row {
  border-color: #fde68a;
  background: linear-gradient(135deg, var(--c-amber-light), #fffbeb);
}

.section-sep {
  font-size: 11px;
  font-weight: 800;
  color: var(--c-brand);
  text-transform: uppercase;
  letter-spacing: .06em;
  padding: 10px 0 8px;
  border-bottom: 2px solid var(--c-brand-light);
  margin: 14px 0 10px;
}

/* ----------------------------------------------------------------
   15. MODALS
   ---------------------------------------------------------------- */
.modal-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgb(0 0 0 / .55);
  backdrop-filter: blur(3px);
  z-index: var(--z-modal);
  justify-content: center;
  align-items: center;
  padding: 16px;
  animation: fadeIn var(--t-fast) var(--ease);
}
.modal-backdrop.open { display: flex; }

.modal {
  background: var(--surface);
  border-radius: var(--r-xl);
  padding: 24px;
  width: 100%;
  max-width: 720px;
  max-height: 90vh;
  max-height: 90dvh;
  overflow-y: auto;
  box-shadow: var(--shadow-xl);
  border: 1px solid var(--border);
  animation: slideUp var(--t) var(--ease);
}

.modal-sm  { max-width: 460px; }
.modal-lg  { max-width: 900px; }
.modal-xl  { max-width: 1100px; }

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
}
.modal-title { font-size: 17px; font-weight: 800; text-wrap: balance; }
.modal-close {
  width: 36px;
  height: 36px;
  min-width: 36px;
  min-height: 36px;
  border-radius: var(--r);
  background: none;
  border: 1px solid var(--border);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  color: var(--text-3);
  flex-shrink: 0;
  transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
}
.modal-close:hover { background: var(--c-red-light); color: var(--c-red); }

/* Confirm dialog */
.confirm-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgb(0 0 0 / .6);
  backdrop-filter: blur(4px);
  z-index: var(--z-confirm);
  justify-content: center;
  align-items: center;
  padding: 16px;
}
.confirm-backdrop.open { display: flex; animation: fadeIn var(--t-fast) var(--ease); }

.confirm-box {
  background: var(--surface);
  border-radius: var(--r-xl);
  padding: 28px;
  max-width: 400px;
  width: 100%;
  text-align: center;
  box-shadow: var(--shadow-xl);
  border: 1px solid var(--border);
  animation: slideUp var(--t) var(--ease);
}
.confirm-icon { font-size: 40px; margin-bottom: 12px; }
.confirm-title { font-size: 18px; font-weight: 800; margin-bottom: 8px; }
.confirm-msg { font-size: 13px; color: var(--text-3); margin-bottom: 22px; line-height: 1.55; }
.confirm-actions { display: flex; gap: 10px; justify-content: center; }

/* ----------------------------------------------------------------
   16. TOAST NOTIFICATIONS
   ---------------------------------------------------------------- */
#toast-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 18px;
  border-radius: var(--r-lg);
  font-size: 13px;
  font-weight: 600;
  color: #fff;
  box-shadow: var(--shadow-md);
  max-width: 380px;
  pointer-events: auto;
  animation: toastIn .3s var(--ease) both;
}
.toast.out { animation: toastOut .3s var(--ease) both; }

.toast-success { background: rgb(16 185 129 / .95); }
.toast-error   { background: rgb(239 68 68 / .95); }
.toast-warn    { background: rgb(245 158 11 / .95); }
.toast-info    { background: rgb(59 130 246 / .95); }

@keyframes toastIn  { from { transform: translateX(110%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@keyframes toastOut { from { transform: translateX(0); opacity: 1; } to { transform: translateX(110%); opacity: 0; } }

/* ----------------------------------------------------------------
   17. PROGRESS BARS
   ---------------------------------------------------------------- */
.progress-wrap {
  height: 7px;
  background: var(--surface-3);
  border-radius: var(--r-full);
  overflow: hidden;
  margin: 5px 0;
}

.progress-fill {
  height: 100%;
  border-radius: var(--r-full);
  background: linear-gradient(90deg, var(--c-brand), var(--c-brand-dark));
  position: relative;
  transition: width .5s var(--ease);
}

.progress-fill::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgb(255 255 255 / .3), transparent);
  animation: shimmer 2s infinite;
}

/* ----------------------------------------------------------------
   18. DOCUMENT CARDS
   ---------------------------------------------------------------- */
.doc-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 12px;
}

.doc-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 14px;
  transition: box-shadow var(--t-fast) var(--ease), transform var(--t-fast) var(--ease);
}
.doc-card:hover { box-shadow: var(--shadow); transform: translateY(-2px); }

.doc-card-header { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 10px; }

.doc-icon {
  width: 44px;
  height: 44px;
  background: var(--surface-2);
  border-radius: var(--r);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
}

.doc-name { font-size: 13px; font-weight: 700; line-height: 1.3; margin-bottom: 3px; word-break: break-word; }
.doc-meta { font-size: 11px; color: var(--text-3); line-height: 1.5; }
.doc-folder-tag {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  background: var(--c-brand-light);
  color: var(--c-brand-xdark);
  padding: 2px 7px;
  border-radius: var(--r-full);
  margin: 2px 2px 0 0;
}

/* ----------------------------------------------------------------
   19. FOLDER SIDEBAR (General Docs)
   ---------------------------------------------------------------- */
.folder-layout { display: flex; gap: 16px; align-items: flex-start; }
.folder-sidebar { width: 200px; flex-shrink: 0; }
.folder-main { flex: 1; min-width: 0; }

.folder-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  border-radius: var(--r);
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-3);
  transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
  margin-bottom: 2px;
  gap: 6px;
}
.folder-item:hover { background: var(--surface-2); color: var(--text); }
.folder-item.active { background: var(--c-brand-faint); color: var(--c-brand-xdark); font-weight: 700; }
body.dark .folder-item.active { background: rgb(16 185 129 / .12); color: var(--c-brand); }

.folder-item-actions { display: flex; gap: 2px; flex-shrink: 0; opacity: 0; transition: opacity var(--t-fast); }
.folder-item:hover .folder-item-actions { opacity: 1; }

.folder-count {
  font-size: 10px;
  background: var(--border);
  color: var(--text-3);
  padding: 2px 7px;
  border-radius: var(--r-full);
  font-weight: 700;
  margin-left: auto;
}

/* ----------------------------------------------------------------
   20. MATERIAL CARDS
   ---------------------------------------------------------------- */
.mat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; }

.mat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 16px;
  transition: box-shadow var(--t-fast) var(--ease), transform var(--t-fast) var(--ease);
}
.mat-card:hover { box-shadow: var(--shadow); transform: translateY(-2px); }

.mat-card-head { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 8px; }
.mat-card-name { font-size: 14px; font-weight: 700; }
.mat-cat-tag { font-size: 10px; font-weight: 700; background: var(--c-brand-light); color: var(--c-brand-xdark); padding: 3px 8px; border-radius: var(--r-full); }
.mat-price { font-size: 22px; font-weight: 800; color: var(--c-brand); margin: 6px 0; }
.mat-trend { font-size: 11px; font-weight: 700; }
.mat-trend.up { color: var(--c-brand-dark); }
.mat-trend.down { color: var(--c-red); }
.mat-sparkline { height: 30px; display: flex; align-items: flex-end; gap: 2px; margin: 8px 0; }
.mat-bar { flex: 1; background: var(--c-brand); border-radius: 2px 2px 0 0; min-height: 2px; opacity: .65; transition: height .3s, opacity var(--t-fast); }
.mat-bar:hover { opacity: 1; }

/* ----------------------------------------------------------------
   21. TIMELINE
   ---------------------------------------------------------------- */
.timeline { display: flex; flex-direction: column; gap: 2px; }

.tl-item {
  display: flex;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--r);
  border-left: 3px solid var(--c-brand);
  background: var(--surface-2);
  transition: transform var(--t-fast) var(--ease);
}
.tl-item:hover { transform: translateX(3px); }

.tl-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--c-brand);
  flex-shrink: 0;
  margin-top: 5px;
}

.tl-time { font-size: 10px; color: var(--text-4); font-weight: 600; margin-bottom: 3px; }
.tl-action { font-size: 12px; font-weight: 700; margin-bottom: 2px; }
.tl-desc { font-size: 12px; color: var(--text-3); line-height: 1.4; }

.tl-diff { margin-top: 6px; font-size: 11px; padding: 6px 8px; background: var(--surface); border-radius: var(--r-sm); }
.tl-diff .old { color: var(--c-red); text-decoration: line-through; }
.tl-diff .arrow { color: var(--text-4); margin: 0 5px; }
.tl-diff .new { color: var(--c-brand-dark); font-weight: 700; }

/* ----------------------------------------------------------------
   22. AVATAR & USER
   ---------------------------------------------------------------- */
.avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--c-brand), var(--c-brand-dark));
  color: #fff;
  font-size: 13px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 2px 6px rgb(16 185 129 / .25);
}

/* Sync status indicator */
.sync-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-4);
  transition: background var(--t-fast) var(--ease);
}
.sync-dot.syncing { background: var(--c-amber); animation: pulse 1s infinite; }
.sync-dot.saved   { background: var(--c-brand); }
.sync-dot.offline { background: var(--c-red); }
@keyframes pulse { 0%,100% { opacity:1; } 50% { opacity:.35; } }

#sync-status { font-size: 16px; line-height: 1; }

/* ----------------------------------------------------------------
   23. WEATHER WIDGET
   ---------------------------------------------------------------- */
.weather-pill {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 5px 13px;
  background: var(--c-brand-faint);
  border: 1px solid var(--c-brand-light);
  border-radius: var(--r-full);
  font-size: 12px;
  font-weight: 700;
  color: var(--c-brand-xdark);
  white-space: nowrap;
}
body.dark .weather-pill { background: rgb(16 185 129 / .1); border-color: rgb(16 185 129 / .2); color: var(--c-brand); }
.weather-icon { font-size: 18px; animation: weatherFloat 4s ease-in-out infinite; }
@keyframes weatherFloat { 0%,100% { transform: scale(1) rotate(0deg); } 50% { transform: scale(1.15) rotate(-5deg); } }

/* ----------------------------------------------------------------
   24. FILTER BAR
   ---------------------------------------------------------------- */
.filter-bar {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  margin-bottom: 16px;
  overflow: hidden;
}
.filter-bar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 11px 16px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
  user-select: none;
  transition: background var(--t-fast) var(--ease);
}
.filter-bar-header:hover { background: var(--surface-2); }
.filter-bar-body { padding: 0 16px 14px; }
.filter-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}
.filter-row select { width: auto; min-width: 140px; }
.filter-count { font-size: 11px; color: var(--text-3); white-space: nowrap; }

/* ----------------------------------------------------------------
   25. EMPTY STATE
   ---------------------------------------------------------------- */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-3);
}
.empty-state .empty-icon { font-size: 44px; opacity: .4; margin-bottom: 14px; }
.empty-state p { font-size: 14px; font-weight: 600; margin-bottom: 6px; }
.empty-state small { font-size: 12px; color: var(--text-4); }

/* ----------------------------------------------------------------
   26. SPINNER / LOADING
   ---------------------------------------------------------------- */
.spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2.5px solid var(--border-2);
  border-top-color: var(--c-brand);
  border-radius: 50%;
  animation: spin .65s linear infinite;
}
.spinner-lg { width: 40px; height: 40px; border-width: 4px; }

.loading-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgb(0 0 0 / .5);
  backdrop-filter: blur(3px);
  z-index: 999;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  color: #fff;
  font-size: 14px;
  font-weight: 600;
}
.loading-overlay.active { display: flex; }

/* ----------------------------------------------------------------
   27. CLIENT SUGGESTIONS DROPDOWN
   ---------------------------------------------------------------- */
.suggestions-drop {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  z-index: var(--z-dropdown);
  background: var(--surface);
  border: 1.5px solid var(--c-brand);
  border-radius: var(--r);
  margin-top: 4px;
  max-height: 200px;
  overflow-y: auto;
  box-shadow: var(--shadow-md);
  display: none;
}
.suggestions-drop.open { display: block; animation: slideDown var(--t-fast) var(--ease); }
.suggestions-item {
  padding: 9px 14px;
  cursor: pointer;
  font-size: 13px;
  transition: background var(--t-fast) var(--ease);
}
.suggestions-item:hover { background: var(--c-brand-faint); }
.suggestions-item.add-new { color: var(--c-blue); font-style: italic; }

/* ----------------------------------------------------------------
   28. GRID HELPERS
   ---------------------------------------------------------------- */
.g2 { display: grid; grid-template-columns: 1fr 1fr;         gap: 12px; }
.g3 { display: grid; grid-template-columns: 1fr 1fr 1fr;     gap: 12px; }
.g4 { display: grid; grid-template-columns: 1fr 1fr 1fr 1fr; gap: 12px; }

.flex        { display: flex; }
.flex-center { display: flex; align-items: center; }
.flex-between{ display: flex; align-items: center; justify-content: space-between; }
.flex-wrap   { flex-wrap: wrap; }
.gap-1 { gap: 4px; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }

/* ----------------------------------------------------------------
   29. UPLOAD PROGRESS
   ---------------------------------------------------------------- */
.upload-progress {
  display: none;
  margin-top: 10px;
}
.upload-progress.active { display: block; }
.upload-bar-wrap { height: 6px; background: var(--surface-3); border-radius: var(--r-full); overflow: hidden; margin-bottom: 5px; }
.upload-bar-fill { height: 100%; background: linear-gradient(90deg, var(--c-brand), var(--c-brand-dark)); border-radius: var(--r-full); width: 0%; transition: width .2s linear; }
.upload-status { font-size: 11px; color: var(--text-3); }

/* ----------------------------------------------------------------
   30. LOGIN PAGE
   ---------------------------------------------------------------- */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #0b1120 0%, #0f2040 50%, #0b1120 100%);
  padding: 20px;
  position: relative;
  overflow: hidden;
}
.login-page::before {
  content: '';
  position: absolute;
  width: 700px;
  height: 700px;
  background: radial-gradient(circle, rgb(16 185 129 / .12) 0%, transparent 65%);
  top: -200px;
  left: -200px;
  animation: bgFloat 10s ease-in-out infinite;
}
.login-page::after {
  content: '';
  position: absolute;
  width: 500px;
  height: 500px;
  background: radial-gradient(circle, rgb(59 130 246 / .08) 0%, transparent 65%);
  bottom: -100px;
  right: -100px;
  animation: bgFloat 14s ease-in-out infinite reverse;
}
@keyframes bgFloat { 0%,100% { transform: translate(0,0); } 50% { transform: translate(20px,-20px); } }

.login-card {
  position: relative;
  z-index: 1;
  background: rgb(255 255 255 / .97);
  backdrop-filter: blur(20px);
  border-radius: 22px;
  padding: 36px 32px;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 30px 60px rgb(0 0 0 / .45);
  border: 1px solid rgb(255 255 255 / .2);
  animation: slideUp .6s var(--ease) both;
}
body.dark .login-card { background: var(--surface); border-color: var(--border); }

.login-logo {
  width: 68px;
  height: 68px;
  background: linear-gradient(135deg, var(--c-brand), var(--c-brand-dark));
  border-radius: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  margin: 0 auto 20px;
  box-shadow: 0 12px 32px rgb(16 185 129 / .35);
  animation: logoFloat 3s ease-in-out infinite;
}
@keyframes logoFloat { 0%,100%{transform:translateY(0) scale(1);} 50%{transform:translateY(-4px) scale(1.03);} }

.login-title { font-size: 22px; font-weight: 800; text-align: center; letter-spacing: -.4px; margin-bottom: 4px; }
.login-sub   { font-size: 13px; color: var(--text-3); text-align: center; margin-bottom: 24px; }

.login-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 16px 0;
  font-size: 12px;
  color: var(--text-4);
}
.login-divider::before, .login-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

.login-error {
  display: none;
  padding: 10px 14px;
  background: var(--c-red-light);
  border: 1px solid #fca5a5;
  color: var(--c-red);
  border-radius: var(--r);
  font-size: 12px;
  font-weight: 600;
  margin-bottom: 14px;
  animation: shake .4s var(--ease);
}
.login-error.show { display: block; }
@keyframes shake { 0%,100%{transform:translateX(0);} 25%,75%{transform:translateX(-4px);} 50%{transform:translateX(4px);} }

.btn-login {
  width: 100%;
  padding: 13px;
  font-size: 14px;
  font-weight: 700;
  background: linear-gradient(135deg, var(--c-brand), var(--c-brand-dark));
  color: #fff;
  border: none;
  border-radius: var(--r-md);
  cursor: pointer;
  transition: all var(--t-fast) var(--ease);
  box-shadow: 0 6px 20px rgb(16 185 129 / .3);
  margin-bottom: 10px;
}
.btn-login:hover { transform: translateY(-2px); box-shadow: 0 10px 28px rgb(16 185 129 / .4); }
.btn-login:active { transform: translateY(0); }

.btn-google {
  width: 100%;
  padding: 11px;
  font-size: 13px;
  font-weight: 600;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--r-md);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  transition: all var(--t-fast) var(--ease);
  color: var(--text);
}
.btn-google:hover { background: var(--surface-2); border-color: var(--border-2); transform: translateY(-1px); }

/* ----------------------------------------------------------------
   31. PRINT
   ---------------------------------------------------------------- */
#print-only-root {
  display: none;
}

@media print {
  .no-print,
  .sidebar,
  .topbar,
  .tab-bar,
  .batch-bar,
  .modal-backdrop,
  .confirm-backdrop,
  #toast-container,
  .loading-overlay { display: none !important; }

  .main { margin-left: 0 !important; }
  .content { padding: 0; }

  .panel {
    box-shadow: none !important;
    border: 1px solid #ccc !important;
    break-inside: avoid;
  }

  body { background: #fff !important; color: #000 !important; }

  /* When printing the statement specifically, the modal is hidden by the
     rule above, so we render a duplicate into #print-only-root which is
     the ONLY visible thing on the page during this particular print. */
  body.printing-statement .main,
  body.printing-statement .app-shell,
  body.printing-statement #app-shell {
    display: none !important;
  }
  body.printing-statement #print-only-root {
    display: block !important;
    padding: 24px;
  }
}

/* ----------------------------------------------------------------
   32. RESPONSIVE
   ---------------------------------------------------------------- */
@media (max-width: 1024px) {
  .sidebar {
    transform: translateX(-100%);
    box-shadow: var(--shadow-xl);
  }
  .sidebar.open { transform: translateX(0); }
  .main { margin-left: 0; }
  .hamburger { display: flex; }
}

/* ----------------------------------------------------------------
   26. GRID SYSTEM UTILITIES & RESPONSIVE ADAPTERS
   ---------------------------------------------------------------- */
.grid { display: grid; }
.grid-cols-1 { grid-template-columns: repeat(1, minmax(0, 1fr)); }
.grid-cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.sm\:grid-cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.sm\:grid-cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.md\:grid-cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.md\:grid-cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.md\:grid-cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.lg\:grid-cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }

.gap-1 { gap: 4px; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }
.gap-6 { gap: 24px; }

/* ----------------------------------------------------------------
   27. ANDROID & MOBILE OPTIMIZATIONS (720p & 1080p VERTICAL LAYOUTS)
   ---------------------------------------------------------------- */
@media (max-width: 768px) {
  /* 1. Prevent Browser Auto-Zoom: 16px minimum font size on all input fields */
  input:not([type="checkbox"]):not([type="radio"]),
  select,
  textarea,
  .form-control,
  .form-input,
  .search-wrap input {
    font-size: 16px !important;
    min-height: 42px !important;
    line-height: 1.4 !important;
    box-sizing: border-box !important;
  }

  input[type="checkbox"], input[type="radio"] {
    min-width: 18px;
    min-height: 18px;
    font-size: 16px !important;
    accent-color: var(--c-brand);
    cursor: pointer;
  }

  /* 2. Topbar on Android (360px - 412px viewports) */
  .topbar {
    height: auto;
    min-height: 52px;
    flex-wrap: nowrap;
    padding: 6px 12px;
    gap: 8px;
  }
  .topbar-left {
    flex: 1 1 auto;
    min-width: 0;
    gap: 8px;
    overflow: hidden;
  }
  .topbar-left h2, .topbar-left .brand-name {
    font-size: 13px !important;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .topbar-right {
    flex: 0 0 auto;
    gap: 6px;
  }
  .topbar-center {
    display: none;
  }

  /* 3. Mobile Touch Targets (>= 44px for thumbs) */
  .btn, .tab-btn, .nav-item {
    min-height: 42px;
  }
  .btn-icon, .modal-close, .hamburger {
    min-width: 44px;
    min-height: 44px;
  }

  /* 4. Table inputs never blocked by virtual keyboard */
  .tbl-wrap, .table-responsive, .table-wrap {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-x pan-y;
    overscroll-behavior-x: contain;
    position: relative;
    /* Soft touch-scroll indicators */
    background:
      linear-gradient(to right, var(--surface) 30%, rgba(30, 41, 59, 0)),
      linear-gradient(to right, rgba(30, 41, 59, 0), var(--surface) 70%) 100% 0,
      radial-gradient(farthest-side at 0 50%, rgba(0, 0, 0, 0.4), rgba(0, 0, 0, 0)),
      radial-gradient(farthest-side at 100% 50%, rgba(0, 0, 0, 0.4), rgba(0, 0, 0, 0)) 100% 0;
    background-repeat: no-repeat;
    background-size: 30px 100%, 30px 100%, 12px 100%, 12px 100%;
    background-attachment: local, local, scroll, scroll;
  }
  .tbl input, .table input,
  .tbl select, .table select,
  .tbl textarea, .table textarea {
    font-size: 16px !important;
    min-height: 40px !important;
    padding: 8px 10px !important;
    min-width: 110px;
    scroll-margin-bottom: 140px; /* Leaves clear space above Android virtual keyboard */
    scroll-margin-top: 80px;
  }
  .tbl tbody td, .table tbody td, .table td {
    padding: 10px 8px;
  }
  /* Prevent table action buttons from collapsing and overlapping */
  .tbl td .btn, .table td .btn, .tbl td .btn-xs, .table td .btn-xs {
    white-space: nowrap !important;
    margin: 2px !important;
    min-height: 36px !important;
    font-size: 12px !important;
    padding: 6px 10px !important;
  }

  /* 5. 720p / 1080p Vertical Layout Grid Collapse */
  .grid-cols-2,
  .grid-cols-3,
  .grid-cols-4,
  .sm\:grid-cols-2,
  .sm\:grid-cols-4,
  .md\:grid-cols-2,
  .md\:grid-cols-3,
  .md\:grid-cols-4,
  .lg\:grid-cols-2,
  .form-row,
  .stats-grid,
  .info-grid,
  .g3, .g4, .g2 {
    grid-template-columns: 1fr !important;
  }

  /* 6. Page Header & Button Overlap Elimination */
  .page-header {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 12px !important;
  }
  .page-header-actions {
    display: flex !important;
    flex-wrap: wrap !important;
    gap: 8px !important;
    width: 100% !important;
  }
  .page-header-actions .btn {
    flex: 1 1 calc(50% - 6px) !important;
    min-height: 42px !important;
    justify-content: center !important;
    text-align: center !important;
    white-space: normal !important;
  }

  /* 7. Modal Dialogs on Android */
  .content { padding: 14px 10px; padding-bottom: max(24px, env(safe-area-inset-bottom, 24px)); }
  .modal {
    width: 96% !important;
    max-width: 96% !important;
    padding: 16px 14px !important;
    margin: auto !important;
    border-radius: var(--r-lg) !important;
    max-height: 88dvh !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch !important;
    scroll-padding-bottom: 120px;
  }
  .modal-backdrop {
    padding: 8px !important;
    align-items: center !important;
  }
  .modal-footer, .confirm-actions {
    flex-wrap: wrap !important;
    gap: 8px !important;
  }
  .modal-footer .btn, .confirm-actions .btn {
    flex: 1 1 100% !important;
    width: 100% !important;
    min-height: 42px !important;
    justify-content: center !important;
  }

  .filter-row {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 8px !important;
    width: 100% !important;
    min-width: 0 !important;
    box-sizing: border-box !important;
  }
  .filter-row select,
  .filter-row input,
  .search-wrap,
  .search-wrap input {
    width: 100% !important;
    min-width: 0 !important;
    box-sizing: border-box !important;
  }
  .tbl-wrap, .table-responsive, .table-wrap {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    overflow-x: auto !important;
    box-sizing: border-box !important;
  }
  .folder-layout { flex-direction: column; }
  .folder-sidebar { width: 100%; min-width: 0; }
}

@media (max-width: 480px) {
  .page-header-actions .btn {
    flex: 1 1 100% !important;
    width: 100% !important;
  }
  .doc-grid   { grid-template-columns: 1fr; }
  .mat-grid   { grid-template-columns: 1fr; }
  .login-card { padding: 20px 16px; }
  .content    { padding: 10px 8px; padding-bottom: max(16px, env(safe-area-inset-bottom, 16px)); }
  #offline-test-strip {
    position: relative;
    top: auto;
  }
  #offline-test-strip + .topbar {
    top: 0;
  }
}

/* ----------------------------------------------------------------
   27. INPUT-WIDE ACCESS CONTROL & LOCK STYLES
   ---------------------------------------------------------------- */
.input-restricted,
input.input-restricted,
select.input-restricted,
textarea.input-restricted {
  background-color: var(--surface-2, #f8fafc) !important;
  color: var(--text-3, #94a3b8) !important;
  border-color: var(--border, #cbd5e1) !important;
  cursor: not-allowed !important;
  opacity: 0.8 !important;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3' y='11' width='18' height='11' rx='2' ry='2'%3E%3C/rect%3E%3Cpath d='M7 11V7a5 5 0 0 1 10 0v4'%3E%3C/path%3E%3C/svg%3E") !important;
  background-repeat: no-repeat !important;
  background-position: right 8px center !important;
  padding-right: 28px !important;
}

.perm-lock-icon {
  font-size: 11px;
  color: #ef4444;
  margin-left: 4px;
  vertical-align: middle;
}

