:root {
  --bg: #0f1419;
  --bg-elevated: #1a2332;
  --bg-card: #1e293b;
  --border: #334155;
  --text: #e2e8f0;
  --text-muted: #94a3b8;
  --accent: #38bdf8;
  --accent-dim: #0ea5e9;
  --success: #4ade80;
  --warn: #fbbf24;
  --error: #f87171;
  --sidebar: #0c1220;
  --radius: 12px;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

.app { display: flex; min-height: 100vh; }

.sidebar {
  width: 240px;
  background: var(--sidebar);
  border-right: 1px solid var(--border);
  padding: 20px 0;
  flex-shrink: 0;
}

.brand {
  padding: 0 20px 20px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 12px;
  text-align: center;
}

.brand h1 {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 0.02em;
}

.version { margin: 6px 0 0; color: var(--text-muted); font-size: 0.78rem; }

nav { display: flex; flex-direction: column; gap: 4px; padding: 0 12px; }

.nav {
  text-align: left;
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 11px 14px;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 0.92rem;
  transition: background 0.15s, color 0.15s;
}

.nav:hover { background: rgba(56, 189, 248, 0.08); color: var(--text); }
.nav.active {
  background: rgba(56, 189, 248, 0.15);
  color: var(--accent);
  font-weight: 600;
}

.content {
  flex: 1;
  padding: 28px 32px;
  overflow: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.tab { display: none; width: 100%; max-width: 820px; }
.tab.active { display: block; }

h2 {
  margin: 0 0 8px;
  font-size: 1.5rem;
  font-weight: 700;
  text-align: center;
  color: var(--text);
}

.subtitle {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.9rem;
  margin: 0 0 20px;
}

.hint { color: var(--text-muted); margin: -4px 0 16px; text-align: center; font-size: 0.88rem; }

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 14px;
  margin-bottom: 24px;
  max-width: 720px;
  margin-left: auto;
  margin-right: auto;
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
}

.card .label {
  font-size: 0.72rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.card .value { font-size: 1.25rem; font-weight: 700; margin-top: 8px; }
.card.ok .value { color: var(--success); }
.card.warn .value { color: var(--warn); }
.card.err .value { color: var(--error); }

.btn {
  padding: 10px 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-elevated);
  color: var(--text);
  cursor: pointer;
  font-weight: 600;
  font-size: 0.88rem;
  transition: filter 0.15s, border-color 0.15s;
}

.btn:hover { filter: brightness(1.08); border-color: var(--accent); }
.btn.primary {
  background: linear-gradient(135deg, var(--accent-dim), var(--accent));
  color: #0f1419;
  border-color: transparent;
}
.btn.primary:hover { filter: brightness(1.05); }

.row {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.grow { flex: 1; min-width: 200px; max-width: 100%; }

select,
input[type=text],
input[type=number],
textarea {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font: inherit;
  min-width: 220px;
  max-width: 100%;
  background: var(--bg-elevated);
  color: var(--text);
}

select:focus,
input:focus,
textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.2);
}

.mono {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  font-family: ui-monospace, "Cascadia Code", monospace;
  font-size: 12px;
  white-space: pre-wrap;
  max-height: 400px;
  overflow: auto;
  text-align: left;
  color: var(--text-muted);
}

.preview { min-height: 320px; color: var(--text); }
.log-view { min-height: 360px; }

table {
  width: 100%;
  border-collapse: collapse;
  background: var(--bg-card);
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
}

th, td {
  padding: 12px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  font-size: 0.88rem;
}

th { background: var(--bg-elevated); font-weight: 600; color: var(--text-muted); }
tr:last-child td { border-bottom: none; }

label {
  display: block;
  font-weight: 600;
  font-size: 0.85rem;
  margin: 14px 0 6px;
  color: var(--text-muted);
}

.chk {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
  margin: 12px 0;
}

.msg { margin-top: 12px; font-size: 0.9rem; text-align: center; }
.msg.ok { color: var(--success); }
.msg.err { color: var(--error); }

.banner {
  background: rgba(251, 191, 36, 0.12);
  border: 1px solid rgba(251, 191, 36, 0.35);
  color: var(--warn);
  padding: 14px 18px;
  border-radius: var(--radius);
  margin-bottom: 20px;
  text-align: center;
  width: 100%;
  max-width: 820px;
}

.banner.err {
  background: rgba(248, 113, 113, 0.12);
  border-color: rgba(248, 113, 113, 0.35);
  color: var(--error);
}

.tab-actions { display: flex; justify-content: center; gap: 10px; margin-top: 12px; flex-wrap: wrap; }
.hidden { display: none; }

.panel {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
}

.printer-list { display: flex; flex-direction: column; gap: 10px; margin: 16px 0; }

.printer-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  background: var(--bg-elevated);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.printer-card:hover { border-color: var(--accent); }
.printer-card.selected {
  border-color: var(--accent);
  background: rgba(56, 189, 248, 0.08);
}

.printer-card .meta { flex: 1; min-width: 0; }
.printer-card .name { font-weight: 600; font-size: 0.95rem; }
.printer-card .type {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.badge {
  font-size: 0.68rem;
  padding: 3px 8px;
  border-radius: 999px;
  background: rgba(56, 189, 248, 0.15);
  color: var(--accent);
  font-weight: 600;
  text-transform: uppercase;
}

.empty-state {
  text-align: center;
  padding: 32px 20px;
  color: var(--text-muted);
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  margin: 16px 0;
}

.empty-state strong { display: block; color: var(--text); margin-bottom: 8px; font-size: 1.05rem; }

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 20px;
}

@media (max-width: 640px) {
  .form-grid { grid-template-columns: 1fr; }
  .sidebar { width: 100%; border-right: none; border-bottom: 1px solid var(--border); }
  .app { flex-direction: column; }
}
