:root {
  --bg: #f1f3f6;
  --card: #ffffff;
  --ink: #111827;
  --muted: #6b7280;
  --line: #e5e7eb;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --accent-ink: #ffffff;
  --ok: #059669;
  --ok-bg: #d1fae5;
  --warn: #b45309;
  --warn-bg: #fef3c7;
  --bad: #dc2626;
  --bad-bg: #fee2e2;
  --info: #1d4ed8;
  --info-bg: #eff6ff;
  --nav: #0f172a;
  --nav-ink: #f1f5f9;
  --nav-muted: #94a3b8;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow-sm: 0 1px 2px rgba(0,0,0,.06), 0 1px 3px rgba(0,0,0,.08);
  --shadow: 0 2px 8px rgba(0,0,0,.08), 0 1px 3px rgba(0,0,0,.06);
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 14.5px;
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); line-height: 1.5; }

h1 { font-size: 22px; font-weight: 700; letter-spacing: -0.02em; margin: 0 0 2px; }
h2 { font-size: 15px; font-weight: 600; letter-spacing: -0.01em; margin: 0 0 16px; color: var(--ink); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.strong { font-weight: 600; }
.ok-text { color: var(--ok); font-weight: 600; }
.warn-text { color: var(--warn); font-weight: 600; }
.hidden { display: none; }

/* ─── Navigation ─────────────────────────────────────────── */
.top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 28px;
  height: 54px;
  background: var(--nav);
  position: sticky;
  top: 0;
  z-index: 30;
}
.brand {
  font-weight: 700;
  font-size: 14px;
  letter-spacing: 0.01em;
  color: var(--nav-ink);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 10px;
}
.brand::before {
  content: "";
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #34d399;
}
.brand:hover { text-decoration: none; color: #fff; }
.top .link {
  color: var(--nav-muted);
  font-size: 13px;
  font-weight: 500;
}
.top .link:hover { color: var(--nav-ink); }

/* ─── Layout ─────────────────────────────────────────────── */
main { max-width: 1060px; margin: 0 auto; padding: 32px 24px 80px; }
main.center { display: flex; min-height: 80vh; align-items: center; justify-content: center; }

/* ─── Cards ──────────────────────────────────────────────── */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 24px;
  margin: 16px 0;
  box-shadow: var(--shadow-sm);
}
.card.empty { text-align: center; padding: 52px 32px; }
.card.empty p { color: var(--muted); margin: 0 0 18px; }

/* ─── Login ──────────────────────────────────────────────── */
.login {
  width: 100%;
  max-width: 400px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  box-shadow: var(--shadow);
}
.login h1 { font-size: 20px; margin-bottom: 2px; }
.login .muted { font-size: 13px; margin: 0; }

/* ─── Toolbar & layout helpers ───────────────────────────── */
.toolbar { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin: 4px 0 16px; flex-wrap: wrap; }
.row-tools { display: flex; gap: 10px; margin-top: 20px; flex-wrap: wrap; }
.stack { display: flex; flex-direction: column; }
.small-gap { gap: 8px; }
.inline { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 680px) { .grid { grid-template-columns: 1fr; } }

/* ─── Forms ──────────────────────────────────────────────── */
.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 16px; min-width: 0; }
.label { font-weight: 600; font-size: 12.5px; color: #374151; }
.hint { color: var(--muted); font-size: 12px; line-height: 1.4; }

input[type="text"],
input[type="password"],
input:not([type]),
textarea,
select {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  font: inherit;
  font-size: 14px;
  background: #fff;
  color: var(--ink);
  transition: border-color .15s, box-shadow .15s;
}
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37,99,235,.12);
}
input[type="file"] { font: inherit; }
.check { display: flex; align-items: center; gap: 8px; margin: 4px 0 16px; }

.color-row { display: flex; align-items: center; gap: 8px; }
.color-pick { width: 42px; height: 38px; padding: 2px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: #fff; flex: none; cursor: pointer; }
.color-text { max-width: 120px; font-family: ui-monospace, Consolas, monospace; font-size: 13px; }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 8px; }

/* ─── Buttons ────────────────────────────────────────────── */
button, .btn {
  font: inherit;
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  border-radius: var(--radius-sm);
  padding: 7px 14px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink);
  text-decoration: none;
  display: inline-block;
  transition: background .12s, border-color .12s, box-shadow .12s;
  white-space: nowrap;
}
button:hover, .btn:hover { background: #f3f4f6; border-color: #d1d5db; text-decoration: none; }

button.primary, .btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
  font-weight: 600;
  box-shadow: 0 1px 3px rgba(37,99,235,.25);
}
button.primary:hover, .btn.primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  box-shadow: 0 2px 6px rgba(37,99,235,.3);
}
button.link {
  border: 0;
  background: none;
  color: var(--accent);
  padding: 4px 6px;
  font-size: 13px;
}
button.link:hover { background: none; text-decoration: underline; }
button:disabled, .btn:disabled { opacity: 0.5; cursor: progress; }

/* ─── Notices ────────────────────────────────────────────── */
.error { color: var(--bad); min-height: 1.2em; margin: 0; font-size: 13px; }

.notice {
  border-radius: 10px;
  padding: 12px 16px;
  margin: 14px 0;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 13.5px;
  line-height: 1.5;
}
.notice.warn { background: var(--warn-bg); border: 1px solid #fcd34d; color: #78350f; }
.notice.info { background: var(--info-bg); border: 1px solid #bfdbfe; color: #1e40af; }

/* ─── Table ──────────────────────────────────────────────── */
.table-wrap {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
table { width: 100%; border-collapse: collapse; min-width: 540px; }

th {
  text-align: left;
  padding: 10px 16px;
  font-size: 11.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  background: #f8f9fb;
  border-bottom: 1px solid var(--line);
}
td {
  padding: 14px 16px;
  border-bottom: 1px solid #f3f4f6;
  vertical-align: middle;
}
tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: #fafbfc; }

td.actions { white-space: nowrap; text-align: right; }
td.actions .btn { margin-left: 6px; padding: 5px 11px; font-size: 13px; }

/* ─── Main store row ─────────────────────────────────────── */
.main-store-row td { background: #fffbf0; }
.main-store-row:hover td { background: #fef9e7; }
.main-store-row td:first-child {
  border-left: 3px solid #f59e0b;
  padding-left: 13px;
}
.main-store-row .strong { color: #92400e; }

/* ─── Badges ─────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.01em;
}
.badge::before {
  content: "";
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex: none;
}
.badge.ok  { background: var(--ok-bg);   color: #065f46; }
.badge.ok::before  { background: var(--ok); }
.badge.warn{ background: var(--warn-bg); color: #78350f; }
.badge.warn::before{ background: var(--warn); }
.badge.off { background: #f3f4f6;        color: var(--muted); }
.badge.off::before { background: #9ca3af; }
.badge.info{ background: var(--info-bg); color: #1e40af; }
.badge.info::before{ background: var(--info); }

.status-box { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }

/* ─── Setup steps ────────────────────────────────────────── */
.steps { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.steps li { display: flex; gap: 12px; align-items: flex-start; }
.tick { width: 22px; height: 22px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-size: 12px; flex: none; margin-top: 1px; font-weight: 700; }
.done .tick { background: var(--ok-bg); color: var(--ok); }
.todo .tick { background: var(--warn-bg); color: var(--warn); }

/* ─── Brand preview ──────────────────────────────────────── */
.preview-wrap { margin-bottom: 16px; }
.preview {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border: 1px dashed var(--line);
  border-radius: 10px;
  padding: 16px 20px;
  background: #faf8f4;
  margin-top: 6px;
}
.pv-mark img { max-height: 48px; max-width: 170px; display: block; }
.pv-name { font-family: Georgia, "Times New Roman", serif; letter-spacing: 0.18em; font-size: 22px; color: #2a2118; }
.pv-tag  { font-family: Georgia, "Times New Roman", serif; letter-spacing: 0.3em; font-size: 10px; color: #7c6f61; margin-top: 3px; text-align: center; }
.pv-button { color: #fff; border-radius: 8px; padding: 7px 16px; font-weight: 600; font-size: 13px; }

/* ─── Tool rows / pre ────────────────────────────────────── */
.tool { display: flex; align-items: center; gap: 12px; margin: 10px 0; flex-wrap: wrap; }
.pre {
  background: #0f172a;
  color: #cbd5e1;
  border-radius: 10px;
  padding: 14px 16px;
  font: 12.5px/1.6 ui-monospace, "Cascadia Code", Consolas, monospace;
  max-height: 340px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
  margin: 14px 0 0;
}

/* ─── Dialog ─────────────────────────────────────────────── */
dialog {
  border: 0;
  border-radius: var(--radius);
  padding: 28px;
  width: min(640px, 95vw);
  box-shadow: 0 24px 64px rgba(15, 23, 42, 0.35), 0 4px 16px rgba(15, 23, 42, 0.15);
}
dialog::backdrop { background: rgba(15, 23, 42, 0.5); backdrop-filter: blur(2px); }
.dialog-actions { display: flex; justify-content: flex-end; margin-top: 16px; gap: 8px; }

/* ─── Toast ──────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: #1e293b;
  color: #f1f5f9;
  padding: 11px 20px;
  border-radius: 10px;
  z-index: 50;
  max-width: 90vw;
  font-size: 13.5px;
  font-weight: 500;
  box-shadow: 0 8px 32px rgba(0,0,0,.3);
  animation: slideUp .2s ease;
}
.toast.bad { background: var(--bad); }
@keyframes slideUp { from { opacity: 0; transform: translateX(-50%) translateY(8px); } to { opacity: 1; transform: translateX(-50%) translateY(0); } }

/* ─── Mobile ─────────────────────────────────────────────── */
@media (max-width: 600px) {
  .top { padding: 0 16px; }
  main { padding: 20px 14px 60px; }
  h1 { font-size: 18px; }
  .toolbar { flex-direction: column; align-items: stretch; }
  .toolbar .btn { width: 100%; text-align: center; }
  .row-tools { flex-direction: column; }
  .row-tools .btn { width: 100%; text-align: center; }
  .grid { grid-template-columns: 1fr; }
  dialog { padding: 20px 16px; }
  th, td { padding: 10px 12px; }
}
