/* ═══════════════════════════════════════════════════════════════
   Dongsung Data Operations Console — Total Local Crawler
   Rebuilt 2026-04-11 · palette sourced from dscpa.co.kr logo
   ─────────────────────────────────────────────────────────────
   Brand ink        #0b1013   ·   Card          #11181c
   Teal (primary)   #00a095   ·   Orange (CTA)  #ea5515
   Blue (info)      #1262af   ·   Bone (text)   #e8ece8
   ─────────────────────────────────────────────────────────────
   Display  : Archivo            Body : IBM Plex Sans KR
   Mono     : JetBrains Mono     Nums : tabular-nums, mono
   ═══════════════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Archivo:wght@500;600;700;800&family=IBM+Plex+Sans+KR:wght@300;400;500;600;700&family=JetBrains+Mono:wght@400;500;600;700&display=swap');

:root {
  /* ── Surfaces ── */
  --ink-950: #06090b;
  --ink-900: #0b1013;          /* page base */
  --ink-800: #0e1519;          /* header / nav */
  --ink-700: #11181c;          /* card */
  --ink-600: #17222a;          /* raised surface, inputs */
  --ink-500: #1f2d36;          /* hover surface */
  --line:    #1c2a33;          /* subtle border */
  --line-2:  #26373f;          /* border-stronger */
  --line-hi: #3a4e58;          /* focused / active border */

  /* ── Text ── */
  --bone:   #e8ece8;           /* primary */
  --bone-2: #c3cac5;           /* secondary */
  --fog:    #7d8c93;           /* muted / labels */
  --fog-2:  #55666e;           /* sub-muted */

  /* ── Brand Signals (from dscpa logo) ── */
  --teal-300: #3ccfba;
  --teal-400: #18b8a6;
  --teal-500: #00a095;         /* primary */
  --teal-600: #008b82;
  --teal-glow: rgba(0, 160, 149, 0.22);
  --teal-tint: rgba(0, 160, 149, 0.08);

  --orange-300: #ff9a5c;
  --orange-400: #ff6a1f;
  --orange-500: #ea5515;       /* CTA / alert */
  --orange-600: #c74310;
  --orange-glow: rgba(234, 85, 21, 0.22);
  --orange-tint: rgba(234, 85, 21, 0.08);

  --blue-300: #5aa3dc;
  --blue-400: #1a72c4;
  --blue-500: #1262af;         /* info */
  --blue-600: #0d4e8a;
  --blue-tint: rgba(18, 98, 175, 0.10);

  /* ── State ── */
  --ok:     var(--teal-500);
  --warn:   #f5a623;
  --err:    #ff4d4f;
  --info:   var(--blue-500);
  --ban:    #d9352f;

  /* ── Legacy token bridge (maps old vars to new tokens) ── */
  --bg:        var(--ink-900);
  --surface:   var(--ink-700);
  --surface2:  var(--ink-600);
  --border:    var(--line);
  --text:      var(--bone);
  --text2:     var(--fog);
  --muted:     var(--fog);
  --accent:    var(--teal-500);
  --accent-hover: var(--teal-400);
  --green:     var(--teal-500);
  --red:       var(--err);
  --yellow:    var(--warn);
  --orange:    var(--orange-500);
  --blue:      var(--blue-500);
  --cyan:      var(--teal-400);
  --pink:      var(--orange-500);
  --accent2:   var(--teal-400);

  /* ── Type ── */
  --ff-display: 'Archivo', 'IBM Plex Sans KR', system-ui, sans-serif;
  --ff-body:    'IBM Plex Sans KR', 'IBM Plex Sans', system-ui, sans-serif;
  --ff-mono:    'JetBrains Mono', 'Fira Code', ui-monospace, Consolas, monospace;

  /* ── Radii & shadow ── */
  --r-sm: 4px;
  --r-md: 8px;
  --r-lg: 12px;
  --shadow-lift: 0 10px 30px rgba(0, 0, 0, 0.45), 0 2px 0 rgba(255,255,255,0.02) inset;
  --shadow-card: 0 1px 0 rgba(255,255,255,0.025) inset, 0 20px 40px -20px rgba(0,0,0,0.6);

  --transition: 160ms cubic-bezier(.4,.2,.2,1);
}

/* ── Reset ── */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  -webkit-text-size-adjust: 100%;
  overflow-x: hidden;
}

body {
  font-family: var(--ff-body);
  font-size: 14px;
  line-height: 1.55;
  color: var(--bone);
  background: var(--ink-900);
  min-height: 100vh;
  max-width: 100vw;
  overflow-x: hidden;
  letter-spacing: 0.005em;
  /* HUD grid background — barely visible graph paper */
  background-image:
    radial-gradient(ellipse 120% 60% at 50% -10%, rgba(0,160,149,0.08), transparent 60%),
    radial-gradient(ellipse 100% 50% at 85% 100%, rgba(234,85,21,0.05), transparent 60%),
    linear-gradient(var(--line) 1px, transparent 1px),
    linear-gradient(90deg, var(--line) 1px, transparent 1px);
  background-size: 100% 100%, 100% 100%, 32px 32px, 32px 32px;
  background-attachment: fixed;
}

/* Noise grain overlay */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><filter id='n'><feTurbulence baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 1  0 0 0 0 1  0 0 0 0 1  0 0 0 0.04 0'/></filter><rect width='160' height='160' filter='url(%23n)'/></svg>");
  opacity: 0.5;
  mix-blend-mode: overlay;
  z-index: 999;
}

a { color: var(--teal-300); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--teal-400); text-decoration: underline; text-underline-offset: 3px; }

::selection { background: var(--teal-glow); color: var(--bone); }

/* ═══════════════════ Header ═══════════════════ */
.header {
  position: sticky;
  top: 0;
  z-index: 100;
  display: grid;
  grid-template-columns: minmax(240px, auto) 1fr auto;
  align-items: center;
  gap: 24px;
  padding: 14px 28px;
  background: linear-gradient(180deg, rgba(14,21,25,0.96), rgba(11,16,19,0.90));
  backdrop-filter: blur(14px) saturate(120%);
  -webkit-backdrop-filter: blur(14px) saturate(120%);
  border-bottom: 1px solid var(--line);
}
.header::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: -1px;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--teal-500) 20%, var(--orange-500) 50%, var(--blue-500) 80%, transparent);
  opacity: 0.55;
  pointer-events: none;
}

.header h1 {
  display: flex;
  align-items: center;
  gap: 12px;
  font-family: var(--ff-display);
  font-weight: 700;
  font-size: 15px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--bone);
  white-space: nowrap;
}
.header h1 span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  color: transparent;
  background: url('/static/favicon.svg') center/contain no-repeat;
  filter: drop-shadow(0 0 10px var(--teal-glow));
  flex-shrink: 0;
}

/* ── Tabs ── */
.tabs {
  display: flex;
  gap: 2px;
  padding: 4px;
  background: var(--ink-700);
  border: 1px solid var(--line);
  border-radius: 10px;
  justify-self: center;
}
.tab {
  position: relative;
  padding: 8px 18px;
  border: none;
  border-radius: 7px;
  background: transparent;
  color: var(--fog);
  font-family: var(--ff-display);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  cursor: pointer;
  transition: color var(--transition), background var(--transition);
}
.tab::before {
  content: "";
  position: absolute;
  left: 10px;
  top: 50%;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--fog-2);
  transform: translateY(-50%);
  transition: background var(--transition), box-shadow var(--transition);
}
.tab { padding-left: 26px; }
.tab:hover { color: var(--bone); background: var(--ink-600); }
.tab:hover::before { background: var(--teal-400); }
.tab.active {
  color: var(--bone);
  background: linear-gradient(180deg, var(--ink-500), var(--ink-600));
  box-shadow: 0 0 0 1px var(--line-hi), 0 4px 12px rgba(0,0,0,0.35);
}
.tab.active::before {
  background: var(--teal-400);
  box-shadow: 0 0 12px var(--teal-400), 0 0 22px var(--teal-glow);
  animation: pulse 2s ease-in-out infinite;
}

/* Lang / shortcuts / restart cluster */
.header > div:last-child {
  display: flex;
  align-items: center;
  gap: 10px;
}
.shortcuts-help {
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--fog) !important;
  font-family: var(--ff-mono);
  font-size: 13px !important;
  background: var(--ink-700);
}
.lang-toggle {
  padding: 6px 12px !important;
  border-radius: 6px !important;
  background: var(--ink-700) !important;
  border: 1px solid var(--line) !important;
  color: var(--bone-2) !important;
  font-family: var(--ff-mono) !important;
  font-size: 11px !important;
  font-weight: 600 !important;
  letter-spacing: 0.08em !important;
  cursor: pointer;
  transition: all var(--transition);
}
.lang-toggle:hover {
  color: var(--teal-300) !important;
  border-color: var(--line-hi) !important;
  background: var(--ink-600) !important;
}
#btnRestart {
  padding: 6px 14px !important;
  border-radius: 6px !important;
  background: transparent !important;
  border: 1px solid var(--orange-500) !important;
  color: var(--orange-400) !important;
  font-family: var(--ff-display) !important;
  font-size: 11px !important;
  font-weight: 700 !important;
  letter-spacing: 0.08em !important;
  text-transform: uppercase;
  cursor: pointer;
  transition: all var(--transition);
}
#btnRestart:hover {
  background: var(--orange-500) !important;
  color: #0b1013 !important;
  box-shadow: 0 0 18px var(--orange-glow);
}

/* ═══════════════════ Tab Content ═══════════════════ */
.tab-content {
  display: none;
  padding: 28px 32px 48px;
  gap: 20px;
  max-width: 100%;
}
.tab-content.active {
  display: flex;
  flex-wrap: wrap;
  animation: fadeUp 420ms cubic-bezier(.22,.8,.24,1) both;
}
.tab-content.active > * { min-width: 0; }
.tab-content.active > .card,
.tab-content.active > .crawl-stats-section,
.tab-content.active > .crawl-scheduler-section,
.tab-content.active > .permits-data-section,
.tab-content.active > .dash-left,
.tab-content.active > .dash-right,
.tab-content.active > .permits-left,
.tab-content.active > .permits-right,
.tab-content.active > .data-layout {
  animation: fadeUp 520ms cubic-bezier(.22,.8,.24,1) both;
}
.tab-content.active > :nth-child(1) { animation-delay: 30ms; }
.tab-content.active > :nth-child(2) { animation-delay: 90ms; }
.tab-content.active > :nth-child(3) { animation-delay: 150ms; }
.tab-content.active > :nth-child(4) { animation-delay: 210ms; }
.tab-content.active > :nth-child(5) { animation-delay: 270ms; }

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

/* ═══════════════════ Card — HUD instrument frame ═══════════════════ */
.card {
  position: relative;
  background: linear-gradient(180deg, var(--ink-700), var(--ink-800) 160%);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 22px 22px 20px;
  box-shadow: var(--shadow-card);
  transition: border-color var(--transition), transform var(--transition);
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
}
.card::before,
.card::after {
  content: "";
  position: absolute;
  width: 12px;
  height: 12px;
  pointer-events: none;
  opacity: 0.55;
}
.card::before {
  top: 8px;
  left: 8px;
  border-top: 1px solid var(--teal-500);
  border-left: 1px solid var(--teal-500);
}
.card::after {
  bottom: 8px;
  right: 8px;
  border-bottom: 1px solid var(--teal-500);
  border-right: 1px solid var(--teal-500);
}
.card:hover { border-color: var(--line-2); }

.card-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px 14px;
  padding-bottom: 14px;
  margin-bottom: 16px;
  border-bottom: 1px dashed var(--line);
  font-family: var(--ff-display);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--bone-2);
  min-width: 0;
}
.card-title::before {
  content: "▸";
  display: inline-block;
  margin-right: 8px;
  color: var(--teal-500);
  font-size: 10px;
  transform: translateY(-1px);
  flex-shrink: 0;
}
.card-title > div:last-child,
.card-title > span:last-child,
.card-title > button:last-child {
  margin-left: auto;
  flex-shrink: 0;
}

/* ═══════════════════ Dashboard layout ═══════════════════ */
.dash-left {
  flex: 1 1 420px;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 20px;
}
.dash-right {
  flex: 0 0 440px;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* ═══════════════════ Status bar + dot ═══════════════════ */
.status-bar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 16px;
  background: var(--ink-800);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  margin-bottom: 16px;
  font-family: var(--ff-mono);
}
.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--fog-2);
  flex-shrink: 0;
  box-shadow: 0 0 0 4px rgba(125,140,147,0.1);
}
.status-dot.idle       { background: var(--fog); box-shadow: 0 0 0 4px rgba(125,140,147,0.12); }
.status-dot.running    { background: var(--teal-400); box-shadow: 0 0 0 4px var(--teal-glow), 0 0 14px var(--teal-400); animation: pulse 1.4s ease-in-out infinite; }
.status-dot.paused     { background: var(--warn); box-shadow: 0 0 0 4px rgba(245,166,35,0.22); }
.status-dot.stopping   { background: var(--orange-500); box-shadow: 0 0 0 4px var(--orange-glow); animation: pulse 1s ease-in-out infinite; }
.status-dot.banned_wait{ background: var(--err); box-shadow: 0 0 0 4px rgba(255,77,79,0.22); animation: pulse 0.9s ease-in-out infinite; }
.status-dot.downloading{ background: var(--blue-400); box-shadow: 0 0 0 4px var(--blue-tint); animation: pulse 1.4s ease-in-out infinite; }
.status-dot.syncing    { background: var(--teal-400); box-shadow: 0 0 0 4px var(--teal-glow); animation: pulse 1.4s ease-in-out infinite; }
.status-dot.error      { background: var(--err); box-shadow: 0 0 0 4px rgba(255,77,79,0.22); }
.status-dot.completed  { background: var(--teal-500); box-shadow: 0 0 0 4px var(--teal-glow); }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.35; }
}

.status-text {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.02em;
  flex: 1;
  color: var(--bone);
}
.status-time {
  font-family: var(--ff-mono);
  font-size: 11px;
  color: var(--fog);
  letter-spacing: 0.02em;
}

/* ═══════════════════ Stat tiles ═══════════════════ */
.status-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}
.status-grid.cols-5 { grid-template-columns: repeat(5, 1fr); }

.stat-box {
  position: relative;
  padding: 14px 12px 12px;
  background: linear-gradient(180deg, var(--ink-800), var(--ink-700));
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  text-align: center;
  overflow: hidden;
}
.stat-box::before {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--teal-500), transparent);
  opacity: 0.3;
}
.stat-value {
  font-family: var(--ff-mono);
  font-size: 26px;
  font-weight: 700;
  line-height: 1.05;
  color: var(--bone);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
}
.stat-label {
  display: block;
  margin-top: 6px;
  font-family: var(--ff-display);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--fog);
}
.stat-value.green  { color: var(--teal-400); text-shadow: 0 0 16px var(--teal-glow); }
.stat-value.red    { color: var(--err); }
.stat-value.yellow { color: var(--warn); }
.stat-value.blue   { color: var(--blue-400); }
.stat-value.accent { color: var(--teal-400); text-shadow: 0 0 16px var(--teal-glow); }

/* ═══════════════════ Progress bar — HUD with scanline ═══════════════════ */
.progress-wrap { margin-top: 12px; }
.progress-bar {
  position: relative;
  height: 8px;
  background: var(--ink-800);
  border: 1px solid var(--line);
  border-radius: 4px;
  overflow: hidden;
}
.progress-fill {
  position: relative;
  height: 100%;
  background: linear-gradient(90deg, var(--teal-500), var(--teal-400));
  border-radius: 3px;
  transition: width 0.4s cubic-bezier(.4,.2,.2,1);
  box-shadow: 0 0 12px var(--teal-glow);
}
.progress-fill::after {
  content: "";
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
    -45deg,
    rgba(255,255,255,0.14) 0,
    rgba(255,255,255,0.14) 2px,
    transparent 2px,
    transparent 8px
  );
  animation: scan 1.4s linear infinite;
}
@keyframes scan {
  0%   { transform: translateX(-12px); }
  100% { transform: translateX(0); }
}
.progress-text {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
  margin-top: 6px;
  font-family: var(--ff-mono);
  font-size: 11px;
  color: var(--fog);
  letter-spacing: 0.02em;
}

/* ── ETA row ── */
.eta-row {
  display: flex;
  gap: 18px;
  margin-top: 10px;
  padding: 10px 14px;
  background: var(--ink-800);
  border: 1px solid var(--line);
  border-left: 2px solid var(--teal-500);
  border-radius: var(--r-md);
}
.eta-item { display: flex; align-items: center; gap: 8px; }
.eta-label {
  font-family: var(--ff-display);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--fog);
}
.eta-value {
  font-family: var(--ff-mono);
  font-size: 12px;
  font-weight: 600;
  color: var(--teal-300);
  font-variant-numeric: tabular-nums;
}

/* ── Current item ── */
.current-item {
  margin-top: 10px;
  padding: 10px 14px;
  background: var(--ink-800);
  border: 1px dashed var(--line);
  border-radius: var(--r-md);
  font-family: var(--ff-mono);
  font-size: 12px;
  color: var(--fog);
  min-height: 40px;
  line-height: 1.5;
  word-break: break-all;
}
.current-item strong { color: var(--teal-300); font-weight: 600; }

/* ═══════════════════ Buttons ═══════════════════ */
.control-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  border: 1px solid transparent;
  border-radius: var(--r-md);
  background: var(--ink-600);
  color: var(--bone);
  font-family: var(--ff-display);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
}
.btn:disabled {
  opacity: 0.38;
  cursor: not-allowed;
  filter: saturate(0.6);
}
.btn:not(:disabled):hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(0,0,0,0.4);
}
.btn-start {
  background: linear-gradient(180deg, var(--teal-400), var(--teal-500));
  color: #0b1013;
  border-color: var(--teal-300);
  box-shadow: 0 0 0 1px var(--teal-500) inset, 0 0 18px var(--teal-glow);
}
.btn-start:hover:not(:disabled) {
  background: linear-gradient(180deg, var(--teal-300), var(--teal-400));
  box-shadow: 0 0 0 1px var(--teal-300) inset, 0 0 24px var(--teal-glow);
}
.btn-pause {
  background: transparent;
  color: var(--warn);
  border-color: var(--warn);
}
.btn-pause:hover:not(:disabled) {
  background: var(--warn);
  color: #0b1013;
  box-shadow: 0 0 18px rgba(245,166,35,0.3);
}
.btn-stop {
  background: transparent;
  color: var(--err);
  border-color: var(--err);
}
.btn-stop:hover:not(:disabled) {
  background: var(--err);
  color: #0b1013;
  box-shadow: 0 0 18px rgba(255,77,79,0.3);
}
.btn-primary {
  background: linear-gradient(180deg, var(--orange-400), var(--orange-500));
  color: #0b1013;
  border-color: var(--orange-300);
  box-shadow: 0 0 0 1px var(--orange-500) inset, 0 0 14px var(--orange-glow);
}
.btn-primary:hover:not(:disabled) {
  background: linear-gradient(180deg, var(--orange-300), var(--orange-400));
}
.btn-secondary {
  background: var(--ink-700);
  color: var(--bone-2);
  border-color: var(--line);
}
.btn-secondary:hover:not(:disabled) {
  color: var(--teal-300);
  border-color: var(--line-hi);
  background: var(--ink-600);
}
.btn-secondary.active {
  background: var(--teal-tint);
  color: var(--teal-300);
  border-color: var(--teal-500);
}
.btn-sm {
  padding: 6px 14px;
  font-size: 10px;
  letter-spacing: 0.08em;
}
.btn-save {
  padding: 12px 28px;
  background: linear-gradient(180deg, var(--teal-400), var(--teal-500));
  color: #0b1013;
  border-color: var(--teal-300);
  box-shadow: 0 0 0 1px var(--teal-500) inset, 0 0 18px var(--teal-glow);
}
.btn-save:hover { background: linear-gradient(180deg, var(--teal-300), var(--teal-400)); }
.btn-accent {
  background: linear-gradient(180deg, var(--teal-400), var(--teal-500)) !important;
  color: #0b1013 !important;
  border: 1px solid var(--teal-300) !important;
  white-space: nowrap;
}

.save-msg {
  font-family: var(--ff-mono);
  font-size: 11px;
  color: var(--teal-400);
  margin-left: 12px;
  letter-spacing: 0.04em;
  opacity: 0;
  transform: translateX(-4px);
  transition: all 260ms ease;
}
.save-msg.show { opacity: 1; transform: translateX(0); }
.save-msg::before { content: "▸ "; color: var(--teal-500); }

/* ═══════════════════ Form elements ═══════════════════ */
.exec-settings {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
.setting-group label {
  display: block;
  font-family: var(--ff-display);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--fog);
  margin-bottom: 8px;
}
.setting-group select,
.setting-group input,
.form-group input,
.form-group select,
.form-group textarea,
.filter-group input,
.filter-group select,
input[type="text"],
input[type="password"],
input[type="number"],
input[type="date"],
input[type="time"],
select,
textarea {
  width: 100%;
  padding: 10px 12px;
  background: var(--ink-800);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  color: var(--bone);
  font-family: var(--ff-body);
  font-size: 13px;
  outline: none;
  transition: border-color var(--transition), background var(--transition), box-shadow var(--transition);
}
input[type="number"],
input[type="date"],
input[type="time"] {
  font-family: var(--ff-mono);
  font-variant-numeric: tabular-nums;
}
.setting-group select:focus,
.setting-group input:focus,
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus,
.filter-group input:focus,
.filter-group select:focus,
input:focus,
select:focus,
textarea:focus {
  border-color: var(--teal-500);
  background: var(--ink-700);
  box-shadow: 0 0 0 3px var(--teal-tint);
}
.setting-group input[type="range"] {
  padding: 4px 0;
  background: transparent;
  border: none;
  -webkit-appearance: none;
  appearance: none;
  height: 22px;
}
.setting-group input[type="range"]::-webkit-slider-runnable-track {
  height: 4px;
  background: var(--ink-800);
  border-radius: 2px;
  border: 1px solid var(--line);
}
.setting-group input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  background: var(--teal-400);
  border: 2px solid var(--ink-900);
  border-radius: 50%;
  margin-top: -7px;
  box-shadow: 0 0 10px var(--teal-glow);
  cursor: pointer;
}
.setting-group input[type="range"]:focus {
  box-shadow: none;
}
.range-val {
  font-family: var(--ff-mono);
  font-size: 11px;
  color: var(--teal-300);
  font-weight: 600;
  margin-left: 6px;
  padding: 2px 8px;
  background: var(--teal-tint);
  border-radius: var(--r-sm);
  border: 1px solid var(--teal-500);
}
.setting-inline { display: flex; align-items: center; gap: 8px; }

/* ── Toggle switch ── */
.toggle {
  position: relative;
  display: inline-block;
  width: 40px;
  height: 22px;
  flex-shrink: 0;
}
.toggle input { display: none; }
.toggle-slider {
  position: absolute;
  inset: 0;
  background: var(--ink-700);
  border: 1px solid var(--line);
  border-radius: 22px;
  cursor: pointer;
  transition: all var(--transition);
}
.toggle-slider::before {
  content: '';
  position: absolute;
  width: 14px;
  height: 14px;
  background: var(--fog);
  border-radius: 50%;
  left: 3px;
  top: 50%;
  transform: translateY(-50%);
  transition: all var(--transition);
}
.toggle input:checked + .toggle-slider {
  background: var(--teal-tint);
  border-color: var(--teal-500);
}
.toggle input:checked + .toggle-slider::before {
  transform: translate(18px, -50%);
  background: var(--teal-400);
  box-shadow: 0 0 10px var(--teal-glow);
}

/* Generic checkbox */
input[type="checkbox"] {
  accent-color: var(--teal-500);
  cursor: pointer;
}

/* ═══════════════════ Logs — CRT terminal ═══════════════════ */
.log-container {
  flex: 1;
  min-height: 320px;
  max-height: 520px;
  overflow-y: auto;
  padding: 14px 16px;
  background:
    repeating-linear-gradient(0deg, rgba(0,160,149,0.02) 0, rgba(0,160,149,0.02) 1px, transparent 1px, transparent 3px),
    #050a0c;
  border: 1px solid var(--line);
  border-left: 2px solid var(--teal-500);
  border-radius: var(--r-md);
  font-family: var(--ff-mono);
  font-size: 12px;
  line-height: 1.55;
  color: var(--bone-2);
}
.log-entry {
  padding: 2px 0;
  display: flex;
  gap: 10px;
}
.log-time {
  color: var(--fog-2);
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
}
.log-level {
  flex-shrink: 0;
  font-weight: 700;
  width: 56px;
  letter-spacing: 0.04em;
}
.log-level.INFO    { color: var(--teal-400); }
.log-level.WARNING { color: var(--warn); }
.log-level.ERROR   { color: var(--err); }
.log-level.DEBUG   { color: var(--fog); }
.log-msg { color: var(--bone-2); word-break: break-all; }

/* ═══════════════════ Settings layout ═══════════════════ */
.settings-layout {
  flex-direction: column;
  max-width: 960px;
  width: 100%;
}
.settings-section { margin-bottom: 0; }

.add-industry-bar {
  display: flex;
  gap: 10px;
  margin-bottom: 14px;
}
.add-industry-bar input { flex: 1; }

.industry-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.industry-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  background: var(--ink-800);
  border: 1px solid var(--line);
  border-radius: 20px;
  font-family: var(--ff-mono);
  font-size: 12px;
  color: var(--bone);
  transition: all var(--transition);
}
.industry-chip:hover {
  border-color: var(--teal-500);
  background: var(--teal-tint);
  color: var(--teal-300);
}
.industry-chip .chip-remove {
  cursor: pointer;
  color: var(--fog);
  font-size: 14px;
  line-height: 1;
  transition: color var(--transition);
}
.industry-chip .chip-remove:hover { color: var(--err); }

#industrySettingsContainer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 14px;
  margin-bottom: 14px;
  min-width: 0;
}
#industrySettingsContainer > * { min-width: 0; }
.industry-card {
  position: relative;
  padding: 18px;
  background: var(--ink-700);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
}
.industry-card::before {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--teal-500), transparent);
}
.industry-card .form-grid { grid-template-columns: 1fr; }
.industry-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 1px dashed var(--line);
}
.industry-card-title {
  font-family: var(--ff-display);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--teal-300);
}
.industry-card-section { margin-bottom: 12px; }
.industry-card-section-title {
  font-family: var(--ff-display);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--fog);
  margin-bottom: 8px;
}

.permit-sheet-row {
  padding: 14px 16px;
  margin-bottom: 10px;
  background: var(--ink-800);
  border: 1px solid var(--line);
  border-left: 2px solid var(--teal-500);
  border-radius: var(--r-md);
}
.permit-sheet-label {
  font-family: var(--ff-display);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--teal-300);
  margin-bottom: 8px;
}
.sheet-test-buttons {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 8px;
}
.sheet-test-result {
  font-family: var(--ff-mono);
  font-size: 11px;
  margin-left: 4px;
  letter-spacing: 0.02em;
}
.sheet-test-result.success { color: var(--teal-400); }
.sheet-test-result.success::before { content: "◉ "; }
.sheet-test-result.error { color: var(--err); }
.sheet-test-result.error::before { content: "✕ "; }
.sheet-test-result.loading { color: var(--fog); }
.sheet-test-result.loading::before { content: "◌ "; }

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}
.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.form-group.full { grid-column: 1 / -1; }
.form-group label {
  font-family: var(--ff-display);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--fog);
}
.form-group input[readonly] {
  opacity: 0.55;
  cursor: not-allowed;
}
.form-row { display: flex; align-items: center; gap: 12px; }
.form-row span {
  font-family: var(--ff-mono);
  font-size: 12px;
  color: var(--fog);
  white-space: nowrap;
}
.form-row input {
  width: 90px;
  text-align: center;
}

/* ═══════════════════ Data tables ═══════════════════ */
.data-table-wrap {
  overflow-x: auto;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  margin-top: 14px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--ink-800);
  max-width: 100%;
  /* subtle scroll indicator on right edge */
  background:
    linear-gradient(to right, var(--ink-800) 30%, rgba(23,34,42,0)) 0 0/20px 100% no-repeat,
    linear-gradient(to right, rgba(23,34,42,0), var(--ink-800) 70%) 100% 0/20px 100% no-repeat,
    radial-gradient(farthest-side at 0 50%, rgba(0,0,0,0.4), transparent) 0 0/12px 100% no-repeat,
    radial-gradient(farthest-side at 100% 50%, rgba(0,0,0,0.4), transparent) 100% 0/12px 100% no-repeat,
    var(--ink-800);
  background-attachment: local, local, scroll, scroll, local;
}
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--ff-body);
  font-size: 13px;
}
.data-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--ink-700);
  color: var(--fog);
  font-family: var(--ff-display);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 12px 14px;
  text-align: left;
  border-bottom: 1px solid var(--line-2);
  white-space: nowrap;
}
.data-table td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  color: var(--bone-2);
  font-variant-numeric: tabular-nums;
}
.data-table tr:nth-child(even) td { background: rgba(23, 34, 42, 0.4); }
.data-table tr:hover td {
  background: var(--teal-tint);
  color: var(--bone);
}
.data-table.compact { font-size: 12px; }
.data-table.compact th,
.data-table.compact td { padding: 7px 10px; }

.detail-stats-table-wrap {
  max-height: 240px;
  overflow-x: auto;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  max-width: 100%;
}

/* Sortable */
.data-table th.sortable {
  cursor: pointer;
  user-select: none;
  position: sticky;
  padding-right: 22px;
  transition: color var(--transition);
}
.data-table th.sortable:hover { color: var(--teal-300); }
.data-table th.sortable::after {
  content: '⇅';
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 10px;
  opacity: 0.32;
}
.data-table th.sortable.active-sort::after { opacity: 1; color: var(--teal-400); }
.data-table th.sortable.active-sort.asc::after  { content: '▲'; }
.data-table th.sortable.active-sort.desc::after { content: '▼'; }

.sort-icon {
  font-size: 10px;
  margin-left: 4px;
  color: var(--fog);
}
.sort-icon.sort-asc,
.sort-icon.sort-desc { color: var(--teal-400); }

#cacheListTable thead th {
  user-select: none;
  position: sticky;
  top: 0;
  background: var(--ink-700);
  transition: background var(--transition);
}
#cacheListTable thead th:hover { background: var(--ink-600); color: var(--teal-300); }

/* ═══════════════════ Pagination ═══════════════════ */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-top: 16px;
}
.pagination button {
  padding: 7px 16px;
  background: var(--ink-700);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  color: var(--bone-2);
  font-family: var(--ff-mono);
  font-size: 12px;
  cursor: pointer;
  transition: all var(--transition);
}
.pagination button:hover:not(:disabled) {
  background: var(--ink-600);
  color: var(--teal-300);
  border-color: var(--line-hi);
}
.pagination button:disabled { opacity: 0.3; cursor: not-allowed; }
.pagination .page-info {
  font-family: var(--ff-mono);
  font-size: 12px;
  color: var(--fog);
  letter-spacing: 0.04em;
}

/* ═══════════════════ Filter / summary ═══════════════════ */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: flex-end;
  padding: 14px;
  background: var(--ink-800);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
}
.filter-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.filter-group label {
  font-family: var(--ff-display);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--fog);
}
.filter-group input,
.filter-group select { min-width: 150px; }
.filter-group .checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--ff-body);
  font-size: 13px;
  color: var(--bone);
  cursor: pointer;
  padding: 10px 0;
}
.filter-group .checkbox-label input[type="checkbox"] {
  min-width: auto;
  width: 16px;
  height: 16px;
}

.summary-bar {
  display: flex;
  gap: 32px;
  padding: 14px 18px;
  margin-top: 14px;
  background: var(--ink-800);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  border-left: 2px solid var(--teal-500);
}
.summary-item {
  display: flex;
  align-items: baseline;
  gap: 10px;
}
.summary-item .label {
  font-family: var(--ff-display);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--fog);
}
.summary-item .value {
  font-family: var(--ff-mono);
  font-size: 18px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.summary-item .value.blue  { color: var(--blue-400); }
.summary-item .value.green { color: var(--teal-400); }
.summary-item .value.accent{ color: var(--teal-400); }

.export-bar {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

/* ═══════════════════ Permits layout ═══════════════════ */
.permits-layout {
  width: 100%;
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
}
.permits-left {
  flex: 1 1 420px;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 20px;
}
.permits-right {
  flex: 0 0 440px;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.sync-table-wrap {
  max-height: 320px;
  overflow-x: auto;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  max-width: 100%;
}
#syncTable th:nth-child(1) { width: 22%; text-align: left; }
#syncTable th:nth-child(2) { width: 14%; text-align: right; }
#syncTable th:nth-child(3) { width: 22%; text-align: center; }
#syncTable th:nth-child(4) { width: 22%; text-align: center; }
#syncTable th:nth-child(5) { width: 20%; text-align: center; }
#syncTable td:nth-child(1) { text-align: left; font-weight: 600; color: var(--bone); }
#syncTable td:nth-child(2) { text-align: right; font-family: var(--ff-mono); color: var(--teal-300); }
#syncTable td:nth-child(3),
#syncTable td:nth-child(4) { text-align: center; font-family: var(--ff-mono); font-size: 12px; }
#syncTable td:nth-child(5) { text-align: center; }

#permitDataTable th:nth-child(1) { width: 48px; text-align: center; }
#permitDataTable td:nth-child(1) { text-align: center; color: var(--fog); font-family: var(--ff-mono); }
#permitDataTable th:nth-child(2) { width: 110px; text-align: center; }
#permitDataTable td:nth-child(2) { text-align: center; font-family: var(--ff-mono); }
#permitDataTable th:nth-child(3) { width: 80px; text-align: center; }
#permitDataTable td:nth-child(3) { text-align: center; }
#permitDataTable th:nth-child(6) { width: 90px; text-align: right; }
#permitDataTable td:nth-child(6) { text-align: right; font-family: var(--ff-mono); }
#permitDataTable th:nth-child(9) { width: 70px; text-align: center; }
#permitDataTable td:nth-child(9) { text-align: center; }

/* ═══════════════════ Data layout ═══════════════════ */
.data-layout {
  width: 100%;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 20px;
}
.data-layout > * { min-width: 0; }

/* ── Column tags ── */
.col-tags { display: flex; flex-wrap: wrap; gap: 6px; font-family: var(--ff-mono); font-size: 12px; }
.col-tag {
  padding: 4px 10px;
  border-radius: var(--r-sm);
  background: var(--ink-700);
  border: 1px solid var(--line);
  color: var(--bone-2);
}
.col-tag.highlight { background: var(--teal-tint); color: var(--teal-300); border-color: var(--teal-500); }
.col-tag.result    { background: var(--orange-tint); color: var(--orange-400); border-color: var(--orange-500); font-weight: 600; }

/* ── API key row ── */
.api-key-display {
  display: flex;
  align-items: center;
  gap: 8px;
}
.api-key-display input { flex: 1; }

/* ═══════════════════ Crawl stats dashboard ═══════════════════ */
.crawl-stats-section {
  width: 100%;
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 18px;
}
.crawl-stats-section > .card { min-width: 0; }
.crawl-stats-section > .card:first-child { grid-column: 1 / -1; }

.cache-section-divider {
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px dashed var(--line);
}
.cache-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
  flex-wrap: wrap;
  gap: 12px;
}
.cache-title {
  font-family: var(--ff-display);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--teal-300);
}
.cache-mini-stats {
  display: flex !important;
  gap: 10px;
  margin: 0 !important;
}
.cache-mini-stats .stat-box {
  padding: 4px 10px;
  min-width: auto;
}
.cache-mini-stats .stat-value { font-size: 14px; }
.cache-mini-stats .stat-label { font-size: 9px; }

.stats-summary-row {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 12px;
  margin-top: 14px;
}

/* ─── Chart containers ─── */
.chart-container {
  height: 180px;
  display: flex;
  align-items: flex-end;
  gap: 2px;
  padding: 14px 0 6px;
  position: relative;
  border-left: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}
.chart-bar-group {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 0;
}
.chart-bar {
  width: 100%;
  max-width: 26px;
  min-height: 2px;
  border-radius: 2px 2px 0 0;
  transition: all 0.3s;
  position: relative;
  box-shadow: 0 0 0 1px var(--ink-900);
}
.chart-bar.success { background: linear-gradient(180deg, var(--teal-400), var(--teal-500)); }
.chart-bar.failed  { background: var(--err); opacity: 0.75; }
.chart-bar.banned  { background: var(--warn); opacity: 0.75; }
.chart-bar.rate    { background: linear-gradient(180deg, var(--orange-400), var(--orange-500)); }
.chart-bar-group:hover .chart-bar {
  opacity: 1;
  filter: brightness(1.2);
  box-shadow: 0 0 14px var(--teal-glow);
}
.chart-bar-group .chart-tooltip {
  display: none;
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  background: var(--ink-800);
  border: 1px solid var(--line-hi);
  border-radius: var(--r-sm);
  padding: 6px 10px;
  font-family: var(--ff-mono);
  font-size: 11px;
  white-space: nowrap;
  z-index: 10;
  pointer-events: none;
  color: var(--bone);
}
.chart-bar-group:hover .chart-tooltip { display: block; }
.chart-date {
  font-family: var(--ff-mono);
  font-size: 10px;
  color: var(--fog);
  margin-top: 6px;
  writing-mode: vertical-rl;
  text-orientation: mixed;
  max-height: 44px;
  overflow: hidden;
}
.chart-zero-line {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  border-bottom: 1px dashed var(--line-2);
}

/* ── Source bars ── */
.source-bars {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 12px 0;
}
.source-bar-row {
  display: flex;
  align-items: center;
  gap: 14px;
}
.source-label {
  width: 56px;
  font-family: var(--ff-display);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--fog);
  text-align: right;
}
.source-bar-bg {
  flex: 1;
  height: 22px;
  background: var(--ink-800);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  overflow: hidden;
  position: relative;
}
.source-bar-fill {
  height: 100%;
  transition: width 0.6s cubic-bezier(.22,.8,.24,1);
  position: relative;
}
.source-bar-fill::after {
  content: "";
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
    -45deg,
    rgba(255,255,255,0.08) 0, rgba(255,255,255,0.08) 2px,
    transparent 2px, transparent 8px
  );
}
.source-bar-fill.naver { background: linear-gradient(90deg, var(--teal-500), var(--teal-400)); }
.source-bar-fill.kakao { background: linear-gradient(90deg, var(--warn), #ffc85e); }
.source-bar-fill.cache { background: linear-gradient(90deg, var(--blue-500), var(--blue-400)); }
.source-pct {
  width: 48px;
  font-family: var(--ff-mono);
  font-size: 12px;
  color: var(--bone);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

/* ═══════════════════ Sheet checkbox list ═══════════════════ */
.sheet-select-section {
  padding: 14px;
  background: var(--ink-800);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
}
.sheet-checkbox-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.sheet-checkbox-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 14px;
  background: var(--ink-700);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  cursor: pointer;
  transition: all var(--transition);
  user-select: none;
  font-family: var(--ff-mono);
  font-size: 12px;
}
.sheet-checkbox-item:hover {
  border-color: var(--teal-500);
  background: var(--ink-600);
}
.sheet-checkbox-item.checked {
  border-color: var(--teal-500);
  background: var(--teal-tint);
  color: var(--teal-300);
}
.sheet-checkbox-item input[type="checkbox"] {
  width: 14px;
  height: 14px;
  cursor: pointer;
}
.sheet-order-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--teal-500);
  color: #0b1013;
  font-family: var(--ff-mono);
  font-size: 10px;
  font-weight: 700;
  flex-shrink: 0;
  box-shadow: 0 0 10px var(--teal-glow);
}
.sheet-order-badge.hidden { visibility: hidden; }

/* Mode description */
.mode-desc {
  font-family: var(--ff-mono);
  font-size: 11px;
  color: var(--fog);
  margin-top: 8px;
  line-height: 1.55;
  padding: 8px 12px;
  background: var(--ink-800);
  border-radius: var(--r-md);
  border-left: 2px solid var(--teal-500);
}

/* ═══════════════════ Scheduler ═══════════════════ */
.scheduler-row {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}
.scheduler-label {
  font-family: var(--ff-display);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--fog);
  min-width: 48px;
}
.scheduler-label.active { color: var(--teal-400); }
.scheduler-time-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.scheduler-time-group label {
  font-family: var(--ff-display);
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--fog);
}
.scheduler-status {
  font-family: var(--ff-mono);
  font-size: 11px;
  color: var(--fog);
  margin-top: 12px;
  min-height: 18px;
  padding: 6px 0;
  border-top: 1px dashed var(--line);
}

.crawl-scheduler-section {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 18px;
  margin-top: 2px;
  min-width: 0;
}
.crawl-scheduler-section > .card { min-width: 0; }

/* Resume info */
.resume-info {
  display: none;
  margin-top: 8px !important;
  padding: 8px 14px !important;
  background: var(--ink-800) !important;
  border: 1px solid var(--line) !important;
  border-left: 2px solid var(--orange-500) !important;
  border-radius: var(--r-md) !important;
  font-family: var(--ff-mono);
  font-size: 12px !important;
  color: var(--orange-300) !important;
}

/* Permits data section (full width) */
.permits-data-section {
  width: 100%;
  min-width: 0;
  flex-basis: 100%;
}
.permits-data-section > * { min-width: 0; }
.permit-data-count {
  font-family: var(--ff-mono);
  font-size: 12px;
  color: var(--fog);
  white-space: nowrap;
}

/* ═══════════════════ Monitor tab ═══════════════════ */
.monitor-layout.active {
  display: grid !important;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px;
  flex-wrap: nowrap !important;
}
.monitor-card {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: 0;
}
.monitor-card-sm { grid-column: 1 / -1; }
.monitor-gauge-row {
  display: flex;
  align-items: center;
  gap: 24px;
}
.gauge-container {
  flex-shrink: 0;
  width: 110px;
  height: 110px;
  position: relative;
  filter: drop-shadow(0 0 14px var(--teal-glow));
}
.gauge-svg { width: 100%; height: 100%; }
.gauge-svg .gauge-fill { stroke: var(--teal-400); }
.gauge-svg .gauge-label { font-family: var(--ff-mono); fill: var(--bone); }

.monitor-stats {
  flex: 1;
  display: flex;
  flex-wrap: wrap;
  gap: 10px 18px;
}
.monitor-stat {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  min-width: 150px;
  padding: 6px 0;
  border-bottom: 1px dashed var(--line);
}
.monitor-stat .stat-label {
  font-family: var(--ff-display);
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--fog);
}
.monitor-stat .stat-value {
  font-family: var(--ff-mono);
  font-size: 13px;
  font-weight: 600;
  color: var(--bone);
  font-variant-numeric: tabular-nums;
}

.monitor-chart {
  width: 100%;
  height: 90px;
  border-radius: var(--r-md);
  background:
    repeating-linear-gradient(0deg, rgba(0,160,149,0.04) 0, rgba(0,160,149,0.04) 1px, transparent 1px, transparent 6px),
    repeating-linear-gradient(90deg, rgba(0,160,149,0.04) 0, rgba(0,160,149,0.04) 1px, transparent 1px, transparent 6px),
    var(--ink-800);
  border: 1px solid var(--line);
}

.cores-detail {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 6px;
}
.core-bar-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--ff-mono);
  font-size: 11px;
}
.core-label { color: var(--fog); width: 26px; flex-shrink: 0; }
.core-bar {
  flex: 1;
  height: 6px;
  background: var(--ink-800);
  border: 1px solid var(--line);
  border-radius: 3px;
  overflow: hidden;
}
.core-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--teal-500), var(--teal-400));
  transition: width 0.5s;
}
.core-val { color: var(--fog); width: 36px; text-align: right; flex-shrink: 0; }

.disk-list { display: flex; flex-direction: column; gap: 14px; }
.disk-item { display: flex; flex-direction: column; gap: 8px; }
.disk-header {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}
.disk-device {
  font-family: var(--ff-mono);
  font-weight: 600;
  font-size: 13px;
  color: var(--bone);
}
.disk-mount { font-family: var(--ff-mono); font-size: 12px; color: var(--fog); }
.disk-fs {
  font-family: var(--ff-mono);
  font-size: 10px;
  color: var(--teal-300);
  background: var(--teal-tint);
  border: 1px solid var(--teal-500);
  padding: 2px 8px;
  border-radius: var(--r-sm);
  letter-spacing: 0.04em;
}
.disk-bar {
  height: 8px;
  background: var(--ink-800);
  border: 1px solid var(--line);
  border-radius: 4px;
  overflow: hidden;
}
.disk-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--teal-500), var(--teal-400));
  transition: width 0.5s;
}
.disk-info {
  display: flex;
  justify-content: space-between;
  font-family: var(--ff-mono);
  font-size: 11px;
  color: var(--fog);
}

.net-speed-row { display: flex; gap: 32px; }
.net-speed-item { display: flex; align-items: center; gap: 10px; }
.net-arrow { font-size: 14px; }
.net-down { color: var(--blue-400); }
.net-up   { color: var(--teal-400); }
.net-detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.monitor-loading {
  color: var(--fog);
  font-family: var(--ff-mono);
  font-size: 12px;
  padding: 14px 0;
}

/* ═══════════════════ Monthly traffic ═══════════════════ */
.traffic-card { grid-column: 1 / -1; }
.traffic-card .card-title { display: flex; align-items: center; }
.traffic-summary {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin: 10px 0 14px;
}
.traffic-summary-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 12px 10px;
  background: var(--ink-800);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  position: relative;
  overflow: hidden;
}
.traffic-summary-item::before {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--teal-500), transparent);
  opacity: 0.4;
}
.traffic-summary-label {
  font-family: var(--ff-display);
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--fog);
  margin-bottom: 6px;
}
.traffic-summary-value {
  font-family: var(--ff-mono);
  font-size: 18px;
  font-weight: 700;
  color: var(--bone);
  font-variant-numeric: tabular-nums;
}
.traffic-summary-value.blue  { color: var(--blue-400); }
.traffic-summary-value.green { color: var(--teal-400); }

.traffic-usage-bar-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 8px 0 12px;
}
.traffic-usage-bar {
  flex: 1;
  height: 10px;
  background: var(--ink-800);
  border: 1px solid var(--line);
  border-radius: 5px;
  overflow: hidden;
}
.traffic-usage-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--teal-500), var(--teal-400));
  border-radius: 5px;
  transition: width 0.5s, background 0.3s;
}
.traffic-usage-text {
  font-family: var(--ff-mono);
  font-size: 11px;
  color: var(--fog);
  white-space: nowrap;
}
.traffic-table-wrap {
  max-height: 260px;
  overflow-x: auto;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  margin-top: 10px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  max-width: 100%;
}
.traffic-table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--ff-mono);
  font-size: 12px;
}
.traffic-table th {
  position: sticky;
  top: 0;
  background: var(--ink-700);
  padding: 8px 12px;
  text-align: right;
  font-family: var(--ff-display);
  color: var(--fog);
  font-weight: 600;
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  border-bottom: 1px solid var(--line-2);
}
.traffic-table th:first-child { text-align: left; }
.traffic-table td {
  padding: 6px 12px;
  text-align: right;
  border-bottom: 1px solid var(--line);
  color: var(--bone-2);
  font-variant-numeric: tabular-nums;
}
.traffic-table td:first-child { text-align: left; color: var(--fog); }
.traffic-table td.blue  { color: var(--blue-400); }
.traffic-table td.green { color: var(--teal-400); }
.traffic-table tr:hover { background: var(--teal-tint); }

/* ═══════════════════ Scrollbar ═══════════════════ */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track { background: var(--ink-900); }
::-webkit-scrollbar-thumb {
  background: var(--ink-500);
  border: 1px solid var(--line);
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover { background: var(--teal-600); }

/* ═══════════════════ Misc helpers ═══════════════════ */
.hidden { display: none !important; }

/* ═══════════════════════════════════════════════════════════════
   Responsive — mobile-first safety + progressive enhancement
   Breakpoints: ≤1100 · ≤900 · ≤720 · ≤480
   ═══════════════════════════════════════════════════════════════ */
@media (max-width: 1100px) {
  .header { padding: 12px 20px; }
  .tab-content { padding: 22px 20px 44px; }
}

@media (max-width: 900px) {
  /* Header: 2-row layout (brand+controls, then tabs full-width) */
  .header {
    grid-template-columns: auto auto;
    grid-template-areas:
      "brand  ctrl"
      "tabs   tabs";
    row-gap: 12px;
    padding: 12px 20px 10px;
  }
  .header h1 { grid-area: brand; justify-self: start; }
  .header > .tabs { grid-area: tabs; justify-self: stretch; }
  .header > div:last-child { grid-area: ctrl; justify-self: end; }
  .tabs {
    width: 100%;
    overflow-x: auto;
    overflow-y: hidden;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    flex-wrap: nowrap;
  }
  .tabs::-webkit-scrollbar { display: none; }
  .tab { flex-shrink: 0; scroll-snap-align: center; }

  .dash-right,
  .permits-right { flex: 1 1 100%; }
  .dash-left,
  .permits-left { flex: 1 1 100%; }
  .status-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .status-grid.cols-5 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .filter-bar { padding: 12px; }
  .stats-summary-row { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .traffic-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .cores-detail { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); }
}

/* Tablet portrait / large phone landscape */
@media (max-width: 720px) {
  /* Grids collapse to 1 col at tablet portrait */
  .exec-settings { grid-template-columns: minmax(0, 1fr); }
  .form-grid { grid-template-columns: minmax(0, 1fr); }
  .crawl-stats-section { grid-template-columns: minmax(0, 1fr); }
  .crawl-scheduler-section { grid-template-columns: minmax(0, 1fr); }
  .monitor-layout.active { grid-template-columns: minmax(0, 1fr); }
  #industrySettingsContainer { grid-template-columns: minmax(0, 1fr); }
  .net-detail-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }

  /* ── Header: collapse to single column, stack brand/tabs/controls ── */
  .header {
    position: static;
    grid-template-columns: 1fr;
    grid-template-areas: none;
    gap: 10px;
    padding: 14px 16px 12px;
  }
  .header h1 {
    grid-area: auto;
    justify-self: center;
    justify-content: center;
    font-size: 13px;
    letter-spacing: 0.08em;
    gap: 10px;
  }
  .header > .tabs { grid-area: auto; justify-self: stretch; }
  .header > div:last-child {
    grid-area: auto;
    justify-self: center;
  }
  .header h1 span { width: 30px; height: 30px; }

  /* Tabs: horizontal scroll snap rail (no wrap) */
  .tabs {
    justify-self: stretch;
    width: 100%;
    flex-wrap: nowrap;
    overflow-x: auto;
    overflow-y: hidden;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding: 4px;
    gap: 4px;
  }
  .tabs::-webkit-scrollbar { display: none; }
  .tab {
    flex-shrink: 0;
    scroll-snap-align: center;
    padding: 9px 16px 9px 26px;
    font-size: 11px;
  }

  /* Controls: flex-wrap, center */
  .header > div:last-child {
    justify-self: stretch;
    width: 100%;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 8px;
  }

  .tab-content {
    padding: 18px 14px 40px;
    gap: 16px;
  }

  .card {
    padding: 18px 16px 16px;
  }
  .card-title {
    font-size: 10px;
  }

  .control-row {
    gap: 8px;
  }
  .btn {
    padding: 10px 16px;
    font-size: 11px;
    flex: 1 1 auto;
    min-height: 42px;
    justify-content: center;
  }
  .btn.btn-sm,
  .btn-secondary.btn-sm,
  .btn-primary.btn-sm {
    flex: 0 0 auto;
    min-height: 34px;
    padding: 7px 14px;
    font-size: 10px;
  }

  /* Filter bar — stack fields, allow search button to span full width */
  .filter-bar {
    flex-direction: column;
    align-items: stretch;
  }
  .filter-bar .filter-group input,
  .filter-bar .filter-group select { min-width: 0; width: 100%; }
  .filter-bar > .btn {
    align-self: stretch !important;
    width: 100%;
  }

  /* Summary bar wraps and stretches */
  .summary-bar { flex-wrap: wrap; gap: 14px 24px; padding: 14px; }

  /* Export bar wraps buttons into a row */
  .export-bar {
    flex-wrap: wrap;
    gap: 6px;
  }
  .export-bar .btn-sm {
    flex: 1 1 calc(33.333% - 6px);
    min-width: 0;
  }

  /* Scheduler rows wrap */
  .scheduler-row {
    flex-wrap: wrap;
    gap: 10px;
  }
  .scheduler-row .toggle { order: -1; }
  .scheduler-time-group { flex: 1 1 120px; min-width: 0; }
  .scheduler-time-group input,
  .scheduler-time-group select { min-width: 0; width: 100%; }

  /* Stat tiles shrink gracefully */
  .stat-value { font-size: 22px; }
  .stat-label { font-size: 9px; }
  .stats-summary-row { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .status-grid { gap: 8px; }
  .status-grid.cols-5 { grid-template-columns: repeat(2, minmax(0, 1fr)); }

  /* Logs: slightly shorter */
  .log-container { min-height: 240px; max-height: 360px; font-size: 11px; padding: 12px; }

  /* Tables: allow natural width (no min-width: 600px), parent wrap scrolls */
  .data-table { font-size: 11.5px; }
  .data-table.compact { font-size: 11px; }
  .data-table th { padding: 9px 11px; font-size: 9px; }
  .data-table td { padding: 8px 11px; }
  .detail-stats-table-wrap { max-height: 260px; }

  /* Pagination: full-width buttons with page info between */
  .pagination { flex-wrap: wrap; gap: 8px; }
  .pagination button { flex: 1 1 auto; min-height: 40px; }
  .pagination .page-info { flex: 1 1 100%; text-align: center; order: -1; }

  /* Monitor gauges: smaller but full stats beside */
  .gauge-container { width: 90px; height: 90px; }
  .monitor-stat { min-width: 120px; }
  .traffic-summary { gap: 8px; }
  .traffic-summary-value { font-size: 16px; }

  /* Cache mini-stats: wrap tighter */
  .cache-header { gap: 8px; }
  .cache-mini-stats { flex-wrap: wrap; gap: 6px !important; }
  .cache-mini-stats .stat-box { padding: 3px 8px; flex: 1 1 auto; }

  /* Forms */
  .form-group input,
  .form-group select,
  .form-group textarea,
  .setting-group input,
  .setting-group select {
    font-size: 15px; /* prevent iOS zoom on focus */
  }
  .form-row input { width: 100%; }

  /* Industry chips wrap */
  .industry-chip { font-size: 11.5px; padding: 6px 12px; }

  /* Sheet checkbox items */
  .sheet-checkbox-item { font-size: 11.5px; padding: 8px 12px; }

  /* Restart button full-width priority */
  #btnRestart { padding: 7px 12px !important; font-size: 10px !important; }
  .lang-toggle { padding: 7px 12px !important; font-size: 10px !important; }
}

/* Small phones */
@media (max-width: 480px) {
  body {
    background-size: 100% 100%, 100% 100%, 24px 24px, 24px 24px;
  }

  .header { padding: 12px 12px 10px; }
  .header h1 { font-size: 12px; letter-spacing: 0.06em; }
  .header h1 span { width: 26px; height: 26px; }
  .tab { padding: 8px 14px 8px 22px; font-size: 10px; }

  .tab-content { padding: 14px 10px 32px; gap: 14px; }

  .card {
    padding: 16px 12px 14px;
    border-radius: 10px;
  }
  .card::before, .card::after { width: 10px; height: 10px; top: 6px; left: 6px; }
  .card::after { top: auto; left: auto; bottom: 6px; right: 6px; }
  .card-title { font-size: 9.5px; letter-spacing: 0.12em; padding-bottom: 12px; margin-bottom: 14px; }

  .stats-summary-row { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .status-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .status-grid.cols-5 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat-box { padding: 12px 10px 10px; }
  .stat-value { font-size: 20px; }

  .traffic-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .traffic-summary-item { padding: 10px 8px; }

  /* Cache / sync tables — scrollable wrapper handles width */
  .detail-stats-table-wrap { max-height: 220px; }

  /* Export bar: 2 per row */
  .export-bar .btn-sm { flex: 1 1 calc(50% - 4px); }

  /* Source bars shrink label */
  .source-label { width: 40px; font-size: 9px; }
  .source-bar-bg { height: 18px; }
  .source-pct { width: 38px; font-size: 11px; }

  /* Charts */
  .chart-container { height: 160px; }
  .monitor-chart { height: 72px; }

  /* Fine-tune gauges */
  .gauge-container { width: 80px; height: 80px; }
  .monitor-gauge-row { gap: 16px; }

  /* Footer safe area */
  .tab-content { padding-bottom: calc(32px + env(safe-area-inset-bottom, 0px)); }
}

/* Very small phones / landscape */
@media (max-width: 360px) {
  .header h1 { font-size: 11px; }
  .card { padding: 14px 10px 12px; }
  .btn { padding: 9px 12px; font-size: 10px; }
  .tab { padding: 7px 12px 7px 20px; font-size: 9.5px; }
  .stats-summary-row { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .export-bar .btn-sm { flex: 1 1 100%; }
}

/* Touch-friendly tweaks */
@media (hover: none) and (pointer: coarse) {
  .btn, .tab, .pagination button, .industry-chip, .sheet-checkbox-item {
    min-height: 44px;
  }
  .btn-sm, .pagination button { min-height: 40px; }
  .toggle { width: 48px; height: 26px; }
  .toggle-slider::before { width: 18px; height: 18px; }
  .toggle input:checked + .toggle-slider::before { transform: translate(22px, -50%); }
}

/* ═══════════════════ Print ═══════════════════ */
@media print {
  body { background: white; color: black; }
  .header, .tabs, .btn, .log-container { display: none; }
  .card { border-color: #ccc; box-shadow: none; }
  .card::before, .card::after { display: none; }
}
