/**
 * Keystone Industrial — global theme (single source of design tokens + shared UI)
 * Load on every module for consistent look: dashboards, industry, staff, reports, auth, settings.
 */

/* ------------------------------------------------------------------------- */
/* Design tokens — aligned with main dashboard (dashboard.php)               */
/* ------------------------------------------------------------------------- */
:root {
  --primary: #4361ee;
  --primary-dark: #3a56d4;
  --primary-light: #4895ef;
  --secondary: #7209b7;
  --accent: #4cc9f0;
  --accent-dark: #38b9e0;
  --warning: #f8961e;
  --danger: #f94144;
  --success: #43aa8b;
  --info: #277da1;
  --dark: #0d1b2a;
  --darker: #0a1522;
  --dark-blue: #1b263b;
  --light: #f8f9fa;
  --card-bg: rgba(30, 41, 59, 0.95);
  --sidebar-bg: rgba(15, 23, 42, 0.98);
  --glow: 0 0 25px rgba(67, 97, 238, 0.25);
  --gradient: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
  --gradient-accent: linear-gradient(135deg, var(--accent) 0%, var(--primary) 100%);
  --shadow: 0 6px 15px rgba(0, 0, 0, 0.1);
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.12);
  --shadow-lg: 0 15px 35px rgba(0, 0, 0, 0.2);
  /* Line color for legacy modules using `border: 1px solid var(--border)` — must stay a color, not shorthand */
  --border: rgba(71, 85, 105, 0.95);
  /* Full border rules for cards / forms in this theme */
  --border-light: 1px solid rgba(148, 163, 184, 0.35);
  --radius: 12px;
  --radius-sm: 8px;
  --radius-xs: 4px;
  --text-dark: #f1f5f9;
  --text-muted: #cbd5e1;
  --text-light: #f8fafc;

  /* Aliases for smaller module pages (industry / staff / reports) */
  --ks-bg: var(--dark);
  --ks-surface: #1e293b;
  --ks-line: rgba(148, 163, 184, 0.35);
  --ks-muted: #cbd5e1;

  /* Chart.js / canvas — read via getComputedStyle in dashboards */
  --ks-chart-text: var(--text-dark);
  --ks-chart-text-muted: var(--text-muted);
  --ks-chart-grid: rgba(148, 163, 184, 0.22);
  --ks-chart-border: rgba(148, 163, 184, 0.35);
  --ks-chart-fill-primary: rgba(67, 97, 238, 0.15);
  --ks-chart-fill-accent: rgba(76, 201, 240, 0.12);

  /* POS, production, reports — shared tokens (one palette with dashboard) */
  --gray: var(--ks-muted);
  --dark-light: #1e293b;
  --light-dark: #e2e8f0;
  --primary-bg: rgba(67, 97, 238, 0.12);
  --secondary-dark: #5a079a;
  --secondary-light: #9d4edd;
  --accent-light: rgba(76, 201, 240, 0.15);
  --danger-light: rgba(249, 65, 68, 0.12);
  --warning-light: rgba(248, 150, 30, 0.12);
  --success-light: rgba(67, 170, 139, 0.12);
  --info-light: rgba(39, 125, 161, 0.12);
  --purple: #9d4edd;
  --transition: all 0.3s ease;
  --gray-50: #f8fafc;
  --gray-100: #f1f5f9;
  --gray-200: #e2e8f0;
  --gray-300: #cbd5e1;
  --gray-400: #94a3b8;
  --gray-500: #64748b;
  --gray-600: #475569;
  --gray-700: #334155;
  --gray-800: #1e293b;
  --gray-900: #0f172a;
  --radius-lg: 14px;
  --header-height: 60px;
  --bottom-nav-height: 60px;
  --sidebar-width: 280px;
  --mobile-header-height: 70px;
  --mobile-bottom-bar-height: 50px;
  --desktop-bottom-bar-height: 40px;
}

/* ------------------------------------------------------------------------- */
/* Base — optional class on auth / simple pages                              */
/* ------------------------------------------------------------------------- */
html.theme-keystone,
.theme-keystone body {
  font-family: "Poppins", "Inter", system-ui, sans-serif;
  background: var(--dark);
  color: var(--text-dark);
  margin: 0;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ------------------------------------------------------------------------- */
/* Auth (login / register)                                                   */
/* ------------------------------------------------------------------------- */
.ks-auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: radial-gradient(ellipse 120% 80% at 50% -20%, rgba(67, 97, 238, 0.35), transparent),
    linear-gradient(165deg, var(--darker) 0%, var(--dark) 45%, #1a1035 100%);
}

/* Draggable support / WhatsApp — above PWA install chip (z-index ~1200), high stacking */
.ks-support-dock {
  position: fixed;
  right: max(12px, env(safe-area-inset-right, 0px));
  bottom: calc(76px + env(safe-area-inset-bottom, 0px));
  left: auto;
  top: auto;
  z-index: 100050;
  display: flex;
  flex-direction: column-reverse;
  align-items: flex-end;
  gap: 10px;
  max-width: calc(100vw - 24px);
  pointer-events: auto;
  visibility: visible;
  opacity: 1;
}
.ks-support-dock__fab {
  flex-shrink: 0;
  width: 56px;
  height: 56px;
  min-width: 56px;
  min-height: 56px;
  border-radius: 50%;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.45), 0 0 0 2px rgba(255, 255, 255, 0.2);
}
.ks-support-dock__fab .fab.fa-whatsapp {
  font-size: 1.65rem;
  line-height: 1;
  color: #fff;
}

.ks-login-box {
  width: 100%;
  max-width: 420px;
  background: var(--card-bg);
  border: var(--border-light);
  border-radius: 20px;
  padding: 36px 32px;
  box-shadow: var(--shadow-lg), var(--glow);
  backdrop-filter: blur(12px);
}

.ks-login-box .login-header,
.ks-login-header {
  text-align: center;
  margin-bottom: 28px;
}

.ks-login-box .login-header i,
.ks-login-header i {
  font-size: 2.5rem;
  background: var(--gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 12px;
  display: inline-block;
}

.ks-login-box h1,
.ks-login-header h1 {
  color: var(--text-light);
  margin: 0 0 6px;
  font-size: 1.5rem;
  font-weight: 600;
}

.ks-login-box .login-header p,
.ks-login-header p {
  color: var(--text-muted);
  margin: 0;
  font-size: 0.95rem;
}

.ks-form-group {
  margin-bottom: 18px;
}

.ks-form-group label {
  display: block;
  margin-bottom: 8px;
  color: var(--ks-muted);
  font-weight: 500;
  font-size: 0.88rem;
}

.ks-form-control,
.ks-login-box .form-control,
.ks-login-box select.form-control {
  width: 100%;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  border: var(--border-light);
  background: rgba(15, 23, 42, 0.85);
  color: var(--text-light);
  font-size: 1rem;
  box-sizing: border-box;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.ks-form-control:focus,
.ks-login-box .form-control:focus {
  outline: none;
  border-color: var(--primary-light);
  box-shadow: 0 0 0 3px rgba(67, 97, 238, 0.2);
}

/* Global readability helpers for light palette across modules/forms */
.theme-keystone.theme-palette-light input,
.theme-keystone.theme-palette-light select,
.theme-keystone.theme-palette-light textarea {
  color: #0f172a;
  border-color: rgba(148, 163, 184, 0.55);
}
.theme-keystone.theme-palette-light input::placeholder,
.theme-keystone.theme-palette-light textarea::placeholder {
  color: #64748b;
  opacity: 1;
}
.theme-keystone.theme-palette-light .form-control,
.theme-keystone.theme-palette-light .ks-form-control,
.theme-keystone.theme-palette-light .ks-login-box .form-control,
.theme-keystone.theme-palette-light .platform-input,
.theme-keystone.theme-palette-light .platform-select {
  background: #ffffff;
  color: #0f172a;
  border-color: rgba(148, 163, 184, 0.55);
}
.theme-keystone.theme-palette-light label,
.theme-keystone.theme-palette-light .platform-label,
.theme-keystone.theme-palette-light .subtitle,
.theme-keystone.theme-palette-light .ks-form-group label {
  color: #334155;
}

/* System-wide form readability: force high-contrast input text regardless of theme. */
input,
textarea,
select,
.form-control,
.ks-form-control,
.platform-input,
.platform-select,
.platform-admin input,
.platform-admin textarea,
.platform-admin select,
.ks-login-box input,
.ks-login-box textarea,
.ks-login-box select {
  background: #ffffff !important;
  color: #111827 !important;
  -webkit-text-fill-color: #111827 !important;
  caret-color: #111827 !important;
  border-color: rgba(100, 116, 139, 0.65) !important;
}

input::placeholder,
textarea::placeholder,
select::placeholder,
.form-control::placeholder,
.ks-form-control::placeholder,
.platform-input::placeholder,
.platform-select::placeholder {
  color: #475569 !important;
  opacity: 1 !important;
}

.ks-btn-login,
.btn-login {
  width: 100%;
  padding: 14px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  color: #fff;
  background: var(--gradient);
  transition: transform 0.15s, box-shadow 0.15s;
}

.ks-btn-login:hover,
.btn-login:hover {
  transform: translateY(-1px);
  box-shadow: var(--glow);
}

.ks-error-message,
.error-message {
  background: rgba(249, 65, 68, 0.12);
  border: 1px solid rgba(249, 65, 68, 0.35);
  color: #fecaca;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  margin-bottom: 18px;
  font-size: 0.9rem;
}

.ks-login-footer,
.login-footer {
  text-align: center;
  margin-top: 22px;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.ks-login-footer a,
.login-footer a {
  color: var(--accent);
  text-decoration: none;
  font-weight: 500;
}

.ks-login-footer a:hover,
.login-footer a:hover {
  text-decoration: underline;
}

/* Register card variant */
.ks-register-card {
  max-width: 440px;
}

.ks-auth-page .card h1 {
  text-align: center;
  margin: 0 0 8px;
  font-size: 1.45rem;
  font-weight: 600;
  color: var(--text-light);
}

.ks-auth-page .subtitle {
  font-size: 0.9rem;
  color: var(--text-muted);
  text-align: center;
  margin-bottom: 16px;
}

.ks-auth-page .field-group {
  margin-bottom: 10px;
}

.ks-auth-page .alert.error {
  background: rgba(249, 65, 68, 0.12);
  border: 1px solid rgba(249, 65, 68, 0.35);
  color: #fecaca;
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 0.85rem;
  margin-bottom: 10px;
}

.ks-auth-page .alert.success {
  background: rgba(67, 170, 139, 0.12);
  border: 1px solid rgba(67, 170, 139, 0.35);
  color: #bbf7d0;
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 0.85rem;
  margin-bottom: 10px;
}

.ks-auth-page .meta {
  margin-top: 14px;
  font-size: 0.82rem;
  color: var(--text-muted);
  text-align: center;
}

.ks-auth-page .meta a {
  color: var(--accent);
  text-decoration: none;
}

.ks-auth-page .card .btn-primary {
  width: 100%;
  margin-top: 8px;
  border-radius: 999px;
}

/* ------------------------------------------------------------------------- */
/* Module shell — industry / staff / small admin pages                      */
/* ------------------------------------------------------------------------- */
.staff-wrap,
.ks-shell {
  max-width: 1100px;
  margin: 0 auto;
  padding: 20px 20px 40px;
}

.staff-top,
.ks-page-top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.staff-top h1,
.ks-page-top h1 {
  margin: 0;
  font-size: 1.35rem;
  font-weight: 600;
  color: var(--text-light);
}

.staff-top .tag,
.ks-page-tag {
  font-size: 0.72rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  display: block;
  margin-bottom: 4px;
}

.staff-subnav,
.ks-subnav {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 20px;
  padding: 10px 12px;
  background: var(--card-bg);
  border-radius: var(--radius);
  border: var(--border-light);
}

.staff-subnav__a,
.ks-subnav a {
  color: var(--text-muted);
  text-decoration: none;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: background 0.15s, color 0.15s;
}

.staff-subnav__a:hover,
.ks-subnav a:hover {
  color: var(--text-light);
  background: rgba(67, 97, 238, 0.15);
}

.staff-subnav__a--active,
.ks-subnav a.active {
  color: #fff;
  background: rgba(67, 97, 238, 0.35);
  box-shadow: 0 0 12px rgba(67, 97, 238, 0.2);
}

.staff-subnav__dash,
.ks-subnav__dash {
  margin-left: auto;
}

.card,
.ks-card {
  background: var(--card-bg);
  border: var(--border-light);
  border-radius: 14px;
  padding: 18px;
  margin-bottom: 16px;
}

.card h2,
.ks-card h2 {
  margin: 0 0 12px;
  font-size: 1.05rem;
  color: var(--text-light);
  font-weight: 600;
}

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

.hub-card {
  display: block;
  padding: 18px;
  border-radius: 14px;
  border: var(--border-light);
  background: rgba(15, 23, 42, 0.55);
  text-decoration: none;
  color: inherit;
  transition: border-color 0.15s, background 0.15s;
}

.hub-card:hover {
  border-color: rgba(67, 97, 238, 0.45);
  background: rgba(67, 97, 238, 0.08);
}

.hub-card i {
  font-size: 1.6rem;
  background: var(--gradient-accent);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 10px;
  display: inline-block;
}

.hub-card h3 {
  margin: 0 0 6px;
  font-size: 1rem;
  color: var(--text-light);
}

.hub-card p {
  margin: 0;
  font-size: 0.82rem;
  color: var(--text-muted);
  line-height: 1.45;
}

label {
  display: block;
  font-size: 0.8rem;
  color: var(--text-dark);
  margin-bottom: 4px;
}

input,
select,
textarea {
  font-family: inherit;
}

.staff-wrap input,
.staff-wrap select,
.staff-wrap textarea,
.ks-shell input,
.ks-shell select,
.ks-shell textarea {
  width: 100%;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: var(--border-light);
  background: rgba(15, 23, 42, 0.9);
  color: var(--text-light);
  font-size: 0.95rem;
  box-sizing: border-box;
}

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

.grid {
  display: grid;
  gap: 12px;
}
@media (min-width: 720px) {
  .grid-2 {
    grid-template-columns: 1fr 1fr;
  }
  .grid-3 {
    grid-template-columns: repeat(3, 1fr);
  }
}

.btn,
.ks-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.9rem;
  text-decoration: none;
  font-family: inherit;
}

.btn-primary,
.ks-btn-primary {
  background: var(--gradient);
  color: #fff;
}

.btn-secondary,
.ks-btn-secondary {
  background: rgba(51, 65, 85, 0.8);
  color: var(--text-light);
  border: var(--border-light);
}

.btn-danger,
.ks-btn-danger {
  background: linear-gradient(135deg, #b91c1c, #991b1b);
  color: #fff;
}

.btn-sm {
  padding: 6px 12px;
  font-size: 0.8rem;
}

table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

table.data th,
table.data td {
  padding: 10px 8px;
  text-align: left;
  border-bottom: var(--border-light);
}

table.data th {
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.72rem;
  text-transform: uppercase;
}

table.data td {
  color: var(--text-dark);
}

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
}

.badge-ok {
  background: rgba(67, 170, 139, 0.2);
  color: #86efac;
}

.badge-warn {
  background: rgba(248, 150, 30, 0.2);
  color: #fcd34d;
}

.badge-muted {
  background: rgba(148, 163, 184, 0.2);
  color: var(--text-muted);
}

.flash {
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  margin-bottom: 14px;
}

.flash-ok {
  background: rgba(67, 170, 139, 0.12);
  border: 1px solid rgba(67, 170, 139, 0.35);
  color: #bbf7d0;
}

.flash-err {
  background: rgba(249, 65, 68, 0.12);
  border: 1px solid rgba(249, 65, 68, 0.35);
  color: #fecaca;
}

.p-note {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 8px;
  line-height: 1.45;
}

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

/* ------------------------------------------------------------------------- */
/* Settings app layout                                                       */
/* ------------------------------------------------------------------------- */
.ks-settings-layout {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  font-family: "Poppins", "Inter", system-ui, sans-serif;
  background: var(--darker);
  color: var(--text-dark);
}

/* Top bar (language + theme) full width; sidebar + main below */
.ks-settings-top {
  width: 100%;
  flex-shrink: 0;
  z-index: 20;
  box-sizing: border-box;
}

.ks-settings-body {
  display: flex;
  flex: 1;
  min-height: 0;
  width: 100%;
}

.ks-settings-sidebar {
  width: 248px;
  flex-shrink: 0;
  background: var(--sidebar-bg);
  border-right: var(--border-light);
  padding: 16px 12px;
  box-sizing: border-box;
}

.ks-settings-sidebar h2 {
  font-size: 0.95rem;
  font-weight: 600;
  margin: 0 0 14px;
  color: var(--text-light);
}

.ks-settings-sidebar .nav-link {
  display: block;
  padding: 9px 12px;
  margin-bottom: 4px;
  border-radius: 999px;
  font-size: 0.85rem;
  color: #cbd5f5;
  text-decoration: none;
  transition: background 0.15s;
}

.ks-settings-sidebar .nav-link:hover {
  background: rgba(67, 97, 238, 0.12);
}

.ks-settings-sidebar .nav-link.active {
  background: var(--gradient);
  color: #fff;
}

.ks-settings-content {
  flex: 1;
  padding: 20px 24px;
  box-sizing: border-box;
  overflow-x: auto;
}

.ks-settings-content .card {
  background: var(--card-bg);
  border: var(--border-light);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 16px;
}

.ks-settings-content .card h3 {
  margin-top: 0;
  font-size: 1rem;
  color: var(--text-light);
}

.ks-settings-content .grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 8px 12px;
}

.ks-settings-content .field-group {
  margin-bottom: 8px;
}

.ks-settings-content label {
  display: block;
  font-size: 0.8rem;
  margin-bottom: 4px;
  color: var(--text-muted);
}

.ks-settings-content input,
.ks-settings-content select,
.ks-settings-content textarea {
  width: 100%;
  padding: 7px 9px;
  border-radius: var(--radius-sm);
  border: var(--border-light);
  background: rgba(15, 23, 42, 0.9);
  color: var(--text-dark);
  font-size: 0.85rem;
  box-sizing: border-box;
  outline: none;
  font-family: inherit;
}

.ks-settings-content input:focus,
.ks-settings-content select:focus,
.ks-settings-content textarea:focus {
  border-color: var(--primary-light);
  box-shadow: 0 0 0 1px rgba(67, 97, 238, 0.35);
}

.ks-settings-content .btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 14px;
  border-radius: 999px;
  border: none;
  background: var(--gradient);
  color: #f9fafb;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  margin-top: 4px;
}

.ks-settings-content .alert {
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  font-size: 0.8rem;
  margin-bottom: 10px;
}

.ks-settings-content .alert.error {
  background: rgba(249, 65, 68, 0.12);
  border: 1px solid rgba(249, 65, 68, 0.35);
  color: #fecaca;
}

.ks-settings-content .alert.success {
  background: rgba(67, 170, 139, 0.12);
  border: 1px solid rgba(67, 170, 139, 0.35);
  color: #bbf7d0;
}

.ks-settings-content table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 8px;
  font-size: 0.8rem;
}

.ks-settings-content th,
.ks-settings-content td {
  padding: 6px 8px;
  border-bottom: var(--border-light);
}

.ks-settings-content th {
  text-align: left;
  color: var(--text-muted);
}

.ks-settings-content .tag {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 0.7rem;
  border: var(--border-light);
}

/* ------------------------------------------------------------------------- */
/* Reports / analytics compact (operations_analytics)                        */
/* ------------------------------------------------------------------------- */
.ks-report-toolbar,
.report-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
  padding: 12px;
  background: var(--card-bg);
  border: var(--border-light);
  border-radius: var(--radius);
  align-items: center;
}

.ks-report-toolbar span,
.report-toolbar span {
  color: var(--text-muted);
  font-size: 12px;
  margin-right: 8px;
}

.ks-report-toolbar a,
.report-toolbar a {
  font-size: 13px;
  padding: 7px 11px;
  border-radius: var(--radius-sm);
  background: rgba(15, 23, 42, 0.8);
  border: var(--border-light);
  color: var(--text-dark);
  text-decoration: none;
  white-space: nowrap;
}

.ks-report-toolbar a:hover,
.report-toolbar a:hover {
  border-color: rgba(67, 97, 238, 0.45);
  color: var(--text-light);
}

.report-exports {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-left: auto;
}

.theme-keystone .ks-ops-header,
.ks-ops-header {
  padding: 16px 20px;
  border-bottom: var(--border-light);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  justify-content: space-between;
  background: rgba(15, 23, 42, 0.5);
}

.ks-ops-header h1 {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-light);
}

.ks-ops-header .meta {
  color: var(--text-muted);
  font-size: 0.85rem;
}

.ks-ops-header .top-links a {
  color: var(--accent);
  text-decoration: none;
  margin-right: 12px;
  font-size: 0.9rem;
}

.ks-ops-header .top-links a:hover {
  text-decoration: underline;
}

.ks-ops-main {
  padding: 16px;
  max-width: 1200px;
  margin: 0 auto;
}

.analytics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 12px;
  margin-top: 12px;
}

.kpi-tile {
  background: var(--card-bg);
  border: var(--border-light);
  border-radius: var(--radius);
  padding: 12px;
}

.kpi-tile .lbl {
  font-size: 12px;
  color: var(--text-muted);
  margin: 0 0 6px;
}

.kpi-tile .val {
  font-size: 20px;
  font-weight: 600;
  margin: 0;
  line-height: 1.2;
  color: var(--text-light);
}

.kpi-tile .sub {
  font-size: 11px;
  color: var(--text-muted);
  margin: 6px 0 0;
}

.theme-keystone .card h3 {
  margin: 0 0 8px;
  font-size: 1.05rem;
  color: var(--text-light);
}

.muted {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin: 0 0 12px;
}

h4.sec {
  margin: 0 0 12px;
  font-size: 15px;
  color: #b9ceff;
  font-weight: 600;
}

.bar-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 8px 0;
  font-size: 13px;
}

.bar-row .lab {
  min-width: 100px;
  color: var(--text-muted);
}

.bar-track {
  flex: 1;
  height: 12px;
  background: rgba(15, 23, 42, 0.9);
  border-radius: 6px;
  overflow: hidden;
  border: var(--border-light);
}

.bar-fill {
  height: 100%;
  background: var(--gradient-accent);
  border-radius: 6px;
  min-width: 2px;
}

.bar-val {
  min-width: 72px;
  text-align: right;
  font-variant-numeric: tabular-nums;
  color: var(--text-light);
}

table.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

table.table th,
table.table td {
  border: var(--border-light);
  padding: 8px;
  text-align: left;
}

table.table th {
  background: rgba(0, 0, 0, 0.2);
  color: var(--text-muted);
}

.split-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

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

/* Improve dropdown/list item visibility across modules */
.theme-keystone select,
.theme-keystone .form-control select,
.theme-keystone select.form-control {
  background: #fffaf1 !important;
  color: #2e2a25 !important;
}

.theme-keystone select option,
.theme-keystone select optgroup {
  background: #fffdf8 !important;
  color: #2e2a25 !important;
}

.theme-keystone select:focus option:checked,
.theme-keystone select option:checked {
  background: #dfe7f6 !important;
  color: #1f2a44 !important;
}

/* Remove legacy scrollbar arrow buttons and keep clean scrollbars */
.theme-keystone *::-webkit-scrollbar-button {
  display: none;
  width: 0;
  height: 0;
}

/* Narrow classical transparent scrollbar (global theme) */
.theme-keystone,
.theme-keystone * {
  scrollbar-width: thin;
  scrollbar-color: rgba(133, 119, 96, 0.5) transparent;
}

.theme-keystone *::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

.theme-keystone *::-webkit-scrollbar-track {
  background: transparent;
}

.theme-keystone *::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, rgba(133, 119, 96, 0.55), rgba(111, 103, 93, 0.5));
  border-radius: 999px;
  border: 2px solid transparent;
  background-clip: padding-box;
}

.theme-keystone *::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(180deg, rgba(133, 119, 96, 0.72), rgba(111, 103, 93, 0.68));
}

.theme-keystone *::-webkit-scrollbar-corner {
  background: transparent;
}

/* ------------------------------------------------------------------------- */
/* Uniform module presentation sweep                                          */
/* ------------------------------------------------------------------------- */
.theme-keystone body,
.theme-keystone .app-body,
.theme-keystone .main-content,
.theme-keystone .content,
.theme-keystone .content-wrapper,
.theme-keystone .page-content,
.theme-keystone .container-fluid {
  background: var(--dark) !important;
  color: var(--text-dark) !important;
}

.theme-keystone .panel,
.theme-keystone .panel-body,
.theme-keystone .module-panel,
.theme-keystone .module-card,
.theme-keystone .widget,
.theme-keystone .box,
.theme-keystone .well,
.theme-keystone .table-responsive,
.theme-keystone .dataTables_wrapper {
  background: var(--card-bg) !important;
  border: var(--border-light) !important;
  border-radius: var(--radius) !important;
  box-shadow: var(--shadow-sm) !important;
  color: var(--text-dark) !important;
}

.theme-keystone .panel-heading,
.theme-keystone .widget-header,
.theme-keystone .box-header,
.theme-keystone .module-header,
.theme-keystone .card-header {
  background: #f1e9dc !important;
  border-bottom: 1px solid rgba(133, 119, 96, 0.26) !important;
  color: #4c453c !important;
}

.theme-keystone .table,
.theme-keystone .dataTable,
.theme-keystone table.dataTable {
  background: transparent !important;
  color: var(--text-dark) !important;
}

.theme-keystone .table thead th,
.theme-keystone .dataTable thead th,
.theme-keystone table.dataTable thead th {
  background: #f1e9dc !important;
  color: #4c453c !important;
  border-color: rgba(133, 119, 96, 0.32) !important;
}

.theme-keystone .table tbody td,
.theme-keystone .dataTable tbody td,
.theme-keystone table.dataTable tbody td {
  border-color: rgba(133, 119, 96, 0.24) !important;
}

.theme-keystone input,
.theme-keystone select,
.theme-keystone textarea {
  background: #fffaf1 !important;
  color: #0f172a !important;
  -webkit-text-fill-color: #0f172a !important;
  caret-color: #0f172a !important;
  border: 1px solid rgba(133, 119, 96, 0.36) !important;
}

/* WebKit autofill otherwise forces low-contrast text on cream fields */
.theme-keystone input:-webkit-autofill,
.theme-keystone input:-webkit-autofill:hover,
.theme-keystone input:-webkit-autofill:focus,
.theme-keystone textarea:-webkit-autofill,
.theme-keystone textarea:-webkit-autofill:hover,
.theme-keystone textarea:-webkit-autofill:focus,
.theme-keystone select:-webkit-autofill,
.theme-keystone select:-webkit-autofill:hover,
.theme-keystone select:-webkit-autofill:focus {
  -webkit-text-fill-color: #0f172a !important;
  caret-color: #0f172a !important;
  box-shadow: 0 0 0 1000px #fffaf1 inset !important;
  transition: background-color 99999s ease-out 0s;
}

.theme-keystone input:focus,
.theme-keystone select:focus,
.theme-keystone textarea:focus {
  border-color: rgba(31, 42, 68, 0.45) !important;
  box-shadow: 0 0 0 3px rgba(31, 42, 68, 0.1) !important;
}

.theme-keystone input::placeholder,
.theme-keystone textarea::placeholder,
.theme-keystone select::placeholder {
  color: #64748b !important;
  opacity: 1 !important;
}
