:root {
  --bg: #f4efe7;
  --paper: #fffdf9;
  --ink: #1f1a15;
  --muted: #6f655b;
  --line: #ddd2c3;
  --malt: #2a1f16;
  --copper: #b4652a;
  --copper-d: #8d4c1c;
  --amber: #e2a23b;
  --ok: #2f7a45;
  --ok-bg: #e5f2e8;
  --warn: #9a6200;
  --warn-bg: #fdf1d8;
  --bad: #a02a22;
  --bad-bg: #fbe5e2;
  --info-bg: #eef0f4;
  --r: 10px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--ink); }
a { color: var(--copper-d); }
h1 { font-size: 1.6rem; margin: .2rem 0 1rem; letter-spacing: -.02em; }
h2 { font-size: 1.15rem; margin: 0 0 .8rem; }
h3 { font-size: 1rem; margin: 0 0 .5rem; }
.muted, small.muted { color: var(--muted); }

header.top { background: var(--malt); color: #fff; padding: 12px 16px; display: flex; flex-wrap: wrap; gap: 10px 24px; align-items: center; border-bottom: 3px solid var(--copper); }
.brand { color: #fff; text-decoration: none; font-weight: 700; font-size: 1.1rem; display: flex; align-items: center; gap: 8px; }
.brand .dot { width: 14px; height: 14px; border-radius: 50%; background: var(--amber); box-shadow: 0 0 0 3px rgba(226,162,59,.3); }
header nav { display: flex; flex-wrap: wrap; gap: 4px; }
header nav a { color: #e9dfd2; text-decoration: none; padding: 6px 10px; border-radius: 6px; font-size: .95rem; }
header nav a.on, header nav a:hover { background: rgba(255,255,255,.12); color: #fff; }
header nav a.muted { color: #a99a8a; }

main { max-width: 1200px; margin: 0 auto; padding: 20px 16px 60px; }
.card { background: var(--paper); border: 1px solid var(--line); border-radius: var(--r); padding: 18px; margin-bottom: 16px; }
.row { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }
.spread { justify-content: space-between; }
.grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.grid2 { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }

label { display: block; font-size: .85rem; color: var(--muted); margin-bottom: 4px; }
input, select, textarea { width: 100%; font: inherit; padding: 10px 11px; border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--ink); }
input[type=checkbox] { width: auto; }
textarea { min-height: 70px; }
.field { margin-bottom: 12px; }
.check { display: flex; gap: 8px; align-items: center; color: var(--ink); font-size: .95rem; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; font: inherit; font-weight: 600; border: 0; border-radius: 8px; padding: 10px 16px; cursor: pointer; text-decoration: none; background: var(--copper); color: #fff; min-height: 44px; }
.btn:hover { background: var(--copper-d); }
.btn.ghost { background: transparent; color: var(--copper-d); border: 1px solid var(--line); }
.btn.ok { background: var(--ok); }
.btn.big { font-size: 1.15rem; padding: 14px 22px; min-height: 56px; }
.btn.small { padding: 6px 10px; min-height: 34px; font-size: .9rem; }
.btn.danger { background: var(--bad); }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: .8rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
.table-wrap { overflow-x: auto; }

.flash { padding: 12px 14px; border-radius: 8px; margin-bottom: 14px; background: var(--ok-bg); color: var(--ok); font-weight: 600; }
.flash.warn { background: var(--warn-bg); color: var(--warn); }
.flash.bad { background: var(--bad-bg); color: var(--bad); }
.note { padding: 10px 12px; border-radius: 8px; background: var(--info-bg); font-size: .92rem; }
.note.warn { background: var(--warn-bg); color: #5c3b00; }

.pill { display: inline-block; font-size: .78rem; font-weight: 700; padding: 2px 8px; border-radius: 99px; background: var(--info-bg); color: var(--muted); }
.pill.ccv { background: #f3e4d4; color: var(--copper-d); }
.pill.bbt { background: #e3ecf5; color: #2c5578; }
.pill.ok { background: var(--ok-bg); color: var(--ok); }
.pill.warn { background: var(--warn-bg); color: var(--warn); }
.pill.bad { background: var(--bad-bg); color: var(--bad); }

/* Tankkort */
.tank { position: relative; overflow: hidden; }
.tank .name { font-size: 1.3rem; font-weight: 800; }
.tank .beer { font-size: 1.1rem; font-weight: 700; margin-top: 6px; }
.tank .meta { color: var(--muted); font-size: .9rem; }
.tank .stats { display: flex; flex-wrap: wrap; gap: 8px 16px; margin: 10px 0 6px; }
.tank .stats b { display: block; font-size: 1.25rem; }
.tank .stats span { font-size: .75rem; color: var(--muted); text-transform: uppercase; }
.gauge { height: 8px; background: #eee5d8; border-radius: 99px; overflow: hidden; }
.gauge i { display: block; height: 100%; background: linear-gradient(90deg, var(--amber), var(--copper)); }
.tank.empty .beer { color: var(--muted); font-weight: 600; }

/* Bryggdag */
.step { display: grid; grid-template-columns: 70px 1fr auto; gap: 12px; align-items: center; padding: 12px; border-radius: 10px; border: 1px solid var(--line); background: #fff; margin-bottom: 8px; }
.step .t { font-variant-numeric: tabular-nums; font-weight: 700; font-size: 1.1rem; }
.step .t small { display: block; font-weight: 400; color: var(--muted); font-size: .75rem; }
.step.done { opacity: .62; background: #faf7f2; }
.step.running { border: 2px solid var(--copper); background: #fff8f0; }
.step.running .t { color: var(--copper-d); }
.step .sub { font-size: .85rem; color: var(--muted); }
.step.late { border-color: var(--bad); }
.clock { font-variant-numeric: tabular-nums; font-size: 2.2rem; font-weight: 800; letter-spacing: -.02em; }
.hops li { margin-bottom: 6px; }
.hops li.done { text-decoration: line-through; color: var(--muted); }

/* Publik tavla – för TV/skärm i bryggeriet */
body.board { background: #17110c; color: #f6efe6; }
body.board main { max-width: none; padding: 24px; }
body.board h1 { color: #fff; font-size: 2rem; }
body.board .card { background: #231a13; border-color: #3a2d22; color: #f6efe6; }
body.board .tank .meta, body.board .tank .stats span, body.board .muted { color: #b6a593; }
body.board .gauge { background: #3a2d22; }
body.board .tank .name { color: var(--amber); }
body.board .grid { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }

/* Publik batchsida */
body.public { background: var(--bg); }
.hero { background: var(--malt); color: #fff; padding: 28px 16px; text-align: center; }
.hero h1 { color: #fff; font-size: 2rem; margin: 0; }
.hero .sub { color: #d9c9b6; }
.kv { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; }
.kv div { background: var(--paper); border: 1px solid var(--line); border-radius: 8px; padding: 10px; text-align: center; }
.kv b { display: block; font-size: 1.3rem; }
.kv span { font-size: .75rem; color: var(--muted); text-transform: uppercase; }

@media (max-width: 600px) {
  .step { grid-template-columns: 56px 1fr; }
  .step form { grid-column: 1 / -1; }
  .step form .btn { width: 100%; }
  h1 { font-size: 1.35rem; }
}
@media print { header.top, .noprint { display: none; } body { background: #fff; } .card { border: 0; } }

/* Värden på tanken */
.vt-buttons { gap: 8px; }
.vt-buttons .btn small { font-weight: 400; opacity: .85; }
.value-form { margin-top: 14px; padding: 14px; background: #fff8f0; border-radius: 10px; border: 1px solid var(--line); }
.big-input { font-size: 1.4rem; font-weight: 700; padding: 12px; }
tr.clickrow { cursor: pointer; }
tr.clickrow:hover td { background: #fbf6ef; }
.step .t a { color: inherit; text-decoration: none; border-bottom: 1px dashed var(--line); }
.timefix summary { cursor: pointer; font-size: .8rem; color: var(--muted); list-style: none; }
.timefix summary::-webkit-details-marker { display: none; }
.timefix input { margin-top: 6px; max-width: 220px; }

/* Utskrivbart protokoll */
body.protocol { background: #e9e4dc; }
.protocol-bar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; padding: 12px 16px; background: var(--malt); color: #fff; position: sticky; top: 0; z-index: 2; }
.protocol-bar .muted { color: #cbbfb1; font-size: .85rem; }
article.protocol { background: #fff; max-width: 210mm; margin: 18px auto; padding: 14mm 14mm 18mm; font-size: 10.5pt; line-height: 1.35; color: #000; box-shadow: 0 2px 12px rgba(0,0,0,.12); }
article.protocol h1 { font-size: 20pt; margin: 2px 0; }
article.protocol h2 { font-size: 11.5pt; margin: 14px 0 4px; padding-bottom: 2px; border-bottom: 1.5px solid #000; text-transform: uppercase; letter-spacing: .04em; }
article.protocol table { font-size: 9.5pt; }
article.protocol th, article.protocol td { padding: 3px 5px; border-bottom: .5px solid #bbb; }
article.protocol th { color: #444; font-size: 8pt; }
.p-head { display: flex; justify-content: space-between; gap: 16px; border-bottom: 3px solid #000; padding-bottom: 8px; margin-bottom: 10px; }
.p-brewery { font-size: 9pt; text-transform: uppercase; letter-spacing: .08em; color: #444; }
.p-meta { text-align: right; font-size: 9.5pt; }
.p-kv { width: auto; min-width: 70%; }
.p-notes { white-space: normal; border: .5px solid #bbb; padding: 6px 8px; }
.p-sign { display: flex; gap: 30px; margin-top: 26px; }
.p-sign div { flex: 1; font-size: 9pt; color: #444; }
.p-sign span { display: block; border-bottom: 1px solid #000; height: 26px; }
@media print {
  @page { size: A4; margin: 12mm; }
  body.protocol { background: #fff; }
  .protocol-bar { display: none; }
  article.protocol { box-shadow: none; margin: 0; padding: 0; max-width: none; }
  .page-break { page-break-before: always; break-before: page; }
  article.protocol tr { break-inside: avoid; }
  article.protocol h2 { break-after: avoid; page-break-after: avoid; }
}
@media (max-width: 600px) { article.protocol { padding: 16px; margin: 0; } .p-head { flex-direction: column; } .p-meta { text-align: left; } }

/* Supportläge (admin inne i ett bryggeri) */
.support-bar { background: #2c5578; color: #fff; padding: 8px 16px; font-size: .9rem; font-weight: 600; }
.support-bar a { color: #cfe3f5; margin-left: 10px; }
