:root {
  --bg: #0e0f11;
  --surface: #17181b;
  --surface-2: #1f2125;
  --line: #2b2e33;
  --text: #f2f2f3;
  --muted: #9a9ea6;
  --red: #e3262f;
  --red-hover: #f03a42;
  --red-soft: rgba(227, 38, 47, 0.14);
  --green: #2fbf71;
  --green-soft: rgba(47, 191, 113, 0.14);
  --amber: #f0a73a;
  --amber-soft: rgba(240, 167, 58, 0.14);
  --radius: 12px;
  --mono: "JetBrains Mono", ui-monospace, monospace;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 Inter, system-ui, -apple-system, Segoe UI, sans-serif;
  -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }
h1, h2, h3 { margin: 0; line-height: 1.2; }
h2 { font-size: 22px; }
h3 { font-size: 14px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 28px 0 10px; font-weight: 600; }
.muted { color: var(--muted); }
.error { color: #ff6b70; font-size: 14px; margin: 4px 0 0; }
.info { color: var(--green); font-size: 14px; margin: 4px 0 0; }

.screen { min-height: 100vh; }
.center { display: grid; place-items: center; padding: 16px; }
.spinner { width: 28px; height: 28px; border: 3px solid var(--line); border-top-color: var(--red); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Buttons */
.btn {
  appearance: none; border: 1px solid var(--line); background: var(--surface-2); color: var(--text);
  font: inherit; font-weight: 600; padding: 10px 16px; border-radius: 10px; cursor: pointer;
  transition: background .15s, border-color .15s, transform .05s;
}
.btn:hover { border-color: #3a3e45; background: #26292e; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.primary { background: var(--red); border-color: var(--red); color: #fff; }
.btn.primary:hover { background: var(--red-hover); border-color: var(--red-hover); }
.btn.danger { background: transparent; border-color: rgba(227,38,47,.5); color: #ff6b70; }
.btn.danger:hover { background: var(--red-soft); }
.btn.ghost { background: transparent; }
.btn.sm { padding: 7px 12px; font-size: 14px; }
.btn.block { width: 100%; }
.link { background: none; border: 0; color: var(--muted); font: inherit; font-size: 14px; cursor: pointer; padding: 8px 0; text-decoration: underline; text-underline-offset: 3px; }
.link:hover { color: var(--text); }

/* Fields */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field > span { font-size: 13px; color: var(--muted); font-weight: 500; }
.field.inline { margin: 0; }
input, select, textarea {
  font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--line);
  border-radius: 10px; padding: 10px 12px; width: 100%; min-width: 0;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--red); outline-offset: -1px; border-color: transparent; }

/* Auth */
.auth { display: grid; grid-template-columns: 1.3fr 1fr; }
.auth-hero { position: relative; overflow: hidden; background: #000; }
.auth-hero img { width: 100%; height: 100%; object-fit: cover; display: block; opacity: .85; }
.auth-hero::after { content: ""; position: absolute; inset: 0; background: linear-gradient(180deg, rgba(0,0,0,0) 40%, rgba(0,0,0,.85) 100%); }
.auth-hero-text { position: absolute; left: 40px; right: 40px; bottom: 40px; z-index: 1; }
.auth-hero-text h1 { font-size: 44px; font-weight: 700; letter-spacing: -.02em; }
.auth-hero-text p { margin: 6px 0 0; color: #d6d7da; font-size: 17px; }
.eyebrow { display: inline-block; font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .14em; color: var(--red); margin-bottom: 8px; }
.auth-panel { display: flex; flex-direction: column; justify-content: center; padding: 48px; max-width: 460px; width: 100%; margin: 0 auto; }
.seg { display: flex; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 4px; margin-bottom: 24px; }
.seg-btn { flex: 1; background: none; border: 0; color: var(--muted); font: inherit; font-weight: 600; padding: 9px; border-radius: 9px; cursor: pointer; }
.seg-btn.active { background: var(--surface-2); color: var(--text); }

@media (max-width: 860px) {
  .auth { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .auth-hero { height: 260px; }
  .auth-hero-text { left: 16px; right: 16px; bottom: 18px; }
  .auth-hero-text h1 { font-size: 32px; }
  .auth-panel { padding: 24px 16px 40px; }
}

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 28px; }
.card.narrow { max-width: 420px; }
.card p { margin: 10px 0 20px; }

/* Top bar */
.topbar {
  position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 24px;
  padding: 12px 24px; background: rgba(14,15,17,.92); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; letter-spacing: -.01em; white-space: nowrap; }
.brand-mark { width: 22px; height: 4px; background: var(--red); border-radius: 2px; box-shadow: 0 0 12px rgba(227,38,47,.6); }
.tabs { display: flex; gap: 4px; flex: 1; }
.tab { background: none; border: 0; color: var(--muted); font: inherit; font-weight: 600; padding: 8px 14px; border-radius: 8px; cursor: pointer; }
.tab:hover { color: var(--text); }
.tab.active { color: var(--text); background: var(--surface-2); }
.who { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 14px; white-space: nowrap; }

@media (max-width: 720px) {
  .topbar { flex-wrap: wrap; gap: 10px; padding: 10px 16px; }
  .tabs { order: 3; flex-basis: 100%; overflow-x: auto; }
  .who { margin-left: auto; }
  #who-name { display: none; }
}

main { max-width: 1100px; margin: 0 auto; padding: 28px 24px 60px; }
@media (max-width: 720px) { main { padding: 20px 16px 48px; } }

.panel-head { margin-bottom: 18px; }
.panel-head p { margin: 6px 0 0; font-size: 14px; }
.row { display: flex; align-items: center; flex-wrap: wrap; }
.row.gap { gap: 8px; }
.row.space { justify-content: space-between; gap: 12px; }
.panel-head.row { justify-content: space-between; gap: 12px; }

/* Clock */
.clock-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 36px 24px;
  text-align: center; max-width: 520px; margin: 0 auto; position: relative; overflow: hidden;
}
.clock-card::before { content: ""; position: absolute; top: 0; left: 0; right: 0; height: 3px; background: var(--line); }
.clock-card.on::before { background: var(--green); box-shadow: 0 0 16px var(--green); }
.clock-status { display: inline-block; font-size: 13px; font-weight: 600; padding: 4px 12px; border-radius: 999px; background: var(--surface-2); color: var(--muted); }
.clock-card.on .clock-status { background: var(--green-soft); color: var(--green); }
.clock-timer { font-family: var(--mono); font-size: 56px; letter-spacing: .02em; margin: 18px 0 4px; font-variant-numeric: tabular-nums; }
.clock-since { font-size: 14px; margin-bottom: 24px; }
.btn.huge { width: 100%; max-width: 320px; padding: 18px; font-size: 18px; border-radius: 14px; background: var(--red); border-color: var(--red); color: #fff; }
.btn.huge:hover { background: var(--red-hover); }
.btn.huge.out { background: var(--surface-2); border-color: var(--line); color: var(--text); }
.btn.huge.out:hover { background: #2a2d32; }
.break-row { display: flex; gap: 10px; justify-content: center; margin-top: 14px; flex-wrap: wrap; }
.break-row .btn { flex: 1 1 140px; max-width: 155px; }
.break-note { font-size: 12px; margin: 10px 0 0; }
.clock-card.break::before { background: var(--amber); box-shadow: 0 0 16px var(--amber); }
.clock-card.break .clock-status { background: var(--amber-soft); color: var(--amber); }
.clock-card.break.over .clock-timer { color: #ff6b70; }
.brk { font-size: 12px; color: var(--muted); }
.brk .over { color: var(--amber); font-weight: 600; }
@media (max-width: 480px) { .clock-timer { font-size: 44px; } }

.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; max-width: 520px; margin: 16px auto 0; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; display: flex; flex-direction: column; gap: 4px; }
.stat-label { font-size: 12px; color: var(--muted); }
.stat-value { font-size: 18px; font-weight: 700; font-variant-numeric: tabular-nums; }
@media (max-width: 480px) { .stats { grid-template-columns: 1fr 1fr; } .stat:last-child { grid-column: span 2; } }
[data-panel="clock"] h3, [data-panel="clock"] .table-wrap { max-width: 520px; margin-left: auto; margin-right: auto; }

/* Tables */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; font-weight: 600; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .06em; padding: 10px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { padding: 10px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tfoot td { border-top: 1px solid var(--line); font-weight: 700; padding: 10px 14px; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table td.nowrap { white-space: nowrap; }
.table input, .table select { padding: 7px 10px; font-size: 14px; }
.rate-input { display: flex; align-items: center; gap: 6px; max-width: 150px; }
.rate-input input { width: 100px; }
.person strong { display: block; font-weight: 600; }
.person span { color: var(--muted); font-size: 13px; }
tr.pending td { background: var(--amber-soft); }

.badge { display: inline-block; font-size: 12px; font-weight: 600; padding: 3px 9px; border-radius: 999px; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.badge.on { background: var(--green-soft); color: var(--green); }
.badge.wait { background: var(--amber-soft); color: var(--amber); }
.badge.open { background: var(--red-soft); color: #ff6b70; }
.edited { font-size: 12px; color: var(--muted); }
.saved-flash { color: var(--green); font-size: 12px; }

.switch { position: relative; display: inline-block; width: 40px; height: 22px; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; background: var(--line); border-radius: 999px; cursor: pointer; transition: background .15s; }
.switch span::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform .15s; }
.switch input:checked + span { background: var(--green); }
.switch input:checked + span::after { transform: translateX(18px); }

.filters { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.filters .field { width: 170px; }

/* Dialog */
dialog { background: var(--surface); color: var(--text); border: 1px solid var(--line); border-radius: 16px; padding: 24px; width: min(440px, calc(100vw - 32px)); }
dialog::backdrop { background: rgba(0,0,0,.6); }
dialog h3 { color: var(--text); text-transform: none; letter-spacing: 0; font-size: 18px; margin: 0 0 18px; }
.person-line { margin: -4px 0 14px; font-size: 14px; }

/* Pay periods */
.period-note { max-width: 520px; margin: 10px auto 0; font-size: 13px; text-align: center; }
.period-bar { display: flex; align-items: center; gap: 8px; margin-bottom: 18px; flex-wrap: wrap; }
.period-title { min-width: 200px; text-align: center; padding: 0 8px; }
.period-title .eyebrow { margin-bottom: 2px; }
.period-title h2 { font-size: 26px; letter-spacing: -.01em; }
.btn.icon { font-size: 22px; line-height: 1; padding: 4px 14px 8px; }
#ts-current { margin-left: auto; }

.pay-stats { display: grid; grid-template-columns: 1.6fr 1fr 1fr 1fr; gap: 12px; }
.pay-stats .stat.big { background: linear-gradient(135deg, rgba(227,38,47,.18), var(--surface) 70%); border-color: rgba(227,38,47,.35); }
.pay-stats .stat.big .stat-value { font-size: 30px; }
.stat.warn { border-color: rgba(227,38,47,.5); }
.stat.warn .stat-value { color: #ff6b70; }
.warning { margin: 12px 0 0; padding: 10px 14px; border-radius: 10px; background: var(--red-soft); color: #ff8a8e; font-size: 14px; }
@media (max-width: 720px) {
  .pay-stats { grid-template-columns: 1fr 1fr; }
  .pay-stats .stat.big { grid-column: span 2; }
  .period-title { flex: 1; min-width: 0; }
  .period-title h2 { font-size: 21px; }
  #ts-current { margin-left: 0; }
}

.section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin: 28px 0 10px; }
.section-head h3 { margin: 0; }
.table tr.zero td { color: var(--muted); }
.table td.strong { font-weight: 700; }
.custom-range { margin-bottom: 12px; }
.custom-range summary { cursor: pointer; color: var(--muted); font-size: 14px; padding: 4px 0 10px; }
.custom-range summary:hover { color: var(--text); }
.filters .error { flex-basis: 100%; margin: 0; }
@media (max-width: 560px) {
  .payroll-table th:nth-child(2), .payroll-table td:nth-child(2),
  .payroll-table th:nth-child(4), .payroll-table td:nth-child(4) { display: none; }
  .payroll-table td, .payroll-table th { padding: 10px; }
}

/* Team tab: unsaved edits + admin-only fields */
.savebar {
  position: sticky; top: 64px; z-index: 4; display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  margin-bottom: 12px; padding: 10px 14px; border-radius: 12px; background: var(--amber-soft); border: 1px solid rgba(240,167,58,.45); color: var(--amber); font-weight: 600; font-size: 14px;
}
.savebar .error { flex-basis: 100%; order: 3; }
.saved-note { margin: 0 0 12px; color: var(--green); font-weight: 600; font-size: 14px; }
.table tr.dirty td { background: rgba(240,167,58,.07); }
.table tr.dirty td:first-child { box-shadow: inset 3px 0 0 var(--amber); }
.text-input { min-width: 160px; }
.notes-input { font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 7px 10px; font-size: 14px; width: 100%; min-width: 220px; resize: vertical; min-height: 36px; line-height: 1.4; }
.notes-input:focus { outline: 2px solid var(--red); outline-offset: -1px; border-color: transparent; }
@media (max-width: 720px) { .savebar { top: 96px; } }
@media (max-width: 560px) {
  .payroll-table th:nth-child(2), .payroll-table td:nth-child(2) { display: none; }
  .payroll-table th:nth-child(3), .payroll-table td:nth-child(3),
  .payroll-table th:nth-child(5), .payroll-table td:nth-child(5) { display: none; }
  .payroll-table th:nth-child(4), .payroll-table td:nth-child(4) { display: table-cell; }
}
.table select[data-field="role"] { min-width: 100px; }
.table .rate-input input { min-width: 90px; }

/* Invoicing / profit */
.pay-stats { grid-template-columns: 1.4fr 1.2fr 1.2fr 1fr 1fr; }
.table td.pos { color: var(--green); font-weight: 700; }
.table td.neg, .stat.loss .stat-value { color: #ff6b70; font-weight: 700; }
#ts-profit-stat:not(.loss) .stat-value { color: var(--green); }
.warning.soft { background: var(--amber-soft); color: var(--amber); }
@media (max-width: 720px) {
  .pay-stats { grid-template-columns: 1fr 1fr; }
  .pay-stats .stat.big { grid-column: span 2; }
}

/* Today tab */
.today-stats { display: grid; grid-template-columns: repeat(6, 1fr); gap: 12px; margin-bottom: 16px; }
.today-stats .on-text { color: var(--green); }
.today-stats .brk-text { color: var(--amber); }
.badge.brk-badge { background: var(--amber-soft); color: var(--amber); }
.table tr.today-out td { color: var(--muted); }
.table tr.today-out td strong { color: var(--text); opacity: .75; }
.warn-text { color: #ff8a8e; }
.small-note { font-size: 13px; margin: 12px 0 0; }
.punch-sub { margin: -8px 0 16px; font-size: 14px; }
.nowrap-row { flex-wrap: nowrap; }
.nowrap-row input { flex: 1; }
@media (max-width: 900px) { .today-stats { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 560px) {
  .today-stats { grid-template-columns: 1fr 1fr; }
  .today-table th:nth-child(6), .today-table td:nth-child(6) { display: none; }
}
.today-stats .stat:last-child { grid-column: auto; }
@media (max-width: 560px) {
  .today-table th:nth-child(3), .today-table td:nth-child(3),
  .today-table th:nth-child(4), .today-table td:nth-child(4) { display: none; }
  .today-table td, .today-table th { padding: 10px 8px; }
}
@media (max-width: 560px) {
  .today-table .btn.sm { padding: 6px 9px; font-size: 13px; white-space: nowrap; }
  .today-table .badge { font-size: 11px; padding: 3px 7px; }
  .today-table td.person strong { font-size: 14px; }
}
.break-row .btn.full-break { flex: 1 1 100%; max-width: 320px; }

/* ===== Quest start screen ===== */
.quest { position: fixed; inset: 0; z-index: 50; background: #05060a; overflow: hidden; cursor: pointer; animation: questIn .35s ease-out; }
.quest.leaving { animation: questOut .35s ease-in forwards; }
.quest-art { position: absolute; inset: 0; display: flex; justify-content: center; }
.quest-art::before { content: ""; position: absolute; inset: -40px; background: url("quest-hero.webp") center / cover; filter: blur(28px) brightness(.35) saturate(1.2); }
.quest-art img { position: relative; height: 100%; max-width: 100%; object-fit: cover; object-position: center top; transform-origin: 50% 100%; animation: breathe 3.4s ease-in-out infinite; }
.quest-art img.hop { animation: hop .45s ease-out, breathe 3.4s ease-in-out .45s infinite; }
.quest-art::after { content: ""; position: absolute; inset: 0; background: radial-gradient(ellipse at 50% 35%, rgba(255,170,60,.18), transparent 60%); animation: glow 3.4s ease-in-out infinite; pointer-events: none; }
.quest-shade { position: absolute; inset: 0; background: linear-gradient(180deg, rgba(0,0,0,.35) 0%, transparent 25%, transparent 50%, rgba(0,0,0,.85) 100%); pointer-events: none; }
.quest-top { position: absolute; top: 16px; left: 16px; right: 16px; display: flex; justify-content: space-between; }
.quest-chip { font: 10px/1 "Press Start 2P", monospace; color: #fff; background: rgba(0,0,0,.55); border: 2px solid #fff; padding: 7px 9px; letter-spacing: .05em; }
.quest-box {
  position: absolute; left: 50%; bottom: 24px; transform: translateX(-50%); width: min(560px, calc(100vw - 32px));
  background: #0c0d1f; border: 4px solid #fff; box-shadow: 0 0 0 4px #000, 0 12px 40px rgba(0,0,0,.6), inset 0 0 0 3px #2a2c55;
  padding: 26px 20px 18px; color: #fff; animation: boxUp .5s steps(6) both .15s;
}
.quest-name { position: absolute; top: -16px; left: 14px; font: 11px/1 "Press Start 2P", monospace; background: #e3262f; color: #fff; border: 3px solid #fff; box-shadow: 0 0 0 3px #000; padding: 6px 9px; }
.quest-hello { font: 10px/1.6 "Press Start 2P", monospace; color: #ffd23f; margin: 0 0 10px; }
.quest-text { font: 13px/1.9 "Press Start 2P", monospace; margin: 0; min-height: 5.7em; word-spacing: -2px; }
.quest-caret { display: inline-block; margin-left: 6px; font-size: 10px; color: #ffd23f; animation: blink .8s steps(2) infinite; visibility: hidden; }
.quest.typed .quest-caret { visibility: visible; }
.quest-start { display: block; margin: 14px auto 0; font: 11px/1 "Press Start 2P", monospace; color: #fff; background: #e3262f; border: 3px solid #fff; box-shadow: 0 0 0 3px #000, 0 4px 0 3px #000; padding: 11px 16px; cursor: pointer; opacity: .45; }
.quest.typed .quest-start { opacity: 1; animation: blink 1.1s steps(2) infinite; }
.quest-start:active { transform: translateY(3px); box-shadow: 0 0 0 3px #000; }
@media (max-width: 480px) { .quest-text { font-size: 11px; } .quest-hello { font-size: 9px; } }

@keyframes breathe { 0%, 100% { transform: scale(1.0) translateY(0); } 50% { transform: scale(1.018) translateY(-5px); } }
@keyframes hop { 0% { transform: translateY(0); } 40% { transform: translateY(-14px); } 100% { transform: translateY(0); } }
@keyframes glow { 0%, 100% { opacity: .55; } 50% { opacity: 1; } }
@keyframes blink { 50% { opacity: 0; } }
@keyframes boxUp { from { transform: translate(-50%, 140%); } to { transform: translate(-50%, 0); } }
@keyframes questIn { from { opacity: 0; } }
@keyframes questOut { to { opacity: 0; } }

/* ===== Comic burst ===== */
.burst { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; background: rgba(0,0,0,.55); cursor: pointer; animation: questIn .15s ease-out; }
.burst.leaving { animation: questOut .3s ease-in forwards; }
.burst-dots { position: absolute; inset: -50%; background: radial-gradient(circle, rgba(255,210,63,.32) 2.2px, transparent 2.8px) 0 0 / 16px 16px; animation: dots 1.8s ease-out; }
.burst-card { position: relative; width: 320px; height: 320px; display: grid; place-items: center; animation: pop .5s cubic-bezier(.2, 1.6, .4, 1) both; }
.burst-star { position: absolute; inset: 0; width: 100%; height: 100%; fill: #ffd23f; stroke: #000; stroke-width: 5; stroke-linejoin: round; filter: drop-shadow(6px 6px 0 #e3262f); animation: spinIn .6s ease-out; }
.burst.out .burst-star { fill: #39d98a; }
.burst.rest .burst-star { fill: #7cc4ff; }
.burst.back .burst-star { fill: #ff9f43; }
.burst-face { position: absolute; top: 22px; width: 116px; height: 116px; border-radius: 6px; border: 4px solid #000; object-fit: cover; box-shadow: 5px 5px 0 #000; background: #000; transform: rotate(-4deg); }
.burst-word { position: relative; margin-top: 96px; font: 50px/0.95 "Bangers", Impact, sans-serif; letter-spacing: 1px; color: #fff; text-align: center; -webkit-text-stroke: 2px #000; text-shadow: 4px 4px 0 #000, 6px 6px 0 #e3262f; transform: rotate(-5deg); padding: 0 30px; }
.burst-sub { position: absolute; bottom: 52px; font: 10px/1.4 "Press Start 2P", monospace; color: #000; background: #fff; border: 3px solid #000; padding: 6px 8px; max-width: 230px; text-align: center; transform: rotate(-2deg); }
.shake { animation: shake .4s ease-in-out; }
@keyframes pop { from { transform: scale(0) rotate(-20deg); } to { transform: scale(1) rotate(0); } }
@keyframes spinIn { from { transform: rotate(-45deg); } to { transform: rotate(0); } }
@keyframes dots { from { transform: scale(.6); opacity: 0; } 30% { opacity: 1; } to { transform: scale(1.1); } }
@keyframes shake { 0%, 100% { transform: translate(0); } 20% { transform: translate(-6px, 2px); } 40% { transform: translate(5px, -3px); } 60% { transform: translate(-4px, 3px); } 80% { transform: translate(3px, -1px); } }

@media (prefers-reduced-motion: reduce) {
  .quest, .quest-art img, .quest-art::after, .quest-box, .quest-caret, .quest.typed .quest-start,
  .burst, .burst-dots, .burst-card, .burst-star, .shake { animation: none !important; }
}
.burst-word.long { font-size: 40px; margin-top: 90px; padding: 0 44px; }
.burst-sub { bottom: 40px; }

/* Team: start date, save game */
.date-input { font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 6px 8px; font-size: 14px; color-scheme: dark; }
.date-input:focus { outline: 2px solid var(--red); outline-offset: -1px; border-color: transparent; }
.save-game { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; margin: 0 0 16px; }
.save-game > div { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1 1 260px; }
.save-game strong { font-family: "Press Start 2P", monospace; font-size: 11px; letter-spacing: .5px; }
.save-game span { font-size: 13px; }
.save-game .error { flex-basis: 100%; margin: 0; }
.burst.save .burst-star { fill: #b48cff; }

/* Late from break: cinematic eyes close-up over a red burst */
.burst-eyes { display: none; position: absolute; left: 0; right: 0; top: 9%; height: 150px; background: #000; border-block: 6px solid #000; box-shadow: 0 0 0 3px #e3262f; overflow: hidden; }
.burst-eyes img { display: block; height: 100%; width: 100%; max-width: 640px; margin: 0 auto; object-fit: cover; object-position: center 45%; -webkit-mask-image: linear-gradient(90deg, transparent, #000 12%, #000 88%, transparent); mask-image: linear-gradient(90deg, transparent, #000 12%, #000 88%, transparent); animation: eyesIn .7s cubic-bezier(.2, .9, .3, 1) both; }
.burst.late { background: rgba(40,0,0,.72); }
.burst.late .burst-eyes { display: block; }
.burst.late .burst-dots { background-image: radial-gradient(circle, rgba(227,38,47,.4) 2.2px, transparent 2.8px); }
.burst.late .burst-card { margin-top: 170px; animation-delay: .35s; }
.burst.late .burst-star { fill: #e3262f; filter: drop-shadow(6px 6px 0 #000); }
.burst.late .burst-face { display: none; }
.burst.late .burst-word { margin-top: 0; text-shadow: 4px 4px 0 #000, 6px 6px 0 #ffd23f; }
@keyframes eyesIn { from { transform: scale(1.6); filter: brightness(2.2); } to { transform: scale(1); filter: brightness(1); } }
@media (max-width: 480px) { .burst-eyes { height: 110px; } .burst.late .burst-card { margin-top: 130px; } }
@media (prefers-reduced-motion: reduce) { .burst-eyes img { animation: none; } }

/* "by Devvo" next to the Clockwise name */
.by { font-weight: 500; opacity: .6; font-size: .72em; margin-left: 2px; }

/* Requests, bonuses, pay stubs */
.tab-count { display: inline-grid; place-items: center; min-width: 18px; height: 18px; padding: 0 5px; margin-left: 4px; border-radius: 999px; background: var(--red); color: #fff; font-size: 11px; font-weight: 700; vertical-align: 1px; }
.req-list { display: flex; flex-direction: column; gap: 10px; margin-bottom: 8px; }
.req-card { display: flex; align-items: center; justify-content: space-between; gap: 14px; border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; background: var(--surface); }
.req-main { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.req-top { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.req-reason { font-size: 13px; overflow-wrap: anywhere; }
.badge.deny { background: var(--red-soft); color: #ff6b70; }
.badge.off-badge { background: rgba(124,196,255,.14); color: #7cc4ff; }
.link-btn { background: none; border: 0; padding: 0; font: inherit; color: var(--text); text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }
.link-btn:disabled { color: var(--muted); text-decoration: none; cursor: not-allowed; }
.check { display: flex; align-items: center; gap: 8px; margin-bottom: 14px; font-weight: 500; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--red); }
.text-input { font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 6px 10px; font-size: 14px; width: 150px; }
.text-input:focus { outline: 2px solid var(--red); outline-offset: -1px; border-color: transparent; }
.small { font-size: 13px; }
.company-form { max-width: 520px; }
.two-col > .field { flex: 1 1 140px; }
.decide-summary p { margin: 0 0 8px; }
.decide-summary { margin-bottom: 12px; }
#decide-pto-calc { line-height: 1.6; }
@media (max-width: 560px) {
  .payroll-table th, .payroll-table td { display: table-cell !important; }
  .payroll-table th:nth-child(2), .payroll-table td:nth-child(2),
  .payroll-table th:nth-child(3), .payroll-table td:nth-child(3),
  .payroll-table th:nth-child(4), .payroll-table td:nth-child(4),
  .payroll-table th:nth-child(5), .payroll-table td:nth-child(5),
  .payroll-table th:nth-child(8), .payroll-table td:nth-child(8),
  .payroll-table th:nth-child(9), .payroll-table td:nth-child(9),
  .payroll-table th:nth-child(10), .payroll-table td:nth-child(10) { display: none !important; }
  .req-card { flex-direction: column; align-items: stretch; }
}
[data-panel="clock"] .section-head, [data-panel="clock"] #pto-balance { max-width: 520px; margin-left: auto; margin-right: auto; }
textarea { resize: vertical; line-height: 1.4; }
.tab { white-space: nowrap; }
.tabs { scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.payroll-table .btn, .payroll-table .link-btn { white-space: nowrap; }

/* Shift fix: break rows */
.brk-edit { border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; margin-bottom: 14px; }
.brk-edit-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; font-size: 13px; color: var(--muted); font-weight: 500; }
.brk-row { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr) auto; gap: 6px; align-items: center; margin-bottom: 10px; padding-bottom: 10px; border-bottom: 1px dashed var(--line); }
.brk-row select { grid-column: 1 / -1; }
#req-dialog { width: min(480px, calc(100vw - 32px)); }
.brk-row input, .brk-row select { padding: 8px; font-size: 14px; }
.brk-edit .small { margin: 0; }

/* Disappointed Chris: big panel + speech bubble */
.burst.scold { background: rgba(10,10,14,.78); }
.burst.scold .burst-star { fill: #3a3d46; filter: drop-shadow(6px 6px 0 #e3262f); }
.burst.scold .burst-dots { background-image: radial-gradient(circle, rgba(227,38,47,.3) 2.2px, transparent 2.8px); }
.burst.scold .burst-face { top: -36px; width: 170px; height: 170px; transform: rotate(3deg); box-shadow: 6px 6px 0 #e3262f; }
.burst.scold .burst-word { margin-top: 118px; font-size: 54px; }
.burst.scold .burst-sub { bottom: 34px; }
.burst-bubble { position: absolute; top: -78px; left: 58%; z-index: 2; width: max-content; max-width: 210px; background: #fff; color: #000; border: 4px solid #000; border-radius: 22px; padding: 10px 14px; font: 22px/1.05 "Bangers", Impact, sans-serif; letter-spacing: .5px; text-align: center; box-shadow: 4px 4px 0 #000; transform: rotate(4deg); animation: bubbleIn .45s .35s cubic-bezier(.2, 1.6, .4, 1) both; }
.burst-bubble::after { content: ""; position: absolute; left: 24px; bottom: -12px; width: 18px; height: 18px; background: #fff; border-right: 4px solid #000; border-bottom: 4px solid #000; transform: rotate(45deg); }
@keyframes bubbleIn { from { transform: scale(0) rotate(-10deg); opacity: 0; } to { transform: scale(1) rotate(4deg); opacity: 1; } }
@media (max-width: 480px) { .burst-bubble { left: 46%; top: -86px; max-width: 170px; font-size: 19px; } .burst.scold .burst-face { width: 150px; height: 150px; } }
@media (prefers-reduced-motion: reduce) { .burst-bubble { animation: none; } }

/* ===== Pay type, orgs, paid status ===== */
.pay-cell { display: flex; align-items: center; gap: 6px; }
.pay-cell select { width: auto; padding: 8px; font-size: 13px; }
.pay-cell .rate-input input { width: 96px; }
.pay-cell .unit { font-size: 12px; }
.org-chips { display: inline-flex; flex-wrap: wrap; gap: 4px; vertical-align: middle; }
.org-chips.sm { display: flex; margin-top: 4px; }
.org-chip { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 999px; color: var(--c); background: color-mix(in srgb, var(--c) 16%, transparent); border: 1px solid color-mix(in srgb, var(--c) 40%, transparent); white-space: nowrap; }
.org-chips.sm .org-chip { font-size: 11px; padding: 1px 6px; }
.org-chip.big { font-size: 13px; padding: 4px 6px 4px 10px; }
.org-chip .link-btn { color: inherit; text-decoration: none; font-weight: 700; }
.org-x { background: none; border: 0; color: inherit; font-size: 16px; line-height: 1; cursor: pointer; padding: 0 2px; opacity: .7; }
.org-x:hover { opacity: 1; }
.org-manager .org-chips { margin-top: 10px; }
.org-manager form input { width: 180px; }
.org-btn { background: none; border: 1px dashed var(--line); border-radius: 10px; padding: 6px 8px; cursor: pointer; color: var(--text); font: inherit; min-width: 70px; text-align: left; }
.org-btn:hover { border-color: var(--muted); }
.org-filter { margin: 0 0 12px; }
.org-filter select { width: auto; min-width: 160px; }
.my-orgs { margin-top: -6px; }
.wise-link { font-size: 12px; color: var(--text); }
.paid-btn .badge { cursor: pointer; }
.paid-note { margin: 8px 0 0; }
#orgs-checks { display: flex; flex-direction: column; gap: 2px; margin-bottom: 12px; max-height: 50vh; overflow: auto; }

/* ===== Hangout ===== */
.office { position: relative; border: 4px solid #000; border-radius: 10px; overflow: hidden; margin-bottom: 20px; box-shadow: 6px 6px 0 #000;
  background:
    repeating-linear-gradient(0deg, transparent 0 22px, rgba(0,0,0,.18) 22px 24px),
    repeating-linear-gradient(90deg, transparent 0 46px, rgba(0,0,0,.12) 46px 48px),
    linear-gradient(#3b2f4a, #2c2438); }
.office::after { content: ""; position: absolute; left: 0; right: 0; bottom: 46px; height: 10px; background: #1b1424; border-top: 3px solid #000; }
.office-sign { display: flex; justify-content: center; padding-top: 14px; }
.office-sign span { font: 11px/1 "Press Start 2P", monospace; color: #fff; background: #1b1b1d; padding: 8px 14px; border: 3px solid #000; box-shadow: inset 0 -3px 0 #e3262f, 3px 3px 0 #000; letter-spacing: 2px; }
.office-clocks { position: relative; z-index: 1; display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; padding: 18px 18px 76px; max-width: 760px; margin: 0 auto; }
.wall-clock { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.wall-clock svg { width: min(110px, 100%); height: auto; filter: drop-shadow(4px 4px 0 #000); }
.wall-clock.night svg circle:first-child { fill: #c9c2b0; }
.wc-plate { display: flex; flex-direction: column; align-items: center; gap: 5px; background: #6b4a2b; border: 3px solid #000; padding: 6px 8px; box-shadow: 3px 3px 0 #000; min-width: 112px; }
.wc-city { font: 9px/1 "Press Start 2P", monospace; color: #ffd23f; letter-spacing: 1px; }
.wc-time { font: 600 13px/1 "JetBrains Mono", monospace; color: #fff; white-space: nowrap; }
.office-floor { position: absolute; left: 0; right: 0; bottom: 0; height: 46px; background: repeating-linear-gradient(90deg, #7a5230 0 58px, #6b4626 58px 60px); border-top: 3px solid #000; }
.office-floor .plant { position: absolute; left: 14px; bottom: 30px; font-size: 40px; }
.office-floor .cooler { position: absolute; right: 18px; bottom: 30px; font-size: 34px; }
@media (max-width: 640px) {
  .office-clocks { grid-template-columns: repeat(2, 1fr); padding-bottom: 70px; }
  .office-floor .plant, .office-floor .cooler { font-size: 28px; bottom: 34px; }
}

.hang-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; align-items: start; }
@media (max-width: 860px) { .hang-grid { grid-template-columns: 1fr; } }
.hang-grid h3 { margin-top: 0; }
.post-form { display: flex; flex-direction: column; gap: 8px; margin-bottom: 14px; }
.post-form button { align-self: flex-end; }
.board-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 14px; }
.note { position: relative; background: var(--note); color: #1a1a1a; padding: 14px 14px 10px; border: 3px solid #000; box-shadow: 4px 4px 0 #000; transform: rotate(-1deg); display: flex; flex-direction: column; gap: 8px; }
.note:nth-child(even) { transform: rotate(1.2deg); }
.note.pinned { outline: 3px solid #e3262f; outline-offset: -8px; }
.note .pin { position: absolute; top: -14px; right: 10px; font-size: 22px; }
.note-text { font-size: 15px; line-height: 1.4; overflow-wrap: anywhere; }
.note-meta { font-size: 12px; color: #333; }
.note-actions { display: flex; gap: 10px; font-size: 12px; }
.note-actions .link-btn { color: #1a1a1a; }

.chat { display: flex; flex-direction: column; }
.chat-list { height: 460px; overflow-y: auto; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); padding: 12px; display: flex; flex-direction: column; gap: 10px; }
.chat-day { align-self: center; font: 9px/1 "Press Start 2P", monospace; color: var(--muted); padding: 6px 0; }
.chat-empty { margin: auto; }
.msg { display: flex; flex-direction: column; align-items: flex-start; max-width: 82%; }
.msg.mine { align-self: flex-end; align-items: flex-end; }
.msg-name { font-size: 12px; font-weight: 700; color: var(--muted); margin: 0 0 3px 4px; }
.bubble { background: var(--surface-2); padding: 8px 12px; border-radius: 14px 14px 14px 4px; font-size: 15px; line-height: 1.4; overflow-wrap: anywhere; border: 2px solid #000; box-shadow: 2px 2px 0 #000; }
.msg.mine .bubble { background: var(--red); color: #fff; border-radius: 14px 14px 4px 14px; }
.msg:last-child .bubble { animation: msgPop .25s ease-out; }
@keyframes msgPop { from { transform: scale(.85); opacity: 0; } }
.msg-meta { font-size: 11px; color: var(--muted); margin-top: 3px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.msg-tools { display: inline-flex; gap: 2px; align-items: center; opacity: 0; transition: opacity .15s; }
.msg:hover .msg-tools, .msg:focus-within .msg-tools { opacity: 1; }
@media (hover: none) { .msg-tools { opacity: .8; } }
.msg-tools .link-btn { font-size: 11px; color: var(--muted); margin-left: 4px; }
.react-add { background: none; border: 0; cursor: pointer; font-size: 14px; padding: 0 2px; }
.reacts { display: flex; gap: 4px; margin-top: 4px; flex-wrap: wrap; }
.react { background: var(--surface-2); border: 1px solid var(--line); border-radius: 999px; padding: 1px 7px; font-size: 12px; cursor: pointer; color: var(--text); }
.react.mine { border-color: var(--red); background: var(--red-soft); }
.chat-form { display: flex; gap: 8px; margin-top: 10px; }
@media (prefers-reduced-motion: reduce) { .msg:last-child .bubble { animation: none; } }
@media (max-width: 560px) {
  .payroll-table th:nth-child(6), .payroll-table td:nth-child(6) { display: none !important; }
}

#shift-dialog { width: min(480px, calc(100vw - 32px)); }

/* ===== Weekly cap ===== */
.cap-bar { max-width: 520px; margin: 0 auto 18px; border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; background: var(--surface); }
.cap-top { display: flex; justify-content: space-between; align-items: baseline; font-size: 13px; color: var(--muted); }
.cap-top strong { font: 600 16px "JetBrains Mono", monospace; color: var(--text); }
.cap-track { height: 12px; background: var(--surface-2); border: 2px solid #000; border-radius: 4px; margin: 8px 0; overflow: hidden; }
.cap-fill { height: 100%; width: 0; background: #39d98a; transition: width .4s; background-image: repeating-linear-gradient(90deg, transparent 0 10px, rgba(0,0,0,.18) 10px 12px); }
.cap-bar.near .cap-fill { background-color: #ffd23f; }
.cap-bar.over .cap-fill { background-color: var(--red); }
.cap-bar.over { border-color: var(--red); }
.cap-note { font-size: 13px; color: var(--muted); margin: 0 0 6px; }
.cap-bar.over .cap-note { color: #ff6b70; }
.cap-input input { width: 70px; }
.week-chip { font: 600 12px "JetBrains Mono", monospace; background: var(--surface-2); color: var(--text); border: 1px solid var(--line); border-radius: 8px; padding: 4px 8px; cursor: pointer; white-space: nowrap; }
.week-chip.near { border-color: #ffd23f; color: #ffd23f; }
.week-chip.over { border-color: var(--red); color: #ff6b70; background: var(--red-soft); }
.over-cap { font-size: 11px; color: #ff6b70; text-align: right; margin-top: 3px; white-space: nowrap; }
.over-cap .link-btn { color: #ff6b70; font-size: 11px; }
#week-dialog { width: min(560px, calc(100vw - 24px)); }
.week-nav { margin-bottom: 12px; }
.week-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 8px; }
.week-stats div { border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; display: flex; flex-direction: column; }
.week-stats span { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.week-stats strong { font: 600 18px "JetBrains Mono", monospace; }
.week-stats .neg strong { color: #ff6b70; }
.week-events { list-style: none; padding: 0; margin: 8px 0 12px; display: flex; flex-direction: column; gap: 6px; font-size: 13px; }
.week-events li { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; border-bottom: 1px dashed var(--line); padding-bottom: 6px; }
.week-form { border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; margin-bottom: 12px; flex: 1 1 220px; }
.week-form h4 { margin: 0 0 4px; font-size: 14px; }
.week-form .field { flex: 1 1 120px; margin-bottom: 8px; }
.week-form .row > input { flex: 1 1 80px; min-width: 0; margin-bottom: 8px; }
.week-forms { align-items: stretch; }
.wrap { flex-wrap: wrap; }

/* ===== Memos ===== */
.memos { margin-bottom: 22px; }
.memo-form { display: flex; flex-direction: column; gap: 8px; border: 1px dashed var(--line); border-radius: 12px; padding: 12px; margin-bottom: 12px; }
.memo-send { align-items: flex-end; justify-content: space-between; flex-wrap: wrap; }
.memo-send .field { margin: 0; }
.memo-list { display: flex; flex-direction: column; gap: 10px; }
.memo { border: 3px solid #000; border-radius: 10px; background: var(--surface); padding: 12px 14px; box-shadow: 4px 4px 0 #000; display: flex; flex-direction: column; gap: 8px; }
.memo.off { opacity: .55; }
.memo-head { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; align-items: baseline; }
.memo-body { font-size: 14px; line-height: 1.45; overflow-wrap: anywhere; }
.memo-stats { display: flex; flex-direction: column; gap: 4px; font-size: 13px; }
.memo-stats details p { margin: 4px 0 0; }
.memo-actions { display: flex; gap: 12px; font-size: 12px; }
.memo .btn { align-self: flex-start; }
.memo-pop { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; padding: 16px; background: rgba(5,5,10,.82); backdrop-filter: blur(3px); }
.memo-pop[hidden] { display: none; }
.memo-card { position: relative; width: min(520px, 100%); max-height: calc(100vh - 32px); overflow-y: auto; background: #14141a; border: 4px solid #000; box-shadow: 0 0 0 3px #e3262f, 8px 8px 0 #000; border-radius: 6px; padding: 18px 20px 20px; animation: memoIn .35s cubic-bezier(.2, 1.4, .4, 1) both; }
.memo-chip { display: flex; justify-content: space-between; font: 10px/1 "Press Start 2P", monospace; color: #ffd23f; letter-spacing: 1px; margin-bottom: 12px; }
.memo-face { float: right; width: 92px; height: 92px; object-fit: cover; border: 3px solid #000; box-shadow: 3px 3px 0 #e3262f; margin: 0 0 8px 12px; transform: rotate(3deg); }
.memo-card h2 { font: 400 28px/1.05 "Bangers", Impact, sans-serif; letter-spacing: 1px; margin: 4px 0 10px; }
.memo-text { font-size: 15px; line-height: 1.5; margin-bottom: 12px; overflow-wrap: anywhere; clear: none; }
.memo-ack { display: block; width: 100%; margin-top: 8px; clear: both; }
@keyframes memoIn { from { transform: scale(.6) translateY(30px); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .memo-card { animation: none; } }
.memo-ack { opacity: 1; }
.memo-stats .badge, .memo > .badge { align-self: flex-start; }
.week-form .row { align-items: flex-end; }
.week-form .field input, .week-form .field select { height: 42px; }
