:root {
  /* Base surfaces (light, airy, mint-tinted) */
  --bg-void: #f4f8f6;
  --bg-deep: #eaf2ee;
  --bg-panel: #ffffff;
  --bg-panel-raised: #f4faf7;
  --bg-panel-hover: #edf6f1;
  --border-soft: rgba(16, 42, 33, 0.07);
  --border-strong: rgba(16, 42, 33, 0.13);

  /* Text */
  --text-primary: #10241d;
  --text-secondary: #4b5f57;
  --text-muted: #9aa8a1;

  /* Brand / accent — mint green */
  --accent: #10b981;
  --accent-soft: rgba(16, 185, 129, 0.10);
  --accent-strong: #059669;
  --accent-deep: #047857;

  /* Secondary accents for variety (kept soft & clean) */
  --violet: #8b5cf6;
  --violet-soft: rgba(139, 92, 246, 0.10);
  --sky: #0ea5e9;
  --sky-soft: rgba(14, 165, 233, 0.10);
  --amber: #f59e0b;
  --amber-soft: rgba(245, 158, 11, 0.10);

  /* Grade tiers */
  --grade-diamond: #0d9488;
  --grade-gold: #d97706;
  --grade-silver: #64748b;
  --grade-bronze: #b45309;
  --grade-fail: #9aa8a1;

  /* Status */
  --status-missing: #ef4444;
  --status-missing-soft: rgba(239, 68, 68, 0.09);
  --status-partial: #f59e0b;
  --status-partial-soft: rgba(245, 158, 11, 0.11);
  --status-verified: #10b981;
  --status-verified-soft: rgba(16, 185, 129, 0.11);

  --radius-sm: 12px;
  --radius-md: 16px;
  --radius-lg: 22px;

  --font-display: 'IBM Plex Sans Thai', 'IBM Plex Sans', sans-serif;
  --font-mono: 'IBM Plex Mono', ui-monospace, monospace;

  --ease-out: cubic-bezier(.16,1,.3,1);
}

* { box-sizing: border-box; }
[x-cloak] { display: none !important; }

html, body {
  background: var(--bg-void);
  color: var(--text-primary);
  font-family: var(--font-display);
  -webkit-font-smoothing: antialiased;
  font-feature-settings: 'tnum' 1, 'cv05' 1;
  font-variant-numeric: tabular-nums;
}

body {
  background-image:
    radial-gradient(1100px 560px at 96% -10%, rgba(16, 185, 129, 0.07), transparent 60%),
    radial-gradient(820px 460px at -8% 6%, rgba(13, 148, 136, 0.05), transparent 55%);
  min-height: 100vh;
  position: relative;
}

/* Subtle grain texture -- the kind of tactile, almost-imperceptible detail
   that separates a considered interface from a flat default one. Applied as
   a fixed overlay so it doesn't scroll or get clipped by cards. */
body::before {
  content: '';
  position: fixed; inset: 0; z-index: -1; pointer-events: none;
  opacity: .025; mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

h1, h2, h3, .field-label, .nav-item span:last-child {
  letter-spacing: -.01em;
}

/* Refined focus ring -- consistent, visible, not the harsh browser default */
:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px var(--bg-panel), 0 0 0 4px var(--accent);
  border-radius: 6px;
}

* { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; scroll-behavior: auto !important; }
}

.mono { font-family: var(--font-mono); }

/* Scrollbar */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 8px; }
::-webkit-scrollbar-thumb:hover { background: var(--accent); }

/* Glass panel -> soft elevated white card */
.glass {
  background: var(--bg-panel);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-lg);
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,.6),
    0 1px 2px rgba(16,42,33,.03),
    0 10px 34px -20px rgba(16,42,33,.16);
  position: relative;
}

.glass-flat {
  background: var(--bg-panel);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-md);
}

/* Nav item - card-style selection (macOS System Settings sidebar feel) */
.nav-item {
  display: flex; align-items: center; gap: 11px;
  padding: 10px 14px; border-radius: 11px;
  color: var(--text-secondary); font-size: 14px; font-weight: 500;
  transition: all .18s var(--ease-out); cursor: pointer; position: relative;
}
.nav-item:hover { background: rgba(16,42,33,.04); color: var(--text-primary); }
.nav-item.active {
  background: #fff; color: var(--accent-strong); font-weight: 600;
  box-shadow: 0 1px 1px rgba(16,42,33,.04), 0 6px 16px -8px rgba(16,42,33,.14);
}
.nav-item.active .nav-icon-chip { background: var(--accent-soft); }
.nav-icon-chip {
  width: 26px; height: 26px; border-radius: 8px;
  display: inline-flex; align-items: center; justify-content: center;
  flex-shrink: 0; transition: background .18s var(--ease-out);
}

/* Status badge */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600;
  white-space: nowrap;
  letter-spacing: .01em;
}
.badge-dot { width: 6px; height: 6px; border-radius: 50%; }
.badge-missing { background: var(--status-missing-soft); color: var(--status-missing); }
.badge-partial { background: var(--status-partial-soft); color: var(--status-partial); }
.badge-verified { background: var(--status-verified-soft); color: var(--status-verified); }
.badge-mandatory { background: rgba(8, 145, 178, .10); color: var(--grade-diamond); }

/* Segmented control (iOS/macOS style pill tabs) */
.segmented {
  display: inline-flex; align-items: center; gap: 2px;
  background: var(--bg-deep); border-radius: 12px; padding: 3px;
}
.segmented-item {
  padding: 7px 14px; border-radius: 9px; font-size: 13px; font-weight: 600;
  color: var(--text-secondary); cursor: pointer; transition: all .2s var(--ease-out);
  white-space: nowrap;
}
.segmented-item.active {
  background: #fff; color: var(--text-primary);
  box-shadow: 0 1px 2px rgba(16,42,33,.05), 0 1px 1px rgba(16,42,33,.04);
}
.segmented-item:not(.active):hover { color: var(--text-primary); }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 9px 16px; border-radius: var(--radius-sm); font-size: 14px; font-weight: 600;
  transition: all .15s var(--ease-out); cursor: pointer; border: 1px solid transparent;
  white-space: nowrap;
}
.btn-primary { background: linear-gradient(180deg, var(--accent), var(--accent-strong)); color: #fff; box-shadow: 0 1px 2px rgba(5,150,105,.15), inset 0 1px 0 rgba(255,255,255,.25); }
.btn-primary:hover { background: linear-gradient(180deg, var(--accent-strong), var(--accent-deep)); box-shadow: 0 0 0 3px var(--accent-soft); }
.btn-ghost { background: var(--bg-panel); border-color: var(--border-strong); color: var(--text-secondary); }
.btn-ghost:hover { color: var(--accent-strong); border-color: var(--accent); background: var(--accent-soft); }
.btn-danger { background: rgba(220,38,38,.08); color: var(--status-missing); }
.btn-danger:hover { background: rgba(220,38,38,.16); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn:active { transform: scale(.97); }

/* Inputs */
.field-label {
  font-size: 12px; font-weight: 600; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: .06em; margin-bottom: 6px; display: block;
}
.input, textarea.input, select.input {
  width: 100%; background: var(--bg-panel); border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm); padding: 9px 12px; color: var(--text-primary);
  font-size: 14px; transition: border-color .15s, box-shadow .15s;
}
.input:focus, textarea.input:focus, select.input:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft);
}
.input::placeholder { color: var(--text-muted); }

/* Tree rows */
.tree-row {
  display: grid;
  grid-template-columns: 1fr auto auto auto auto;
  align-items: center;
  gap: 12px;
  padding: 10px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background .12s var(--ease-out);
  border: 1px solid transparent;
}
.tree-row:hover { background: var(--bg-panel-hover); }
.tree-row.is-header { font-weight: 600; }
.tree-row.is-active { background: var(--accent-soft); border-color: rgba(16,185,129,.3); }

.tree-toggle {
  width: 20px; height: 20px; display: inline-flex; align-items: center; justify-content: center;
  color: var(--text-muted); transition: transform .18s var(--ease-out);
  flex-shrink: 0;
}
.tree-toggle.open { transform: rotate(90deg); }

/* Gem grade badge */
.gem {
  position: relative;
  width: 108px; height: 108px;
  display: flex; align-items: center; justify-content: center;
}
.gem svg { width: 100%; height: 100%; filter: drop-shadow(0 8px 20px var(--gem-glow, rgba(16,185,129,.28))); }

/* Progress bar */
.progress-track {
  height: 8px; border-radius: 999px; background: var(--bg-deep);
  overflow: hidden; border: 1px solid var(--border-soft);
}
.progress-fill {
  height: 100%; border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), var(--grade-diamond));
  transition: width .6s var(--ease-out);
}

/* Slide-over panel */
.slideover-backdrop {
  position: fixed; inset: 0; background: rgba(16,42,33,.32);
  backdrop-filter: blur(2px); z-index: 40;
}
.slideover-panel {
  position: fixed; top: 0; right: 0; height: 100%;
  width: min(560px, 100vw);
  background: var(--bg-panel);
  border-left: 1px solid var(--border-soft);
  z-index: 41; overflow-y: auto;
  box-shadow: -24px 0 60px rgba(16,42,33,.12);
}

/* Fade/slide transitions */
.slide-enter { transition: transform .32s var(--ease-out); }
.slide-enter-start { transform: translateX(100%); }

/* Card hover lift */
.lift { transition: transform .18s var(--ease-out), box-shadow .18s var(--ease-out); }
.lift:hover { transform: translateY(-2px); box-shadow: 0 12px 28px -12px rgba(16,42,33,.13); }

/* Skeleton loading shimmer */
@keyframes shimmer { 0% { background-position: -400px 0; } 100% { background-position: 400px 0; } }
.skeleton {
  background: linear-gradient(90deg, var(--bg-panel) 0%, var(--bg-panel-hover) 50%, var(--bg-panel) 100%);
  background-size: 800px 100%;
  animation: shimmer 1.4s infinite linear;
  border-radius: var(--radius-sm);
}

/* Dropzone */
.dropzone {
  border: 1.5px dashed var(--border-strong); border-radius: var(--radius-md);
  padding: 24px; text-align: center; transition: all .15s var(--ease-out);
  background: var(--bg-panel-raised);
}
.dropzone.drag-over { border-color: var(--accent); background: var(--accent-soft); }

/* Utility scan-line accent divider */
.accent-divider {
  height: 1px; background: linear-gradient(90deg, transparent, var(--border-strong), transparent);
}

/* Header top accent bar */
.header-accent-bar {
  height: 2px;
  background: linear-gradient(90deg, var(--accent), var(--grade-diamond), var(--sky), var(--accent));
  opacity: .6;
}

/* Hero mesh background */
.hero-mesh {
  position: absolute; inset: 0; pointer-events: none; border-radius: inherit; overflow: hidden;
}
.hero-mesh::before {
  content: '';
  position: absolute; inset: -40%;
  background:
    radial-gradient(420px 260px at 12% 15%, rgba(16,185,129,.11), transparent 60%),
    radial-gradient(380px 300px at 88% 25%, rgba(13,148,136,.08), transparent 60%),
    radial-gradient(360px 280px at 75% 90%, rgba(14,165,233,.06), transparent 60%),
    radial-gradient(300px 240px at 10% 90%, rgba(139,92,246,.05), transparent 60%);
}

/* Popover pop-in animation */
@keyframes pop-in {
  from { opacity: 0; transform: translateY(-4px) scale(.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
[x-show].glass, .popover-anim { animation: pop-in .16s var(--ease-out); }

/* Dashboard entrance stagger */
@keyframes rise-in {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: translateY(0); }
}
.rise-in { animation: rise-in .55s var(--ease-out) both; }

/* Gentle ambient pulse for the hero gem */
@keyframes gentle-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.045); }
}
.pulse-slow { animation: gentle-pulse 3.6s ease-in-out infinite; }

/* Colorful stat card */
.stat-card {
  border-radius: var(--radius-md);
  padding: 18px;
  position: relative;
  overflow: hidden;
  transition: transform .25s var(--ease-out), box-shadow .25s var(--ease-out), border-color .25s var(--ease-out);
  border: 1px solid var(--border-soft);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.5);
}
.stat-card:hover { transform: translateY(-3px); box-shadow: inset 0 1px 0 rgba(255,255,255,.5), 0 16px 32px -16px rgba(16,42,33,.16); }
.stat-card-icon {
  width: 38px; height: 38px; border-radius: 11px;
  display: inline-flex; align-items: center; justify-content: center;
  margin-bottom: 12px;
}

/* Section progress row hover */
.section-row {
  border-radius: var(--radius-md);
  padding: 14px 16px;
  transition: background .18s var(--ease-out), transform .18s var(--ease-out);
  cursor: pointer;
}
.section-row:hover { background: var(--bg-panel-raised); transform: translateX(2px); }

/* Live pill (monitoring feel) */
.live-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--status-verified);
  box-shadow: 0 0 0 0 rgba(5,150,105,.5);
  animation: live-ping 2s cubic-bezier(0,0,.2,1) infinite;
}
@keyframes live-ping {
  0% { box-shadow: 0 0 0 0 rgba(5,150,105,.45); }
  70% { box-shadow: 0 0 0 8px rgba(5,150,105,0); }
  100% { box-shadow: 0 0 0 0 rgba(5,150,105,0); }
}

/* ===== Tier ladder: prominent grade progression display ===== */
.tier-ladder { position: relative; }
.tier-ladder-track {
  position: absolute; top: 26px; left: 12.5%; right: 12.5%; height: 3px;
  background: var(--bg-deep); border-radius: 999px; overflow: hidden; z-index: 0;
}
@media (max-width: 640px) { .tier-ladder-track { top: 20px; } }
.tier-ladder-fill {
  height: 100%; border-radius: 999px;
  background: linear-gradient(90deg, #b5651d, #94a3b8, #d97706, #0d9488);
  transition: width 1s var(--ease-out);
}
.tier-stop {
  position: relative; z-index: 1;
  display: flex; flex-direction: column; align-items: center;
  padding-top: 4px; transition: opacity .3s var(--ease-out);
}
.tier-stop-pending { opacity: .45; }
.tier-stop-reached { opacity: .85; }
.tier-stop-current { opacity: 1; }
.tier-gem {
  width: 52px; height: 52px;
  filter: drop-shadow(0 4px 10px rgba(16,42,33,.12));
  transition: transform .3s var(--ease-out);
}
.tier-stop-current .tier-gem { width: 64px; height: 64px; }
@media (max-width: 640px) {
  .tier-gem { width: 38px; height: 38px; }
  .tier-stop-current .tier-gem { width: 46px; height: 46px; }
}
.tier-current-badge {
  position: absolute; top: -10px; left: 50%; transform: translateX(-50%);
  background: var(--text-primary); color: #fff;
  font-size: 9.5px; font-weight: 700; letter-spacing: .04em;
  padding: 2px 8px; border-radius: 999px; white-space: nowrap;
}

/* Toggle switch base transition polish */
.toggle-thumb { transition: transform .22s var(--ease-out); }

.file-row { transition: background .15s var(--ease-out), transform .15s var(--ease-out); }
.file-row:hover { background: var(--bg-panel-hover); transform: translateX(2px); }

/* ===== Prominent "passed" checkmark ===== */
.pass-check {
  width: 18px; height: 18px; border-radius: 50%; flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--bg-deep); border: 1.5px solid var(--border-strong);
  transition: all .25s var(--ease-out);
}
.pass-check-on {
  background: var(--status-verified); border-color: var(--status-verified); color: #fff;
  box-shadow: 0 0 0 3px var(--status-verified-soft);
}

/* ===== Prominent score badge ===== */
.score-badge {
  display: inline-flex; align-items: baseline; gap: 3px; flex-shrink: 0;
  font-family: var(--font-mono); font-weight: 700; font-size: 13px;
  padding: 4px 10px; border-radius: 999px;
  background: var(--bg-panel-raised); color: var(--text-primary);
  border: 1px solid var(--border-soft);
  transition: all .25s var(--ease-out);
}
.score-badge-full {
  background: var(--status-verified); color: #fff; border-color: var(--status-verified);
  box-shadow: 0 2px 8px -2px rgba(5,150,105,.4);
}
.score-badge-unit { font-family: var(--font-display); font-weight: 500; font-size: 10.5px; opacity: .75; margin-left: 1px; }

/* ===== Slim top progress bar shown during background sync ===== */
@keyframes sync-sweep {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(250%); }
}
.sync-bar {
  position: fixed; top: 0; left: 0; right: 0; height: 2.5px; z-index: 60;
  background: var(--border-soft); overflow: hidden;
}
.sync-bar-fill {
  height: 100%; width: 40%;
  background: linear-gradient(90deg, transparent, var(--accent), var(--grade-diamond), transparent);
  animation: sync-sweep 1s ease-in-out infinite;
}

@media (max-width: 768px) {
  .tree-row { grid-template-columns: 1fr auto; }
  .tree-row .tree-meta-desktop { display: none; }
}
