/* repair_os — workshop operations UI.
   Identity: a repair café's physical world — order tags, benches, custody,
   repair states. Signature: the order TAG (big monospace code + live QR).
   Served as a static file (CSP: no external fonts/scripts). */

:root {
  --bg: #e9ebef;
  --surface: #ffffff;
  --surface-2: #f5f6f8;
  --ink: #1a1d21;
  --ink-soft: #58616d;
  --ink-faint: #8a93a0;
  --line: #dce0e6;
  --line-soft: #eaedf1;

  --accent: #0e7a6b;          /* repair green */
  --accent-ink: #0a5346;
  --accent-wash: #dff0ec;

  --nav: #21252b;             /* graphite bench */
  --nav-2: #191c21;
  --nav-ink: #b9c2cd;
  --nav-ink-soft: #7d8794;
  --nav-active: #0e7a6b;

  --info: #1f5fb0;   --info-wash: #e7f0fb;
  --warn: #a2560a;   --warn-wash: #fbefdf;
  --danger: #b12a20; --danger-wash: #fbeae8;
  --slate: #566173; --slate-wash: #eceef2;

  --r: 11px; --r-sm: 7px; --r-xs: 5px;
  --shadow: 0 1px 2px rgba(20,25,35,.06), 0 4px 16px -8px rgba(20,25,35,.14);
  --shadow-lg: 0 8px 40px -12px rgba(20,25,35,.28);
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", "Fira Code", Menlo, monospace;
  --sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; font-family: var(--sans); color: var(--ink); background: var(--bg);
  font-size: 14.5px; line-height: 1.5; -webkit-font-smoothing: antialiased;
}
a { color: var(--accent-ink); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; font-weight: 640; letter-spacing: -.01em; }
h2 { font-size: 1.32rem; }
h3 { font-size: 1.02rem; }
p { margin: .5rem 0; }

/* ---- app shell ---------------------------------------------------------- */
.shell { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.sidebar {
  background: linear-gradient(180deg, var(--nav), var(--nav-2));
  color: var(--nav-ink); display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh; padding: 1rem .75rem;
}
.brand { display: flex; align-items: center; gap: .55rem; padding: .3rem .5rem 1.1rem; }
.brand .mark {
  width: 30px; height: 30px; border-radius: 8px; background: var(--accent);
  display: grid; place-items: center; color: #fff; font-weight: 800; font-size: 1rem;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.14);
}
.brand b { color: #fff; font-size: 1.02rem; letter-spacing: -.02em; }
.brand small { display: block; color: var(--nav-ink-soft); font-size: .68rem; letter-spacing: .04em; }
.nav-group { margin-top: .4rem; }
.nav-group > .lbl {
  font-size: .64rem; text-transform: uppercase; letter-spacing: .12em;
  color: var(--nav-ink-soft); padding: .6rem .6rem .3rem;
}
.nav a {
  display: flex; align-items: center; gap: .6rem; color: var(--nav-ink);
  padding: .5rem .6rem; border-radius: var(--r-sm); font-size: .9rem; font-weight: 500;
}
.nav a:hover { background: rgba(255,255,255,.06); text-decoration: none; color: #fff; }
.nav a.active { background: rgba(14,122,107,.22); color: #fff; box-shadow: inset 2px 0 0 var(--accent); }
.nav a .ico { width: 18px; text-align: center; opacity: .85; }
.sidebar .foot { margin-top: auto; padding: .6rem; font-size: .72rem; color: var(--nav-ink-soft); }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 20; background: rgba(233,235,239,.86);
  backdrop-filter: saturate(1.4) blur(8px); border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 1rem; padding: .6rem 1.4rem;
}
.topbar .crumb { font-weight: 620; letter-spacing: -.01em; }
.topbar .spacer { margin-left: auto; }
.rolesw { display: flex; gap: .25rem; background: var(--surface); border: 1px solid var(--line);
  border-radius: 999px; padding: .2rem; box-shadow: var(--shadow); }
.rolesw a { padding: .28rem .7rem; border-radius: 999px; font-size: .8rem; color: var(--ink-soft); font-weight: 550; }
.rolesw a:hover { text-decoration: none; color: var(--ink); }
.rolesw a.active { background: var(--ink); color: #fff; }
.rolesw form { display: inline; margin: 0; }
.rolesw button { background: transparent; border: 0; box-shadow: none; color: var(--ink-soft);
  padding: .28rem .7rem; border-radius: 999px; font-size: .8rem; font-weight: 550; }
.rolesw button:hover { filter: none; color: var(--ink); }
.rolesw button.active { background: var(--ink); color: #fff; }
.content { padding: 1.5rem 1.6rem 4rem; max-width: 1180px; width: 100%; }
.page-head { display: flex; align-items: flex-end; gap: 1rem; margin-bottom: 1.2rem; flex-wrap: wrap; }
.page-head .sub { color: var(--ink-soft); font-size: .9rem; }

/* ---- cards -------------------------------------------------------------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r);
  box-shadow: var(--shadow); padding: 1.1rem 1.2rem; margin-bottom: 1.1rem; }
.card > h3:first-child { margin-bottom: .7rem; }
.card-flush { padding: 0; overflow: hidden; }
.grid { display: grid; gap: 1.1rem; }
.grid-2 { grid-template-columns: 1fr 1fr; }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.eyebrow { font-size: .66rem; text-transform: uppercase; letter-spacing: .13em; color: var(--ink-faint);
  font-weight: 640; }

/* ---- stat tiles --------------------------------------------------------- */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: .8rem; margin-bottom: 1.1rem; }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: .85rem 1rem; box-shadow: var(--shadow); }
.tile .n { font-size: 1.7rem; font-weight: 700; font-family: var(--mono); letter-spacing: -.02em; }
.tile .k { font-size: .74rem; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-faint); }
.tile.alert .n { color: var(--danger); }
.tile.good .n { color: var(--accent-ink); }

/* ---- buttons ------------------------------------------------------------ */
.btn, button {
  font: inherit; font-weight: 570; cursor: pointer; border: 1px solid transparent;
  border-radius: var(--r-sm); padding: .5rem .9rem; background: var(--accent); color: #fff;
  display: inline-flex; align-items: center; gap: .4rem; transition: filter .12s, background .12s;
}
.btn:hover, button:hover { filter: brightness(1.06); }
.btn:active, button:active { filter: brightness(.96); }
.btn-ghost, button.ghost { background: var(--surface); color: var(--ink); border-color: var(--line); box-shadow: var(--shadow); }
.btn-ghost:hover, button.ghost:hover { background: var(--surface-2); filter: none; }
.btn-danger, button.danger { background: var(--danger); }
.btn-sm, button.sm { padding: .32rem .62rem; font-size: .82rem; }
.btn:focus-visible, button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}
.btnrow { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }

/* ---- forms -------------------------------------------------------------- */
label { font-size: .84rem; font-weight: 550; color: var(--ink-soft); }
input[type=text], input[type=password], input[type=number], input[type=file], select, textarea {
  font: inherit; width: 100%; padding: .5rem .6rem; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--r-sm); color: var(--ink);
}
input::placeholder, textarea::placeholder { color: var(--ink-faint); }
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
.field { margin-bottom: .75rem; }
.field > label { display: block; margin-bottom: .25rem; }
.pw-field { position: relative; }
.pw-field input { padding-right: 2.3rem; }
.pw-toggle {
  position: absolute; right: .25rem; top: 50%; transform: translateY(-50%);
  background: transparent; border: 0; box-shadow: none; color: var(--ink-faint);
  padding: .25rem .4rem; line-height: 1; font-size: .95rem;
}
.pw-toggle:hover { background: transparent; filter: none; color: var(--ink); }
.field-row { display: flex; gap: .6rem; flex-wrap: wrap; align-items: end; }
.check { display: inline-flex; align-items: center; gap: .4rem; font-weight: 500; }
.check input { width: auto; }
.inlineform { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; margin: .4rem 0; }
.inlineform input[type=text], .inlineform select { width: auto; flex: 1 1 8rem; min-width: 7rem; }

/* ---- badges / chips ----------------------------------------------------- */
.badge { display: inline-flex; align-items: center; gap: .3rem; font-size: .74rem; font-weight: 600;
  padding: .14rem .5rem; border-radius: 999px; background: var(--slate-wash); color: var(--slate);
  white-space: nowrap; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .8; }
.badge--intake { background: var(--info-wash); color: var(--info); }
.badge--active { background: var(--warn-wash); color: var(--warn); }
.badge--waiting { background: var(--slate-wash); color: var(--slate); }
.badge--ready  { background: var(--accent-wash); color: var(--accent-ink); }
.badge--closed { background: #e6e8ec; color: #6a7382; }
.badge--danger { background: var(--danger-wash); color: var(--danger); }
.badge.plain::before { display: none; }
.muted { color: var(--ink-soft); }
.faint { color: var(--ink-faint); font-size: .84rem; }
.mono { font-family: var(--mono); }

/* ---- tables ------------------------------------------------------------- */
table { border-collapse: collapse; width: 100%; font-size: .9rem; }
thead th { text-align: left; font-size: .68rem; text-transform: uppercase; letter-spacing: .07em;
  color: var(--ink-faint); font-weight: 640; padding: .6rem .8rem; border-bottom: 1px solid var(--line); }
tbody td { padding: .6rem .8rem; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: var(--surface-2); }
.code-cell { font-family: var(--mono); font-weight: 680; font-size: .98rem; letter-spacing: .04em; }

/* ---- order TAG (signature) --------------------------------------------- */
.tag {
  position: relative; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r); box-shadow: var(--shadow); padding: 1rem 1.1rem 1.1rem;
  display: grid; grid-template-columns: auto 1fr; gap: 1rem; align-items: center;
}
.tag .qr { width: 118px; height: 118px; background: #fff; border: 1px solid var(--line);
  border-radius: var(--r-sm); padding: 6px; }
.tag .qr img { width: 100%; height: 100%; image-rendering: pixelated; display: block; }
.tag .bigcode { font-family: var(--mono); font-size: 2.6rem; font-weight: 720; letter-spacing: .06em; line-height: 1; }
.tag .oid { font-family: var(--mono); color: var(--ink-faint); font-size: .82rem; margin-top: .2rem; }
.tag .tagmeta { display: flex; flex-direction: column; gap: .35rem; }

/* ---- timeline ----------------------------------------------------------- */
.thread { display: flex; flex-direction: column; gap: .1rem; }
.chip { align-self: center; text-align: center; font-size: .78rem; color: var(--ink-soft);
  background: var(--surface-2); border: 1px solid var(--line-soft); border-radius: 999px;
  padding: .22rem .7rem; margin: .5rem 0; }
.chip b { color: var(--ink); }
.bubble { position: relative; background: var(--surface); border: 1px solid var(--line);
  border-radius: 13px; padding: .55rem .85rem; margin: .3rem 0; max-width: 74%; box-shadow: var(--shadow); }
.bubble .meta { font-size: .7rem; color: var(--ink-faint); margin-bottom: .18rem; display: flex; gap: .4rem; flex-wrap: wrap; }
.bubble.out { align-self: flex-end; background: var(--accent-wash); border-color: #bfe0d9; }
.bubble.in { align-self: flex-start; }
.bubble.internal { background: var(--warn-wash); border-color: #f0dcbf; }
.evt { align-self: center; width: min(88%, 620px); background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-sm); padding: .5rem .8rem; margin: .35rem 0; font-size: .86rem; box-shadow: var(--shadow); }
.evt.work { border-left: 3px solid var(--accent); }
.evt.incident { border-left: 3px solid var(--danger); background: var(--danger-wash); }
.evt .ico { margin-right: .35rem; }
.media-thumbs { display: flex; gap: .5rem; flex-wrap: wrap; margin-top: .4rem; }
.media-thumbs img { width: 132px; height: 100px; object-fit: cover; border-radius: var(--r-sm); border: 1px solid var(--line); }

/* item-view media grid (specs/ui_item_view.md group 8) */
.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .7rem; margin-top: .6rem; }
.mtile { margin: 0; border: 1px solid var(--line); border-radius: var(--r-sm); overflow: hidden; background: var(--surface-2); }
.mtile > a { display: block; }
.mtile img { width: 100%; height: 118px; object-fit: cover; display: block; }
.mtile-video { position: relative; display: block; }
.mtile-video .play { position: absolute; inset: 0; display: grid; place-items: center;
  color: #fff; font-size: 1.6rem; text-shadow: 0 1px 6px rgba(0,0,0,.6); pointer-events: none; }
.mtile-file { display: grid; place-items: center; height: 118px; color: var(--ink-faint);
  font-size: 1.6rem; text-align: center; }
.mtile figcaption { padding: .35rem .5rem; font-size: .75rem; display: flex; gap: .35rem;
  align-items: center; flex-wrap: wrap; }

/* ---- composer / quick actions ------------------------------------------ */
.composer { position: sticky; top: 52px; z-index: 5; }
.actions-bar { display: flex; gap: .4rem; flex-wrap: wrap; }
details.qa { border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--surface-2); margin: .5rem 0; }
details.qa > summary { cursor: pointer; padding: .5rem .8rem; font-weight: 560; font-size: .88rem; list-style: none; }
details.qa > summary::-webkit-details-marker { display: none; }
details.qa > summary::before { content: "▸ "; color: var(--ink-faint); }
details.qa[open] > summary::before { content: "▾ "; }
details.qa .body { padding: .3rem .8rem .8rem; }

/* ---- filters / counts --------------------------------------------------- */
.counts { display: flex; gap: .4rem; flex-wrap: wrap; margin: .8rem 0; }
.counts a { font-size: .78rem; padding: .2rem .55rem; border-radius: 999px; background: var(--surface);
  border: 1px solid var(--line); color: var(--ink-soft); }
.counts a:hover { text-decoration: none; border-color: var(--accent); color: var(--accent-ink); }
.counts a.active { background: var(--accent-wash); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }

/* ---- empty state -------------------------------------------------------- */
.empty { text-align: center; color: var(--ink-faint); padding: 2rem; font-size: .9rem; }

/* ---- print (labels) ----------------------------------------------------- */
@media print {
  .sidebar, .topbar, .no-print { display: none !important; }
  .shell { grid-template-columns: 1fr; }
  .content { padding: 0; }
  .card { box-shadow: none; border: none; }
}

/* ---- responsive --------------------------------------------------------- */
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center;
    padding: .5rem .8rem; }
  .sidebar .brand { padding: .2rem .4rem; }
  .nav-group { margin: 0; } .nav-group > .lbl { display: none; }
  .nav { display: flex; flex-wrap: wrap; } .sidebar .foot { display: none; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .bubble { max-width: 90%; }
  .content { padding: 1rem; }
}
