:root {
  color-scheme: dark;
  --bg: #0b0f0e;
  --surface: #121816;
  --surface-2: #171f1c;
  --border: #26302d;
  --text: #f1f5f3;
  --muted: #8d9c96;
  --accent: #55e09b;
  --accent-strong: #2fc77d;
  --danger: #ff6b72;
  --warning: #f2bf5e;
  --radius: 18px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 300px; min-height: 100vh; background: radial-gradient(circle at 80% -10%, #173026 0, transparent 35%), var(--bg); color: var(--text); }
button, input, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .45; }
.app-shell { width: min(1080px, 100%); margin: 0 auto; padding: 0 24px 48px; }
.topbar { min-height: 90px; display: flex; align-items: center; justify-content: space-between; gap: 20px; border-bottom: 1px solid var(--border); }
.brand { display: flex; gap: 13px; align-items: center; }
.brand-mark { width: 44px; height: 44px; display: grid; place-items: center; border-radius: 13px; background: var(--accent); color: #07130e; box-shadow: 0 0 30px #55e09b20; }
.brand-mark svg { width: 27px; fill: currentColor; }
h1, h2, p { margin: 0; }
h1 { font-size: 18px; letter-spacing: -.02em; }
.brand p { color: var(--muted); font-size: 12px; margin-top: 3px; }
.connection-badge { display: flex; align-items: center; gap: 8px; padding: 8px 12px; border: 1px solid var(--border); border-radius: 999px; font-size: 12px; color: var(--muted); background: #111614cc; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.connection-badge.online { color: var(--accent); border-color: #55e09b44; }
.connection-badge.online .status-dot { background: var(--accent); box-shadow: 0 0 0 4px #55e09b1c; }
.connection-badge.connecting .status-dot { background: var(--warning); animation: pulse 1s infinite; }
main { display: grid; gap: 18px; padding-top: 24px; }
.panel { background: linear-gradient(145deg, #151c19, #101513); border: 1px solid var(--border); border-radius: var(--radius); padding: 22px; box-shadow: 0 15px 50px #00000018; }
.section-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 19px; }
.eyebrow { color: var(--accent); text-transform: uppercase; letter-spacing: .14em; font-size: 10px; font-weight: 750; margin-bottom: 5px; }
h2 { font-size: 19px; letter-spacing: -.02em; }
.connection-row { display: flex; align-items: end; gap: 12px; }
.field { display: grid; gap: 7px; margin-bottom: 15px; }
.field.grow { flex: 1; margin-bottom: 0; }
.field > span, .editor-toolbar { font-size: 12px; color: var(--muted); font-weight: 600; }
input[type="text"], input[type="url"], textarea { width: 100%; color: var(--text); background: #0b100e; border: 1px solid #2d3935; border-radius: 10px; padding: 11px 12px; outline: none; transition: border-color .15s, box-shadow .15s; }
textarea { resize: vertical; line-height: 1.5; }
input:focus, textarea:focus { border-color: var(--accent-strong); box-shadow: 0 0 0 3px #55e09b12; }
.hint { color: var(--muted); font-size: 11px; margin-top: 10px; }
.button { min-height: 42px; border-radius: 10px; border: 1px solid transparent; padding: 0 17px; font-weight: 700; font-size: 13px; color: var(--text); display: inline-flex; align-items: center; justify-content: center; gap: 8px; transition: transform .1s, background .15s; }
.button:active { transform: translateY(1px); }
.button.primary { color: #06110c; background: var(--accent); }
.button.primary:hover { background: #69e6a8; }
.button.secondary { background: #25332e; border-color: #34453f; }
.button.secondary:hover, .button.ghost:hover { background: #2b3b35; }
.button.ghost { background: transparent; border-color: var(--border); color: #c1cbc7; }
.button.full { width: 100%; margin-top: 8px; }
.button.full.image-test-button { margin-top: 0; }
.button svg { width: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; }
.dashboard-grid { display: grid; grid-template-columns: 1.15fr .85fr; gap: 18px; }
.printer-hero { min-height: 105px; display: flex; align-items: center; gap: 17px; padding: 8px 0 17px; }
.printer-icon { width: 66px; height: 66px; flex: 0 0 auto; display: grid; place-items: center; border-radius: 18px; background: #1b2421; color: var(--muted); }
.printer-icon.ready { color: var(--accent); background: #183027; }
.printer-icon.error { color: var(--danger); background: #30191b; }
.printer-icon svg { width: 38px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linejoin: round; }
.status-title, .status-subtitle { display: block; }
.status-title { font-size: 18px; font-weight: 750; }
.status-subtitle { color: var(--muted); font-size: 12px; margin-top: 5px; }
.facts { display: grid; grid-template-columns: 1fr 1fr; margin: 0 0 20px; border: 1px solid var(--border); border-radius: 11px; overflow: hidden; }
.facts div { padding: 11px 13px; }
.facts div + div { border-left: 1px solid var(--border); }
.facts dt { color: var(--muted); font-size: 10px; text-transform: uppercase; letter-spacing: .1em; }
.facts dd { margin: 4px 0 0; font-size: 13px; font-weight: 650; }
.card-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.icon-button { width: 36px; height: 36px; display: grid; place-items: center; color: var(--muted); background: transparent; border: 1px solid var(--border); border-radius: 9px; }
.icon-button:hover { color: var(--accent); }
.icon-button svg { width: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.checkbox-row { display: flex; gap: 9px; align-items: center; color: #c7d0cc; font-size: 12px; margin: 2px 0 16px; }
.checkbox-row input { accent-color: var(--accent-strong); width: 16px; height: 16px; }
.advanced-panel { padding: 0; overflow: hidden; }
details summary { list-style: none; display: flex; justify-content: space-between; align-items: center; padding: 20px 22px; cursor: pointer; user-select: none; }
details summary::-webkit-details-marker { display: none; }
details summary strong { display: block; font-size: 16px; }
details summary svg { width: 22px; fill: none; stroke: var(--muted); stroke-width: 1.8; transition: transform .2s; }
details[open] summary svg { transform: rotate(180deg); }
.advanced-content { padding: 0 22px 22px; border-top: 1px solid var(--border); }
.editor-toolbar { display: flex; justify-content: space-between; align-items: center; padding: 16px 0 9px; }
code, .code-editor { font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace; }
.code-editor { font-size: 12px; tab-size: 2; min-height: 260px; }
.advanced-actions { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-top: 10px; }
.validation-message { font-size: 12px; color: var(--muted); }
.validation-message.error { color: var(--danger); }
.text-button { color: var(--muted); border: 0; background: transparent; padding: 5px; font-size: 12px; }
.text-button:hover { color: var(--accent); }
.activity-log { list-style: none; padding: 0; margin: 0; display: grid; gap: 7px; max-height: 280px; overflow: auto; }
.activity-item { display: grid; grid-template-columns: 62px 76px 1fr; gap: 10px; align-items: baseline; font-size: 12px; padding: 9px 10px; background: #0c110f; border-radius: 8px; }
.activity-time { color: #62716b; font-variant-numeric: tabular-nums; }
.activity-method { color: var(--accent); font-family: monospace; }
.activity-message { color: #bac5c0; overflow-wrap: anywhere; }
.activity-item.error .activity-method, .activity-item.error .activity-message { color: var(--danger); }
.empty-log { color: var(--muted); font-size: 12px; text-align: center; padding: 22px; }
.toast { position: fixed; z-index: 10; left: 50%; bottom: max(24px, env(safe-area-inset-bottom)); transform: translate(-50%, 20px); max-width: calc(100vw - 32px); padding: 11px 16px; border-radius: 10px; background: #eaf3ef; color: #111815; font-size: 13px; font-weight: 650; box-shadow: 0 10px 40px #0008; opacity: 0; pointer-events: none; transition: .2s; }
.toast.visible { opacity: 1; transform: translate(-50%, 0); }
.toast.error { background: #ffdade; color: #501216; }
@keyframes pulse { 50% { opacity: .35; } }
@media (max-width: 700px) {
  .app-shell { padding: 0 14px 32px; }
  .topbar { min-height: 76px; }
  .brand p { display: none; }
  .connection-badge { padding: 7px 9px; }
  .dashboard-grid { grid-template-columns: 1fr; }
  .connection-row { align-items: stretch; flex-direction: column; }
  .panel { padding: 18px; }
  .activity-item { grid-template-columns: 58px 1fr; }
  .activity-message { grid-column: 1 / -1; }
}
@media (min-width: 701px) and (max-height: 800px) {
  .app-shell { padding-bottom: 28px; }
  .topbar { min-height: 72px; }
  main { gap: 12px; padding-top: 14px; }
  .panel { padding: 16px 18px; }
  .section-heading { margin-bottom: 12px; }
  .connection-row .field { gap: 5px; }
  .connection-panel .hint { margin-top: 6px; }
  .dashboard-grid { gap: 12px; }
  .quick-print-card .field { gap: 5px; margin-bottom: 10px; }
  .quick-print-card textarea { padding-block: 8px; }
  .quick-print-card .checkbox-row { margin-bottom: 10px; }
  .printer-hero { min-height: 92px; padding-bottom: 12px; }
  .facts { margin-bottom: 14px; }
}
@media (max-width: 400px) {
  .brand-mark { width: 38px; height: 38px; }
  h1 { font-size: 16px; }
  .connection-badge { font-size: 0; }
  .status-dot { width: 9px; height: 9px; }
  .card-actions { grid-template-columns: 1fr; }
}
