:root {
  --ink: #161410;
  --muted: #6b6458;
  --line: #e4ddd0;
  --paper: #f6f1e8;
  --card: #fffdf8;
  --navy: #152238;
  --navy-2: #1e334f;
  --copper: #c45c26;
  --copper-dark: #9a4419;
  --ok: #2c6e4f;
  --danger: #b42318;
  --shadow: 0 10px 30px rgba(21, 34, 56, 0.08);
  --radius: 16px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { height: 100%; font-size: 18px; -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body.sb-app-body, body.sb-login-body {
  font-family: Heebo, "Segoe UI", Tahoma, sans-serif;
  background: var(--paper);
  color: var(--ink);
  min-height: 100%;
  font-size: 1.05rem;
  line-height: 1.45;
}

button, input, select, textarea { font-family: inherit; font-size: 1.05rem; }
button { cursor: pointer; }
a { color: inherit; }

.sb-login-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(1200px 400px at 100% -10%, rgba(196, 92, 38, 0.18), transparent 50%),
    linear-gradient(180deg, #152238, #1b2c48 55%, #f6f1e8 55%);
}
.sb-login {
  width: min(420px, 100%);
  background: var(--card);
  border-radius: 24px;
  padding: 32px 28px 24px;
  box-shadow: var(--shadow);
  text-align: center;
}
.sb-login-mark {
  width: 64px; height: 64px; margin: 0 auto 12px;
  border-radius: 18px; background: var(--navy); color: #f3d3b0;
  display: grid; place-items: center; font-weight: 800; font-size: 22px; letter-spacing: 0.04em;
}
.sb-login h1 { margin: 0 0 4px; font-size: 26px; }
.sb-login p { margin: 0 0 22px; color: var(--muted); }
.sb-login form { text-align: right; display: grid; gap: 12px; }
.sb-login label { display: grid; gap: 8px; font-size: 1rem; font-weight: 700; color: var(--navy); }
.sb-login input[type="text"],
.sb-login input[type="password"] {
  width: 100%; border: 1px solid var(--line); border-radius: 12px; padding: 16px 14px; background: #fff; min-height: 52px;
}
.sb-check { display: flex !important; align-items: center; gap: 8px; font-weight: 500 !important; color: var(--muted) !important; font-size: 1rem !important; }
.sb-login-lost { display: inline-block; margin-top: 14px; color: var(--muted); font-size: 1rem; }
.sb-alert { background: #fde8e6; color: var(--danger); padding: 10px 12px; border-radius: 10px; margin-bottom: 12px; font-weight: 600; }

.sb-shell { min-height: 100vh; }
.sb-top {
  position: sticky; top: 0; z-index: 20;
  background: var(--navy); color: #f7efe4;
  display: flex; align-items: center; gap: 10px;
  min-height: 64px;
  padding: 12px 16px;
  padding-top: calc(12px + env(safe-area-inset-top, 0px));
}
.sb-top h1 { font-size: 1.15rem; margin: 0; font-weight: 800; flex: 1; line-height: 1.35; }
.sb-brand { font-weight: 800; letter-spacing: 0.04em; color: #f3d3b0; font-size: 1rem; }
.sb-greet { font-weight: 700; color: #f3d3b0; font-size: 0.92rem; max-width: 42%; line-height: 1.3; }
.sb-icon-btn, .sb-btn {
  border: 0; border-radius: 14px; padding: 14px 16px; font-weight: 700; font-size: 1.05rem;
}
.sb-icon-btn { background: transparent; color: #f7efe4; min-width: 48px; min-height: 48px; font-size: 1.3rem; }
.sb-btn { min-height: 52px; display: inline-flex; align-items: center; justify-content: center; text-decoration: none; }
.sb-btn-primary { background: var(--copper); color: #fff; }
.sb-btn-primary:active { background: var(--copper-dark); }
.sb-btn-ghost { background: #fff; color: var(--navy); border: 1px solid var(--line); }
.sb-btn-navy { background: var(--navy); color: #fff; }
.sb-btn-danger { background: #fde8e6; color: var(--danger); }
.sb-btn-block { width: 100%; }
.sb-btn-sm { padding: 14px 16px; font-size: 1.05rem; min-height: 52px; }

.sb-page { padding: 16px; padding-bottom: calc(32px + var(--safe-b)); max-width: 920px; margin: 0 auto; }
.sb-bottom-safe {
  height: calc(16px + var(--safe-b));
  flex-shrink: 0;
}
.sb-impersonate {
  background: var(--copper);
  color: #fff;
  padding: 10px 16px;
  font-weight: 700;
  font-size: 0.95rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.sb-impersonate a { color: #fff; text-decoration: underline; font-weight: 800; }
.sb-side-nav .sb-nav-switch {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 10px; border-radius: 12px;
  color: #f3d3b0; text-decoration: none; font-weight: 700;
  min-height: 48px;
}
.sb-boot { padding: 80px 20px; text-align: center; color: var(--muted); }

.sb-sidebar {
  position: fixed; top: 0; right: 0; bottom: 0;
  width: min(300px, 86vw);
  background: var(--navy); color: #f7efe4;
  z-index: 40;
  transform: translateX(110%);
  transition: transform 0.2s ease;
  overflow-y: auto;
  padding: 18px 12px calc(28px + 16px + var(--safe-b));
}
body.sb-menu-open .sb-sidebar { transform: translateX(0); }
.sb-sidebar-brand {
  font-weight: 800; letter-spacing: 0.04em; color: #f3d3b0;
  padding: 8px 10px 16px; font-size: 1.05rem;
}
.sb-side-nav a, .sb-side-nav .sb-nav-logout, .sb-side-nav .sb-nav-refresh {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 10px; border-radius: 12px;
  color: #c9d4e5; text-decoration: none; font-weight: 700;
  min-height: 48px;
}
.sb-side-nav .sb-nav-refresh {
  width: 100%;
  border: 0;
  background: transparent;
  cursor: pointer;
  font: inherit;
  text-align: right;
}
.sb-side-nav a.is-active { background: var(--navy-2); color: #f3d3b0; }
.sb-side-nav svg { flex: 0 0 auto; }
.sb-side-group { margin-bottom: 4px; }
.sb-side-group summary {
  list-style: none; cursor: pointer; display: flex; align-items: center; gap: 10px;
  padding: 12px 10px; border-radius: 12px; font-weight: 800; color: #f7efe4;
}
.sb-side-group summary::-webkit-details-marker { display: none; }
.sb-side-sub { padding: 0 4px 6px 0; }
.sb-side-sub a { font-size: 0.95rem; padding-right: 36px; }
.sb-backdrop {
  display: none; position: fixed; inset: 0;
  background: rgba(10, 8, 6, 0.45); z-index: 35;
}
body.sb-menu-open .sb-backdrop { display: block; }
.sb-menu-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  align-self: center;
}

.sb-card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 16px; margin-bottom: 12px;
}
.sb-shift { padding: 0; margin-bottom: 6px; overflow: hidden; }
.sb-shift-head {
  width: 100%; display: flex; align-items: center; gap: 8px;
  padding: 8px 12px; min-height: 44px; border: 0; background: transparent;
  text-align: right; font: inherit; color: inherit; cursor: pointer;
}
.sb-shift-head strong { font-size: 0.95rem; }
.sb-shift-chevron { color: var(--muted); font-size: 0.85rem; transition: transform 0.15s; }
.sb-shift.is-open .sb-shift-chevron { transform: rotate(-180deg); }
.sb-shift-body { display: none; padding: 12px 16px 16px; border-top: 1px solid var(--line); }
.sb-shift.is-open .sb-shift-body { display: block; }
.sb-shift-body .sb-grid { margin-top: 12px; }
.sb-card-link { display: block; text-decoration: none; color: inherit; }
.sb-card-link strong { font-size: 1.15rem; }
.sb-row { display: flex; align-items: center; gap: 12px; }
.sb-row > :last-child { margin-right: auto; }
.sb-grow { flex: 1; min-width: 0; }
.sb-muted { color: var(--muted); font-size: 0.95rem; }
.sb-weight { font-weight: 800; color: var(--navy); white-space: nowrap; font-size: 1.15rem; }
.sb-chip {
  display: inline-block; background: #efe4d4; color: var(--navy);
  border-radius: 999px; padding: 6px 12px; font-size: 0.9rem; font-weight: 700;
}
.sb-chip-zug { background: #f3d3b0; }
.sb-chip-truss { background: #dce7f3; }
.sb-chip-motor { background: #d7eadf; }

.sb-title { margin: 0 0 4px; font-size: 1.35rem; }
.sb-grid { display: grid; gap: 12px; }
.sb-home-pick .sb-btn { min-height: 64px; font-size: 18px; }
[hidden] { display: none !important; }
.sb-grid-2 { grid-template-columns: 1fr; }

.sb-field { display: grid; gap: 8px; font-size: 1rem; font-weight: 700; }
.sb-field input, .sb-field select, .sb-field textarea {
  width: 100%; border: 1px solid var(--line); border-radius: 12px; padding: 14px 14px; background: #fff; font-weight: 500; min-height: 52px;
}
.sb-field textarea { min-height: 180px; resize: vertical; line-height: 1.6; }
.sb-field textarea.sb-notes { min-height: 88px; }
.sb-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 12px; }
.sb-actions .sb-btn, .sb-actions a.sb-btn { flex: 1 1 100%; }
.sb-fab {
  position: fixed; bottom: calc(16px + var(--safe-b)); left: 16px;
  background: var(--copper); color: #fff; border: 0; border-radius: 999px;
  padding: 16px 22px; font-weight: 800; font-size: 1.05rem; box-shadow: 0 10px 24px rgba(196,92,38,.35); z-index: 25;
  min-height: 52px; text-decoration: none; display: inline-flex; align-items: center;
}

.sb-empty { text-align: center; padding: 40px 16px; color: var(--muted); }
.sb-empty h2 { color: var(--ink); margin: 0 0 8px; }

.sb-total-bar {
  background: var(--navy); color: #fff; border-radius: var(--radius);
  padding: 16px; display: flex; justify-content: space-between; align-items: center; gap: 12px;
  margin-bottom: 14px; font-size: 1rem;
}
.sb-total-bar strong { font-size: 1.4rem; color: #f3d3b0; }
.sb-hours-bar {
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
}
.sb-hours-bar-title {
  font-size: 1rem;
  font-weight: 700;
  color: #f7efe4;
}
.sb-hours-bar-main {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
}
.sb-hours-bar-main strong {
  font-size: 1.4rem;
  color: #f3d3b0;
  line-height: 1.15;
}
.sb-hours-split { display: grid; gap: 4px; }
.sb-hours-bar-main .sb-hours-split strong { font-size: 1.05rem; }
.sb-tabs.sb-tabs-sm a {
  padding: 6px 12px;
  min-height: 0;
  font-size: 0.85rem;
}
.sb-hours-bar-sub {
  font-size: 0.7rem;
  line-height: 1.45;
  font-weight: 600;
  color: #c9d4e5;
}

.sb-qty { display: flex; align-items: center; gap: 8px; }
.sb-qty button {
  width: 52px; height: 52px; border-radius: 12px; border: 1px solid var(--line); background: #fff; font-size: 1.6rem;
}
.sb-qty input { width: 80px; text-align: center; border: 1px solid var(--line); border-radius: 12px; padding: 12px; min-height: 52px; }

.sb-cat { border: 1px solid var(--line); border-radius: 14px; overflow: hidden; background: #fff; margin-bottom: 10px; }
.sb-cat summary {
  list-style: none; cursor: pointer; padding: 16px; font-weight: 800; background: #faf6ef; font-size: 1.1rem; min-height: 52px;
}
.sb-cat summary::-webkit-details-marker { display: none; }
.sb-prod {
  display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-top: 1px solid var(--line); flex-wrap: wrap;
}
.sb-prod button { margin-right: auto; flex: 1 1 140px; }

.sb-tabs { display: flex; gap: 8px; overflow: auto; padding-bottom: 8px; margin-bottom: 8px; }
.sb-tabs button, .sb-tabs a {
  border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 12px 16px; font-weight: 700; white-space: nowrap; min-height: 48px; font-size: 1rem;
  display: inline-flex; align-items: center; text-decoration: none; color: inherit;
}
.sb-tabs button.is-on, .sb-tabs a.is-on { background: var(--navy); color: #fff; border-color: var(--navy); }

.sb-toast {
  position: fixed; top: 16px; left: 50%; transform: translateX(-50%);
  background: var(--navy); color: #fff; padding: 10px 16px; border-radius: 999px; z-index: 50;
  font-weight: 700; display: none;
}
.sb-toast.is-on { display: block; }

.sb-letter {
  background: #fff; min-height: 70vh; padding: 28px 24px 80px; border: 1px solid var(--line);
  border-radius: 8px; position: relative;
}
.sb-letter-head { display: flex; justify-content: space-between; gap: 16px; align-items: flex-start; border-bottom: 2px solid var(--navy); padding-bottom: 16px; margin-bottom: 24px; }
.sb-letter-head img { max-height: 72px; max-width: 180px; object-fit: contain; }
.sb-letter-meta { text-align: left; font-size: 13px; color: var(--muted); }
.sb-letter h2 { margin: 0 0 16px; font-size: 28px; }
.sb-letter-body { white-space: pre-wrap; line-height: 1.8; min-height: 200px; }
.sb-stamp { position: absolute; bottom: 24px; left: 24px; max-height: 110px; max-width: 140px; object-fit: contain; }

.sb-table { width: 100%; border-collapse: collapse; }
.sb-table th, .sb-table td { text-align: right; padding: 8px 6px; border-bottom: 1px solid var(--line); }
.sb-table th { font-size: 12px; color: var(--muted); }

.sb-report-unit { break-inside: avoid; margin-bottom: 18px; }
.sb-user { font-size: 12px; color: #c9d4e5; }

.sb-seg { display: flex; background: #efe8dc; border-radius: 12px; padding: 4px; gap: 4px; }
.sb-seg button { flex: 1; border: 0; background: transparent; border-radius: 10px; padding: 10px 8px; font-weight: 700; }
.sb-seg button.is-on { background: #fff; box-shadow: var(--shadow); }

.sb-preview-img { max-height: 80px; display: block; margin-top: 8px; }
.sb-card .sb-check { font-weight: 600; color: var(--ink) !important; }
.sb-apk-status { margin: 0; }
.sb-offline-banner {
  margin: 0 0 12px;
  padding: 10px 12px;
  border: 1px solid rgba(21, 34, 56, 0.18);
  background: rgba(21, 34, 56, 0.06);
  line-height: 1.4;
}
.sb-offline-banner strong { font-weight: 700; }
.sb-push-hint { margin-top: 0.5rem; line-height: 1.45; }
.sb-install-help .sb-install-steps { margin: 0.75rem 1.25rem 0.5rem 0; padding: 0; line-height: 1.5; }
.sb-install-help .sb-install-steps li { margin-bottom: 0.4rem; }
.sb-install-note { margin: 0.5rem 0 0; font-size: 0.92em; }

.sb-month-nav {
  display: flex; align-items: center; gap: 8px; margin-bottom: 14px;
}
.sb-month-nav strong { flex: 1; text-align: center; font-size: 1.05rem; }
.sb-month-nav .sb-btn { flex: 0 1 auto; min-height: 44px; padding: 10px 12px; font-size: 0.9rem; }
.sb-clock-card .sb-btn { margin-top: 4px; }
.sb-spec-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  cursor: pointer;
  padding: 10px 12px;
  font-size: 14px;
}
.sb-spec-row strong { font-size: 14px; font-weight: 700; }
.sb-spec-row .sb-muted { font-size: 13px; }
.sb-spec-row input[type="checkbox"] {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  margin-top: 2px;
}
.sb-spec-list .sb-card-link strong { font-size: 14px; }
.sb-spec-list .sb-muted { font-size: 13px; }
.sb-spec-top-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  width: 100%;
}
.sb-spec-name {
  flex: 0 0 50%;
  max-width: 50%;
  min-width: 0;
  margin: 0;
  gap: 4px;
  font-size: 0.82rem;
}
.sb-spec-name input {
  min-height: 44px;
  height: 44px;
  padding: 8px 10px;
  font-size: 0.95rem;
  border-radius: 10px;
}
.sb-spec-top-btn {
  flex: 0 0 calc(25% - 6px);
  max-width: calc(25% - 6px);
  min-height: 44px;
  height: 44px;
  padding: 8px 6px;
  font-size: 0.82rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sb-spec-cat {
  margin: 14px 0 6px;
  font-size: calc(1rem + 2px);
  font-weight: 800;
  color: var(--sb-navy);
}
.sb-spec-cat:first-child { margin-top: 0; }
@media (max-width: 420px) {
  .sb-spec-top-row { flex-wrap: wrap; }
  .sb-spec-name { flex: 1 1 100%; max-width: 100%; }
  .sb-spec-top-btn { flex: 1 1 calc(50% - 4px); max-width: none; }
}
.sb-linkish {
  border: 0;
  background: transparent;
  color: var(--copper);
  font: inherit;
  font-weight: 800;
  padding: 0;
  text-decoration: underline;
  cursor: pointer;
}
.sb-print-only { display: none !important; }
.sb-spec-letter .sb-letter-head { margin-bottom: 16px; }
.sb-spec-print-head { margin-bottom: 12px; }
.sb-spec-print-head h2 { margin: 0 0 4px; font-size: 16px; }
.sb-spec-print-head p { margin: 0; color: var(--muted); font-size: 13px; }
.sb-access-grid { display: grid; gap: 8px; margin-top: 12px; }
.sb-access-grid .sb-check { font-weight: 600; color: var(--ink) !important; }
.sb-warn { color: #e8a06a; font-weight: 800; font-size: 0.82rem; }
.sb-shift-head .sb-warn { color: var(--copper); }
.sb-modal {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(10, 8, 6, 0.5);
  display: grid; place-items: center; padding: 16px;
}
.sb-modal-card { width: min(480px, 100%); max-height: 90vh; overflow: auto; }
.sb-row-menu {
  position: fixed; z-index: 70;
  min-width: 160px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 6px;
}
.sb-row-menu-del {
  width: 100%;
  border: 0;
  background: #fde8e6;
  color: var(--danger);
  font-weight: 800;
  border-radius: 10px;
  padding: 12px 14px;
  text-align: right;
}
[data-row-kind] { -webkit-touch-callout: none; }
.sb-review-page { page-break-before: always; break-before: page; margin-top: 24px; }
.sb-review-page img { max-width: 100%; height: auto; display: block; margin-top: 12px; }

.sb-cal-nav {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.sb-cal-head {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
  text-align: center;
  font-weight: 700;
  color: var(--muted);
  font-size: 0.85rem;
  margin-bottom: 6px;
}
.sb-cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
  margin-bottom: 16px;
}
.sb-cal-cell {
  min-height: 52px;
  border: 1px solid rgba(20, 40, 70, 0.12);
  border-radius: 10px;
  background: #fff;
  padding: 6px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  cursor: pointer;
  font: inherit;
  color: inherit;
}
.sb-cal-cell.is-empty {
  background: transparent;
  border-color: transparent;
  cursor: default;
}
.sb-cal-cell.has-events {
  border-color: var(--copper);
  background: rgba(180, 110, 60, 0.08);
}
.sb-cal-cell.is-ok {
  border-color: #2f8f4e;
  background: rgba(47, 143, 78, 0.22);
}
.sb-cal-cell.is-bad {
  border-color: #c23b3b;
  background: rgba(194, 59, 59, 0.2);
}
.sb-cal-cell.is-mixed {
  border-color: #8a6a2f;
  background: linear-gradient(
    135deg,
    rgba(47, 143, 78, 0.28) 0%,
    rgba(47, 143, 78, 0.28) 50%,
    rgba(194, 59, 59, 0.28) 50%,
    rgba(194, 59, 59, 0.28) 100%
  );
}
.sb-cal-cell.is-ok .sb-cal-dot { color: #1f6b38; }
.sb-cal-cell.is-bad .sb-cal-dot { color: #a12828; }
.sb-cal-num { font-weight: 700; }
.sb-cal-dot {
  font-size: 0.75rem;
  font-weight: 800;
  color: var(--copper);
}
.sb-truss-pal-row, .sb-truss-rect, .sb-truss-stock {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: flex-end;
}
.sb-truss-rect label, .sb-truss-stock {
  font-weight: 700;
}
.sb-truss-board-wrap {
  overflow: auto;
  background: #f6f1ea;
  border-radius: 12px;
}
.sb-truss-board {
  width: 100%;
  min-height: 280px;
  touch-action: none;
  background: #fff;
}
.sb-truss-grid { stroke: rgba(20, 40, 70, 0.15); stroke-width: 0.4; }
.sb-truss-piece { fill: #c47a45; stroke: #6b3e1e; stroke-width: 1.2; }
.sb-truss-piece.is-corner { fill: #1e3a5f; stroke: #0d1c30; }
.sb-truss-piece.is-on { stroke: #111; stroke-width: 2.4; }
.sb-truss-bom { width: 100%; border-collapse: collapse; }
.sb-truss-bom th, .sb-truss-bom td {
  border-bottom: 1px solid rgba(20, 40, 70, 0.1);
  padding: 6px 4px;
  text-align: right;
}

@media (min-width: 768px) {
  html { font-size: 16px; }
  .sb-grid-2 { grid-template-columns: 1fr 1fr; }
  .sb-actions .sb-btn, .sb-actions a.sb-btn { flex: 0 1 auto; }
  .sb-prod button { flex: 0 0 auto; }
}

@media (min-width: 900px) {
  .sb-shell { display: flex; align-items: stretch; }
  .sb-sidebar {
    position: sticky; top: 0; height: 100vh; flex: 0 0 260px;
    transform: none; width: 260px;
  }
  .sb-main { flex: 1; min-width: 0; }
  .sb-menu-btn, .sb-backdrop { display: none !important; }
  body.sb-menu-open .sb-backdrop { display: none !important; }
}
