:root {
  --bg: #f3f2ef; --card: #ffffff; --ink: #1c1d21; --muted: #6b6e76; --line: #e2e0db;
  --accent: #e85d1a; --accent-ink: #fff; --accent-soft: #fdeee6; --danger: #c62828;
  --stage: #d9d6cf; --radius: 10px;
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root { --bg:#141518; --card:#1d1f23; --ink:#ececec; --muted:#9a9ca3; --line:#2e3036;
          --accent-soft:#3a2418; --stage:#2a2c31; }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font-size: 14px; }
.hidden { display: none !important; }
.muted { color: var(--muted); } .small { font-size: 12px; } .center { text-align: center; }
.error { color: var(--danger); min-height: 1em; }
.pad { padding: 16px; }
code { background: var(--accent-soft); padding: 1px 5px; border-radius: 4px; }

input, select, textarea, button { font: inherit; color: inherit; }
input, select, textarea {
  width: 100%; padding: 7px 9px; border: 1px solid var(--line); border-radius: 7px;
  background: var(--bg);
}
textarea { resize: vertical; font-family: ui-monospace, "SF Mono", Consolas, monospace; font-size: 13px; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
label { display: flex; flex-direction: column; gap: 4px; font-weight: 500; font-size: 13px; }
label.check { flex-direction: row; align-items: center; gap: 8px; font-weight: 400; }
label.check input { width: auto; }
button {
  border: 1px solid var(--line); background: var(--card); border-radius: 7px;
  padding: 7px 12px; cursor: pointer; white-space: nowrap;
}
button:hover { border-color: var(--muted); }
button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
button.primary:hover { filter: brightness(1.07); }
button.ghost { background: transparent; }
button.danger { color: var(--danger); }
button.big { padding: 10px 26px; font-size: 15px; }
button:disabled { opacity: .5; cursor: default; }

.brand { font-weight: 700; font-size: 16px; display: flex; align-items: center; gap: 8px; }
.brand small { font-weight: 400; color: var(--muted); }
.logo { color: var(--accent); font-size: 20px; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); }

.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { width: min(380px, 100%); padding: 28px; display: flex; flex-direction: column; gap: 14px; }

.topbar {
  display: flex; align-items: center; gap: 12px; padding: 10px 16px;
  background: var(--card); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5;
}
.topbar select { width: auto; max-width: 240px; }
.spacer { flex: 1; }

.layout { display: grid; grid-template-columns: minmax(320px, 1fr) minmax(360px, 1.15fr); gap: 16px; padding: 16px; }
@media (max-width: 900px) { .layout { grid-template-columns: 1fr; } }
.pane { padding: 16px; display: flex; flex-direction: column; gap: 14px; min-width: 0; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin: -4px 0 0; }
.tab { border: none; border-bottom: 2px solid transparent; border-radius: 0; background: none; padding: 8px 10px; color: var(--muted); }
.tab.active { color: var(--ink); border-bottom-color: var(--accent); font-weight: 600; }
.tabpane { display: flex; flex-direction: column; gap: 10px; }

.filters { display: flex; gap: 8px; }
.filters select { max-width: 45%; }
.listhead { display: flex; justify-content: space-between; align-items: center; }
.assetlist { border: 1px solid var(--line); border-radius: 8px; overflow: auto; max-height: calc(100vh - 290px); min-height: 200px; }
.grouphead {
  position: sticky; top: 0; background: var(--bg); padding: 6px 10px; font-weight: 600; font-size: 12px;
  display: flex; align-items: center; gap: 8px; border-bottom: 1px solid var(--line); cursor: pointer;
}
.grouphead input, .asset input, .listhead input { width: auto; margin: 0; }
.asset { display: grid; grid-template-columns: 22px 92px 1fr; gap: 8px; align-items: center; padding: 6px 10px; border-bottom: 1px solid var(--line); cursor: pointer; }
.asset:hover { background: var(--accent-soft); }
.asset.sel { background: var(--accent-soft); }
.asset .tag { font-family: ui-monospace, Consolas, monospace; font-weight: 600; }
.asset .desc { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.asset .desc small { color: var(--muted); }

.row { display: flex; gap: 10px; align-items: flex-end; }
.row.end { align-items: center; }
.grow { flex: 1; } .narrow { width: 90px; }

.editor { border: 1px solid var(--line); border-radius: 8px; padding: 14px; background: var(--bg); display: flex; flex-direction: column; gap: 12px; }
.editor input, .editor select, .editor textarea { background: var(--card); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 12px; }
.span2 { grid-column: span 2; }
.checks { display: flex; gap: 16px; align-items: center; grid-column: span 2; }

.preview { display: flex; flex-direction: column; gap: 8px; }
.preview-stage {
  background: var(--stage); border-radius: 8px; min-height: 220px; display: grid; place-items: center; padding: 24px;
  background-image: radial-gradient(rgba(0,0,0,.07) 1px, transparent 1px); background-size: 14px 14px;
}
.preview-stage img { max-width: 100%; max-height: 300px; background: #fff; box-shadow: 0 2px 10px rgba(0,0,0,.25); border-radius: 3px; image-rendering: pixelated; }
.warnings { margin: 0; padding-left: 18px; color: #b26a00; font-size: 12px; }

.printbar { display: flex; align-items: center; gap: 10px; border-top: 1px solid var(--line); padding-top: 14px; }

dialog { border: none; border-radius: var(--radius); padding: 0; width: min(640px, 96vw); background: var(--card); color: var(--ink); }
dialog::backdrop { background: rgba(0,0,0,.45); }
.dialog-body { padding: 20px; display: flex; flex-direction: column; gap: 14px; }
.dialog-body h2 { margin: 0; font-size: 18px; }
.printerlist { display: flex; flex-wrap: wrap; gap: 6px; }
.printerlist button.active { border-color: var(--accent); background: var(--accent-soft); }

.toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--ink); color: var(--card);
  padding: 10px 18px; border-radius: 8px; z-index: 50; max-width: 90vw; box-shadow: 0 4px 16px rgba(0,0,0,.3);
}
.toast.err { background: var(--danger); color: #fff; }
