/* ═══════════════════════════════════════════════
   DESIGN TOKENS — Light Theme (Default)
═══════════════════════════════════════════════ */
:root {
  /* Core palette - Light */
  --bg:        #f8fafc;
  --bg2:       #f1f5f9;
  --bg3:       #e2e8f0;
  --surface:   #ffffff;
  --surface2:  #f8fafc;
  --border:    #cbd5e1;
  --border2:   #94a3b8;

  /* Accent: Blue & Orange */
  --amber:     #f97316;
  --amber2:    #fb923c;
  --amber-dim: rgba(249,115,22,.15);
  --amber-glow:rgba(249,115,22,.3);

  /* Accent: Electric blue */
  --teal:      #3b82f6;
  --teal2:     #60a5fa;
  --teal-dim:  rgba(59,130,246,.12);

  /* Status */
  --pass:      #10b981;
  --fail:      #ef4444;
  --pass-dim:  rgba(16,185,129,.15);
  --fail-dim:  rgba(239,68,68,.15);

  /* Text */
  --tx:        #1e293b;
  --tx2:       #64748b;
  --tx3:       #94a3b8;

  /* Fonts */
  --font-head: 'Syne', sans-serif;
  --font-body: 'Noto Sans Thai', 'Syne', sans-serif;
  --font-mono: 'DM Mono', 'Courier New', monospace;

  /* Sizing */
  --r:         8px;
  --r2:        12px;
  --r3:        16px;

  /* Shadow */
  --shadow-sm: 0 1px 3px rgba(0,0,0,.1);
  --shadow:    0 4px 16px rgba(0,0,0,.08);
  --shadow-lg: 0 12px 40px rgba(0,0,0,.6);
}

/* ═══════════════════════════════════════════════
   RESET & BASE
═══════════════════════════════════════════════ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html { scroll-behavior: smooth; }
body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--tx);
  min-height: 100vh;
  font-size: 14px;
  line-height: 1.6;
  overscroll-behavior: none;
}
button { font-family: var(--font-body); cursor: pointer; }
input, select, textarea { font-family: var(--font-body); }

/* ═══════════════════════════════════════════════
   PAGE SYSTEM
═══════════════════════════════════════════════ */
.page { display: none !important; }
.page.active { display: block !important; }
#page-login.active { display: flex !important; }

/* ═══════════════════════════════════════════════
   LOGIN PAGE
═══════════════════════════════════════════════ */
#page-login {
  min-height: 100vh;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 25%, #f093fb 50%, #4facfe 100%);
  background: linear-gradient(135deg, #ff6b6b 0%, #ee5a24 25%, #f39c12 50%, #3498db 75%, #2980b9 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  position: relative;
  overflow: hidden;
}

/* Decorative circles */
#page-login::before {
  content: '';
  position: absolute;
  width: 300px;
  height: 300px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 50%;
  top: -100px;
  left: -100px;
  animation: float 20s ease-in-out infinite;
}

#page-login::after {
  content: '';
  position: absolute;
  width: 200px;
  height: 200px;
  background: rgba(52, 152, 219, 0.15);
  border-radius: 50%;
  bottom: -50px;
  right: -50px;
  animation: float 15s ease-in-out infinite reverse;
}

@keyframes float {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  50% { transform: translateY(-30px) rotate(180deg); }
}

.login-container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 80px;
  max-width: 1200px;
  width: 100%;
  position: relative;
  z-index: 1;
}

.login-content {
  flex: 1;
  max-width: 550px;
  color: #ffffff;
}

.login-hero-title {
  font-size: 4rem;
  font-weight: 700;
  line-height: 1;
  margin-bottom: 16px;
  font-family: var(--font-head);
}

.login-hero-title .dot {
  color: #00d4ff;
  font-weight: 700;
}

.login-hero-subtitle {
  font-size: 1.4rem;
  font-weight: 600;
  margin-bottom: 24px;
  letter-spacing: 0.5px;
  opacity: 0.95;
}

.login-hero-desc {
  font-size: 1rem;
  line-height: 1.8;
  opacity: 0.85;
  margin-bottom: 32px;
}

.btn-learn-more {
  padding: 14px 32px;
  background: transparent;
  color: #ffffff;
  border: 2px solid #ffffff;
  border-radius: 50px;
  font-size: 0.9rem;
  font-weight: 600;
  letter-spacing: 1px;
  transition: all 0.3s ease;
  cursor: pointer;
  text-transform: uppercase;
}

.btn-learn-more:hover {
  background: #ffffff;
  color: #3498db;
  transform: scale(1.05);
}



.login-card {
  background: rgba(255, 255, 255, 0.95);
  background: linear-gradient(135deg, rgba(255,255,255,0.95) 0%, rgba(248,249,250,0.95) 100%);
  border: none;
  border-radius: 24px;
  padding: 48px 40px;
  width: 100%;
  max-width: 420px;
  position: relative;
  z-index: 1;
  box-shadow: 0 20px 60px rgba(0,0,0,.15), 0 0 0 1px rgba(255,255,255,.3);
  animation: fadeUp .5s cubic-bezier(.16,1,.3,1) both;
  backdrop-filter: blur(10px);
}

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}

.brand { text-align: center; margin-bottom: 36px; }

.brand-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 64px;
  height: 64px;
  margin: 0 auto 16px;
  border-radius: 50%;
  background: linear-gradient(135deg, #ff6b6b 0%, #f39c12 50%, #3498db 100%);
  animation: spin 12s linear infinite;
  box-shadow: 0 8px 20px rgba(52, 152, 219, 0.3);
}

.brand-icon svg {
  width: 34px;
  height: 34px;
  filter: drop-shadow(0 0 4px rgba(240,165,0,.8));
}

@keyframes spin { to { transform: rotate(360deg); } }

.brand h1 {
  font-family: var(--font-head);
  font-size: 1.8rem;
  font-weight: 700;
  letter-spacing: 1px;
  color: #2c3e50;
  line-height: 1;
  margin-bottom: 6px;
  text-transform: uppercase;
}

.brand h1 span { 
  background: linear-gradient(135deg, #ff6b6b 0%, #f39c12 50%, #3498db 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.brand p {
  font-size: .75rem;
  color: #7f8c8d;
  letter-spacing: 2px;
  text-transform: uppercase;
  font-weight: 600;
}

/* Form */
.fg { margin-bottom: 16px; }

.lbl {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 1px;
  font-size: .64rem;
  font-weight: 600;
  color: #7f8c8d;
  text-transform: none;
  letter-spacing: .25px;
  margin-bottom: 6px;
  font-family: Arial, sans-serif;
}

.lbl-title {
  font-size: .64rem;
  font-weight: 600;
  color: #7f8c8d;
  line-height: 1.1;
}

.lbl-sub {
  font-size: .6rem;
  font-weight: 500;
  color: #94a3b8;
  line-height: 1.1;
}

.lbl-th {
  font-size: .6rem;
  font-weight: 500;
  color: #94a3b8;
  line-height: 1.2;
  display: block;
}

.lbl-icon {
  cursor: pointer;
  opacity: 0.9;
  transition: opacity .2s, transform .2s, color .2s;
  font-size: .62rem;
  color: #ef4444;
  white-space: nowrap;
  font-weight: 400;
  line-height: 1.15;
}

.lbl-icon:hover {
  opacity: 1;
  transform: scale(1.08);
  color: #dc2626;
}

input[type=text],
input[type=password] {
  width: 100%;
  padding: 8px 10px;
  background: #ffffff;
  border: 2px solid #e1e8ed;
  border-radius: 7px;
  color: #2c3e50;
  font-size: .77rem;
  font-family: Arial, sans-serif;
  transition: all .3s ease;
  font-weight: 500;
}

input[type=text]:focus,
input[type=password]:focus {
  outline: none;
  border-color: #00d4ff;
  box-shadow: 0 0 0 3px rgba(0, 212, 255, 0.15);
}

input.field-error { border-color: var(--fail) !important; }
input.field-ok    { border-color: var(--pass); }

.btn-primary {
  width: 100%;
  padding: 12px;
  background: linear-gradient(135deg, #00d2ff 0%, #3a7bd5 100%);
  background: #00d4ff;
  color: #ffffff;
  border: none;
  border-radius: 30px;
  font-size: .95rem;
  font-weight: 700;
  font-family: var(--font-head);
  letter-spacing: 1px;
  text-transform: uppercase;
  transition: all .3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  box-shadow: 0 8px 20px rgba(0, 212, 255, 0.3);
}

#btn-login {
  font-size: .86rem;
  letter-spacing: .6px;
}

.btn-primary:hover:not(:disabled) {
  background: #00b8e6;
  transform: translateY(-3px);
  box-shadow: 0 12px 30px rgba(0, 212, 255, 0.4);
}

.btn-primary:active { transform: translateY(0); }
.btn-primary:disabled { opacity: .5; cursor: not-allowed; }

/* Responsive Login Page */
@media (max-width: 1024px) {
  .login-container {
    flex-direction: column;
    gap: 40px;
    padding: 20px 10px;
  }
  
  .login-content {
    text-align: center;
    max-width: 100%;
  }
  
  .login-hero-title {
    font-size: 3rem;
  }
  
  .login-hero-subtitle {
    font-size: 1.2rem;
  }
  
  .login-card {
    max-width: 100%;
    width: 100%;
  }
}

@media (max-width: 640px) {
  .login-hero-title {
    font-size: 2.5rem;
  }
  
  .login-hero-subtitle {
    font-size: 1rem;
  }
  
  .login-hero-desc {
    font-size: 0.9rem;
  }
}

/* Alerts */
.alert {
  padding: 12px 16px;
  border-radius: var(--r);
  font-size: .85rem;
  font-weight: 600;
  margin-bottom: 16px;
  display: none;
  border-left: 3px solid;
}

.alert.show { display: block; animation: fadeUp .3s ease; }
.alert.error   { background: var(--fail-dim); border-color: var(--fail); color: #ff8080; }
.alert.success { background: var(--pass-dim); border-color: var(--pass); color: var(--pass); }
.alert.info    { background: var(--teal-dim); border-color: var(--teal); color: var(--teal); }

/* ═══════════════════════════════════════════════
   TOPBAR
═══════════════════════════════════════════════ */
.topbar {
  height: 56px;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(228, 228, 231, 0.8);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 12px rgba(0,0,0,.08);
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--tx);
  cursor: pointer;
  -webkit-user-select: none;
  user-select: none;
}

.logo:focus-visible {
  outline: 2px solid rgba(0, 212, 255, 0.55);
  outline-offset: 3px;
  border-radius: 8px;
}

.logo-icon {
  width: 32px;
  height: 32px;
  background: var(--amber);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 2px 8px var(--amber-glow);
}

.logo-icon svg { width: 18px; height: 18px; }

.logo-name {
  font-family: var(--font-head);
  font-size: 1.1rem;
  font-weight: 800;
  letter-spacing: -0.5px;
}

.logo-name span { color: var(--amber); }

.topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.topbar-clock {
  font-family: var(--font-mono);
  font-size: .72rem;
  color: var(--tx3);
  background: var(--bg3);
  padding: 4px 10px;
  border-radius: 20px;
  border: 1px solid var(--border);
}

.tag-user {
  font-size: .78rem;
  color: var(--tx2);
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 110px;
}

.tag-team {
  background: var(--amber-dim);
  border: 1px solid rgba(240,165,0,.3);
  color: var(--amber);
  padding: 3px 10px;
  border-radius: 20px;
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .5px;
  text-transform: uppercase;
  white-space: nowrap;
}

.btn-logout {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--tx2);
  padding: 5px 14px;
  border-radius: 6px;
  font-size: .78rem;
  font-weight: 600;
  transition: all .2s;
  white-space: nowrap;
}

.btn-logout:hover {
  background: var(--fail-dim);
  border-color: var(--fail);
  color: #ff8080;
}

.btn-theme-toggle {
  background: rgba(255, 255, 255, .12);
  border: 1px solid rgba(255, 255, 255, .15);
  color: var(--tx);
  padding: 5px 10px;
  border-radius: 6px;
  cursor: pointer;
  transition: all .3s;
  display: flex;
  align-items: center;
  gap: 4px;
}

.btn-theme-toggle:hover {
  background: rgba(255, 255, 255, .18);
  border-color: rgba(255, 255, 255, .25);
  transform: translateY(-1px);
}

.btn-theme-toggle svg {
  width: 16px;
  height: 16px;
}

body.dark-theme .topbar {
  background: rgba(13, 17, 23, 0.98);
  border-bottom-color: rgba(123, 104, 238, 0.2);
  box-shadow: 0 2px 12px rgba(0,0,0,.4);
}

body.dark-theme .logo-name {
  color: #e6edf3;
}

body.dark-theme .btn-theme-toggle {
  background: rgba(123, 104, 238, 0.15);
  border-color: rgba(123, 104, 238, 0.35);
  color: #e6edf3;
}

body.dark-theme .btn-theme-toggle:hover {
  background: rgba(123, 104, 238, 0.28);
  border-color: rgba(123, 104, 238, 0.6);
}

body.dark-theme .topbar-clock {
  background: rgba(33, 38, 45, 0.9);
  border-color: rgba(123, 104, 238, 0.2);
  color: #8b949e;
}

body.dark-theme .tag-user {
  color: #c9d1d9;
}
body.dark-theme {
  --bg: #0d1117;
  --bg2: #161b22;
  --bg3: #1c2333;
  --surface: #21262d;
  --surface2: #2d333b;
  --border: #30363d;
  --border2: #444c56;
  --amber: #f0a500;
  --amber2: #fbbf24;
  --amber-dim: rgba(240,165,0,.15);
  --amber-glow: rgba(240,165,0,.3);
  --teal: #00d4aa;
  --teal2: #34d399;
  --teal-dim: rgba(0,212,170,.12);
  --pass: #00c27a;
  --fail: #ff4d4d;
  --pass-dim: rgba(0,194,122,.15);
  --fail-dim: rgba(255,77,77,.15);
  --tx: #e6edf3;
  --tx2: #8b949e;
  --tx3: #6e7681;
  --shadow-sm: 0 1px 3px rgba(0,0,0,.4);
  --shadow: 0 4px 16px rgba(0,0,0,.5);
}

body.dark-theme #theme-icon {
  fill: #fbbf24;
}

body:not(.dark-theme) #theme-icon {
  fill: #3b82f6;
}

/* ═══════════════════════════════════════════════
   TOOL PAGE BODY
═══════════════════════════════════════════════ */
#page-tool { 
  background: linear-gradient(135deg, #7b68ee 0%, #9b59b6 25%, #667eea 50%, #4fa8f6 75%, #3a7bd5 100%);
  min-height: 100vh;
  position: relative;
  overflow: hidden;
}

/* Dark theme background */
body.dark-theme #page-tool {
  background: linear-gradient(135deg, #1a1625 0%, #2d1b4e 25%, #1e2a4a 50%, #1a3a52 75%, #0f2847 100%);
}

/* Decorative circles for main page */
#page-tool::before {
  content: '';
  position: absolute;
  width: 400px;
  height: 400px;
  background: rgba(0, 212, 255, 0.15);
  border-radius: 50%;
  top: -150px;
  left: -100px;
  animation: float 20s ease-in-out infinite;
  z-index: 0;
}

body.dark-theme #page-tool::before {
  background: rgba(0, 212, 255, 0.08);
}

#page-tool::after {
  content: '';
  position: absolute;
  width: 300px;
  height: 300px;
  background: rgba(147, 51, 234, 0.12);
  border-radius: 50%;
  bottom: -80px;
  right: -80px;
  animation: float 15s ease-in-out infinite reverse;
  z-index: 0;
}

body.dark-theme #page-tool::after {
  background: rgba(147, 51, 234, 0.06);
}

.tool-body::before {
  content: '';
  position: absolute;
  width: 250px;
  height: 250px;
  background: rgba(0, 212, 255, 0.1);
  border-radius: 50%;
  top: 50%;
  right: 10%;
  animation: float 18s ease-in-out infinite;
  z-index: 0;
}

body.dark-theme .tool-body::before {
  background: rgba(0, 212, 255, 0.05);
}

@keyframes float {
  0%, 100% { transform: translateY(0) translateX(0) scale(1); }
  33% { transform: translateY(-30px) translateX(20px) scale(1.05); }
  66% { transform: translateY(20px) translateX(-20px) scale(0.95); }
}

.tool-body {
  max-width: 1080px;
  margin: 0 auto;
  padding: 20px 20px 32px;
  position: relative;
  z-index: 1;
}

/* Tabs Navigation */
.tabs-nav {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  border-bottom: 2px solid rgba(255, 255, 255, 0.4);
  padding: 0 4px;
  position: relative;
  z-index: 1;
}

.tab-btn {
  padding: 10px 20px;
  background: rgba(255, 255, 255, 0.3);
  border: none;
  color: rgba(255, 255, 255, 0.85);
  font-size: .7rem;
  font-weight: 600;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: all .2s;
  border-radius: 12px 12px 0 0;
  backdrop-filter: blur(10px);
}

.tab-btn:hover { 
  color: #ffffff; 
  background: rgba(255, 255, 255, 0.4);
}

.tab-btn.active { 
  color: #00d4ff; 
  border-bottom-color: #00d4ff;
  background: rgba(255, 255, 255, 0.95);
  font-weight: 700;
}

.tab-content { display: none; }
.tab-content.active { display: block; }

/* ─── ADMIN TAB HIDDEN BY DEFAULT ─── */
#tab-btn-admin { display: none; }
body.is-admin #tab-btn-admin { display: inline-flex; align-items: center; gap: 5px; }

/* ─── ADMIN PANEL ─── */
.admin-panel { padding: 4px 0; }
.admin-sub-tabs { display: flex; gap: 6px; margin-bottom: 20px; flex-wrap: wrap; }
.admin-sub-btn {
  padding: 8px 18px; border-radius: 8px; border: 1.5px solid rgba(255,255,255,.3);
  background: rgba(255,255,255,.18); color: rgba(255,255,255,.85);
  font-size: .76rem; font-weight: 600; cursor: pointer; transition: all .18s;
  backdrop-filter: blur(8px);
}
.admin-sub-btn:hover { background: rgba(255,255,255,.3); }
.admin-sub-btn.active { background: rgba(255,255,255,.95); color: #f97316; border-color: #f97316; }
.admin-sub-content { display: none; }
.admin-sub-content.active { display: block; }

/* ─── ADMIN CARD ─── */
.adm-card {
  background: rgba(255,255,255,.92); border: 1px solid rgba(0,0,0,.08);
  border-radius: 14px; box-shadow: 0 4px 18px rgba(0,0,0,.08);
  overflow: hidden; margin-bottom: 18px;
}
body.dark-theme .adm-card { background: rgba(30,30,50,.88); border-color: rgba(255,255,255,.1); }
.adm-card-header {
  padding: 14px 20px; border-bottom: 1px solid rgba(0,0,0,.06);
  display: flex; align-items: center; justify-content: space-between;
  background: rgba(249,115,22,.06);
}
body.dark-theme .adm-card-header { border-color: rgba(255,255,255,.07); background: rgba(249,115,22,.08); }
.adm-card-title { font-weight: 700; font-size: .95rem; color: #f97316; display: flex; align-items: center; gap: 8px; }
.adm-card-body { padding: 20px; }

.manual-admin-card .adm-card-title { color: #dc2626; }
.manual-admin-desc { color: #b91c1c; }
.manual-add-bar { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.manual-add-field { flex: 1; min-width: 140px; }
.manual-add-field-body { flex: 2; min-width: 220px; }
.manual-add-field-btn { flex: 0; min-width: 90px; }
.manual-textarea-input {
  width: 100%; padding: 9px 13px; border: 1.5px solid var(--border);
  border-radius: 8px; font-size: .92rem; font-family: var(--font-body);
  background: var(--bg2); color: var(--tx); outline: none; transition: border-color .18s;
  resize: vertical; min-height: 84px;
}
.manual-textarea-input:focus { border-color: #ef4444; }
.manual-admin-list { display: flex; flex-direction: column; gap: 10px; margin-top: 8px; }
.manual-admin-row {
  padding: 12px; border: 1px solid rgba(239,68,68,.18); border-radius: 12px;
  background: rgba(255,255,255,.6);
}
body.dark-theme .manual-admin-row { background: rgba(50,20,20,.28); border-color: rgba(239,68,68,.25); }
.manual-admin-top-row { display: flex; gap: 8px; align-items: center; }
.manual-admin-toggle { flex: 0; padding-top: 6px; }
.manual-admin-main { display: flex; flex-direction: column; gap: 8px; }
.manual-title-input { border-color: rgba(239,68,68,.25); }
.manual-title-input:focus { border-color: #ef4444; }
.manual-admin-actions { display: flex; gap: 6px; flex-shrink: 0; align-items: center; }
.manual-empty {
  padding: 12px 14px; border: 1px dashed rgba(239,68,68,.3); border-radius: 12px;
  color: #b91c1c; background: rgba(255,255,255,.55); font-size: .83rem;
}
.manual-status { font-size: .8rem; color: var(--tx2); }

/* ─── ADMIN FIELD ─── */
.adm-field { margin-bottom: 16px; }
.adm-label { font-size: .83rem; font-weight: 600; color: var(--tx); margin-bottom: 5px; display: block; }
.adm-desc { font-size: .77rem; color: var(--tx2); margin-bottom: 7px; }
.adm-input {
  width: 100%; padding: 9px 13px; border: 1.5px solid var(--border);
  border-radius: 8px; font-size: .92rem; font-family: var(--font-mono);
  background: var(--bg2); color: var(--tx); outline: none; transition: border-color .18s;
}
.adm-input:focus { border-color: #f97316; }
.adm-row { display: flex; gap: 8px; align-items: center; }
.adm-row .adm-input { flex: 1; }
.adm-unit { font-size: .85rem; color: var(--tx2); font-family: var(--font-mono); white-space: nowrap; }

/* ─── ADMIN BTN ─── */
.adm-btn { padding: 9px 20px; border-radius: 8px; border: none; cursor: pointer; font-size: .88rem; font-weight: 600; transition: all .18s; font-family: var(--font-body); }
.adm-btn-primary { background: #f97316; color: #fff; }
.adm-btn-primary:hover { background: #fb923c; }
.adm-btn-secondary { background: var(--bg2); color: var(--tx2); border: 1px solid var(--border); }
.adm-btn-secondary:hover { background: var(--bg3); }
.adm-btn-danger { background: rgba(239,68,68,.09); color: #ef4444; border: 1px solid rgba(239,68,68,.2); font-size:.8rem; padding:6px 12px; }
.adm-btn-danger:hover { background: rgba(239,68,68,.16); }
.adm-btn-success { background: rgba(16,185,129,.09); color: #10b981; border: 1px solid rgba(16,185,129,.2); font-size:.8rem; padding:6px 12px; }
.adm-btn-success:hover { background: rgba(16,185,129,.16); }
.adm-btn-row { display: flex; gap: 8px; margin-top: 16px; flex-wrap: wrap; }

/* ─── FORMULA PREVIEW ─── */
.adm-formula-preview {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: 8px; padding: 13px 15px;
  font-family: var(--font-mono); font-size: .83rem; color: var(--tx2); margin-top: 8px; line-height: 1.8;
}
.adm-formula-preview em { color: #3b82f6; font-style: normal; font-weight: 600; }
.adm-formula-preview .pass-thr { color: #10b981; font-weight: 700; }
/* ── Formula Token Builder ── */
.fml-bar {
  min-height: 54px; background: var(--bg3); border: 2px dashed var(--bd);
  border-radius: 10px; padding: 8px 10px;
  display: flex; flex-wrap: wrap; align-items: center; gap: 4px;
  transition: border-color .2s, background .2s;
}
.fml-bar.drag-over { border-color: var(--accent); background: rgba(123,104,238,.07); }
.fml-empty { color: var(--tx3); font-size: .82rem; padding: 4px; }
.fml-insert-ind {
  width: 3px; min-height: 30px; border-radius: 2px;
  background: transparent; transition: background .12s; flex-shrink: 0;
}
.fml-insert-ind.active { background: var(--accent); width: 3px; }
.fml-tok {
  display: inline-flex; align-items: center;
  padding: 4px 9px; border-radius: 7px; font-size: .84rem; font-weight: 600;
  cursor: grab; -webkit-user-select: none; user-select: none; border: 1.5px solid transparent;
  transition: opacity .15s, box-shadow .15s;
  position: relative;
}
.fml-tok:active { cursor: grabbing; }
.fml-tok.fml-dragging { opacity: .35; }
.fml-tok-var    { background: rgba(157, 159, 161, 0.42);  color: #3b82f6; border-color: rgba(59,130,246,.35); }
.fml-tok-num    { background: rgba(19, 208, 145, 0.167);  color: #10b981; border-color: rgba(16,185,129,.35); }
.fml-tok-op     { background: rgba(216, 209, 7, 0.4);  color: #f97316; border-color: rgba(249,115,22,.35); }
.fml-tok-op-add { background: rgba(6,182,212,.14);   color: #06b6d4; border-color: rgba(6,182,212,.4) !important; }
.fml-tok-op-sub { background: rgba(253, 54, 54, 0.228);   color: #ef4444; border-color: rgba(239,68,68,.4) !important; }
.fml-tok-op-mul { background: rgba(139,92,246,.14);  color: #8b5cf6; border-color: rgba(139,92,246,.4) !important; }
.fml-tok-op-div { background: rgba(240, 15, 206, 0.301);   color: #ec4899; border-color: rgba(236,72,153,.4) !important; }
.fml-tok-paren  { background: rgba(224, 253, 35, 0.372);  color: #a855f7; border-color: rgba(168,85,247,.35); }
.fml-tok-del {
  position: absolute; top: -7px; right: -7px;
  width: 16px; height: 16px;
  display: flex; align-items: center; justify-content: center;
  background: #ef4444; border: none; border-radius: 50%;
  color: #fff; font-size: .68rem; font-weight: 700;
  cursor: pointer; line-height: 1; padding: 0;
  opacity: 0; transition: opacity .15s;
  z-index: 2;
}
.fml-tok:hover .fml-tok-del { opacity: 1; }
.fml-tok-del:hover { background: #dc2626; }
.fml-palette-label { font-size: .74rem; color: var(--tx3); margin: 10px 0 5px; }
.fml-palette { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.fml-palette-group {
  font-size: .72rem; color: var(--tx3); width: 100%; margin-top: 6px;
}
.fml-pal-tok {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 5px 11px; border-radius: 7px; font-size: .84rem; font-weight: 600;
  cursor: grab; -webkit-user-select: none; user-select: none; border: 1.5px solid transparent;
  transition: box-shadow .15s, transform .1s;
}
.fml-pal-tok:hover { box-shadow: 0 2px 8px rgba(0,0,0,.18); transform: translateY(-1px); }
.fml-const-inp {
  width: 86px; padding: 5px 8px; border-radius: 7px;
  border: 1.5px solid var(--bd); background: var(--bg3); color: var(--tx); font-size: .83rem;
}
.fml-add-const-btn {
  padding: 5px 11px; border-radius: 7px; border: 1.5px solid var(--bd);
  background: var(--bg3); color: var(--tx); font-size: .8rem; cursor: pointer;
  transition: background .15s;
}
.fml-add-const-btn:hover { background: var(--accent); color: #fff; border-color: var(--accent); }
.adm-formula-test {
  font-size: .8rem; margin-top: 8px; padding: 7px 11px; border-radius: 7px;
  min-height: 0;
}
.adm-formula-test.ok  { background: rgba(16,185,129,.1);  color: #10b981; }
.adm-formula-test.err { background: rgba(239,68,68,.1);  color: #ef4444; }

/* ─── USERS TAB: ADD FORM ─── */
.adm-add-user-bar {
  display: flex; flex-wrap: wrap; gap: 8px; padding: 14px 16px 10px;
  border-bottom: 1.5px solid var(--border); background: var(--bg2);
  border-radius: 12px 12px 0 0;
}
.adm-add-field { display: flex; flex-direction: column; flex: 1; min-width: 110px; }
.adm-add-field-role { flex: 0 0 160px; }
.adm-add-actions { display: flex; flex-direction: column; justify-content: flex-end; }
.adm-add-label { font-size: .7rem; font-weight: 700; color: var(--tx2); text-transform: uppercase; letter-spacing: .05em; margin-bottom: 4px; }
.adm-add-label .req { color: #ef4444; }

/* ─── USERS TAB: FILTER BAR ─── */
.adm-filter-bar {
  display: flex; flex-wrap: wrap; gap: 8px; padding: 10px 16px 12px;
  border-bottom: 1px solid var(--border); background: var(--surface);
}
.adm-filter-field { display: flex; flex-direction: column; }
.adm-filter-search { flex: 1; min-width: 200px; }
.adm-filter-actions { justify-content: flex-end; min-width: 120px; }
.adm-filter-label { font-size: .7rem; font-weight: 700; color: var(--tx2); text-transform: uppercase; letter-spacing: .05em; margin-bottom: 4px; }
.adm-filter-inp { padding: 7px 10px; border: 1.5px solid var(--border); border-radius: 8px; background: var(--bg2); color: var(--tx); font-size: .85rem; outline: none; }
.adm-filter-inp:focus { border-color: var(--accent); }

/* Keep Admin Users controls visually aligned (input/select/button same height) */
.adm-add-user-bar .adm-tbl-inp,
.adm-add-user-bar .adm-tbl-sel,
.adm-filter-bar .adm-filter-inp,
.adm-filter-bar .adm-tbl-sel,
.adm-add-user-bar .adm-add-actions .adm-btn,
.adm-filter-actions .adm-btn {
  height: 44px;
  min-height: 44px;
  box-sizing: border-box;
}

.adm-add-user-bar .adm-add-actions .adm-btn,
.adm-filter-actions .adm-btn {
  padding: 0 16px;
  line-height: 1;
}

/* ─── USERS TABLE ─── */
.adm-loading-row { text-align: center; padding: 20px; color: var(--tx2); font-size: .88rem; }
.adm-table-wrap { overflow-x: auto; margin-top: 0; }
.adm-table { width: 100%; border-collapse: collapse; font-size: .85rem; }
.adm-table th { background: rgba(123,104,238,.06); color: var(--tx2); font-weight: 700; font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; padding: 8px 10px; text-align: left; border-bottom: 1.5px solid var(--border); white-space: nowrap; }
.adm-table td { padding: 6px 8px; border-bottom: 1px solid var(--bg2); color: var(--tx); vertical-align: middle; }
.adm-table tr:last-child td { border-bottom: none; }
.adm-table tr:hover td { background: rgba(123,104,238,.03); }
.adm-users-table .col-num   { width: 36px; text-align: center; }
.adm-users-table .col-username { white-space: nowrap; }
.adm-users-table .col-name,
.adm-users-table .col-team  { min-width: 110px; }
.adm-users-table .col-role  { width: 160px; }
.adm-users-table .col-pw    { min-width: 140px; }
.adm-users-table .col-status { width: 80px; text-align: center; }
.adm-users-table .col-act   { width: 80px; text-align: center; }
.adm-tbl-inp {
  width: 100%; box-sizing: border-box;
  padding: 5px 8px; border: 1.5px solid var(--border); border-radius: 7px;
  background: var(--bg2); color: var(--tx); font-size: .82rem; outline: none;
}
.adm-tbl-inp:focus { border-color: var(--accent); }
#fldlbl-list .adm-tbl-inp:not(:placeholder-shown) {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 8%, var(--bg2));
  color: var(--tx);
  font-weight: 600;
}
.adm-tbl-sel {
  width: 100%; box-sizing: border-box;
  padding: 5px 8px; border: 1.5px solid var(--border); border-radius: 7px;
  background: var(--bg2); color: var(--tx); font-size: .82rem; outline: none; cursor: pointer;
}
.adm-tbl-sel:focus { border-color: var(--accent); }
.status-badge { display: inline-block; padding: 3px 10px; border-radius: 20px; font-size: .73rem; font-weight: 600; cursor: pointer; user-select: none; }
.status-active   { background: rgba(16,185,129,.12); color: #10b981; border: 1px solid rgba(16,185,129,.22); }
.status-inactive { background: rgba(239,68,68,.09); color: #ef4444; border: 1px solid rgba(239,68,68,.2); }
.role-badge { display: inline-block; padding: 2px 8px; border-radius: 20px; font-size: .73rem; font-weight: 700; }
.role-superadmin { background: rgba(168,85,247,.12); color: #a855f7; border: 1px solid rgba(168,85,247,.25); }
.role-admin { background: rgba(249,115,22,.12); color: #f97316; border: 1px solid rgba(249,115,22,.25); }
.role-user  { background: rgba(59,130,246,.1); color: #3b82f6; border: 1px solid rgba(59,130,246,.2); }

/* ─── EXTRA FIELDS (TOOL FORM) ─── */
#extra-fields-wrap { margin-bottom: 12px; }
.xf-card { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; overflow: hidden; }
.xf-card-title { padding: 10px 16px; font-size: .85rem; font-weight: 700; color: var(--tx); border-bottom: 1px solid var(--border); background: var(--bg2); }
.xf-fields { display: flex; flex-direction: column; }
/* A row holds one or more fields; multiple fields share a line when flagged inline */
.xf-row { display: flex; flex-wrap: wrap; border-bottom: 1px solid var(--bg2); }
.xf-row:last-child { border-bottom: none; }
.xf-row > .xf-field { flex: 1 1 0; min-width: 0; border-bottom: none; }
.xf-field { padding: 10px 16px; border-bottom: 1px solid var(--bg2); }
.xf-field:last-child { border-bottom: none; }
.xf-inp { width: 100%; box-sizing: border-box; }
/* Size extra fields to their content instead of stretching full width:
   dropdowns fit the widest option, numbers stay compact. */
/* align-self stops the flex column (.ifield) from stretching these to full width */
.xf-field select.xf-inp { width: auto; min-width: 110px; max-width: 100%; align-self: flex-start; }
.xf-field input[type=number].xf-inp { width: auto; min-width: 110px; max-width: 180px; align-self: flex-start; }
.lbl-req { color: #ef4444; }
.xf-toggle { display: inline-flex; align-items: center; position: relative; cursor: pointer; width: 46px; height: 24px; }
.xf-toggle input { opacity: 0; width: 0; height: 0; position: absolute; }
/* Off-state track: darker than the card so the toggle stands out (was var(--border) which blended in) */
.xf-toggle-slider { position: absolute; inset: 0; background: #94a3b8; border: 1px solid #64748b; border-radius: 24px; transition: .25s; }
.xf-toggle-slider::before { content: ''; position: absolute; height: 18px; width: 18px; left: 2px; bottom: 2px; background: #fff; border-radius: 50%; box-shadow: 0 1px 2px rgba(0,0,0,.35); transition: .25s; }
.xf-toggle input:checked + .xf-toggle-slider { background: #16a34a; border-color: #15803d; }
/* ON-state knob turns green */
.xf-toggle input:checked + .xf-toggle-slider::before { transform: translateX(22px); background: #4ade80; box-shadow: 0 1px 2px rgba(0,0,0,.3); }
.xf-photo-wrap { display: flex; flex-direction: column; gap: 6px; }
.xf-photo-prev img { max-width: 100px; max-height: 70px; border-radius: 6px; object-fit: cover; cursor: pointer; border: 1px solid var(--border); margin-top: 4px; }
.xf-photo-actions { display: flex; gap: 6px; }

/* ─── ADMIN: FIELD BUILDER ─── */
.xfb-add-bar { display: flex; flex-wrap: wrap; gap: 8px; padding-bottom: 14px; border-bottom: 1px solid var(--border); margin-bottom: 14px; align-items: flex-end; }
.xfb-add-bar .adm-tbl-inp,
.xfb-add-bar .adm-tbl-sel { flex: 1; min-width: 110px; }
.xfb-req-label { display: flex; align-items: center; gap: 5px; font-size: .82rem; color: var(--tx2); white-space: nowrap; cursor: pointer; }
.xfb-list { display: flex; flex-direction: column; gap: 6px; }
.xfb-row { display: flex; align-items: center; gap: 8px; padding: 8px 10px; background: var(--bg2); border-radius: 8px; border: 1px solid var(--border); flex-wrap: wrap; }
.xfb-row-label { flex: 1; font-size: .85rem; font-weight: 600; color: var(--tx); min-width: 80px; }
.xfb-type-tag { font-size: .72rem; padding: 2px 8px; border-radius: 10px; background: rgba(123,104,238,.12); color: var(--accent); font-weight: 700; white-space: nowrap; }
.xfb-row-options { font-size: .75rem; color: var(--tx3); flex-basis: 100%; padding-top: 2px; }
.xfb-row-actions { display: flex; gap: 4px; margin-left: auto; }

/* ─── EXAMPLE IMG MANAGER ─── */
.ex-img-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 14px; margin-top: 4px; }
.ex-img-card {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: 10px; overflow: hidden; position: relative;
}
.ex-img-thumb {
  width: 100%; height: 110px; object-fit: cover; display: block;
  cursor: zoom-in; transition: opacity .2s; background: var(--bg3);
}
.ex-img-thumb.placeholder { object-fit: none; height: 110px; background: var(--bg3); opacity: .4; }
.ex-img-label { padding: 8px 10px 4px; font-size: .8rem; font-weight: 700; color: var(--tx); }
.ex-img-sub { padding: 0 10px 8px; font-size: .73rem; color: var(--tx2); }
.ex-img-actions { padding: 0 8px 10px; display: flex; gap: 6px; flex-wrap: wrap; }
.ex-img-tag { display: inline-block; padding:2px 8px; border-radius:12px; font-size:.7rem; background:rgba(16,185,129,.1); color:#10b981; border:1px solid rgba(16,185,129,.2); margin-bottom:4px; }
.ex-img-tag.custom { background:rgba(249,115,22,.1); color:#f97316; border-color:rgba(249,115,22,.2); }

/* Page header */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 16px;
  padding: 10px 16px;
  border-bottom: 2px solid rgba(255, 255, 255, 0.35);
  background: rgba(255, 255, 255, 0.15);
  border-radius: 16px;
  backdrop-filter: blur(10px);
  position: relative;
  z-index: 1;
}

.page-header-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
  min-width: 170px;
  flex-shrink: 0;
}

.progress-mini-label {
  font-size: .78rem;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.96);
  letter-spacing: .01em;
}

.progress-mini-stats {
  display: inline-flex;
  align-items: baseline;
  gap: 10px;
  color: #ffffff;
}

.progress-mini-stats strong {
  font-family: var(--font-mono);
  font-size: 1.18rem;
  line-height: 1;
  color: #ffffff;
}

.progress-mini-stats span {
  font-size: .9rem;
  font-family: var(--font-mono);
  color: rgba(255, 255, 255, 0.92);
}

.progress-mini-track {
  width: 170px;
  height: 12px;
  border-radius: 99px;
  background: rgba(15, 23, 42, 0.28);
  border: 1px solid rgba(255, 255, 255, 0.35);
  overflow: hidden;
}

.progress-mini-bar {
  width: 0%;
  height: 100%;
  border-radius: 99px;
  background: #22d3ee;
  box-shadow: none;
  transition: width .35s ease;
}

.progress-donut {
  --progress: 0%;
  width: 84px;
  height: 84px;
  border-radius: 50%;
  background: conic-gradient(#00d4ff 0 var(--progress), rgba(255,255,255,.25) var(--progress) 100%);
  position: relative;
  box-shadow: 0 10px 24px rgba(0,0,0,.12);
}

.progress-donut::before {
  content: '';
  position: absolute;
  inset: 9px;
  border-radius: 50%;
  background: rgba(255,255,255,.9);
  box-shadow: inset 0 0 0 1px rgba(123,104,238,.12);
}

.progress-donut-inner {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  z-index: 1;
  color: #00a3d7;
}

.progress-donut-inner strong {
  display: block;
  font-family: var(--font-mono);
  font-size: .96rem;
  line-height: 1;
}

.progress-donut-inner span {
  font-size: .58rem;
  color: #6b7280;
  margin-top: 2px;
  line-height: 1.1;
}

.page-header-left h2 {
  font-family: var(--font-head);
  font-size: 1.3rem;
  font-weight: 700;
  color: #ffffff;
  letter-spacing: -.5px;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.page-header-left p {
  font-size: .78rem;
  color: rgba(255, 255, 255, 0.9);
  margin-top: 3px;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.1);
}

/* ═══════════════════════════════════════════════
   PROGRESS BAR
═══════════════════════════════════════════════ */
.progress-wrap {
  display: none;
  margin-bottom: 16px;
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid rgba(123, 104, 238, 0.2);
  border-radius: 18px;
  padding: 14px 18px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
  backdrop-filter: blur(10px);
  position: relative;
  z-index: 1;
}

.progress-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.progress-header-left {
  font-size: .74rem;
  font-weight: 600;
  color: #7b68ee;
  text-transform: uppercase;
  letter-spacing: .8px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.progress-pct-badge {
  font-family: var(--font-mono);
  font-size: .74rem;
  font-weight: 600;
  color: #00d4ff;
  background: rgba(0, 212, 255, 0.12);
  padding: 3px 10px;
  border-radius: 20px;
  border: 1px solid rgba(0, 212, 255, 0.25);
}

.progress-track {
  height: 6px;
  background: rgba(123, 104, 238, 0.12);
  border-radius: 99px;
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, #7b68ee, #00d4ff);
  border-radius: 99px;
  transition: width .5s cubic-bezier(.34,1.56,.64,1);
  width: 0%;
  position: relative;
}

.progress-bar::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,.3), transparent);
  animation: shimmer 2s infinite;
}

@keyframes shimmer {
  0%, 100% { transform: translateX(-200%); }
  50%       { transform: translateX(200%); }
}

.progress-footer {
  margin-top: 2px;
  font-family: var(--font-mono);
  font-size: .64rem;
  color: rgba(255, 255, 255, 0.85);
}

body.dark-theme .progress-wrap {
  background: rgba(33, 38, 45, 0.95);
  border-color: rgba(123, 104, 238, 0.3);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
}

body.dark-theme .progress-header-left {
  color: #00d4ff;
}

body.dark-theme .progress-track {
  background: rgba(123, 104, 238, 0.2);
}

/* ═══════════════════════════════════════════════
   MAIN GRID LAYOUT
═══════════════════════════════════════════════ */
.main-grid {
  display: grid;
  grid-template-columns: 58fr 42fr;
  gap: 14px;
  align-items: start;
}

@media (max-width: 960px) {
  .main-grid { grid-template-columns: 1fr; }
}

.col-left, .col-right {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* ═══════════════════════════════════════════════
   SECTION CARDS
═══════════════════════════════════════════════ */
.scard {
  background: rgba(255, 255, 255, 0.98);
  border: none;
  border-radius: 14px;
  overflow: visible;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
  transition: box-shadow .3s, transform .3s;
  backdrop-filter: blur(10px);
  position: relative;
}

.scard:has(.ac-wrap) {
  overflow: visible !important;
}

.scard-body {
  overflow: visible !important;
}

.scard:hover { 
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.14); 
  transform: translateY(-1px);
}

.scard-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid rgba(123, 104, 238, 0.15);
  background: linear-gradient(135deg, rgba(123, 104, 238, 0.08), rgba(0, 212, 255, 0.08));
  border-radius: 14px 14px 0 0;
}

.scard-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-body);
  font-size: .8rem;
  font-weight: 700;
  color: #7b68ee;
  text-transform: none;
  letter-spacing: .2px;
}

.scard-title .icon {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, rgba(123, 104, 238, 0.15), rgba(0, 212, 255, 0.15));
  border: 1px solid rgba(123, 104, 238, 0.25);
  border-radius: 7px;
  font-size: .8rem;
}

.scard-body { padding: 14px 16px; }

body.dark-theme .scard {
  background: rgba(33, 38, 45, 0.95);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}

body.dark-theme .scard-header {
  background: linear-gradient(135deg, rgba(123, 104, 238, 0.12), rgba(0, 212, 255, 0.12));
  border-bottom-color: rgba(123, 104, 238, 0.25);
}

body.dark-theme .scard-title {
  color: #00d4ff;
}

/* ═══════════════════════════════════════════════
   FORM ELEMENTS
═══════════════════════════════════════════════ */
.ifield {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.lbl {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 1px;
  font-size: .64rem;
  font-weight: 600;
  color: #7b68ee;
  text-transform: none;
  letter-spacing: .25px;
  margin-bottom: 6px;
  font-family: Arial, sans-serif;
}

input[type=number] {
  padding: 8px 10px;
  background: #ffffff;
  border: 2px solid #e1e8ed;
  border-radius: 7px;
  color: #2c3e50;
  font-family: Arial, sans-serif;
  font-size: .76rem;
  font-weight: 500;
  width: 100%;
  max-width: 112px;
  transition: all .3s ease;
  -moz-appearance: textfield;
}

input[type=number]::-webkit-outer-spin-button,
input[type=number]::-webkit-inner-spin-button { -webkit-appearance: none; }

/* Placeholder numbers — very faint so users know it's an example */
input[type=number]::placeholder { color: rgba(44, 62, 80, 0.22); }
body.dark-theme input[type=number]::placeholder { color: rgba(230, 237, 243, 0.2); }

/* Filled number input — visually distinct from empty */
.scard input[type=number]:not(:placeholder-shown),
.xf-field input[type=number]:not(:placeholder-shown) {
  border-color: #3b82f6;
  background: rgba(59, 130, 246, 0.06);
  color: #1d4ed8;
  font-weight: 700;
}
body.dark-theme .scard input[type=number]:not(:placeholder-shown),
body.dark-theme .xf-field input[type=number]:not(:placeholder-shown) {
  border-color: #3b82f6;
  background: rgba(59, 130, 246, 0.12);
  color: #93c5fd;
}

/* Filled time input */
input[type=time].has-value {
  border-color: #3b82f6;
  background: rgba(59, 130, 246, 0.06);
  color: #1d4ed8;
  font-weight: 700;
}
body.dark-theme input[type=time].has-value {
  border-color: #3b82f6;
  background: rgba(59, 130, 246, 0.12);
  color: #93c5fd;
}

/* Filled PV stepper */
.pv-stepper.filled {
  border-color: #3b82f6;
  background: rgba(59, 130, 246, 0.06);
}
.pv-stepper.filled .pv-val {
  color: #1d4ed8;
  font-weight: 700;
}
body.dark-theme .pv-stepper.filled {
  border-color: #3b82f6;
  background: rgba(59, 130, 246, 0.12);
}
body.dark-theme .pv-stepper.filled .pv-val { color: #93c5fd; }

input[type=time] {
  padding: 8px 10px;
  background: #ffffff;
  border: 2px solid #e1e8ed;
  border-radius: 7px;
  color: #2c3e50;
  font-size: .76rem;
  font-family: Arial, sans-serif;
  width: 100%;
  transition: all .3s ease;
  font-weight: 500;
}

select {
  padding: 8px 10px;
  background: #ffffff;
  border: 2px solid #e1e8ed;
  border-radius: 7px;
  color: #2c3e50;
  font-size: .76rem;
  font-family: Arial, sans-serif;
  width: 100%;
  transition: all .3s ease;
  font-weight: 500;
}

input[type=number]:focus,
input[type=time]:focus,
select:focus,
input[type=text]:focus,
input[type=password]:focus {
  outline: none;
  border-color: #00d4ff;
  box-shadow: 0 0 0 3px rgba(0, 212, 255, 0.15);
}

select option { background: var(--bg2); }

body.dark-theme input[type=number],
body.dark-theme input[type=time],
body.dark-theme input[type=text],
body.dark-theme input[type=password],
body.dark-theme select,
body.dark-theme textarea {
  background: #161b22;
  border-color: #3b4654;
  color: #e6edf3;
}

body.dark-theme select option {
  background: #161b22;
  color: #e6edf3;
}

body.dark-theme select option:checked {
  background: #2563eb;
  color: #ffffff;
}

/* ═══════════════════════════════════════════════
   SITE INFO SECTION
═══════════════════════════════════════════════ */
.site-row {
  display: grid;
  grid-template-columns: .9fr 1.3fr;
  gap: 10px;
  margin-bottom: 10px;
}

.subcon-config-row {
  display: grid;
  grid-template-columns: .95fr .75fr 1.3fr;
  gap: 8px;
}

.site-row input[type=text],
.subcon-config-row select {
  height: 46px;
  min-height: 46px;
  box-sizing: border-box;
}

.helper-sync-row {
  margin-top: 6px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.helper-sync-status {
  font-size: .68rem;
  color: var(--tx3);
  line-height: 1.3;
}

.helper-sync-status.info { color: var(--tx3); }
.helper-sync-status.success { color: var(--pass); }
.helper-sync-status.warn { color: var(--amber); }

.btn-helper-refresh {
  display: none;
  align-items: center;
  gap: 4px;
  padding: 6px 10px;
  border: 1px solid rgba(123, 104, 238, 0.35);
  border-radius: 7px;
  background: rgba(123, 104, 238, 0.08);
  color: #6b5cd3;
  font-size: .68rem;
  font-weight: 700;
  cursor: pointer;
}

.btn-helper-refresh:hover {
  background: rgba(123, 104, 238, 0.16);
}

.btn-helper-refresh:disabled {
  opacity: .65;
  cursor: not-allowed;
}

@media (max-width: 900px) { .site-row { grid-template-columns: .85fr 1.15fr; } }
@media (max-width: 480px) { .site-row { grid-template-columns: 1fr; } }
@media (max-width: 640px) { .subcon-config-row { grid-template-columns: 1fr; } }

.ac-wrap { position: relative; }

.ac-list {
  position: fixed;
  min-width: 200px;
  max-width: 420px;
  background: rgba(255, 255, 255, 0.98);
  border: 2px solid rgba(123, 104, 238, 0.35);
  border-radius: 14px;
  max-height: 260px;
  overflow-y: auto;
  z-index: 2147483647;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.2);
  display: none;
}

body.dark-theme .ac-list {
  background: rgba(33, 38, 45, 0.98);
  border-color: rgba(123, 104, 238, 0.5);
}

.ac-list::-webkit-scrollbar { width: 5px; }
.ac-list::-webkit-scrollbar-track { background: rgba(248, 250, 252, 0.5); }
.ac-list::-webkit-scrollbar-thumb { background: rgba(123, 104, 238, 0.3); border-radius: 4px; }

body.dark-theme .ac-list::-webkit-scrollbar-track { background: rgba(28, 35, 51, 0.5); }
body.dark-theme .ac-list::-webkit-scrollbar-thumb { background: rgba(123, 104, 238, 0.5); }

.ac-list div {
  padding: 11px 16px;
  cursor: pointer;
  font-size: .85rem;
  transition: background .15s;
  border-bottom: 1px solid rgba(123, 104, 238, 0.1);
  color: #2c3e50;
}

body.dark-theme .ac-list div {
  color: #e6edf3;
  border-bottom-color: rgba(123, 104, 238, 0.2);
}

.ac-list div:last-child { border-bottom: none; }
.ac-list div:hover { 
  background: rgba(0, 212, 255, 0.08);
}
.ac-list div strong { color: #7b68ee; font-weight: 700; }
.ac-list div small { color: #64748b; }

body.dark-theme .ac-list div strong { color: #00d4ff; }
body.dark-theme .ac-list div small { color: #8b949e; }

.site-names {
  display: none;
  padding: 10px 12px;
  background: rgba(248, 250, 252, 0.85);
  border: 1px solid rgba(123, 104, 238, 0.18);
  border-radius: 14px;
  margin-top: 10px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.04);
}

.sn-row {
  font-size: .76rem;
  color: var(--tx2);
  padding: 2px 0;
  display: flex;
  align-items: center;
  gap: 5px;
  flex-wrap: nowrap;
  white-space: nowrap;
  overflow-x: auto;
}

.sn-row strong { color: #5b6ee1; font-weight: 600; }
.sn-label { color: var(--tx3); font-size: .7rem; margin-left: 6px; }
.sn-sep { color: var(--tx3); opacity: .65; margin: 0 4px; }

body.dark-theme .site-names {
  background: rgba(45, 55, 72, 0.6);
  border-color: rgba(123, 104, 238, 0.3);
}

body.dark-theme .sn-row strong { color: #a5b4fc; }
body.dark-theme .sn-row { color: #c9d1d9; }

/* GPS row inside site-names */
.sn-gps-row { flex-wrap: wrap; white-space: normal; gap: 6px; padding-top: 4px; border-top: 1px dashed rgba(0,0,0,.12); margin-top: 2px; }
body.dark-theme .sn-gps-row { border-top-color: rgba(255,255,255,.15); }
.site-map-btn {
  display: inline-flex; align-items: center; gap: 3px;
  font-size: .7rem; padding: 1px 7px; border-radius: 12px;
  background: #3b82f6; color: #fff; text-decoration: none;
  white-space: nowrap; transition: background .15s;
}
.site-map-btn:hover { background: #2563eb; }
.sn-user-gps { color: var(--tx3); font-size: .7rem; }
.sn-gps-dist { font-size: .7rem; font-weight: 600; }

/* Admin GPS toggle */
.gps-toggle-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0; }
.gps-toggle-label { display: flex; align-items: center; gap: 8px; font-size: .85rem; font-weight: 600; color: var(--tx1); cursor: default; }
.gps-toggle-icon { font-size: 1.1rem; }
.adm-toggle-btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 5px 14px 5px 6px;
  border-radius: 20px; border: none; cursor: pointer;
  background: #e5e7eb; color: #6b7280; font-size: .8rem; font-weight: 600;
  transition: background .2s, color .2s; min-width: 84px;
}
.adm-toggle-btn.active { background: #22c55e; color: #fff; }
.adm-toggle-knob {
  width: 22px; height: 22px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25);
  transition: background .2s;
  flex-shrink: 0;
}
body.dark-theme .adm-toggle-btn { background: #374151; color: #9ca3af; }
body.dark-theme .adm-toggle-btn.active { background: #16a34a; color: #fff; }
.gps-radius-row { margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--border); transition: opacity .2s; }
.gps-status-msg { margin-top: 12px; padding: 8px 12px; border-radius: 8px; font-size: .82rem; }
.gps-status-msg.gps-on { background: rgba(34,197,94,.1); color: #15803d; border: 1px solid rgba(34,197,94,.3); }
.gps-status-msg.gps-off { background: rgba(245,158,11,.1); color: #b45309; border: 1px solid rgba(245,158,11,.3); }
body.dark-theme .gps-status-msg.gps-on { color: #4ade80; background: rgba(34,197,94,.08); border-color: rgba(34,197,94,.2); }
body.dark-theme .gps-status-msg.gps-off { color: #fbbf24; background: rgba(245,158,11,.08); border-color: rgba(245,158,11,.2); }

/* ═══════════════════════════════════════════════
   SYSTEM PARAMS ROW
═══════════════════════════════════════════════ */
.sys-params {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 14px;
  background: rgba(248, 250, 252, 0.85);
  border: 1px solid rgba(123, 104, 238, 0.18);
  border-radius: 16px;
  margin-bottom: 14px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

body.dark-theme .sys-params {
  background: rgba(45, 55, 72, 0.6);
  border-color: rgba(123, 104, 238, 0.3);
}

.sys-params-meta {
  display: grid;
  grid-template-columns: minmax(0, .82fr) minmax(0, .9fr) minmax(0, .9fr) minmax(0, 1.18fr);
  gap: 8px;
  align-items: start;
}

.sys-params-meta > .ifield {
  min-width: 0;
}

.sys-params-meta > .ifield > .lbl,
.module-input-field > .lbl {
  min-height: 30px;
}

.sys-params-meta input[type=number],
.sys-params-meta input[type=time] {
  max-width: none;
  min-width: 0;
}

.sys-params-meta .time-row {
  width: 100%;
}

.sys-params-meta .time-row input[type=time] {
  flex: 1 1 auto;
}

.sys-params-meta .btn-now {
  flex: 0 0 auto;
}

.sys-params-photos {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  align-items: start;
}

.sys-photo-field {
  min-width: 0;
}

.sys-photo-field .img-upload-box {
  height: 100%;
}

@media (max-width: 600px) {
  .sys-params-meta { grid-template-columns: 1fr 1fr; }
  .sys-params-meta > :first-child { grid-column: 1 / -1; }
  .sys-params-meta #inp-time-g { min-width: 136px; }
  .sys-params-photos { grid-template-columns: 1fr; }
}

/* ═══════════════════════════════════════════════
   PV STEPPER
═══════════════════════════════════════════════ */
.pv-stepper-wrap { display: flex; flex-direction: column; gap: 4px; }

.pv-stepper.pv-auto { pointer-events: none; }

.time-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.btn-now {
  padding: 7px 10px;
  border: 1px solid rgba(123, 104, 238, 0.35);
  border-radius: 7px;
  background: rgba(123, 104, 238, 0.08);
  color: #6b5cd3;
  font-size: .68rem;
  font-weight: 700;
  cursor: pointer;
}

.btn-now:hover { background: rgba(123, 104, 238, 0.16); }

.time-gap-warning {
  font-size: .68rem;
  color: #b45309;
  min-height: 16px;
}

body.dark-theme .time-gap-warning { color: #fbbf24; }

.pv-stepper {
  display: flex;
  align-items: center;
  width: 100%;
  min-height: 38px;
  padding: 0 10px;
  border: 2px solid #e1e8ed;
  border-radius: 7px;
  background: #ffffff;
  box-shadow: none;
}

.pv-stepper button {
  background: #ffffff;
  color: #7b68ee;
  border: none;
  width: 36px;
  height: 38px;
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .15s, color .15s;
  flex-shrink: 0;
  font-weight: 700;
}

.pv-stepper button:hover { 
  background: rgba(0, 212, 255, 0.15);
  color: #00d4ff;
}

.pv-stepper button:active { background: rgba(123, 104, 238, 0.2); }

.pv-val {
  font-size: .76rem;
  font-weight: 500;
  color: #2c3e50;
  width: 100%;
  text-align: left;
  line-height: 1;
  padding: 0;
  border: none;
}

.pv-hint {
  font-size: .62rem;
  color: var(--tx3);
  font-family: Arial, sans-serif;
}

.pv-kw-display {
  font-size: .68rem;
  color: var(--tx2);
  font-family: Arial, sans-serif;
  margin-top: 0;
  line-height: 1.2;
  font-weight: 500;
}

/* ═══════════════════════════════════════════════
   MODULE GRID
═══════════════════════════════════════════════ */
.mod-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
  max-width: 600px;
  margin: 0 auto;
}

.mod-col {
  background: rgba(248, 250, 252, 0.95);
  border: 1px solid rgba(123, 104, 238, 0.18);
  border-radius: 16px;
  overflow: hidden;
  transition: border-color .2s, box-shadow .2s;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.mod-col:hover { 
  border-color: rgba(0, 212, 255, 0.35);
  box-shadow: 0 4px 16px rgba(0, 212, 255, 0.12);
}

.mod-header {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 14px;
  background: linear-gradient(135deg, rgba(123, 104, 238, 0.08), rgba(0, 212, 255, 0.08));
  border-bottom: 1px solid rgba(123, 104, 238, 0.15);
  font-family: var(--font-mono);
  font-size: .72rem;
  font-weight: 600;
  color: #7b68ee;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.mod-header::before {
  content: '';
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: linear-gradient(135deg, #7b68ee, #00d4ff);
  box-shadow: 0 0 8px rgba(0, 212, 255, 0.5);
  flex-shrink: 0;
}

.mod-body {
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.module-inputs-row {
  display: grid;
  gap: 10px;
  align-items: start;
}

.module-inputs-row.cols-3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.module-inputs-row.cols-2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.module-input-field,
.module-photo-field {
  min-width: 0;
}

.module-input-field input[type=number],
.module-input-field input[type=time] {
  max-width: none;
  min-width: 0;
}

.module-input-field .time-row {
  width: 100%;
}

.module-input-field .time-row input[type=time] {
  flex: 1 1 auto;
}

/* Keep key measurement controls on one visual baseline */
.sys-params-meta input[type=number],
.sys-params-meta input[type=time],
.module-input-field input[type=number],
.module-input-field input[type=time],
.sys-params-meta .btn-now,
.module-input-field .btn-now,
.sys-params-meta .pv-stepper {
  height: 46px;
  min-height: 46px;
  box-sizing: border-box;
}

.sys-params-meta .time-row,
.module-input-field .time-row {
  align-items: stretch;
}

.sys-params-meta .btn-now,
.module-input-field .btn-now {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 12px;
  line-height: 1;
}

.module-photos-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  align-items: start;
}

body.dark-theme .mod-col {
  background: rgba(45, 55, 72, 0.6);
  border-color: rgba(123, 104, 238, 0.3);
}

body.dark-theme .mod-col:hover {
  border-color: rgba(0, 212, 255, 0.5);
  box-shadow: 0 4px 16px rgba(0, 212, 255, 0.2);
}

body.dark-theme .mod-header {
  background: linear-gradient(135deg, rgba(123, 104, 238, 0.15), rgba(0, 212, 255, 0.15));
  border-bottom-color: rgba(123, 104, 238, 0.25);
  color: #00d4ff;
}

@media (max-width: 480px) {
  .module-inputs-row.cols-3,
  .module-inputs-row.cols-2,
  .module-photos-row {
    grid-template-columns: 1fr;
  }
}

/* ═══════════════════════════════════════════════
   IMAGE UPLOAD
═══════════════════════════════════════════════ */
.img-upload-box {
  border: 2px dashed rgba(123, 104, 238, 0.3);
  border-radius: 14px;
  background: rgba(248, 250, 252, 0.6);
  overflow: hidden;
  position: relative;
  transition: all .2s;
}

.img-upload-box:not(.filled) { cursor: pointer; }

.img-upload-box:not(.filled):hover {
  border-color: #00d4ff;
  background: rgba(0, 212, 255, 0.08);
  border-style: solid;
}

.img-upload-box.filled {
  border-style: solid;
  border-color: var(--pass);
  background: var(--pass-dim);
}

.img-upload-box.drag-over {
  border-color: #7b68ee;
  background: rgba(123, 104, 238, 0.1);
  border-style: solid;
}

.img-placeholder-area {
  padding: 6px 4px 4px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  min-height: 54px;
  cursor: pointer;
}
.img-placeholder-area::before {
  content: '+';
  font-size: 2.4rem;
  font-weight: 300;
  line-height: 1;
  color: rgba(123, 104, 238, 0.45);
  pointer-events: none;
}

.img-ph-svg { width: 42px; height: 36px; opacity: .75; }
.img-ph-hint { font-size: .56rem; color: var(--tx3); line-height: 1.2; text-align: center; }

.img-actions-bar {
  display: flex;
  justify-content: center;
  gap: 4px;
  padding: 4px;
}

.img-btn {
  border: none;
  border-radius: 8px;
  font-size: .62rem;
  font-weight: 600;
  padding: 5px 9px;
  display: flex;
  align-items: center;
  gap: 3px;
  transition: all .15s;
  cursor: pointer;
}

.img-btn-file { 
  background: rgba(123, 104, 238, 0.12);
  border: 1px solid rgba(123, 104, 238, 0.25);
  color: #7b68ee;
}
/* Hide file-picker and camera buttons — + icon is the only interaction.
   NOTE: extra (xf) photo fields have no clickable upload box, so their
   เลือก/ถ่าย buttons are their only way to add an image — keep them visible. */
.sys-photo-field .img-btn-file,
.module-photo-field .img-btn-file,
.sys-photo-field .img-btn-cam,
.module-photo-field .img-btn-cam { display: none !important; }

.img-btn-file:hover { 
  background: rgba(123, 104, 238, 0.2);
  border-color: #7b68ee;
}

.img-btn-cam  { 
  background: rgba(0, 212, 255, 0.12);
  border: 1px solid rgba(0, 212, 255, 0.25);
  color: #00d4ff;
}

.img-btn-cam:hover { 
  background: rgba(0, 212, 255, 0.2);
  border-color: #00d4ff;
}

.img-btn-del  { 
  background: var(--fail-dim);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: var(--fail);
}

.img-btn-del:hover { 
  background: rgba(255,77,77,.2);
  border-color: var(--fail);
}

.img-preview-wrap { position: relative; width: 100%; height: 80px; }
.img-preview-wrap img { width: 100%; height: 80px; object-fit: cover; display: block; cursor: zoom-in; transition: opacity .2s; border-radius: 4px 4px 0 0; }

.img-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,.5);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity .2s;
  pointer-events: none;
}

.img-preview-wrap:hover .img-overlay { opacity: 1; }
.img-overlay span { font-size: 1.2rem; }

.img-fname {
  display: block;
  font-size: .55rem;
  color: var(--tx3);
  padding: 2px 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
  font-family: var(--font-mono);
}

.img-file { display: none; }

@keyframes spin-anim { to { transform: rotate(360deg); } }

.img-spin {
  display: none;
  width: 14px;
  height: 14px;
  border: 2px solid var(--border);
  border-top-color: var(--amber);
  border-radius: 50%;
  animation: spin-anim .7s linear infinite;
  margin: 4px auto;
}

.img-ok-badge {
  display: none;
  position: absolute;
  top: 4px;
  right: 4px;
  background: var(--pass);
  color: #fff;
  border-radius: 50%;
  width: 18px;
  height: 18px;
  font-size: .6rem;
  align-items: center;
  justify-content: center;
  z-index: 2;
  font-weight: 700;
}

.img-upload-box.filled .img-ok-badge { display: flex; }

/* ═══════════════════════════════════════════════
   FORMULA CARD
═══════════════════════════════════════════════ */
.fcard {
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid rgba(123, 104, 238, 0.15);
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 4px 16px rgba(123, 104, 238, 0.08);
  backdrop-filter: blur(10px);
  position: relative;
  z-index: 1;
}

.fcard-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid rgba(123, 104, 238, 0.12);
  background: linear-gradient(135deg, rgba(123, 104, 238, 0.06), rgba(0, 212, 255, 0.06));
}

.fcard-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-body);
  font-size: .8rem;
  font-weight: 700;
  color: #7b68ee;
  text-transform: none;
  letter-spacing: .2px;
}

.fcard-body {
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.feq {
  padding: 6px 12px;
  background: rgba(248, 250, 252, 0.9);
  border: 1px solid rgba(123, 104, 238, 0.15);
  border-left: 3px solid #00d4ff;
  border-radius: 10px;
  transition: border-left-color .2s, box-shadow .2s;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.04);
}

.feq:hover { 
  border-left-color: #7b68ee; 
  box-shadow: 0 2px 8px rgba(123, 104, 238, 0.1);
}

.feq-name {
  font-size: .6rem;
  color: #7b68ee;
  text-transform: uppercase;
  letter-spacing: .8px;
  margin-bottom: 2px;
  font-family: Arial, sans-serif;
  font-weight: 700;
}

.feq-body {
  font-family: Arial, sans-serif;
  font-size: .84rem;
  color: var(--tx);
  line-height: 1.9;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 3px;
}
.feq-line {
  flex: 0 0 100%;
}
.feq-body em { color: #00d4ff; font-style: normal; font-weight: 600; }
/* ─── Math fraction renderer ─── */
.mfrac {
  display: inline-flex; flex-direction: column; align-items: center;
  vertical-align: middle; padding: 0 2px; font-size: .88em;
}
.mnum {
  border-bottom: 1.5px solid currentColor; padding: 0 5px 2px;
  text-align: center; white-space: nowrap;
}
.mden { padding: 2px 5px 0; text-align: center; white-space: nowrap; }
.mop  { opacity: .7; padding: 0 1px; }
.mparen { color: var(--tx3); }
.pr-lbl { font-style: normal; font-weight: 400; color: var(--tx); }

.fwhere {
  margin-top: 2px;
  padding: 7px 12px;
  background: rgba(248, 250, 252, 0.9);
  border-radius: 10px;
  border: 1px solid rgba(123, 104, 238, 0.15);
  font-size: .66rem;
  color: var(--tx3);
  font-family: Arial, sans-serif;
  line-height: 1.6;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.04);
}

.fwhere em { color: #7b68ee; font-style: normal; font-weight: 600; }

.manual-wrap { margin-top: 12px; }
.manual-card {
  background: rgba(255, 248, 248, .96);
  border: 1px solid rgba(239, 68, 68, .22);
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 4px 16px rgba(239,68,68,.08);
}
body.dark-theme .manual-card { background: rgba(50,20,20,.62); border-color: rgba(239,68,68,.28); }
.manual-card-header {
  padding: 12px 16px;
  background: linear-gradient(135deg, rgba(239,68,68,.08), rgba(251,146,60,.08));
  border-bottom: 1px solid rgba(239,68,68,.14);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.manual-card-title {
  font-family: var(--font-body);
  font-size: .8rem;
  font-weight: 700;
  color: #dc2626;
  text-transform: none;
  letter-spacing: .2px;
}
.manual-card-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}
.manual-refresh-btn {
  background: rgba(239, 68, 68, 0.08);
  border: 1px solid rgba(239, 68, 68, 0.24);
  color: #dc2626;
  font-size: .66rem;
  padding: 4px 10px;
  border-radius: 8px;
  cursor: pointer;
  transition: all .15s;
  display: flex;
  align-items: center;
  gap: 4px;
  font-weight: 700;
}
.manual-refresh-btn:hover {
  background: rgba(239, 68, 68, 0.16);
  border-color: rgba(185, 28, 28, 0.5);
  transform: translateY(-1px);
}
.manual-refresh-btn:disabled {
  opacity: .6;
  cursor: not-allowed;
  transform: none;
}
.manual-card-body { padding: 12px 16px 14px; display: flex; flex-direction: column; gap: 10px; }
.manual-item {
  border-left: 3px solid #ef4444;
  padding: 10px 12px;
  background: rgba(255,255,255,.72);
  border-radius: 10px;
}
body.dark-theme .manual-item { background: rgba(30,10,10,.55); }
.manual-item-title { font-weight: 800; color: #b91c1c; font-size: .84rem; margin-bottom: 4px; }
.manual-item-body { white-space: pre-line; color: #7f1d1d; font-size: .82rem; line-height: 1.6; }
body.dark-theme .manual-item-title { color: #fca5a5; }
body.dark-theme .manual-item-body { color: #fecaca; }

/* ── Manual Image Slideshow (user-facing) ── */
.manual-img-slideshow {
  margin-top: 10px;
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  background: #111;
  border-radius: 10px;
  overflow: hidden;
  cursor: zoom-in;
}
.manual-img-slides { position: absolute; inset: 0; }
.manual-img-slide {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: contain;
  opacity: 0;
  transition: opacity .7s ease-in-out;
  background: #111;
}
.manual-img-slide.active { opacity: 1; z-index: 1; }
.manual-img-dots {
  position: absolute; bottom: 8px; left: 50%; transform: translateX(-50%);
  display: flex; gap: 7px; z-index: 2;
}
.manual-img-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: rgba(255,255,255,.45); border: 1.5px solid rgba(255,255,255,.6);
  cursor: pointer; transition: background .2s, transform .15s;
}
.manual-img-dot.active { background: #fff; transform: scale(1.25); }
.manual-img-dot:hover { background: rgba(255,255,255,.8); }

/* ── Admin image strip ── */
.manual-admin-imgs {
  display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-start; margin-top: 4px;
}
.manual-admin-img-thumb {
  position: relative; width: 80px; height: 60px; border-radius: 7px;
  overflow: hidden; border: 1.5px solid rgba(239,68,68,.25); background: #111; flex-shrink: 0;
}
.manual-admin-img-thumb img {
  width: 100%; height: 100%; object-fit: cover; display: block;
}
.manual-admin-img-del {
  position: absolute; top: 2px; right: 2px;
  background: rgba(0,0,0,.62); color: #fff; border: none; border-radius: 50%;
  width: 18px; height: 18px; font-size: .65rem; line-height: 18px; text-align: center;
  cursor: pointer; padding: 0; transition: background .15s;
}
.manual-admin-img-del:hover { background: #dc2626; }
.manual-admin-img-add {
  width: 80px; height: 60px; border-radius: 7px;
  border: 1.5px dashed rgba(239,68,68,.4); background: rgba(239,68,68,.05);
  color: #ef4444; font-size: 1.4rem; line-height: 60px; text-align: center;
  cursor: pointer; transition: background .15s, border-color .15s; flex-shrink: 0;
}
.manual-admin-img-add:hover { background: rgba(239,68,68,.12); border-color: #ef4444; }
.manual-admin-img-uploading {
  width: 80px; height: 60px; border-radius: 7px;
  border: 1.5px solid rgba(239,68,68,.25); background: rgba(239,68,68,.08);
  font-size: .65rem; color: #b91c1c; display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}

/* PDF button in manual item (user-facing) */
.manual-pdf-btn {
  display: inline-flex; align-items: center; gap: 5px;
  margin-top: 8px; padding: 5px 14px;
  background: #dc2626; color: #fff; border: none; border-radius: 6px;
  font-size: .78rem; font-weight: 600; cursor: pointer;
  transition: background .15s;
}
.manual-pdf-btn:hover { background: #b91c1c; }
body.dark-theme .manual-pdf-btn { background: #ef4444; }
body.dark-theme .manual-pdf-btn:hover { background: #dc2626; }
/* PDF URL field in admin */
.manual-add-field-pdf { flex: 1; min-width: 220px; }
.manual-pdf-hint { font-weight: 400; font-size: .74rem; color: #6b7280; }
.manual-pdf-url-input { margin-top: 0; font-size: .78rem; }
/* PDF upload wrap */
.manual-pdf-upload-wrap {
  display: flex; align-items: center; gap: 7px; flex-wrap: wrap; margin-top: 2px;
}
.manual-pdf-pick-btn { font-size: .78rem; padding: 4px 11px; white-space: nowrap; }
.manual-pdf-filename { font-size: .76rem; color: #6b7280; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
body.dark-theme .manual-pdf-filename { color: #9ca3af; }
.manual-pdf-clear-btn {
  background: none; border: none; cursor: pointer; color: #9ca3af;
  font-size: .8rem; padding: 2px 5px; border-radius: 4px; flex-shrink: 0;
  transition: color .12s;
}
.manual-pdf-clear-btn:hover { color: #dc2626; }
.manual-pdf-badge {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: .72rem; background: #fee2e2; color: #b91c1c;
  padding: 2px 8px; border-radius: 4px; margin-top: 4px;
}
body.dark-theme .manual-pdf-badge { background: rgba(220,38,38,.2); color: #fca5a5; }
.manual-pdf-badge-link { cursor: pointer; text-decoration: underline dotted; }
.manual-pdf-badge-link:hover { background: #fecaca; }
/* PDF Viewer Modal */
.pdf-modal {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,.76); z-index: 2100;
  align-items: center; justify-content: center;
}
.pdf-modal.open { display: flex; }
.pdf-modal-box {
  background: #fff; border-radius: 12px;
  width: 90vw; max-width: 920px; height: 88vh;
  display: flex; flex-direction: column; overflow: hidden;
  box-shadow: 0 24px 64px rgba(0,0,0,.55);
}
body.dark-theme .pdf-modal-box { background: #1e1e2e; }
.pdf-modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 11px 16px; border-bottom: 1px solid #e5e7eb; flex-shrink: 0;
}
body.dark-theme .pdf-modal-header { border-color: rgba(255,255,255,.12); }
.pdf-modal-title { font-weight: 700; font-size: .93rem; color: #1e293b; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
body.dark-theme .pdf-modal-title { color: #f1f5f9; }
.pdf-modal-actions { display: flex; align-items: center; gap: 6px; flex-shrink: 0; margin-left: 10px; }
.pdf-modal-action-btn {
  background: #f1f5f9; border: 1px solid #e2e8f0; cursor: pointer;
  font-size: .78rem; font-weight: 600; color: #475569;
  padding: 4px 11px; border-radius: 6px; white-space: nowrap;
  transition: background .12s, color .12s;
}
.pdf-modal-action-btn:hover { background: #e2e8f0; color: #1e293b; }
body.dark-theme .pdf-modal-action-btn { background: rgba(255,255,255,.08); border-color: rgba(255,255,255,.15); color: #cbd5e1; }
body.dark-theme .pdf-modal-action-btn:hover { background: rgba(255,255,255,.16); color: #f1f5f9; }
.pdf-modal-close {
  background: none; border: none; cursor: pointer;
  font-size: 1.05rem; color: #64748b; padding: 4px 9px; border-radius: 6px;
  transition: background .12s;
}
.pdf-modal-close:hover { background: #fee2e2; color: #dc2626; }
body.dark-theme .pdf-modal-close:hover { background: rgba(239,68,68,.2); color: #fca5a5; }
.pdf-modal-body { flex: 1; overflow: hidden; }
.pdf-modal-frame { width: 100%; height: 100%; border: none; display: block; }

body.dark-theme .fcard {
  background: rgba(33, 38, 45, 0.95);
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.3);
}

body.dark-theme .fcard-header {
  background: linear-gradient(135deg, rgba(123, 104, 238, 0.12), rgba(0, 212, 255, 0.12));
  border-bottom-color: rgba(123, 104, 238, 0.25);
}

body.dark-theme .fcard-title {
  color: #00d4ff;
}

body.dark-theme .feq {
  background: rgba(45, 55, 72, 0.6);
  border-color: rgba(123, 104, 238, 0.25);
}

body.dark-theme .fwhere {
  background: rgba(45, 55, 72, 0.6);
  border-color: rgba(123, 104, 238, 0.25);
}

/* ═══════════════════════════════════════════════
   RESULT CARD
═══════════════════════════════════════════════ */
.rcard {
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid rgba(0, 212, 255, 0.25);
  border-top: 3px solid #00d4ff;
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
  backdrop-filter: blur(10px);
  position: relative;
  z-index: 1;
}

.rcard-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid rgba(0, 212, 255, 0.15);
  background: linear-gradient(135deg, rgba(0, 212, 255, 0.06), rgba(123, 104, 238, 0.06));
}

.rcard-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-body);
  font-size: .8rem;
  font-weight: 700;
  color: #00d4ff;
  text-transform: none;
  letter-spacing: .2px;
}

.rcard-body { padding: 14px 16px; }

body.dark-theme .rcard {
  background: rgba(33, 38, 45, 0.95);
  border-color: rgba(0, 212, 255, 0.35);
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.3);
}

body.dark-theme .rcard-header {
  background: linear-gradient(135deg, rgba(0, 212, 255, 0.12), rgba(123, 104, 238, 0.12));
  border-bottom-color: rgba(0, 212, 255, 0.25);
}

.rgrid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}

.ritem {
  background: rgba(248, 250, 252, 0.9);
  border: 1px solid rgba(123, 104, 238, 0.15);
  border-radius: 14px;
  padding: 12px 10px;
  text-align: center;
  transition: border-color .2s, transform .2s, box-shadow .2s;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.04);
}

.ritem:hover {
  border-color: rgba(0, 212, 255, 0.35);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 212, 255, 0.15);
}

.rlbl {
  font-size: .72rem;
  color: #7b68ee;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 6px;
  font-family: var(--font-mono);
  font-weight: 700;
}

body.dark-theme .ritem {
  background: rgba(45, 55, 72, 0.6);
  border-color: rgba(123, 104, 238, 0.25);
}

body.dark-theme .ritem:hover {
  border-color: rgba(0, 212, 255, 0.5);
  box-shadow: 0 4px 12px rgba(0, 212, 255, 0.25);
}

body.dark-theme .rlbl {
  color: #00d4ff;
}

.rval {
  font-family: Arial, sans-serif;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--tx);
  white-space: nowrap;
}

.badge-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: nowrap;
  padding-top: 10px;
  border-top: 1px solid var(--border);
  overflow: hidden;
}

.pbadge, .fbadge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 16px;
  border-radius: 6px;
  font-family: var(--font-mono);
  font-size: .82rem;
  font-weight: 500;
  letter-spacing: 1px;
  text-transform: uppercase;
}

.pbadge {
  background: var(--pass-dim);
  border: 1px solid var(--pass);
  color: var(--pass);
  box-shadow: 0 0 16px rgba(0,194,122,.15);
}

.fbadge {
  background: var(--fail-dim);
  border: 1px solid var(--fail);
  color: var(--fail);
  box-shadow: 0 0 16px rgba(255,77,77,.15);
}

.errbadge {
  background: rgba(255,165,0,.12);
  border: 1px solid #ff9800;
  color: #ff9800;
  box-shadow: 0 0 16px rgba(255,152,0,.2);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 16px;
  border-radius: 6px;
  font-family: var(--font-mono);
  font-size: .82rem;
  font-weight: 500;
  letter-spacing: 1px;
  text-transform: uppercase;
  animation: pulse-warn .8s ease-in-out infinite alternate;
}

@keyframes pulse-warn {
  from { opacity: .7; }
  to   { opacity: 1; }
}

.badge-sub {
  font-size: .72rem;
  color: var(--tx3);
  font-family: var(--font-mono);
}

.pr-err-detail-btn {
  background: none;
  border: 1px solid #ff9800;
  color: #ff9800;
  border-radius: 4px;
  padding: 1px 8px;
  font-size: .7rem;
  cursor: pointer;
  font-family: var(--font-mono);
  transition: background .15s;
}
.pr-err-detail-btn:hover { background: rgba(255,152,0,.15); }

/* ═══════════════════════════════════════════════
   ACTIONS CARD
═══════════════════════════════════════════════ */
.actions-card {
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid rgba(123, 104, 238, 0.15);
  border-radius: 14px;
  padding: 14px 16px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
  backdrop-filter: blur(10px);
  position: relative;
  z-index: 1;
}

body.dark-theme .actions-card {
  background: rgba(33, 38, 45, 0.95);
  border-color: rgba(123, 104, 238, 0.25);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
}

.actions-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.btn-action {
  padding: 12px 20px;
  border: none;
  border-radius: var(--r);
  font-size: .88rem;
  font-weight: 700;
  font-family: var(--font-head);
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all .2s;
  position: relative;
  overflow: hidden;
  white-space: nowrap;
  letter-spacing: .3px;
}

.btn-action:hover:not(:disabled) { transform: translateY(-2px); }
.btn-action:active { transform: translateY(0) !important; }
.btn-action:disabled { opacity: .4; cursor: not-allowed; }

.btn-save {
  background: linear-gradient(135deg, #00d4ff 0%, #0ea5e9 100%);
  color: #ffffff;
  flex: 1;
  justify-content: center;
  box-shadow: 0 6px 20px rgba(0, 212, 255, 0.35);
  border: none;
}

.btn-save:hover:not(:disabled) {
  background: linear-gradient(135deg, #00bfea 0%, #0284c7 100%);
  box-shadow: 0 8px 30px rgba(0, 212, 255, 0.45);
}

.btn-export {
  background: rgba(123, 104, 238, 0.12);
  border: 1px solid rgba(123, 104, 238, 0.3);
  color: #7b68ee;
  flex: 1;
  justify-content: center;
}

.btn-export:hover:not(:disabled) {
  background: rgba(123, 104, 238, 0.2);
  border-color: #7b68ee;
  box-shadow: 0 4px 16px rgba(123, 104, 238, 0.25);
}

.btn-reset {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--tx2);
  padding: 12px 16px;
}

.btn-reset:hover:not(:disabled) {
  background: var(--fail-dim);
  border-color: var(--fail);
  color: var(--fail);
}

.collapse-btn {
  background: rgba(123, 104, 238, 0.08);
  border: 1px solid rgba(123, 104, 238, 0.2);
  color: #7b68ee;
  font-size: .66rem;
  padding: 4px 10px;
  border-radius: 8px;
  cursor: pointer;
  transition: all .15s;
  display: flex;
  align-items: center;
  gap: 4px;
  font-weight: 600;
}

.collapse-btn:hover {
  background: rgba(123, 104, 238, 0.15);
  color: #7b68ee;
  border-color: #7b68ee;
  transform: translateY(-1px);
}

.collapse-body {
  transition: max-height .3s ease, opacity .3s ease;
  overflow: hidden;
  max-height: 3000px;
  opacity: 1;
}

.collapse-body.closed { max-height: 0; opacity: 0; }

/* ═══════════════════════════════════════════════
   CAMERA MODAL
═══════════════════════════════════════════════ */
.cam-modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.96);
  z-index: 9998;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 12px 20px;
  box-sizing: border-box;
  backdrop-filter: blur(12px);
}

.cam-modal.show { display: flex; }

.cam-label {
  font-size: .85rem;
  color: var(--tx2);
  text-align: center;
  font-family: var(--font-mono);
}

.cam-video {
  width: min(96vw, 600px);
  max-height: 65vh;
  flex: 1 1 auto;
  min-height: 0;
  object-fit: contain;
  border-radius: var(--r2);
  background: #000;
  display: block;
  box-shadow: var(--shadow-lg);
}

#cam-canvas { display: none; }

.cam-actions { 
  display: flex; 
  gap: 8px; 
  flex-shrink: 0;
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

.cam-btn {
  padding: 8px 16px;
  border: none;
  border-radius: var(--r);
  font-size: .8rem;
  font-weight: 600;
  font-family: var(--font-head);
  transition: all .2s;
}

.cam-snap {
  background: var(--amber);
  color: #0d1117;
  box-shadow: 0 4px 16px rgba(240,165,0,.4);
}

.cam-snap:hover { background: var(--amber2); transform: translateY(-2px); }

.cam-switch {
  background: var(--surface2);
  color: var(--tx);
  border: 1px solid var(--border2);
  padding: 8px 14px;
}

.cam-switch:hover { background: var(--surface); }

.cam-cancel {
  background: var(--fail-dim);
  border: 1px solid var(--fail);
  color: var(--fail);
}

.cam-cancel:hover { background: rgba(255,77,77,.2); }

/* ═══════════════════════════════════════════════
   EXPORT PREVIEW MODAL
═══════════════════════════════════════════════ */
.export-preview-modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.96);
  z-index: 9997;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  padding: 20px;
  backdrop-filter: blur(12px);
}

.export-preview-modal.show { display: flex; }

.exp-label {
  font-family: var(--font-mono);
  font-size: .85rem;
  color: var(--tx2);
  text-align: center;
}

.exp-canvas-wrap {
  max-width: 95vw;
  max-height: 72vh;
  border-radius: var(--r2);
  overflow: auto;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border);
}

.exp-canvas-wrap img { display: block; max-width: 100%; height: auto; }

.exp-actions { display: flex; gap: 12px; }

.exp-btn {
  padding: 12px 28px;
  border: none;
  border-radius: var(--r);
  font-size: .9rem;
  font-weight: 700;
  font-family: var(--font-head);
  transition: all .2s;
  cursor: pointer;
}

.exp-download {
  background: var(--amber);
  color: #0d1117;
  box-shadow: 0 4px 16px rgba(240,165,0,.4);
}

.exp-download:hover { background: var(--amber2); transform: translateY(-2px); }

.exp-close {
  background: var(--surface2);
  border: 1px solid var(--border2);
  color: var(--tx2);
}

.exp-close:hover { border-color: var(--fail); color: var(--fail); }

/* ═══════════════════════════════════════════════
   LIGHTBOX
═══════════════════════════════════════════════ */
.lightbox {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.97);
  z-index: 9999;
  align-items: center;
  justify-content: center;
  cursor: zoom-out;
  backdrop-filter: blur(8px);
}

.lightbox.show { display: flex; animation: fadeIn .2s ease; }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.lb-img-wrap {
  position: relative;
  max-width: 94vw;
  max-height: 90vh;
  overflow: hidden;
  cursor: zoom-in;
}

.lb-img-wrap.zoomed {
  cursor: grab;
}

.lb-img-wrap.zoomed:active {
  cursor: grabbing;
}

.lb-img-wrap img {
  max-width: 94vw;
  max-height: 88vh;
  border-radius: var(--r);
  box-shadow: 0 0 80px rgba(0,0,0,.8);
  display: block;
  transition: transform 0.2s ease-out;
  transform-origin: center center;
  touch-action: none;
}

.lb-close {
  position: fixed;
  top: 16px;
  right: 16px;
  background: linear-gradient(135deg, #7b68ee, #00d4ff);
  border: none;
  color: #fff;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: all .2s;
  box-shadow: 0 4px 14px rgba(123, 104, 238, 0.5);
  z-index: 10001;
}

.lb-close:hover { filter: brightness(1.15); transform: scale(1.1) rotate(90deg); }

.lb-label {
  position: absolute;
  bottom: -36px;
  left: 0;
  right: 0;
  text-align: center;
  font-size: .8rem;
  color: var(--tx2);
  font-family: var(--font-mono);
}

.lb-actions {
  position: fixed;
  top: max(12px, env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 8px;
  z-index: 10002;
}

.lb-act-btn {
  border: 1px solid rgba(255,255,255,.35);
  background: rgba(13,17,23,.6);
  color: #e6edf3;
  border-radius: 8px;
  padding: 6px 10px;
  font-size: .72rem;
  font-weight: 700;
  cursor: pointer;
}

.lb-act-btn:hover {
  background: rgba(123,104,238,.55);
  border-color: rgba(123,104,238,.75);
}

.lb-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 40px;
  height: 40px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,.35);
  background: rgba(13,17,23,.62);
  color: #e6edf3;
  display: none;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 10003;
  font-size: 1.35rem;
  font-weight: 700;
}

.lb-nav:hover {
  background: rgba(123,104,238,.58);
  border-color: rgba(123,104,238,.78);
}

.lb-nav-prev { left: 10px; }
.lb-nav-next { right: 10px; }

/* ═══════════════════════════════════════════════
   TOAST
═══════════════════════════════════════════════ */
#toast-container {
  position: fixed;
  top: 68px;
  right: 20px;
  z-index: 9998;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  padding: 12px 18px;
  border-radius: var(--r);
  font-size: .82rem;
  font-weight: 600;
  pointer-events: auto;
  animation: slideIn .35s cubic-bezier(.16,1,.3,1);
  max-width: 320px;
  border: 1px solid;
  font-family: var(--font-body);
}

.toast-exit { animation: slideOut .3s ease forwards; }

@keyframes slideIn { from { opacity: 0; transform: translateX(20px) scale(.95); } to { opacity: 1; transform: none; } }
@keyframes slideOut { to { opacity: 0; transform: translateX(20px) scale(.95); } }

.toast-success { background: rgba(0, 194, 122, .18); border-color: var(--pass); color: var(--pass); box-shadow: 0 8px 22px rgba(0,194,122,.22); }
.toast-error   { background: rgba(248, 219, 219, 0.751); border-color: var(--fail); color: #b20707; box-shadow: 0 8px 22px rgba(255,77,77,.22); }
.toast-info    { background: rgba(0, 212, 170, .18); border-color: var(--teal); color: var(--teal); box-shadow: 0 8px 22px rgba(0,212,170,.18); }
.toast-warn    {
  background: rgba(255, 245, 235, .96);
  border-color: #fb923c;
  color: #c2410c;
  box-shadow: 0 8px 22px rgba(194, 65, 12, .18);
}

.center-popup {
  position: fixed;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%) scale(.96);
  width: min(86vw, 440px);
  padding: 14px 16px;
  border-radius: 12px;
  background: rgba(255, 248, 245, .98);
  border: 1px solid #fb923c;
  color: #c2410c;
  font-size: .92rem;
  font-weight: 700;
  text-align: center;
  box-shadow: 0 14px 34px rgba(194, 65, 12, .28);
  z-index: 10003;
  opacity: 0;
  visibility: hidden;
  transition: opacity .18s ease, transform .18s ease, visibility .18s ease;
  pointer-events: none;
}

.center-popup.show {
  opacity: 1;
  visibility: visible;
  transform: translate(-50%, -50%) scale(1);
}

/* ══ CONFIRM MODAL ══ */
.confirm-modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.55);
  z-index: 10010;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(4px);
}
.confirm-modal.show { display: flex; }
.confirm-modal-box {
  background: var(--surface);
  border: 1px solid var(--border2);
  border-radius: 16px;
  padding: 28px 28px 22px;
  width: min(88vw, 420px);
  box-shadow: 0 20px 48px rgba(0,0,0,.45);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  text-align: center;
  animation: confirmIn .18s ease;
}
@keyframes confirmIn { from { transform: scale(.92); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.confirm-modal-icon { font-size: 2rem; line-height: 1; }
.confirm-modal-msg {
  font-size: .92rem;
  font-weight: 600;
  color: var(--tx);
  line-height: 1.55;
  white-space: pre-line;
}
.confirm-modal-actions {
  display: flex;
  gap: 10px;
  margin-top: 6px;
  width: 100%;
}
.confirm-btn {
  flex: 1;
  padding: 10px 0;
  border-radius: 8px;
  font-size: .88rem;
  font-weight: 700;
  cursor: pointer;
  transition: all .18s;
  border: 1px solid transparent;
}
.confirm-cancel {
  background: var(--surface2);
  border-color: var(--border2);
  color: var(--tx2);
}
.confirm-cancel:hover { border-color: var(--fail); color: var(--fail); }
.confirm-ok {
  background: var(--amber);
  color: #0d1117;
  box-shadow: 0 4px 12px rgba(240,165,0,.35);
}
.confirm-ok:hover { background: var(--amber2); transform: translateY(-1px); }

/* ── Remark Modal ── */
.remark-modal-box { width: min(88vw, 460px) !important; }
.remark-modal-field { width: 100%; text-align: left; }
.remark-modal-label {
  display: block; font-size: .78rem; font-weight: 700;
  color: var(--fail); margin-bottom: 5px;
}
.remark-modal-textarea {
  width: 100%; padding: 8px 10px; border-radius: 8px;
  border: 1.5px solid var(--fail); font-size: .88rem;
  resize: vertical; background: var(--surface2); color: var(--tx);
  box-sizing: border-box; font-family: var(--font-body); line-height: 1.5;
  transition: border-color .15s;
}
.remark-modal-textarea:focus {
  outline: none; border-color: #dc2626;
  box-shadow: 0 0 0 3px rgba(220,38,38,.15);
}
.remark-modal-ok { transition: opacity .15s, background .18s, transform .18s; }
.remark-modal-ok:disabled { opacity: .45; cursor: not-allowed; transform: none !important; }

/* ═══════════════════════════════════════════════
   PR ERROR MODAL
═══════════════════════════════════════════════ */
.pr-error-modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.6);
  z-index: 10020;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(4px);
}
.pr-error-modal.show { display: flex; }
.pr-error-box {
  background: var(--surface);
  border: 1px solid #ff9800;
  border-radius: 16px;
  padding: 24px 24px 20px;
  width: min(96vw, 560px);
  box-shadow: 0 20px 48px rgba(0,0,0,.5), 0 0 0 1px rgba(255,152,0,.3);
  display: flex;
  flex-direction: column;
  gap: 14px;
  animation: confirmIn .18s ease;
}
.pr-error-header {
  display: flex;
  align-items: center;
  gap: 10px;
}
.pr-error-icon {
  font-size: 1.6rem;
  color: #ff9800;
  animation: pulse-warn .8s ease-in-out infinite alternate;
}
.pr-error-title {
  font-size: .92rem;
  font-weight: 700;
  color: #ff9800;
}
.pr-error-rule {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  background: rgba(255,152,0,.08);
  border: 1px solid rgba(255,152,0,.25);
  border-radius: 10px;
  padding: 12px 16px;
}
.pr-err-math {
  font-size: 1.05rem;
  font-weight: 700;
  font-family: var(--font-mono);
  color: var(--tx);
}
.pr-err-arrow {
  font-size: 1.2rem;
  color: #ff9800;
  font-weight: 700;
}
.pr-error-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .8rem;
}
.pr-error-table th {
  background: var(--surface2);
  color: var(--tx2);
  font-weight: 600;
  padding: 6px 10px;
  text-align: left;
  border-bottom: 1px solid var(--border2);
}
.pr-error-table td {
  padding: 7px 10px;
  border-bottom: 1px solid var(--border);
  color: var(--tx);
  font-family: var(--font-mono);
  font-size: .78rem;
  vertical-align: top;
}
.pr-error-table td:first-child,
.pr-error-table td:last-child { white-space: nowrap; }
.pr-err-row-psys td { color: var(--amber); }
.pr-err-sub {
  display: block;
  font-size: .72rem;
  color: var(--tx3);
  margin-top: 2px;
  font-weight: 400;
}
.pr-err-row-pr td { color: var(--fail); font-weight: 700; }
.pr-error-causes {
  font-size: .78rem;
  color: var(--tx2);
}
.pr-error-causes-title {
  font-weight: 700;
  color: var(--tx);
  margin-bottom: 5px;
  font-size: .8rem;
}
.pr-error-causes ul {
  margin: 0;
  padding-left: 18px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.pr-error-actions {
  margin-top: 4px;
}
.pr-error-actions .confirm-btn {
  width: 100%;
  background: #ff9800;
  color: #0d1117;
  border: none;
  box-shadow: 0 4px 12px rgba(255,152,0,.35);
}
.pr-error-actions .confirm-btn:hover { background: #ffb74d; transform: translateY(-1px); }

/* ═══════════════════════════════════════════════
   ADMIN SUB-FORMULA BOXES
═══════════════════════════════════════════════ */
.subfml-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}
.subfml-box {
  background: var(--surface2);
  border: 1px solid var(--border2);
  border-radius: 10px;
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.subfml-box-label {
  font-size: .68rem;
  color: var(--tx3);
  font-weight: 600;
  letter-spacing: .5px;
  text-transform: uppercase;
}
.subfml-box-eq {
  font-size: .86rem;
  font-family: var(--font-mono);
  color: var(--tx);
  font-weight: 500;
}
.subfml-box-eq em { color: var(--amber); font-style: normal; }
.subfml-box.subfml-pr {
  border-color: rgba(255,152,0,.4);
  background: rgba(255,152,0,.06);
}
.subfml-box.subfml-pr .subfml-box-label { color: #ff9800; }

.pref-fml-bar {
  border-color: rgba(255,152,0,.4);
  background: rgba(255,152,0,.04);
}

.fml-clear-btn {
  background: none;
  border: 1px solid var(--border2);
  color: var(--tx3);
  border-radius: 5px;
  padding: 1px 8px;
  font-size: .7rem;
  cursor: pointer;
  margin-left: 8px;
  transition: border-color .15s, color .15s;
}
.fml-clear-btn:hover {
  border-color: var(--fail);
  color: var(--fail);
}

/* ═══════════════════════════════════════════════
   LOADING OVERLAY
═══════════════════════════════════════════════ */
@keyframes spinner { to { transform: rotate(360deg); } }

.spinner-inline {
  width: 14px;
  height: 14px;
  border: 2px solid rgba(0,0,0,.2);
  border-top-color: rgba(0,0,0,.8);
  border-radius: 50%;
  animation: spinner .7s linear infinite;
  display: inline-block;
  vertical-align: middle;
}

.lov {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(13,17,23,.88);
  z-index: 9990;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(8px);
}

.lov.show { display: flex; }

.lbox {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-top: 2px solid var(--amber);
  border-radius: var(--r2);
  padding: 36px 48px;
  text-align: center;
  box-shadow: var(--shadow-lg);
}

.lbox .lspin {
  width: 44px;
  height: 44px;
  border: 3px solid var(--border);
  border-top-color: var(--amber);
  border-radius: 50%;
  animation: spinner .8s linear infinite;
  margin: 0 auto 14px;
}

.lbox p {
  font-size: .9rem;
  font-weight: 600;
  color: var(--tx2);
  font-family: var(--font-mono);
}

/* ═══════════════════════════════════════════════
   RECORDS HISTORY TABLE
═══════════════════════════════════════════════ */
.records-container {
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid rgba(123, 104, 238, 0.15);
  border-radius: 24px;
  padding: 18px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.1);
  backdrop-filter: blur(10px);
  position: relative;
  z-index: 1;
}

body.dark-theme .records-container {
  background: rgba(33, 38, 45, 0.95);
  border-color: rgba(123, 104, 238, 0.25);
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.3);
}

.btn-refresh-mini {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 5px 12px;
  background: rgba(0, 212, 255, 0.12);
  border: 1px solid rgba(0, 212, 255, 0.3);
  border-radius: 18px;
  color: #00d4ff;
  font-size: .75rem;
  font-weight: 600;
  cursor: pointer;
  transition: all .2s;
  margin-left: 8px;
}

.btn-refresh-mini:hover {
  background: #00d4ff;
  color: #ffffff;
  box-shadow: 0 2px 8px rgba(0, 212, 255, 0.25);
}

.records-loading, .records-error {
  text-align: center;
  padding: 32px 24px;
  max-width: 400px;
  margin: 0 auto;
}

.records-loading .spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border);
  border-top-color: var(--teal);
  border-radius: 50%;
  animation: spinner .8s linear infinite;
  margin: 0 auto 16px;
}

.records-loading p {
  font-size: .9rem;
  color: var(--tx2);
  font-weight: 600;
}

.records-error {
  color: var(--fail);
  font-weight: 600;
}

.records-table-wrap {
  overflow-x: auto;
}

.records-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .75rem;
}

.records-table thead {
  background: var(--bg3);
  border-bottom: 2px solid var(--border);
}

.records-table th {
  padding: 8px 10px;
  text-align: left;
  font-weight: 700;
  color: var(--tx);
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .5px;
  white-space: nowrap;
}

.records-table tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background .15s;
}

.records-table tbody tr:hover {
  background: var(--surface);
}

.records-table td {
  padding: 5px 10px;
  color: var(--tx2);
  white-space: nowrap;
  line-height: 1.2;
}

/* Click-to-filter badges in the record-history table */
.rec-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background .15s ease, border-color .15s ease, color .15s ease, transform .1s ease;
}
.rec-badge:hover {
  background: rgba(59,130,246,0.12);
  border-color: rgba(59,130,246,0.4);
  color: #1d4ed8;
  transform: translateY(-1px);
}
.rec-badge.active {
  background: #3b82f6;
  border-color: #1d4ed8;
  color: #fff;
}
.rec-badge.active strong { color: #fff; }
body.dark-theme .rec-badge:hover { background: rgba(96,165,250,0.18); color: #93c5fd; }

.records-toolbar {
  margin: 0 0 12px;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
  flex-wrap: nowrap;
}

.records-toolbar-actions {
  margin-left: 0;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.records-search {
  flex: 1 1 auto;
  min-width: 260px;
  max-width: none;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--tx);
  font-size: .82rem;
  padding: 10px 12px;
  outline: none;
}

.records-search:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 2px rgba(0,212,255,.14);
}

.records-date-filter {
  flex: 0 0 auto;
  min-width: 170px;
  max-width: 190px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--tx);
  font-size: .8rem;
  padding: 9px 10px;
  outline: none;
}

.records-date-filter:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 2px rgba(0,212,255,.14);
}

.records-clear-filter-btn {
  flex-shrink: 0;
  border-color: rgba(148,163,184,.4);
  background: rgba(148,163,184,.12);
}

.records-clear-filter-btn:hover {
  border-color: rgba(148,163,184,.6);
  background: rgba(148,163,184,.2);
}

.record-images {
  display: flex;
  gap: 4px;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: center;
}

.record-img-group {
  display: inline-flex;
  gap: 0;
  align-items: center;
}

.record-img-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 34px;
  height: 24px;
  padding: 0 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 3px;
  color: var(--teal);
  font-size: .82rem;
  font-weight: 700;
  cursor: pointer;
  transition: all .2s;
  white-space: nowrap;
}

.record-img-btn:hover {
  background: var(--teal-dim);
  border-color: var(--teal);
}

.record-img-gallery-btn {
  position: relative;
}

.record-img-gallery-btn::after {
  content: attr(data-count);
  position: absolute;
  right: -6px;
  top: -6px;
  min-width: 14px;
  height: 14px;
  padding: 0 3px;
  border-radius: 999px;
  background: #00d4aa;
  color: #0b1220;
  border: 1px solid rgba(11, 18, 32, 0.12);
  font-size: .58rem;
  line-height: 14px;
  font-weight: 800;
  text-align: center;
}

.record-img-gallery-btn.record-img-gallery-low::after {
  background: #cbd5e1;
  color: #0b1220;
}

.record-img-gallery-btn.record-img-gallery-mid::after {
  background: #38bdf8;
  color: #0b1220;
}

.record-img-gallery-btn.record-img-gallery-high::after {
  background: #00d4aa;
  color: #0b1220;
}

.record-actions {
  display: flex;
  gap: 6px;
}

.record-action-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  background: rgba(123,104,238,.12);
  border: 1px solid rgba(123,104,238,.35);
  border-radius: 6px;
  color: var(--tx);
  font-size: .68rem;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  transition: all .2s;
}

.record-action-btn:hover {
  background: rgba(123,104,238,.2);
  border-color: rgba(123,104,238,.55);
}

.record-delete-btn {
  background: rgba(220,38,38,.1);
  border-color: rgba(220,38,38,.35);
  color: #dc2626;
}
.record-delete-btn:hover {
  background: rgba(220,38,38,.2);
  border-color: rgba(220,38,38,.6);
}

.remark-cell { max-width: 180px; }
.remark-fail-text {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  color: #dc2626;
  font-size: .78rem;
  line-height: 1.4;
  cursor: default;
  word-break: break-word;
}

.records-export-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid rgba(0, 212, 255, 0.35);
  background: rgba(0, 212, 255, 0.12);
  color: var(--tx);
  font-size: .76rem;
  font-weight: 700;
  cursor: pointer;
  transition: all .2s;
}

.records-export-btn:hover {
  background: rgba(0, 212, 255, 0.2);
  border-color: rgba(0, 212, 255, 0.5);
}

.records-pagination {
  margin-top: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.records-page-info {
  font-size: .72rem;
  color: var(--tx3);
}

.records-page-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.records-page-btn {
  min-width: 30px;
  height: 30px;
  padding: 0 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--tx2);
  font-size: .72rem;
  font-weight: 700;
  cursor: pointer;
}

.records-page-btn.active {
  background: rgba(123,104,238,.2);
  border-color: rgba(123,104,238,.55);
  color: var(--tx);
}

.records-page-btn:disabled {
  opacity: .5;
  cursor: not-allowed;
}

.record-empty {
  text-align: center;
  padding: 48px 24px;
  color: var(--tx3);
  font-size: .9rem;
}

/* Charts Summary */
.charts-panel {
  margin-bottom: 16px;
}

.charts-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.charts-panel-head h3 {
  margin: 0;
  font-size: .78rem;
  letter-spacing: .45px;
  color: #7b68ee;
  text-transform: uppercase;
}

body.dark-theme .charts-panel-head h3 {
  color: #00d4ff;
}

.charts-collapse-btn {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  border: 1px solid rgba(0, 212, 255, 0.35);
  background: rgba(0, 212, 255, 0.12);
  color: var(--tx);
  font-size: .95rem;
  line-height: 1;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all .2s;
}

.charts-collapse-btn:hover {
  background: rgba(0, 212, 255, 0.2);
  border-color: rgba(0, 212, 255, 0.5);
}

.charts-summary {
  margin-bottom: 24px;
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 16px;
}

@media (max-width: 900px) {
  .records-toolbar {
    flex-wrap: wrap;
    align-items: stretch;
  }

  .records-toolbar-actions {
    margin-left: 0;
  }

  .records-search {
    min-width: 100%;
  }

  .charts-summary {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .records-toolbar {
    gap: 8px;
  }

  .records-search,
  .records-date-filter,
  .records-clear-filter-btn {
    min-width: 0;
    max-width: none;
  }

  .records-date-filter,
  .records-clear-filter-btn {
    flex: 1 1 calc(50% - 4px);
    justify-content: center;
  }

  .records-toolbar-actions {
    width: 100%;
  }

  .records-toolbar-actions .records-export-btn {
    width: 100%;
    justify-content: center;
  }
}

.chart-card {
  background: rgba(255, 255, 255, 0.95);
  border: 1px solid rgba(123, 104, 238, 0.15);
  border-radius: 20px;
  padding: 16px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
  backdrop-filter: blur(10px);
}

body.dark-theme .chart-card {
  background: rgba(33, 38, 45, 0.95);
  border-color: rgba(123, 104, 238, 0.25);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
}

.chart-card h3 {
  font-size: .85rem;
  font-weight: 700;
  color: #7b68ee;
  margin-bottom: 12px;
  text-align: center;
  text-transform: uppercase;
  letter-spacing: .5px;
}

body.dark-theme .chart-card h3 {
  color: #00d4ff;
}

.chart-canvas-wrap {
  position: relative;
  height: 240px;
}

.chart-canvas-wrap canvas {
  max-width: 100%;
  max-height: 100%;
}

/* ═══════════════════════════════════════════════
   PRINT
═══════════════════════════════════════════════ */
@media print {
  .topbar, .actions-card, #tool-alert, .progress-wrap, #loading-overlay,
  #toast-container, .lightbox, #page-login, .cam-modal, .export-preview-modal { display: none !important; }
  body { background: #fff !important; color: #000 !important; font-size: 12px; }
  .main-grid { display: block !important; }
  .scard, .fcard, .rcard { box-shadow: none !important; border: 1px solid #ccc !important; margin-bottom: 16px; }
  .collapse-body.closed { max-height: none !important; opacity: 1 !important; }
}

/* ═══════════════════════════════════════════════
   RESPONSIVE
═══════════════════════════════════════════════ */
@media (max-width: 768px) {
  .topbar { height: 52px; padding: 0 14px; }
  .topbar-clock { display: none; }
  .tag-user { max-width: 80px; }
  .tool-body { padding: 12px 12px 24px; }
  .main-grid { gap: 10px; }
  .rgrid { overflow-x: auto; }
  .ritem { min-width: 90px; }
  .sys-params-meta { grid-template-columns: 1fr 1fr; }

  input[type=number],
  input[type=time],
  input[type=text],
  input[type=password],
  select {
    height: 46px;
    min-height: 46px;
    padding-top: 10px;
    padding-bottom: 10px;
    box-sizing: border-box;
  }

  .pv-stepper {
    height: 46px;
    min-height: 46px;
    box-sizing: border-box;
  }

  .time-row {
    align-items: stretch;
  }

  .time-row input[type=time],
  .btn-now {
    height: 46px;
    min-height: 46px;
    box-sizing: border-box;
  }

  .btn-now {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 12px;
  }

  .site-names {
    overflow: visible;
  }

  .sn-row {
    flex-wrap: wrap;
    white-space: normal;
    overflow-x: visible;
    row-gap: 6px;
  }

  .sn-row strong,
  .sn-label {
    word-break: break-word;
  }
}

@media (max-width: 480px) {
  .tag-user { display: none; }
  .logo-name { font-size: 1rem; }
  .btn-action { padding: 11px 14px; font-size: .82rem; }
  .rval { font-size: .9rem; }

  .sn-sep {
    display: none;
  }
}
