/* Wine Stock shared UI: graphite cellar surfaces, label-paper text, brass reserved for actions. */
:root {
  color-scheme: dark;
  --bg: #111419;
  --surface: #191d24;
  --surface-2: #212630;
  --surface-3: #2a303b;
  --sunken: #0d1015;
  --line: #2b313c;
  --line-2: #3c4452;
  --text: #f3efe6;
  --text-2: #b9bfca;
  --text-3: #8e96a4;
  --brass: #d4b98a;
  --brass-2: #e6d1a8;
  --brass-ink: #1d170e;
  --brass-soft: rgb(212 185 138 / .14);
  --ok: #3ddc97;
  --info: #5cb8ff;
  --warn: #ffb04a;
  --bad: #ff6b72;
  --radius-s: 7px;
  --radius: 10px;
  --radius-l: 14px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --serif: "PT Serif", Georgia, "Times New Roman", serif;
  --shadow: 0 18px 48px rgb(0 0 0 / .42);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scrollbar-color: var(--line-2) var(--bg); }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 var(--font);
  font-variant-numeric: tabular-nums;
}
img, svg, canvas { display: block; max-width: 100%; }
[hidden] { display: none !important; }

h1, h2 { font-family: var(--serif); font-weight: 700; letter-spacing: -.005em; margin: 0; color: var(--text); }
h1 { font-size: 26px; line-height: 1.2; }
h2 { font-size: 19px; line-height: 1.3; }
h3 { font-size: 15px; line-height: 1.35; font-weight: 650; margin: 0; }
p { margin: 0; }
a { color: var(--brass); text-underline-offset: 3px; }
a:hover { color: var(--brass-2); }
small, .muted { color: var(--text-2); }
.caption { font-size: 13px; color: var(--text-3); }
code, pre { font: 12.5px/1.5 ui-monospace, "SF Mono", Menlo, Consolas, monospace; }
pre { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }

/* Controls ---------------------------------------------------------------- */
button, .button {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 40px; padding: 8px 16px;
  border: 1px solid var(--line-2); border-radius: var(--radius-s);
  background: var(--surface-2); color: var(--text);
  font: 600 14px/1.25 var(--font); text-align: center; text-decoration: none;
  cursor: pointer; transition: background-color .12s, border-color .12s, color .12s;
}
button:hover, .button:hover { background: var(--surface-3); border-color: #4b5464; color: var(--text); }
button:disabled, .button[aria-disabled=true] { opacity: .45; cursor: default; pointer-events: none; }
button.primary, .button.primary { background: var(--brass); border-color: var(--brass); color: var(--brass-ink); }
button.primary:hover, .button.primary:hover { background: var(--brass-2); border-color: var(--brass-2); color: var(--brass-ink); }
button.ghost, .button.ghost { background: transparent; border-color: transparent; color: var(--text-2); }
button.ghost:hover, .button.ghost:hover { background: var(--surface-2); color: var(--text); }
button.danger, .button.danger { background: transparent; border-color: rgb(255 107 114 / .45); color: #ff9da2; }
button.danger:hover, .button.danger:hover { background: rgb(255 107 114 / .12); border-color: var(--bad); color: #ffc2c5; }
button.small, .button.small { min-height: 32px; padding: 5px 11px; font-size: 13px; }
.icon-button { width: 36px; min-height: 36px; padding: 0; background: transparent; border-color: transparent; color: var(--text-2); font-size: 18px; }
.icon-button:hover { background: var(--surface-2); border-color: var(--line-2); }

input, select, textarea {
  width: 100%; min-height: 40px; padding: 8px 12px;
  border: 1px solid var(--line-2); border-radius: var(--radius-s);
  background: var(--sunken); color: var(--text);
  font: 400 14.5px/1.4 var(--font);
}
textarea { resize: vertical; line-height: 1.5; }
select { appearance: none; padding-right: 36px; cursor: pointer;
  background-image: linear-gradient(45deg, transparent 50%, var(--text-2) 50%), linear-gradient(135deg, var(--text-2) 50%, transparent 50%);
  background-position: calc(100% - 18px) 52%, calc(100% - 13px) 52%; background-size: 5px 5px; background-repeat: no-repeat; }
input::placeholder, textarea::placeholder { color: #6f7785; }
input:focus, select:focus, textarea:focus { border-color: var(--brass); outline: none; box-shadow: 0 0 0 3px var(--brass-soft); }
input[type=checkbox], input[type=radio] { width: 17px; height: 17px; min-height: 0; padding: 0; margin: 0; accent-color: var(--brass); flex: none; cursor: pointer; }
input[type=file] { padding: 6px 8px; color: var(--text-2); }
input[type=file]::file-selector-button { margin-right: 12px; padding: 5px 12px; border: 1px solid var(--line-2); border-radius: 6px; background: var(--surface-2); color: var(--text); font: 600 13px/1.3 var(--font); cursor: pointer; }
input[type=number] { font-variant-numeric: tabular-nums; }
:focus-visible { outline: 2px solid var(--brass); outline-offset: 2px; }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: none; }

/* Label above control; hint below. */
.field { display: grid; gap: 6px; min-width: 0; margin: 0; font-size: 13px; font-weight: 600; color: var(--text-2); }
.field > small, .hint { font-size: 12.5px; font-weight: 400; color: var(--text-3); }
.check { display: inline-flex; align-items: center; gap: 9px; margin: 0; font-size: 14px; color: var(--text); cursor: pointer; }

/* Surfaces ---------------------------------------------------------------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-l); padding: 20px; min-width: 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.card-head h2 { display: flex; align-items: center; gap: 8px; }
.card-tools { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.stack { display: grid; gap: 12px; }

details > summary { cursor: pointer; list-style: none; }
details > summary::-webkit-details-marker { display: none; }
details.fold > summary { display: flex; align-items: center; gap: 10px; color: var(--text-2); font-weight: 600; font-size: 14px; padding: 4px 0; }
details.fold > summary::before { content: ""; width: 7px; height: 7px; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(-45deg); transition: transform .15s; margin: 0 2px; }
details.fold[open] > summary::before { transform: rotate(45deg); }
details.fold > summary:hover { color: var(--text); }
details.fold[open] > summary { margin-bottom: 12px; }

/* Status pills: colour always paired with text. */
.pill { display: inline-flex; align-items: center; gap: 7px; padding: 3px 10px 3px 9px; border-radius: 999px; background: var(--surface-2); color: var(--text-2); font-size: 12.5px; font-weight: 600; line-height: 1.4; white-space: nowrap; }
.pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; flex: none; }
.pill.ok { color: var(--ok); background: rgb(61 220 151 / .12); }
.pill.warn { color: var(--warn); background: rgb(255 176 74 / .13); }
.pill.bad { color: #ff8b91; background: rgb(255 107 114 / .13); }
.pill.info { color: var(--info); background: rgb(92 184 255 / .12); }
.pill.busy::before { animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .25; } }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font-size: 12.5px; font-weight: 600; color: var(--text-3); padding: 9px 12px; border-bottom: 1px solid var(--line-2); white-space: nowrap; }
td { padding: 11px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
tbody tr:last-child > * { border-bottom: 0; }
.table-scroll { overflow-x: auto; }

dialog {
  width: min(540px, calc(100vw - 24px)); max-height: calc(100vh - 32px); overflow: auto;
  padding: 24px; border: 1px solid var(--line-2); border-radius: 16px;
  background: var(--surface); color: var(--text); box-shadow: var(--shadow);
}
dialog::backdrop { background: rgb(6 8 11 / .74); }
dialog h2 { margin-bottom: 18px; padding-right: 40px; }
.dialog-close { position: absolute; top: 14px; right: 14px; width: 36px; min-height: 36px; padding: 0; border-color: transparent; background: transparent; color: var(--text-2); font-size: 24px; font-weight: 400; line-height: 1; }
.dialog-close:hover { background: var(--surface-2); }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; flex-wrap: wrap; margin-top: 22px; }

.message { min-height: 0; font-size: 14px; color: var(--text-2); }
.message:empty { display: none; }
.message.error { color: #ff9da2; }
.message.success { color: var(--ok); }

/* Contextual help ---------------------------------------------------------- */
.help-button { display: inline-flex; justify-content: center; align-items: center; flex: none; width: 22px; height: 22px; min-height: 22px; padding: 0; border: 1px solid #5a6373; border-radius: 50%; background: transparent; color: var(--text-2); font: 700 12px/1 var(--font); vertical-align: middle; }
.help-button:hover, .help-button[aria-expanded=true] { color: var(--text); border-color: var(--brass); background: var(--surface-3); }
#helpPopover { position: fixed; z-index: 1000; width: max-content; max-width: min(420px, calc(100vw - 24px)); max-height: 60vh; overflow: auto; white-space: pre-line; padding: 14px 16px; border: 1px solid var(--line-2); border-radius: var(--radius); background: #262c37; color: var(--text); box-shadow: var(--shadow); font-size: 14px; line-height: 1.55; }

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; } }

html[data-admin="false"] [data-admin-only]{display:none!important}
