/*
CCS - Theme: "instrument panel on poured concrete".

@web @ccs
Bright chromatically-quiet lab surface so measured colors read true; dark
slab sidebar; oxide-red accent; drafting borders (2px ink, hard shadows);
IBM Plex Mono for every number and code; concrete grain overlay; print
styles for QL-62mm and Letter 30-up label sheets.
Keywords: theme, layout, components, swatches, print labels
*/

:root {
  --paper: #edeae4;          /* poured-concrete paper */
  --paper-2: #e4e0d8;
  --card: #f6f4ef;
  --ink: #1e1c18;
  --ink-soft: #6b665c;
  --line: #cfc9bd;
  --slab: #262521;           /* wet cement */
  --slab-2: #32302b;
  --slab-ink: #d8d3c8;
  --oxide: #b5432a;          /* iron-oxide red accent */
  --oxide-deep: #93341f;
  --ochre: #b08a2e;
  --moss: #5d7040;
  --sky: #4a6d8c;
  --good: #4c6b3c;
  --warn: #a4541d;
  --bad: #a02c1d;
  --mono: "IBM Plex Mono", ui-monospace, "Cascadia Mono", Menlo, monospace;
  --sans: "Archivo", "Helvetica Neue", Arial, sans-serif;
  --shadow: 3px 3px 0 rgba(30, 28, 24, .16);
  --shadow-lift: 5px 5px 0 rgba(30, 28, 24, .2);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }

body {
  font-family: var(--sans);
  font-size: 14.5px;
  color: var(--ink);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
}
/* concrete grain */
body::before {
  content: ""; position: fixed; inset: 0; z-index: 0; pointer-events: none; opacity: .05;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)'/%3E%3C/svg%3E");
}
.hidden { display: none !important; }

/* ============ login ============ */
.login-screen { position: fixed; inset: 0; display: flex; z-index: 50; }
.login-left {
  flex: 1.2; background: var(--paper); position: relative; overflow: hidden;
  display: flex; flex-direction: column; justify-content: center; padding: 6vw;
}
.login-mark {
  font-family: var(--mono); font-weight: 600; letter-spacing: .35em;
  border: 2px solid var(--ink); display: inline-block; width: fit-content;
  padding: .35em .6em .35em .95em; margin-bottom: 2rem; background: var(--card);
  box-shadow: var(--shadow);
}
.login-left h1 {
  font-size: clamp(3rem, 7vw, 6rem); line-height: .95; margin: 0;
  font-weight: 800; font-stretch: 115%; letter-spacing: -.01em; text-transform: uppercase;
}
.login-tag { font-family: var(--mono); color: var(--ink-soft); margin-top: 1.6rem; font-size: .85rem; }
.login-strip { position: absolute; left: 0; right: 0; bottom: 0; height: 14px; display: flex; }
.login-strip span { flex: 1; animation: rise .8s cubic-bezier(.2,.8,.2,1) both; }
@keyframes rise { from { transform: translateY(14px); } }
.login-right {
  flex: 1; background: var(--slab); display: flex; align-items: center; justify-content: center;
  border-left: 2px solid var(--ink);
}
.login-form { width: min(360px, 84%); color: var(--slab-ink); }
.login-form-head {
  font-family: var(--mono); font-size: .78rem; letter-spacing: .3em; color: #8f897c;
  border-bottom: 1px solid #4a473f; padding-bottom: .8rem; margin-bottom: 1.6rem;
}
.login-form label { display: block; font-size: .8rem; letter-spacing: .06em; text-transform: uppercase; margin-bottom: 1.1rem; color: #9a9487; }
.login-form input {
  display: block; width: 100%; margin-top: .45rem; padding: .7rem .8rem;
  background: var(--slab-2); color: var(--slab-ink); border: 1px solid #4a473f;
  font-family: var(--mono); font-size: 1rem; outline: none;
}
.login-form input:focus { border-color: var(--oxide); }
.login-error { color: #e08975; font-family: var(--mono); font-size: .82rem; margin-top: 1rem; min-height: 1.2em; }

/* ============ app frame ============ */
.app { display: flex; height: 100vh; position: relative; z-index: 1; }
.sidebar {
  width: 216px; flex-shrink: 0; background: var(--slab); color: var(--slab-ink);
  display: flex; flex-direction: column; border-right: 2px solid var(--ink);
}
.brand { padding: 1.3rem 1.2rem 1.1rem; border-bottom: 1px solid #45423a; display: flex; gap: .8rem; align-items: center; }
.brand-mark {
  font-family: var(--mono); font-weight: 600; font-size: 1.05rem; letter-spacing: .18em;
  background: var(--oxide); color: #f6ece8; padding: .5em .35em .5em .55em;
}
.brand-name { font-weight: 800; font-stretch: 112%; text-transform: uppercase; font-size: .82rem; line-height: 1.15; letter-spacing: .04em; }
#nav { padding: 1rem .7rem; flex: 1; overflow-y: auto; }
#nav a {
  display: flex; align-items: center; gap: .65rem; color: #a9a396; text-decoration: none;
  font-size: .88rem; letter-spacing: .03em; padding: .5rem .55rem; margin-bottom: 2px;
  border-left: 3px solid transparent;
}
#nav a:hover { color: var(--slab-ink); background: var(--slab-2); }
#nav a.active { color: #f1ede4; border-left-color: var(--oxide); background: var(--slab-2); }
.nav-glyph { font-family: var(--mono); width: 1.2em; text-align: center; opacity: .8; }
.nav-rule { border-top: 1px solid #45423a; margin: .8rem .4rem; }
.sidebar-foot { padding: 1rem 1.2rem; border-top: 1px solid #45423a; }
.whoami { font-family: var(--mono); font-size: .78rem; color: #8f897c; margin-bottom: .5rem; word-break: break-all; }

.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar {
  height: 54px; flex-shrink: 0; display: flex; align-items: center; gap: 1rem;
  padding: 0 1.4rem; border-bottom: 2px solid var(--ink); background: var(--card);
}
.scanbox { display: flex; align-items: center; gap: .5rem; flex: 0 1 430px; border: 1.5px solid var(--ink); background: var(--paper); padding: .32rem .6rem; box-shadow: var(--shadow); }
.scan-glyph { font-family: var(--mono); color: var(--oxide); }
#scanbox { border: 0; outline: 0; background: transparent; font-family: var(--mono); font-size: .85rem; width: 100%; color: var(--ink); }
.topbar-status { margin-left: auto; font-family: var(--mono); font-size: .75rem; color: var(--ink-soft); }

.view { flex: 1; overflow-y: auto; padding: 1.6rem 1.8rem 3rem; animation: viewin .25s ease both; }
@keyframes viewin { from { opacity: 0; transform: translateY(6px); } }

/* ============ primitives ============ */
h2.page-title {
  font-size: 1.5rem; font-weight: 800; font-stretch: 112%; text-transform: uppercase;
  letter-spacing: .02em; margin: 0 0 .2rem;
}
.page-sub { color: var(--ink-soft); font-size: .85rem; margin-bottom: 1.4rem; font-family: var(--mono); }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.2rem; }
.page-head .actions { display: flex; gap: .5rem; flex-wrap: wrap; }

.card {
  background: var(--card); border: 2px solid var(--ink); box-shadow: var(--shadow);
  padding: 1.1rem 1.2rem; margin-bottom: 1.2rem;
}
.card-title { font-family: var(--mono); font-size: .72rem; letter-spacing: .28em; text-transform: uppercase; color: var(--ink-soft); margin-bottom: .9rem; }
.grid { display: grid; gap: 1.2rem; }
.grid.cols-2 { grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.grid.cols-4 { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }

.stat { border: 2px solid var(--ink); background: var(--card); box-shadow: var(--shadow); padding: .9rem 1rem; animation: viewin .3s ease both; }
.stat .n { font-family: var(--mono); font-size: 1.9rem; font-weight: 600; line-height: 1; }
.stat .l { font-size: .72rem; letter-spacing: .16em; text-transform: uppercase; color: var(--ink-soft); margin-top: .45rem; }
.stat.alert .n { color: var(--oxide); }

.btn {
  font-family: var(--sans); font-weight: 600; font-size: .82rem; letter-spacing: .04em;
  border: 2px solid var(--ink); background: var(--card); color: var(--ink);
  padding: .5rem .9rem; cursor: pointer; box-shadow: var(--shadow);
  transition: transform .06s ease, box-shadow .06s ease;
}
.btn:hover { transform: translate(-1px,-1px); box-shadow: var(--shadow-lift); }
.btn:active { transform: translate(1px,1px); box-shadow: 1px 1px 0 rgba(30,28,24,.2); }
.btn-accent { background: var(--oxide); color: #f8efe9; border-color: var(--oxide-deep); }
.btn-ghost { background: transparent; box-shadow: none; border-color: #57534a; color: #a9a396; }
.btn-xs { font-size: .72rem; padding: .3rem .6rem; }
.btn-block { width: 100%; margin-top: .6rem; }
.btn[disabled] { opacity: .45; cursor: not-allowed; transform: none !important; }

table.tbl { width: 100%; border-collapse: collapse; font-size: .86rem; }
.tbl th {
  font-family: var(--mono); font-size: .68rem; text-transform: uppercase; letter-spacing: .18em;
  color: var(--ink-soft); text-align: left; border-bottom: 2px solid var(--ink); padding: .45rem .55rem;
}
.tbl td { padding: .5rem .55rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tbl tr:hover td { background: rgba(181, 67, 42, .05); }
.tbl tr.rowlink { cursor: pointer; }
.tbl td.num, .tbl th.num { text-align: right; font-family: var(--mono); }
.mono { font-family: var(--mono); }
.soft { color: var(--ink-soft); }
.code-chip { font-family: var(--mono); font-size: .8rem; background: var(--paper-2); border: 1px solid var(--line); padding: .1rem .4rem; white-space: nowrap; }

.badge { font-family: var(--mono); font-size: .68rem; letter-spacing: .08em; padding: .18rem .5rem; border: 1.5px solid currentColor; text-transform: uppercase; white-space: nowrap; }
.badge.b-ready, .badge.b-active, .badge.b-cast { color: var(--sky); }
.badge.b-done, .badge.b-cured, .badge.b-good { color: var(--good); }
.badge.b-planned, .badge.b-waiting, .badge.b-draft { color: var(--ochre); }
.badge.b-overdue, .badge.b-bad { color: var(--bad); }
.badge.b-curing, .badge.b-demolded, .badge.b-finishing { color: var(--warn); }
.badge.b-neutral, .badge.b-archived, .badge.b-skipped { color: var(--ink-soft); }

/* swatches: physical tile feel */
.swatch {
  display: inline-block; width: 26px; height: 26px; border: 1.5px solid var(--ink);
  box-shadow: inset 0 2px 3px rgba(255,255,255,.35), inset 0 -2px 3px rgba(0,0,0,.25), 2px 2px 0 rgba(30,28,24,.18);
  vertical-align: middle;
}
.swatch.lg { width: 64px; height: 64px; }
.swatch.xl { width: 110px; height: 110px; }
.tilecard { border: 2px solid var(--ink); background: var(--card); box-shadow: var(--shadow); padding: .7rem; display: flex; gap: .8rem; align-items: center; }
.tilewall { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .8rem; }
.tilewall .tile { border: 2px solid var(--ink); background: var(--card); box-shadow: var(--shadow); cursor: pointer; }
.tilewall .tile:hover { transform: translate(-1px,-1px); box-shadow: var(--shadow-lift); }
.tilewall .tile .chip { height: 84px; border-bottom: 2px solid var(--ink); box-shadow: inset 0 3px 5px rgba(255,255,255,.3), inset 0 -3px 5px rgba(0,0,0,.22); }
.tilewall .tile .meta { padding: .45rem .55rem; font-family: var(--mono); font-size: .7rem; line-height: 1.5; }

.de-badge { font-family: var(--mono); font-weight: 600; padding: .15rem .45rem; border: 1.5px solid var(--ink); }
.de-0 { background: #dfe8d3; } .de-1 { background: #efe8c8; } .de-2 { background: #f3d9bd; } .de-3 { background: #f0c4b4; }

/* forms */
.frm label { display: block; font-size: .74rem; letter-spacing: .1em; text-transform: uppercase; color: var(--ink-soft); margin-bottom: .8rem; }
.frm input, .frm select, .frm textarea {
  display: block; width: 100%; margin-top: .3rem; padding: .5rem .6rem;
  border: 1.5px solid var(--ink); background: var(--paper); font-family: var(--mono);
  font-size: .9rem; color: var(--ink); outline: none;
}
.frm input:focus, .frm select:focus, .frm textarea:focus { border-color: var(--oxide); background: #fff; }
.frm-row { display: flex; gap: .8rem; } .frm-row > label { flex: 1; }
.inline-input { width: 90px !important; display: inline-block !important; padding: .25rem .4rem !important; text-align: right; }

/* modal */
.modal-back { position: fixed; inset: 0; background: rgba(30,28,24,.5); z-index: 60; display: flex; align-items: flex-start; justify-content: center; padding: 6vh 1rem; overflow-y: auto; }
.modal { background: var(--card); border: 2px solid var(--ink); box-shadow: 8px 8px 0 rgba(30,28,24,.3); width: min(680px, 96vw); animation: viewin .18s ease both; }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: .9rem 1.2rem; border-bottom: 2px solid var(--ink); background: var(--paper-2); }
.modal-head .t { font-weight: 800; font-stretch: 110%; text-transform: uppercase; letter-spacing: .03em; }
.modal-body { padding: 1.2rem; max-height: 74vh; overflow-y: auto; }

/* toast */
#toast-root { position: fixed; bottom: 1.2rem; right: 1.2rem; z-index: 80; display: flex; flex-direction: column; gap: .5rem; }
.toast { border: 2px solid var(--ink); background: var(--slab); color: var(--slab-ink); font-family: var(--mono); font-size: .8rem; padding: .7rem 1rem; box-shadow: var(--shadow-lift); animation: viewin .2s ease both; max-width: 420px; }
.toast.err { background: var(--oxide-deep); color: #f8e9e4; }

/* weighing sheet */
.sheet-row-active td { background: #fbf3d8 !important; }
.sheet-done { color: var(--good); font-weight: 600; }
.kbd { font-family: var(--mono); border: 1px solid var(--line); background: var(--paper-2); font-size: .72rem; padding: 0 .35rem; }

/* palette map */
.palette-map { width: 100%; border: 2px solid var(--ink); background: #fff; box-shadow: var(--shadow); }
.palette-map circle { cursor: pointer; stroke: rgba(30,28,24,.55); stroke-width: .6; }
.palette-map circle:hover { stroke-width: 2; stroke: var(--ink); }

.track-steps { display: flex; gap: .35rem; flex-wrap: wrap; }
.track-step { font-family: var(--mono); font-size: .68rem; border: 1.5px solid var(--line); padding: .15rem .45rem; color: var(--ink-soft); }
.track-step.cur { border-color: var(--oxide); color: var(--oxide); font-weight: 600; }
.track-step.done { border-color: var(--good); color: var(--good); }

.empty { border: 2px dashed var(--line); padding: 2.2rem; text-align: center; color: var(--ink-soft); font-family: var(--mono); font-size: .85rem; }

/* ============ labels / print ============ */
.print-root { display: none; }
.label-preview { display: flex; flex-wrap: wrap; gap: .6rem; }
/* Portrait 29 × 46 mm for DK-22211 film tape — fits a 2" (50.8 mm) tile back. */
.label {
  width: 29mm; height: 46mm; border: 1px solid #999; background: #fff; color: #000;
  display: flex; flex-direction: column; align-items: center; gap: .7mm;
  padding: 1.4mm; overflow: hidden; page-break-inside: avoid;
}
.label img { width: 23mm; height: 23mm; }
.label .lb-txt { width: 100%; min-width: 0; flex: 1; display: flex; flex-direction: column; align-items: center; }
.label .lb-code { font-family: var(--mono); font-weight: 700; font-size: 11pt; letter-spacing: .02em; }
.label .lb-line { max-width: 100%; font-family: var(--mono); font-size: 6.2pt; line-height: 1.3; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.label .lb-track { width: 100%; text-align: center; font-family: var(--mono); font-size: 6.4pt; margin-top: auto; border-top: .3mm solid #000; padding-top: .6mm; white-space: nowrap; overflow: hidden; }

@media print {
  body > *:not(#print-root) { display: none !important; }
  body::before { display: none; }
  .print-root { display: block !important; }
  body { background: #fff; }
  @page { margin: 4mm; }
  .print-root.tpl-ql29 .label { border: none; margin: 0 auto 2mm auto; }
  /* 24-up 1.5" square sheet (Avery 22805-style), Letter, 4 × 6 grid */
  .print-root.tpl-sheet24 { display: grid !important; grid-template-columns: repeat(4, 38.1mm); column-gap: 7.9mm; row-gap: 3.2mm; justify-content: center; }
  .print-root.tpl-sheet24 .label { width: 38.1mm; height: 38.1mm; border: none; padding: 1mm; gap: .4mm; }
  .print-root.tpl-sheet24 .label img { width: 18mm; height: 18mm; }
  .print-root.tpl-sheet24 .label .lb-code { font-size: 9pt; }
  .print-root.tpl-sheet24 .label .lb-summary { display: none; }
}

@media (max-width: 900px) {
  .sidebar { width: 62px; }
  .brand-name, .sidebar-foot .whoami { display: none; }
  #nav a { justify-content: center; padding: .6rem .2rem; }
  #nav a .nav-glyph + * { display: none; }
  .login-left { display: none; }
}
