/* ─── Reset & Variables ─────────────────────────────────────────────────────── */
:root {
  --bg:         #0d1117;
  --surface:    #161b22;
  --surface2:   #1e2530;
  --surface3:   #252d3a;
  --border:     #30363d;
  --border2:    #404858;
  --accent:     #4f9cf9;
  --accent-dim: #1c3a6e;
  --green:      #3fb950;
  --green-dim:  #0d2e18;
  --yellow:     #d29922;
  --yellow-dim: #2e2008;
  --red:        #f85149;
  --red-dim:    #2e0d0d;
  --text:       #e6edf3;
  --text2:      #8b949e;
  --text3:      #58657a;
  --radius:     8px;
  --radius-sm:  5px;
  --shadow:     0 2px 8px rgba(0,0,0,.4);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.6;
  min-height: 100vh;
}

/* ─── Header ─────────────────────────────────────────────────────────────────── */
.app-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 100;
}
.header-inner {
  max-width: 1200px; margin: 0 auto;
  padding: 12px 24px;
  display: flex; align-items: center; justify-content: space-between;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-logo {
  width: 38px; height: 38px;
  background: var(--accent); color: #fff;
  border-radius: 8px;
  font-size: 14px; font-weight: 800; letter-spacing: -1px;
  display: flex; align-items: center; justify-content: center;
}
.brand-name { font-size: 1.05rem; font-weight: 700; color: var(--text); }
.brand-sub  { font-size: 0.75rem; color: var(--text2); }
.header-badge {
  font-size: 0.72rem; padding: 4px 10px;
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: 20px; color: var(--text2);
}
.header-badge.ok  { background: var(--green-dim); border-color: var(--green); color: var(--green); }
.header-badge.err { background: var(--red-dim);   border-color: var(--red);   color: var(--red);   }

/* ─── Connection bar ─────────────────────────────────────────────────────────── */
.conn-bar {
  background: var(--surface2);
  border-bottom: 1px solid var(--border);
}
.conn-bar-inner {
  max-width: 1200px; margin: 0 auto;
  padding: 10px 24px;
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
}
.conn-label {
  font-size: 0.75rem; font-weight: 600; color: var(--text2);
  text-transform: uppercase; letter-spacing: .06em;
  white-space: nowrap; margin-right: 4px;
}
.conn-bar-inner input[type="text"],
.conn-bar-inner input[type="password"] {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); color: var(--text);
  font-size: 0.82rem; padding: 5px 9px; outline: none;
  transition: border-color .15s;
}
.conn-bar-inner input:focus { border-color: var(--accent); }
#g-server   { width: 170px; }
#g-username { width: 110px; }
#g-password { width: 110px; }
.toggle-label {
  display: flex; align-items: center; gap: 6px;
  font-size: 0.8rem; color: var(--text2); cursor: pointer; white-space: nowrap;
}
.toggle-label input { accent-color: var(--accent); }
.btn-test {
  background: var(--surface3); border: 1px solid var(--border2);
  border-radius: var(--radius-sm); color: var(--text);
  cursor: pointer; font-size: 0.8rem; font-weight: 500; padding: 5px 14px;
  transition: background .15s;
}
.btn-test:hover { background: #303848; }
.conn-chip {
  font-size: 0.75rem; padding: 3px 9px; border-radius: 12px;
  transition: all .2s;
}
.conn-chip.ok   { background: var(--green-dim); color: var(--green); }
.conn-chip.err  { background: var(--red-dim);   color: var(--red); }
.conn-chip.info { background: var(--accent-dim);color: var(--accent); }

/* ─── Tab nav ────────────────────────────────────────────────────────────────── */
.tab-nav {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  padding: 0 24px;
  max-width: 100%;
  overflow-x: auto;
}
.tab {
  background: none; border: none;
  border-bottom: 2px solid transparent;
  color: var(--text2);
  cursor: pointer;
  display: flex; align-items: center; gap: 6px;
  font-size: 0.85rem; font-weight: 500;
  padding: 11px 20px;
  transition: color .15s, border-color .15s;
  white-space: nowrap;
}
.tab:hover  { color: var(--text); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.tab-icon   { font-size: 0.8em; }

/* ─── Layout ─────────────────────────────────────────────────────────────────── */
.main-content {
  max-width: 1200px; margin: 0 auto;
  padding: 24px;
}
.tab-pane  { display: none; }
.tab-pane.active { display: block; }
.hidden { display: none !important; }

.pane-layout {
  display: grid;
  grid-template-columns: minmax(0,1fr) minmax(0,1fr);
  gap: 20px;
  align-items: start;
}
@media (max-width: 860px) {
  .pane-layout { grid-template-columns: 1fr; }
}
.pane-form     { display: flex; flex-direction: column; gap: 14px; }
.pane-progress { display: flex; flex-direction: column; gap: 12px; }
.pane-info     { display: flex; flex-direction: column; gap: 14px; }

/* ─── Cards ──────────────────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}
.card-title {
  font-size: 0.75rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .07em;
  color: var(--text2);
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}

/* ─── Form fields ────────────────────────────────────────────────────────────── */
.field {
  display: flex; flex-direction: column; gap: 5px;
  margin-bottom: 10px;
}
.field:last-child { margin-bottom: 0; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

label { font-size: 0.82rem; color: var(--text2); }
.hint { font-size: 0.75rem; color: var(--text3); font-style: italic; }

input[type="text"],
input[type="password"],
select {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 0.88rem;
  padding: 7px 10px;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
  width: 100%;
}
input:focus, select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(79,156,249,.15);
}
input::placeholder { color: var(--text3); }

/* ─── Mode cards ─────────────────────────────────────────────────────────────── */
.mode-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.mode-card {
  border: 2px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer; padding: 12px;
  transition: border-color .15s, background .15s;
  position: relative;
}
.mode-card:hover { border-color: var(--border2); background: var(--surface2); }
.mode-card.selected { border-color: var(--accent); background: var(--accent-dim); }
.mode-card input { position: absolute; opacity: 0; pointer-events: none; }
.mode-title { font-size: 0.85rem; font-weight: 600; color: var(--text); margin-bottom: 4px; }
.mode-desc  { font-size: 0.75rem; color: var(--text2); }

/* ─── Check options ──────────────────────────────────────────────────────────── */
.options-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 8px; }
.check-option {
  display: flex; align-items: flex-start; gap: 10px;
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); cursor: pointer; padding: 10px;
  transition: border-color .15s;
}
.check-option:hover { border-color: var(--border2); }
.check-option input[type="checkbox"] {
  accent-color: var(--accent);
  flex-shrink: 0; margin-top: 2px;
  width: 15px; height: 15px;
}
.opt-name { font-size: 0.82rem; font-weight: 500; color: var(--text); }
.opt-desc { font-size: 0.72rem; color: var(--text2); margin-top: 2px; }

/* ─── Buttons ────────────────────────────────────────────────────────────────── */
.btn-primary, .btn-secondary {
  border: none; border-radius: var(--radius-sm);
  cursor: pointer; font-size: 0.85rem; font-weight: 500;
  padding: 8px 20px;
  transition: opacity .15s, background .15s;
}
.btn-primary   { background: var(--accent); color: #fff; }
.btn-primary:hover   { opacity: .88; }
.btn-secondary { background: var(--surface3); border: 1px solid var(--border2); color: var(--text); }
.btn-secondary:hover { background: #303848; }
button:disabled { opacity: .4; cursor: not-allowed; }

.form-footer {
  display: flex; align-items: center; gap: 12px; margin-top: 4px;
}
.form-hint { font-size: 0.75rem; color: var(--text3); }

/* ─── Callouts ───────────────────────────────────────────────────────────────── */
.callout {
  border-radius: var(--radius);
  font-size: 0.82rem;
  padding: 10px 14px;
  line-height: 1.5;
}
.callout-info {
  background: var(--accent-dim);
  border: 1px solid #2a4e8a;
  color: #93c5fd;
}
.callout-info strong { color: #bfdbfe; }
.callout-warn {
  background: var(--yellow-dim);
  border: 1px solid #5a3e0a;
  color: #fbbf24;
}
.callout-warn strong, .callout-warn em { color: #fde68a; }
.callout code {
  background: rgba(0,0,0,.25); border-radius: 3px;
  padding: 1px 5px; font-size: .9em;
}

/* ─── Progress panel ─────────────────────────────────────────────────────────── */
.progress-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}
.progress-status {
  display: flex; align-items: center; gap: 8px;
  font-size: 0.88rem; font-weight: 500;
  margin-bottom: 12px;
}
.pstatus-dot {
  width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0;
}
.pstatus-dot.idle    { background: var(--text3); }
.pstatus-dot.running { background: var(--accent); animation: pulse-dot 1.2s ease-in-out infinite; }
.pstatus-dot.success { background: var(--green); }
.pstatus-dot.failed  { background: var(--red); }
@keyframes pulse-dot { 0%,100%{opacity:1} 50%{opacity:.35} }

.progress-bar-wrap {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 8px;
}
.progress-bar-track {
  flex: 1; height: 8px;
  background: var(--surface3); border-radius: 4px;
  overflow: hidden;
}
.progress-bar-fill {
  height: 100%; background: var(--accent); border-radius: 4px;
  transition: width .5s ease;
}
.progress-bar-fill.done    { background: var(--green); }
.progress-bar-fill.failed  { background: var(--red); }
.progress-pct {
  font-size: 0.82rem; font-weight: 700; color: var(--accent);
  width: 36px; text-align: right; flex-shrink: 0;
}
.progress-meta { font-size: 0.75rem; color: var(--text2); }

/* ─── Table grid ─────────────────────────────────────────────────────────────── */
.table-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
}
.table-grid-inner {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(165px, 1fr));
  gap: 6px;
  max-height: 300px;
  overflow-y: auto;
}
.tcard {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-left: 3px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 7px 9px;
  font-size: 0.72rem;
  transition: border-color .2s;
}
.tcard .tname  { font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tcard .trows  { color: var(--text2); margin-top: 2px; }
.tcard.ok       { border-left-color: var(--green); }
.tcard.FAILED   { border-left-color: var(--red); background: #1f0e0e; }
.tcard.check    { border-left-color: var(--yellow); }
.tcard.active   { border-left-color: var(--accent); background: #131e30; }
.tcard.excluded { opacity: .4; }
.tcard.active .tname { animation: flicker 1.2s ease-in-out infinite; }
@keyframes flicker { 0%,100%{opacity:1} 50%{opacity:.55} }

.table-section-header {
  font-size: 0.72rem; font-weight: 600; color: var(--text2);
  text-transform: uppercase; letter-spacing: .06em;
  margin-bottom: 8px;
}

/* ─── Unit list (batch) ──────────────────────────────────────────────────────── */
.unit-list {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  max-height: 380px;
  overflow-y: auto;
}
.unit-row {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 14px;
  border-bottom: 1px solid var(--border);
  font-size: 0.82rem;
}
.unit-row:last-child { border-bottom: none; }
.unit-row:hover { background: var(--surface2); }
.unit-code { font-weight: 600; width: 80px; flex-shrink: 0; }
.unit-db   { color: var(--text2); flex: 1; font-size: 0.75rem; }
.unit-badge {
  font-size: 0.7rem; font-weight: 600;
  padding: 2px 8px; border-radius: 10px;
  white-space: nowrap;
}
.unit-badge.success { background: var(--green-dim); color: var(--green); }
.unit-badge.failed  { background: var(--red-dim);   color: var(--red); }
.unit-badge.running { background: var(--accent-dim); color: var(--accent); }
.unit-badge.skipped { background: var(--surface3);   color: var(--text3); }
.unit-badge.error   { background: var(--red-dim);    color: var(--red); }
.unit-badge.no-mdb  { background: var(--yellow-dim); color: var(--yellow); }
.unit-badge.pending { background: var(--surface3);   color: var(--text2); }

/* ─── Result actions (download links) ───────────────────────────────────────── */
.result-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.dl-link {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); color: var(--text2);
  font-size: 0.78rem; padding: 5px 12px;
  text-decoration: none;
  transition: background .15s, color .15s;
}
.dl-link:hover { background: var(--surface3); color: var(--text); }
.summary-path {
  font-size: 0.78rem; color: var(--text2); padding: 6px;
  background: var(--surface2); border-radius: var(--radius-sm);
  border: 1px solid var(--border); word-break: break-all;
}

/* ─── Log tail ───────────────────────────────────────────────────────────────── */
.log-panel {
  background: #0a0d14;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
  font-family: 'Consolas', 'Fira Code', monospace;
  font-size: 0.71rem;
  color: var(--text2);
  max-height: 150px;
  overflow-y: auto;
  white-space: pre-wrap;
  line-height: 1.5;
}
.log-panel:empty::before { content: 'Logs will appear here...'; color: var(--text3); }
.log-err  { color: var(--red); }
.log-warn { color: var(--yellow); }
.log-info { color: var(--text2); }

/* ─── Result panel (licence/pos) ─────────────────────────────────────────────── */
.result-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  font-size: 0.82rem;
  margin-top: 8px;
}
.result-panel table { width: 100%; border-collapse: collapse; }
.result-panel th, .result-panel td {
  padding: 7px 10px; text-align: left;
  border-bottom: 1px solid var(--border);
  font-size: 0.8rem;
}
.result-panel th { color: var(--text2); font-weight: 500; font-size: 0.72rem; text-transform: uppercase; }
.result-panel tr:last-child td { border-bottom: none; }

.ok-text   { color: var(--green); }
.fail-text { color: var(--red); }
.warn-text { color: var(--yellow); }

/* ─── Info cards (side panel) ────────────────────────────────────────────────── */
.info-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
}
.info-title {
  font-size: 0.75rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .06em;
  color: var(--text2); margin-bottom: 10px;
}
.info-list { padding-left: 18px; color: var(--text2); font-size: 0.82rem; }
.info-list li { margin-bottom: 6px; }
.info-list code {
  background: var(--surface2); border-radius: 3px;
  padding: 1px 5px; font-size: .9em; color: var(--text);
}
.code-block {
  display: block;
  background: var(--surface2); border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 0.75rem; color: var(--text2);
  white-space: pre; overflow-x: auto;
  border: 1px solid var(--border);
}

/* ─── Summary stats strip ───────────────────────────────────────────────────── */
.summary-strip {
  display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 8px;
}
.stat-box {
  flex: 1; min-width: 80px;
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 8px 12px; text-align: center;
}
.stat-box .stat-val { font-size: 1.4rem; font-weight: 700; color: var(--text); }
.stat-box .stat-lbl { font-size: 0.68rem; color: var(--text2); text-transform: uppercase; letter-spacing: .05em; }
.stat-box.ok-box     { border-color: var(--green); }
.stat-box.ok-box .stat-val { color: var(--green); }
.stat-box.fail-box   { border-color: var(--red); }
.stat-box.fail-box .stat-val { color: var(--red); }
