/* Admin builds on card.css tokens. */
body.admin { font-size: 14.5px; }
[hidden] { display: none !important; }

/* ---------- controls ---------- */
.btn {
  font: inherit; font-weight: 500; display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px;
  border-radius: 8px; border: 1px solid var(--line); background: var(--paper); color: var(--ink); cursor: pointer;
  text-decoration: none; white-space: nowrap; line-height: 1.2;
}
.btn:hover { border-color: var(--ink-3); }
.btn.primary { background: var(--ink); color: #fff; border-color: var(--ink); }
.btn.primary:hover { background: #333; }
.btn.danger { color: #b3261e; border-color: #f0c8c4; }
.btn.danger:hover { background: #fdf0ef; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--ink-2); }
.btn.ghost:hover { color: var(--ink); background: rgb(0 0 0 / 0.04); }
.btn.sm { padding: 4px 9px; font-size: 13px; }
.btn:disabled { opacity: 0.4; cursor: default; }

input, select, textarea {
  font: inherit; color: var(--ink); background: var(--paper); border: 1px solid var(--line);
  border-radius: 7px; padding: 7px 10px; width: 100%; min-width: 0;
}
textarea { resize: vertical; line-height: 1.4; }
input:focus, select:focus, textarea:focus { outline: 2px solid color-mix(in srgb, var(--accent) 30%, transparent); border-color: var(--accent); }
input[type='checkbox'] { width: auto; accent-color: var(--ink); }
input[type='color'] { padding: 2px; height: 36px; width: 56px; }
label { font-size: 12.5px; font-weight: 500; color: var(--ink-2); display: block; margin-bottom: 4px; }
.field { margin-bottom: 14px; }
.row { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; }
.row > .field { flex: 1 1 180px; }
.check { display: inline-flex; gap: 8px; align-items: center; font-size: 14px; color: var(--ink); cursor: pointer; margin: 0; }
.hint { font-size: 12px; color: var(--ink-3); margin-top: 4px; }
.muted { color: var(--ink-3); }

/* ---------- login ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-box { width: min(360px, 100%); background: var(--paper); border: 1px solid var(--line); border-radius: 14px; padding: 32px 28px; display: grid; gap: 10px; }
.login-box .brand { font-size: 28px; margin-bottom: 12px; }
.error { color: #b3261e; font-size: 13px; min-height: 1em; }
.muted-link { color: var(--ink-3); font-size: 13px; text-align: center; text-decoration: none; margin-top: 6px; }

/* ---------- layout ---------- */
.topbar { position: sticky; top: 0; z-index: 20; background: color-mix(in srgb, var(--bg) 94%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.topbar-inner { display: flex; align-items: center; gap: 20px; height: 60px; }
.brand.small { font-size: 21px; text-decoration: none; color: var(--ink); }
.tabs { display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none; flex: 1; }
.tabs a { padding: 7px 12px; border-radius: 8px; text-decoration: none; color: var(--ink-2); font-weight: 500; white-space: nowrap; }
.tabs a:hover { background: rgb(0 0 0 / 0.04); color: var(--ink); }
.tabs a.active { background: var(--ink); color: #fff; }
.topbar-actions { display: flex; gap: 4px; }

#view { padding: 28px 0 80px; }
.view-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 20px; flex-wrap: wrap; }
.view-head h1 { font-family: var(--serif); font-size: 28px; }
.view-head .actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.panel { background: var(--paper); border: 1px solid var(--line); border-radius: 12px; padding: 20px; margin-bottom: 20px; }
.panel h2 { font-family: var(--serif); font-size: 19px; margin-bottom: 14px; }

@media (max-width: 820px) {
  .topbar-inner { flex-wrap: wrap; height: auto; padding: 10px 0; gap: 8px; }
  .tabs { order: 3; flex-basis: 100%; }
  .topbar-actions { margin-left: auto; }
}

/* ---------- cocktail list ---------- */
.list-group { margin-bottom: 28px; }
.list-group h2 { font-family: var(--serif); font-size: 20px; color: var(--c); border-bottom: 2px solid var(--c); padding-bottom: 6px; margin-bottom: 8px; display: flex; gap: 8px; align-items: baseline; }
.list-group h2 small { font-family: var(--sans); font-size: 13px; color: var(--ink-3); font-weight: 400; }
.item-row {
  display: grid; grid-template-columns: 44px 1fr auto; gap: 12px; align-items: center;
  padding: 8px 10px; border-radius: 10px; background: var(--paper); border: 1px solid var(--line); margin-bottom: 6px;
}
.item-row.hidden-item { opacity: 0.55; }
.item-row .thumb { width: 44px; height: 44px; border-radius: 8px; background: color-mix(in srgb, var(--c) 7%, #fff); display: grid; place-items: center; }
.item-row .thumb img { height: 38px; }
.item-row .title { font-weight: 600; text-decoration: none; color: var(--ink); }
.item-row .title:hover { text-decoration: underline; }
.item-row .meta { font-size: 12.5px; color: var(--ink-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item-row .ops { display: flex; gap: 4px; align-items: center; }
.badge { font-size: 11px; font-weight: 600; padding: 2px 7px; border-radius: 999px; background: #eee; color: var(--ink-2); }
.badge.warn { background: #fff3d6; color: #8a5a00; }

/* ---------- editor ---------- */
.editor { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 24px; align-items: start; }
.editor .preview { position: sticky; top: 84px; }
.editor .preview .card:hover { transform: none; box-shadow: none; }
@media (max-width: 960px) { .editor { grid-template-columns: 1fr; } .editor .preview { position: static; } }

.lines { display: grid; gap: 6px; }
.line { display: grid; grid-template-columns: 22px minmax(0, 1.4fr) minmax(0, 0.8fr) minmax(0, 1.2fr) auto; gap: 6px; align-items: center; }
.line .grip { color: var(--ink-3); cursor: grab; text-align: center; user-select: none; }
.line .parsed { grid-column: 2 / -1; font-size: 11.5px; color: var(--ink-3); margin: -2px 0 4px; }
.line .parsed.warn { color: #8a5a00; }
.line.dragging { opacity: 0.4; }
.line-head { display: grid; grid-template-columns: 22px minmax(0, 1.4fr) minmax(0, 0.8fr) minmax(0, 1.2fr) 34px; gap: 6px; font-size: 12px; color: var(--ink-3); }
@media (max-width: 640px) {
  .line, .line-head { grid-template-columns: 22px 1fr 1fr auto; }
  .line .link { grid-column: 2 / 4; }
  .line-head span:nth-child(4) { display: none; }
}

.svg-tools { display: grid; grid-template-columns: 110px 1fr; gap: 16px; }
.svg-preview { width: 110px; height: 130px; border: 1px dashed var(--line); border-radius: 10px; display: grid; place-items: center; background: #fafafa; }
.svg-preview img { max-height: 110px; max-width: 100px; }
.gen { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 8px; align-items: end; }
.ai-box { padding: 12px; border-radius: 10px; background: linear-gradient(135deg, #fdf6ee, #f4f0fb); border: 1px solid var(--line); }
.ai-box code { font-size: 12px; }
details summary { cursor: pointer; font-weight: 500; margin: 6px 0; }

.sticky-actions { position: sticky; bottom: 0; background: color-mix(in srgb, var(--bg) 94%, transparent); backdrop-filter: blur(6px); padding: 12px 0; display: flex; gap: 8px; border-top: 1px solid var(--line); margin-top: 12px; }
.sticky-actions .spacer { flex: 1; }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; background: var(--paper); border: 1px solid var(--line); border-radius: 12px; }
table { border-collapse: collapse; width: 100%; font-size: 13.5px; }
th { text-align: left; font-weight: 600; font-size: 12px; color: var(--ink-3); padding: 10px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; background: #fcfbf9; }
td { padding: 5px 8px; border-bottom: 1px solid #f3f0ea; vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
td input, td select { padding: 5px 7px; }
td.num input { width: 80px; }
td.center { text-align: center; }
tr.dirty td { background: #fffbea; }

/* ---------- shopping ---------- */
.shop-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr); gap: 24px; align-items: start; }
@media (max-width: 960px) { .shop-layout { grid-template-columns: 1fr; } }
.pick-group { margin-bottom: 16px; }
.pick-group h3 { font-size: 13px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--c); margin-bottom: 6px; }
.pick { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 5px 8px; border-radius: 8px; }
.pick:hover { background: #faf8f4; }
.pick.on { background: color-mix(in srgb, var(--c) 8%, #fff); }
.pick .name { flex: 1; cursor: pointer; }
.stepper { display: inline-flex; align-items: center; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: var(--paper); }
.stepper button { border: 0; background: none; width: 28px; height: 28px; cursor: pointer; font-size: 16px; color: var(--ink-2); }
.stepper button:hover { background: #f3f0ea; }
.stepper input { border: 0; width: 42px; text-align: center; padding: 0; border-radius: 0; -moz-appearance: textfield; }
.stepper input::-webkit-inner-spin-button { -webkit-appearance: none; }

.result { position: sticky; top: 84px; max-height: calc(100vh - 100px); overflow: auto; }
.result h3 { font-family: var(--serif); font-size: 17px; margin: 16px 0 6px; padding-bottom: 4px; border-bottom: 1px solid var(--line); }
.result h3:first-of-type { margin-top: 0; }
.shop-line { display: grid; grid-template-columns: auto 1fr auto; gap: 4px 10px; padding: 6px 2px; border-bottom: 1px dotted var(--line); align-items: baseline; }
.shop-line.done .what { text-decoration: line-through; color: var(--ink-3); }
.shop-line .what { font-weight: 500; }
.shop-line .qty { text-align: right; font-weight: 600; white-space: nowrap; }
.shop-line .qty small { font-weight: 400; color: var(--ink-3); font-size: 12px; }
.shop-line .uses { grid-column: 2 / -1; font-size: 12px; color: var(--ink-3); }
.freeze { color: #1e7ab8; font-size: 12px; font-weight: 600; }
.summary { display: flex; gap: 16px; flex-wrap: wrap; font-size: 13px; color: var(--ink-2); margin-bottom: 12px; }
.summary strong { color: var(--ink); }

@media print {
  body.admin.printing-shop .topbar, body.admin.printing-shop .view-head, body.admin.printing-shop .picker, body.admin.printing-shop .no-print { display: none !important; }
  body.admin.printing-shop .shop-layout { display: block; }
  body.admin.printing-shop .result { position: static; max-height: none; overflow: visible; border: 0; padding: 0; }
  body.admin.printing-shop .shop-line { break-inside: avoid; }
}

/* ---------- toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 100;
  background: var(--ink); color: #fff; padding: 10px 18px; border-radius: 10px; font-size: 14px;
  box-shadow: 0 8px 30px rgb(0 0 0 / 0.2); max-width: calc(100% - 32px);
}
.toast.error { background: #b3261e; }
.ai-banner { padding: 12px 16px; border-radius: 10px; margin-bottom: 18px; background: linear-gradient(135deg, #fdf6ee, #f4f0fb); border: 1px solid #e6dcf5; }
.ai-banner a { margin-left: 8px; color: var(--ink-2); }
.ai-new textarea { font-size: 15px; }
.drag-handle {
  display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 8px; flex: none;
  color: var(--ink-3); cursor: grab; touch-action: none; margin-left: 2px;
}
.drag-handle svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }
.drag-handle:hover, .drag-handle:focus-visible { color: var(--ink); background: rgb(0 0 0 / 0.05); outline: none; }
.item-row:has(.drag-handle) { cursor: grab; user-select: none; }
.dragging { position: relative; z-index: 5; box-shadow: 0 10px 28px rgb(0 0 0 / 0.14); transform: scale(1.01); opacity: 0.95; }
body.is-dragging, body.is-dragging * { cursor: grabbing !important; user-select: none !important; }
