:root {
  --red: #e30613; --ink: #1f2328; --muted: #6b7280; --line: #e5e7eb; --bg: #f6f7f9; --card: #fff;
  --ok: #1a7f37; --ok-bg: #e7f6ec; --warn: #9a6700; --warn-bg: #fff4d6; --bad: #b42318; --bad-bg: #fde8e7;
  --info: #0b5cad; --info-bg: #e6f0fb; --muted-bg: #eef0f3;
}
* { box-sizing: border-box; }
body { margin: 0; font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; color: var(--ink); background: var(--bg); }
button, input, select { font: inherit; }
h1, h2, h3 { margin: 0 0 8px; line-height: 1.25; }
h2 { font-size: 18px; } h3 { font-size: 15px; }
a { color: var(--info); }

/* top bar */
#topbar { display: flex; align-items: center; gap: 16px; padding: 10px 20px; background: #111; color: #fff; flex-wrap: wrap; }
.brand { font-weight: 600; display: flex; gap: 8px; align-items: center; }
.logo { color: var(--red); font-weight: 800; font-size: 20px; letter-spacing: -0.5px; }
.proto { font-size: 10px; border: 1px solid #555; padding: 1px 6px; border-radius: 10px; color: #bbb; }
.roles { display: flex; gap: 6px; align-items: center; margin-left: auto; }
.seg { background: #2a2a2a; color: #ddd; border: 1px solid #444; padding: 6px 12px; border-radius: 6px; cursor: pointer; }
.seg.active { background: var(--red); border-color: var(--red); color: #fff; }
#topbar select { padding: 6px 8px; border-radius: 6px; border: 1px solid #444; background: #2a2a2a; color: #fff; }
.tools { display: flex; gap: 6px; }
.tools button { background: transparent; color: #ddd; border: 1px solid #555; border-radius: 6px; padding: 6px 10px; cursor: pointer; }

/* time bar */
#timebar { background: #fff; border-bottom: 1px solid var(--line); padding: 10px 20px; display: flex; flex-direction: column; gap: 8px; }
.clockrow { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.clock { display: flex; gap: 6px; align-items: center; }
.clock .now { font-weight: 700; font-size: 16px; margin-right: 6px; }
.chips { display: flex; gap: 4px; flex-wrap: wrap; }
.chip { border: 1px solid var(--line); background: #fff; border-radius: 14px; padding: 2px 10px; cursor: pointer; font-size: 12px; }
.chip:hover:not(:disabled) { border-color: var(--red); color: var(--red); }
.chip:disabled { opacity: .35; cursor: default; }
.chip.cur { background: var(--red); color: #fff; border-color: var(--red); opacity: 1; }
.flash { padding: 8px 12px; border-radius: 6px; }

main { padding: 16px 20px 60px; max-width: 1400px; margin: 0 auto; }
.tabs { display: flex; gap: 2px; border-bottom: 2px solid var(--line); margin-bottom: 16px; flex-wrap: wrap; }
.tab { padding: 8px 14px; cursor: pointer; border: none; background: none; color: var(--muted); font-weight: 600; border-bottom: 2px solid transparent; margin-bottom: -2px; }
.tab.active { color: var(--red); border-bottom-color: var(--red); }
.count { background: var(--red); color: #fff; border-radius: 10px; padding: 0 6px; font-size: 11px; margin-left: 4px; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 16px; margin-bottom: 16px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-side { display: grid; grid-template-columns: 340px 1fr; gap: 16px; align-items: start; }
@media (max-width: 1000px) { .grid2, .grid-side { grid-template-columns: 1fr; } }
.muted { color: var(--muted); } .small { font-size: 12px; } .right { text-align: right; } .nowrap { white-space: nowrap; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }

.badge { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 12px; font-weight: 600; }
.ok { background: var(--ok-bg); color: var(--ok); } .warn { background: var(--warn-bg); color: var(--warn); }
.bad { background: var(--bad-bg); color: var(--bad); } .info { background: var(--info-bg); color: var(--info); }
.muted-b { background: var(--muted-bg); color: var(--muted); }

.btn { border: 1px solid var(--line); background: #fff; padding: 7px 14px; border-radius: 6px; cursor: pointer; font-weight: 600; }
.btn:hover:not(:disabled) { border-color: #bbb; }
.btn.primary { background: var(--red); color: #fff; border-color: var(--red); }
.btn.dark { background: #111; color: #fff; border-color: #111; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.sm { padding: 3px 9px; font-size: 12px; }

table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 600; border-bottom: 1px solid var(--line); padding: 6px 8px; }
td { border-bottom: 1px solid var(--line); padding: 7px 8px; vertical-align: top; }
tr.dim td { opacity: .5; }
tr.hl td { background: #fffaf0; }
.chg .from { color: var(--muted); text-decoration: line-through; margin-right: 4px; }
.chg .to { font-weight: 600; }
ul.notes { margin: 0; padding-left: 16px; } ul.notes li { margin: 1px 0; }

/* forms */
.field { display: grid; grid-template-columns: 240px 1fr; gap: 10px; padding: 9px 0; border-bottom: 1px dashed var(--line); align-items: start; }
.field:last-child { border-bottom: none; }
.field label { font-weight: 600; }
.field .meta { font-size: 12px; color: var(--muted); margin-top: 3px; }
.field input[type=text], .field input[type=date], .field input[type=number], .field select, .finput { padding: 6px 8px; border: 1px solid #cfd4da; border-radius: 6px; min-width: 200px; }
.checks { display: flex; gap: 12px; flex-wrap: wrap; }
.steps { display: flex; gap: 4px; margin-bottom: 14px; flex-wrap: wrap; }
.step { padding: 5px 10px; border-radius: 14px; background: var(--muted-bg); color: var(--muted); font-size: 12px; font-weight: 600; cursor: pointer; border: none; }
.step.active { background: var(--red); color: #fff; }
.errors { background: var(--bad-bg); color: var(--bad); padding: 10px 14px; border-radius: 6px; margin: 8px 0; }
.errors ul { margin: 4px 0 0; padding-left: 18px; }

/* status banner */
.banner { padding: 14px 16px; border-radius: 10px; margin-bottom: 16px; }
.banner .h { font-size: 18px; font-weight: 700; }
.banner .n { margin-top: 4px; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; margin-bottom: 16px; }
.kpi { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; }
.kpi .v { font-size: 22px; font-weight: 700; } .kpi .l { font-size: 12px; color: var(--muted); }

.timeline-item { padding: 8px 0; border-bottom: 1px solid var(--line); display: grid; grid-template-columns: 52px 1fr; gap: 8px; }
.timeline-item .d { font-weight: 700; font-size: 12px; color: var(--red); }
.done { color: var(--ok); font-weight: 700; font-size: 12px; }

.notice { border-left: 3px solid var(--red); padding: 6px 10px; margin-bottom: 8px; background: #fafafa; }
.notice .t { font-weight: 600; } .notice .a { font-size: 11px; color: var(--muted); }

.ticket { border: 2px solid #111; border-radius: 10px; padding: 16px; background: #fff; }
.ticket .th { display: flex; justify-content: space-between; border-bottom: 1px solid #111; padding-bottom: 8px; margin-bottom: 8px; }

#modal .overlay { position: fixed; inset: 0; background: rgba(0,0,0,.4); display: flex; align-items: flex-start; justify-content: center; padding: 40px 16px; overflow: auto; z-index: 10; }
#modal .box { background: #fff; border-radius: 10px; max-width: 820px; width: 100%; padding: 20px 24px; }
#modal li { margin-bottom: 4px; }

@media print {
  body * { visibility: hidden; }
  .ticket, .ticket * { visibility: visible; }
  .ticket { position: absolute; left: 0; top: 0; width: 100%; }
}

/* info tooltips */
.tip { position: relative; display: inline-flex; align-items: center; justify-content: center; width: 15px; height: 15px; margin-left: 6px; border-radius: 50%; border: 1px solid #9ca3af; color: #6b7280; background: #fff; font: italic 700 10px/1 Georgia, serif; cursor: help; vertical-align: middle; }
#topbar .tip { background: transparent; color: #bbb; border-color: #777; }
.tip:hover::after, .tip:focus::after { content: attr(data-tip); position: absolute; top: 22px; left: 50%; transform: translateX(-50%); width: 270px; padding: 8px 10px; border-radius: 6px; background: #111; color: #fff; font: 400 12px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; text-align: left; white-space: normal; z-index: 30; box-shadow: 0 4px 12px rgba(0,0,0,.2); }
#topbar .tip:hover::after, #topbar .tip:focus::after { left: auto; right: -10px; transform: none; }
#topbar { gap: 10px; font-size: 13px; }
#topbar .seg { padding: 6px 10px; }
#topbar .tools button { padding: 6px 8px; }
#topbar select { max-width: 230px; }
