:root {
  --red: #e03a30;
  --blue: #1f5fb0;
  --turquoise: #1aa6bd;
  --turquoise-ink: #086272;
  --wood: #8b4513;
  --wood-deep: #6e3410;
  --ocean: #2b6fa6;
  --slate: #6e7780;
  --ink: #1b2428;
  --sand: #f3eee4;
  --sand-2: #e7dfd2;
  --paper: #fff;
  --line: #e4dcd0;
  --good: #1f8a4c;
  --amber: #c4841d;
  --needed: #c62828;
  --grey: #8b939a;
  --shadow: 0 12px 32px rgba(62, 40, 18, 0.08);
  --radius: 18px;
  --tap: 48px;
  --font: "Outfit", "Avenir Next", "Segoe UI", sans-serif;
  --display: "Fraunces", Georgia, serif;
  --safe-t: env(safe-area-inset-top);
  --safe-b: env(safe-area-inset-bottom);
  --tab: calc(68px + var(--safe-b));
  --sidebar: 240px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  color: var(--ink);
  background: var(--sand);
  min-height: 100dvh;
  touch-action: manipulation;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--turquoise-ink); }
img { max-width: 100%; display: block; }
h1, h2, h3 { font-family: var(--display); font-weight: 560; letter-spacing: -0.02em; margin: 0; }
p { margin: 0; }

.topbar, .sidebar { background: var(--wood); color: white; }
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 10px;
  min-height: calc(56px + var(--safe-t));
  padding: calc(8px + var(--safe-t)) 14px 8px;
}
.brand { display: flex; align-items: center; gap: 10px; color: white; text-decoration: none; min-width: 0; }
.fp-mark { width: 36px; height: 36px; flex: none; background: white; border-radius: 9px; }
.brand-name { font-family: var(--display); font-size: 18px; line-height: 1; }
.brand-tag { display: block; font-family: var(--font); font-size: 11px; opacity: 0.8; letter-spacing: 0.04em; margin-top: 3px; }
.top-title { margin-left: auto; font-size: 14px; font-weight: 600; opacity: 0.92; }
.sidebar { display: none; }
.main { padding: 16px 16px var(--tab); max-width: 1100px; margin: 0 auto; }
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: grid; grid-template-columns: repeat(5, 1fr);
  background: rgba(255,255,255,.94);
  backdrop-filter: blur(10px);
  border-top: 1px solid var(--line);
  padding-bottom: var(--safe-b);
}
.tabbar a {
  text-decoration: none; color: var(--slate);
  min-height: 60px; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; font-size: 11px; font-weight: 600;
}
.tabbar a.on { color: var(--turquoise-ink); }
.tabbar svg { width: 22px; height: 22px; }

.page-head { display: flex; justify-content: space-between; gap: 12px; align-items: flex-end; margin-bottom: 14px; }
.page-head h1 { font-size: 32px; }
.lead { color: var(--slate); margin-top: 4px; }
.legend { color: var(--slate); font-size: 13px; margin: -6px 0 14px; }

.stack { display: grid; gap: 12px; }
.control-cards { display: grid; gap: 12px; }
.control-card {
  display: block; text-decoration: none; color: inherit;
  background: var(--paper); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 16px; border: 1px solid transparent; min-height: 132px;
}
.control-card:active { transform: translateY(1px); }
.control-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.kicker { font-size: 13px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; color: var(--slate); }
.big-num { font-family: var(--display); font-size: 28px; margin-top: 6px; }
.subnums { color: var(--slate); font-size: 14px; margin-top: 6px; }
.lamp {
  width: 22px; height: 22px; border-radius: 50%; display: inline-block; flex: none;
  box-shadow: 0 0 0 6px rgba(255,255,255,.5);
}
.lamp-lg { width: 54px; height: 54px; box-shadow: 0 0 0 8px rgba(255,255,255,.8), 0 8px 20px rgba(0,0,0,.08); }
.lamp-red { background: #e23b32; box-shadow: 0 0 0 6px rgba(226,59,50,.15); }
.lamp-amber { background: #f0b429; box-shadow: 0 0 0 6px rgba(240,180,41,.2); }
.lamp-green { background: #2e9b57; box-shadow: 0 0 0 6px rgba(46,155,87,.16); }
.lamp-grey { background: #c5ccd1; box-shadow: 0 0 0 6px rgba(140,148,156,.18); }
.lamp-lg.lamp-red { box-shadow: 0 0 0 8px rgba(226,59,50,.16), 0 8px 18px rgba(226,59,50,.25); }
.lamp-lg.lamp-amber { box-shadow: 0 0 0 8px rgba(240,180,41,.2), 0 8px 18px rgba(196,132,29,.2); }
.lamp-lg.lamp-green { box-shadow: 0 0 0 8px rgba(46,155,87,.16), 0 8px 18px rgba(31,138,76,.2); }
.mix { display: flex; height: 8px; border-radius: 99px; overflow: hidden; background: var(--sand-2); margin-top: 12px; }
.mix span { display: block; min-width: 0; }
.mix-red { background: #e23b32; }
.mix-amber { background: #f0b429; }
.mix-green { background: #2e9b57; }

.section-title { display: flex; align-items: center; justify-content: space-between; margin: 22px 0 10px; }
.section-title h2 { font-size: 22px; }
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.tile {
  display: block; width: 100%; text-align: left; text-decoration: none; color: inherit;
  background: var(--paper); border-radius: 16px; border: 0;
  box-shadow: var(--shadow); padding: 12px 12px 12px 14px; min-height: 96px;
  border-left: 6px solid var(--grey); position: relative;
}
[hidden] { display: none !important; }
.tile.light-red { border-left-color: #e23b32; }
.tile.light-amber { border-left-color: #f0b429; }
.tile.light-green { border-left-color: #2e9b57; }
.tile.light-grey { border-left-color: #c5ccd1; }
.tile b { display: block; font-size: 15px; }
.tile span { display: block; color: var(--slate); font-size: 12px; margin-top: 4px; }
.tile em { font-style: normal; font-weight: 700; font-size: 12px; }
.group-label { grid-column: 1 / -1; font-size: 13px; font-weight: 700; color: var(--slate); letter-spacing: .06em; text-transform: uppercase; margin-top: 6px; }

.btn, .btn-row button, .seg button {
  min-height: var(--tap); border-radius: 14px; border: 0; padding: 0 16px; font-weight: 650;
}
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; text-decoration: none; }
.btn-block { width: 100%; }
.btn-primary { background: var(--turquoise); color: white; }
.btn-wood { background: var(--wood); color: white; }
.btn-good { background: var(--good); color: white; }
.btn-danger { background: var(--needed); color: white; }
.btn-ghost { background: white; color: var(--ink); border: 1px solid var(--line); }
.btn-small { min-height: 40px; border-radius: 12px; padding: 0 12px; font-size: 14px; }
.btn:disabled { opacity: .55; }
.btn-row { display: flex; gap: 8px; }
.btn-row > * { flex: 1; }

.card, .panel {
  background: var(--paper); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px;
}
.muted { color: var(--slate); font-size: 14px; }
.text-link { font-weight: 650; text-decoration: none; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; margin: 8px 0; }
.chip { background: var(--sand-2); border-radius: 999px; padding: 4px 10px; font-size: 12px; font-weight: 700; }
.chip.urgent { background: #fde2e0; color: var(--needed); }
.chip.normal { background: #fff3d6; color: #8a5a10; }
.chip.cat { background: #e5f6f8; color: var(--turquoise-ink); }

.tabs { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 8px; margin-bottom: 8px; }
.tabs button, .tabs a {
  flex: none; min-height: 42px; border-radius: 999px; border: 1px solid var(--line);
  background: white; padding: 0 14px; text-decoration: none; color: var(--ink); font-weight: 650;
}
.tabs .on { background: var(--ink); color: white; border-color: var(--ink); }

.board { display: grid; gap: 12px; }
.column h2 { font-size: 16px; margin-bottom: 8px; display: flex; justify-content: space-between; }
.job, .order {
  display: grid; grid-template-columns: 72px 1fr; gap: 10px;
  background: white; border-radius: 16px; padding: 10px; margin-bottom: 10px;
  box-shadow: var(--shadow); text-decoration: none; color: inherit; text-align: left; border: 0; width: 100%;
}
.job img, .ph {
  width: 72px; height: 72px; object-fit: cover; border-radius: 12px; background: var(--sand-2);
}
.ph { display: grid; place-items: center; color: var(--slate); font-size: 12px; }
.job b, .order b { display: block; }
.clamp { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.filters { display: flex; gap: 8px; overflow-x: auto; margin-bottom: 10px; }
.filters select, .field input, .field select, .field textarea {
  width: 100%; min-height: var(--tap); border-radius: 12px; border: 1px solid var(--line);
  background: white; padding: 10px 12px; font-size: 16px;
}
.field { display: grid; gap: 6px; margin-bottom: 12px; }
.field label { font-weight: 650; font-size: 14px; }
.field textarea { min-height: 96px; resize: vertical; }

.log { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.log li { background: white; border-radius: 14px; padding: 12px; box-shadow: var(--shadow); }
.log-when { color: var(--slate); font-size: 12px; font-weight: 700; margin-bottom: 4px; }

.check-item { background: white; border-radius: 16px; padding: 12px; box-shadow: var(--shadow); margin-bottom: 10px; }
.check-item p { font-weight: 650; margin-bottom: 8px; }
.seg { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.seg button { background: var(--sand); border: 2px solid transparent; }
.seg button.on-ok { background: #e5f6ec; border-color: var(--good); color: #0f6a36; }
.seg button.on-fault { background: #fde8e6; border-color: var(--needed); color: var(--needed); }
.seg button.on-na { background: #eef1f3; border-color: var(--slate); }
.fault-box, .photo-box { margin-top: 10px; display: grid; gap: 8px; }
.progress-track { height: 6px; background: var(--sand-2); border-radius: 99px; overflow: hidden; margin: 8px 0 12px; }
.progress-track span { display: block; height: 100%; background: var(--turquoise); }
.sticky-actions {
  position: sticky; bottom: calc(var(--tab) - 8px); display: flex; gap: 8px;
  background: linear-gradient(transparent, var(--sand) 20%); padding: 16px 0 8px;
}
.photo-preview { width: 100%; max-height: 220px; object-fit: cover; border-radius: 12px; }
.file input { display: none; }
.file { min-height: var(--tap); border-radius: 14px; background: var(--ocean); color: white; display: grid; place-items: center; font-weight: 700; }

.banner {
  border-radius: 16px; padding: 14px; color: white; margin-bottom: 12px;
}
.banner.red { background: linear-gradient(135deg, #c62828, #e03a30); }
.banner.amber { background: linear-gradient(135deg, #a56b12, #e0a122); }
.banner.green { background: linear-gradient(135deg, #0f6a36, #1aa6bd); }
.banner.grey { background: linear-gradient(135deg, #5c656c, #8b939a); }

.login {
  min-height: 100dvh; display: grid;
}
.login-hero {
  min-height: 34dvh; padding: calc(28px + var(--safe-t)) 22px 48px; color: white;
  background:
    radial-gradient(800px 240px at 10% 0%, rgba(255,214,170,.9), transparent 55%),
    linear-gradient(165deg, #f6a15a 0%, #d86a45 28%, #1aa6bd 72%, #2b6fa6 100%);
  position: relative; overflow: hidden;
}
.login-hero .fp-mark { width: 64px; height: 64px; }
.login-hero h1 { font-size: 40px; margin-top: 12px; }
.dolphin {
  position: absolute; right: -10px; bottom: -8px; width: 180px; opacity: .35;
}
.login-card {
  margin-top: -28px; background: var(--sand); border-radius: 28px 28px 0 0;
  padding: 22px 18px calc(24px + var(--safe-b));
}
.demo { margin-top: 16px; }
.demo summary { font-weight: 700; min-height: 44px; display: grid; align-items: center; }
.demo button {
  width: 100%; text-align: left; background: white; border: 1px solid var(--line);
  border-radius: 12px; padding: 10px 12px; margin-top: 8px; min-height: 48px;
}
.row-link, .menu a, .menu button {
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
  width: 100%; text-align: left; text-decoration: none; color: inherit;
  background: white; border: 0; border-radius: 14px; min-height: 52px; padding: 12px 14px;
  box-shadow: var(--shadow); font-weight: 650; margin-bottom: 8px;
}
.person { display: flex; justify-content: space-between; gap: 8px; align-items: center; }
.fold { background: white; border-radius: 16px; padding: 8px 12px; margin-top: 8px; }
.fold summary { min-height: 44px; font-weight: 700; }
.fold ul { margin: 4px 0 10px; padding-left: 18px; }
.fold li { margin: 3px 0; }
.error-box { background: #fde8e6; color: #7a1d1d; border-radius: 14px; padding: 12px; margin-bottom: 12px; }
.loader { display: grid; place-items: center; min-height: 40dvh; gap: 10px; color: var(--slate); }
.loader .lamps { display: flex; gap: 10px; }
.loader .lamp { animation: pulse 1.2s ease-in-out infinite; }
.loader .lamp:nth-child(2) { animation-delay: .15s; }
.loader .lamp:nth-child(3) { animation-delay: .3s; }
@keyframes pulse { 50% { transform: scale(.86); opacity: .7; } }
#toasts { position: fixed; left: 12px; right: 12px; bottom: calc(var(--tab) + 8px); z-index: 50; display: grid; gap: 8px; }
.toast { background: var(--ink); color: white; border-radius: 14px; padding: 12px 14px; box-shadow: var(--shadow); }
.two { display: grid; gap: 10px; }
hr.soft { border: 0; border-top: 1px solid var(--line); margin: 14px 0; }

@media (min-width: 960px) {
  body { display: block; }
  .sidebar {
    display: flex; flex-direction: column; position: fixed; inset: 0 auto 0 0; width: var(--sidebar);
    padding: 18px 14px;
  }
  .sidebar nav { display: grid; gap: 4px; margin-top: 22px; }
  .sidebar a {
    color: white; text-decoration: none; min-height: 44px; border-radius: 12px;
    display: flex; align-items: center; padding: 0 12px; font-weight: 650;
  }
  .sidebar a.on, .sidebar a:hover { background: rgba(255,255,255,.14); }
  .sidebar .who { margin-top: auto; font-size: 14px; }
  .sidebar .who button { margin-top: 8px; width: 100%; }
  .shell { margin-left: var(--sidebar); }
  .topbar { background: transparent; color: var(--ink); position: static; padding: 18px 28px 0; }
  .topbar .brand { display: none; }
  .top-title { margin-left: 0; font-family: var(--display); font-size: 28px; }
  .tabbar { display: none; }
  .main { padding: 8px 28px 40px; }
  .control-cards { grid-template-columns: repeat(3, 1fr); }
  .grid { grid-template-columns: repeat(4, 1fr); }
  .board { grid-template-columns: repeat(4, minmax(0, 1fr)); align-items: start; }
  .board .tabs-only { display: none; }
  .mobile-tabs { display: none; }
  .login { grid-template-columns: 1.1fr .9fr; min-height: 100dvh; }
  .login-hero { min-height: 100dvh; display: flex; flex-direction: column; justify-content: flex-end; padding: 48px; }
  .login-card { margin: 0; border-radius: 0; display: grid; align-content: center; padding: 48px; }
  #toasts { left: calc(var(--sidebar) + 24px); right: 24px; bottom: 24px; max-width: 420px; }
  .sticky-actions { bottom: 0; }
  .two { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 959px) {
  .desk-only { display: none; }
  .board section { display: none; }
  .board section.is-on { display: block; }
}
@media (prefers-reduced-motion: reduce) {
  .loader .lamp { animation: none; }
}
:focus-visible { outline: 3px solid var(--turquoise); outline-offset: 2px; }
