:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #f0f2f5;
  --border: #e1e4ea;
  --text: #1d2433;
  --muted: #5f6b7c;
  --brand: #1f3a5f;
  --brand-ink: #ffffff;
  --accent: #2f6fde;
  --ok: #157f3b;      --ok-bg: #e4f4ea;
  --warn: #9a5b00;    --warn-bg: #fdf1dc;
  --bad: #b42318;     --bad-bg: #fde8e6;
  --info: #2f5fb3;    --info-bg: #e5edfb;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #11151c; --surface: #181e27; --surface-2: #202834; --border: #2c3644;
    --text: #e7ebf1; --muted: #9aa6b6; --brand: #2a4b78; --accent: #6b9cf0;
    --ok: #5fcf88; --ok-bg: #173323; --warn: #f0b552; --warn-bg: #3a2c12;
    --bad: #f28b82; --bad-bg: #3d1d1b; --info: #8fb2f2; --info-bg: #1c2a44;
    --shadow: none; color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body { font: 15px/1.45 Inter, system-ui, -apple-system, "Segoe UI", sans-serif; -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); }
h1, h2, h3 { margin: 0; line-height: 1.2; }
h1 { font-size: 22px; font-weight: 700; }
h2 { font-size: 17px; font-weight: 600; }
.boot { padding: 40px; text-align: center; color: var(--muted); }

/* ---------- shell ---------- */
.topbar { background: var(--brand); color: var(--brand-ink); position: sticky; top: 0; z-index: 10; }
.topbar-inner { max-width: 1240px; margin: 0 auto; display: flex; align-items: center; gap: 16px; padding: 0 16px; height: 56px; }
.brand { font-weight: 700; letter-spacing: .2px; white-space: nowrap; }
.nav { display: flex; gap: 2px; overflow-x: auto; flex: 1; scrollbar-width: none; }
.nav::-webkit-scrollbar { display: none; }
.nav a { color: rgba(255,255,255,.78); text-decoration: none; padding: 8px 12px; border-radius: 8px; white-space: nowrap; font-weight: 500; position: relative; }
.nav a:hover { color: #fff; background: rgba(255,255,255,.08); }
.nav a.active { color: #fff; background: rgba(255,255,255,.16); }
.badge { display: inline-block; min-width: 18px; padding: 0 5px; margin-left: 6px; border-radius: 9px; background: #e5484d; color: #fff; font-size: 11px; line-height: 18px; text-align: center; font-weight: 700; }
.who { display: flex; align-items: center; gap: 10px; white-space: nowrap; font-size: 13px; }
.who a { color: #fff; opacity: .85; }
.role-chip { background: rgba(255,255,255,.16); padding: 2px 8px; border-radius: 999px; font-size: 12px; }
main { max-width: 1240px; margin: 0 auto; padding: 20px 16px 60px; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.page-head .sub { color: var(--muted); font-size: 13px; margin-top: 4px; }

/* ---------- controls ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid var(--border); background: var(--surface); padding: 8px 14px; border-radius: 8px; cursor: pointer; font-weight: 500; white-space: nowrap; }
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(1.06); }
.btn.danger { color: var(--bad); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.sm { padding: 4px 10px; font-size: 13px; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
label.field { display: grid; gap: 4px; font-size: 13px; font-weight: 500; color: var(--muted); }
label.field > span.hint { font-weight: 400; font-size: 12px; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], input[type=time], input[type=tel], select, textarea {
  width: 100%; border: 1px solid var(--border); background: var(--surface); border-radius: 8px; padding: 8px 10px; color: var(--text);
}
textarea { min-height: 70px; resize: vertical; }
input:focus, select:focus, textarea:focus, .btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.toolbar select, .toolbar input { width: auto; }
.check { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; color: var(--text); font-weight: 400; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.stack { display: grid; gap: 12px; }

/* ---------- cards & tables ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-pad { padding: 16px; }
.card + .card { margin-top: 16px; }
.stats > .card { margin-top: 0; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font-weight: 600; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; padding: 10px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; }
td { padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
tfoot td { font-weight: 600; background: var(--surface-2); }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.empty { padding: 32px; text-align: center; color: var(--muted); }
.pill { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.pill.ok { color: var(--ok); background: var(--ok-bg); }
.pill.warn { color: var(--warn); background: var(--warn-bg); }
.pill.bad { color: var(--bad); background: var(--bad-bg); }
.pill.info { color: var(--info); background: var(--info-bg); }
.pill.neutral { color: var(--muted); background: var(--surface-2); }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat { padding: 14px 16px; }
.stat .k { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; font-weight: 600; }
.stat .v { font-size: 24px; font-weight: 700; margin-top: 4px; font-variant-numeric: tabular-nums; }
.section-title { margin: 24px 0 10px; display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; }
.notice { padding: 12px 14px; border-radius: 8px; background: var(--warn-bg); color: var(--warn); font-size: 14px; margin-bottom: 16px; }
.notice.info { background: var(--info-bg); color: var(--info); }

/* ---------- week board ---------- */
.week { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 8px; }
.day { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); min-height: 180px; display: flex; flex-direction: column; }
.day.today { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.day-head { padding: 8px 10px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: baseline; }
.day-head b { font-size: 13px; }
.day-head span { font-size: 12px; color: var(--muted); }
.day-body { padding: 6px; display: grid; gap: 6px; align-content: start; flex: 1; }
.add-day { border: 1px dashed var(--border); background: transparent; color: var(--muted); border-radius: 8px; padding: 4px; cursor: pointer; font-size: 12px; }
.add-day:hover { color: var(--accent); border-color: var(--accent); }
.shift { text-align: left; width: 100%; border: 1px solid var(--border); border-left: 4px solid var(--info); background: var(--surface-2); border-radius: 8px; padding: 6px 8px; cursor: pointer; font-size: 12.5px; line-height: 1.35; }
.shift:hover { filter: brightness(.98); }
.shift .t { font-weight: 600; }
.shift .n { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.shift.s-done { border-left-color: var(--ok); }
.shift.s-working { border-left-color: var(--accent); }
.shift.s-missed-in, .shift.s-missed-out { border-left-color: var(--bad); }
.shift.s-cancelled { opacity: .55; text-decoration: line-through; border-left-color: var(--muted); }
@media (max-width: 900px) {
  .week { grid-template-columns: 1fr; }
  .day { min-height: 0; }
  .grid3 { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 560px) {
  .grid2, .grid3 { grid-template-columns: 1fr; }
  .who .name { display: none; }
  h1 { font-size: 20px; }
}

/* ---------- VA ---------- */
.hero { padding: 22px; display: grid; gap: 14px; }
.hero .label { font-size: 12px; text-transform: uppercase; letter-spacing: .05em; font-weight: 600; color: var(--muted); }
.hero .client { font-size: 22px; font-weight: 700; }
.hero .when { color: var(--muted); }
.hero .timer { font-size: 40px; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -.5px; }
.clock-btn { font-size: 18px; font-weight: 700; padding: 16px; border-radius: 12px; border: 0; cursor: pointer; color: #fff; width: 100%; }
.clock-btn.in { background: var(--ok); }
.clock-btn.out { background: var(--bad); }
.clock-btn:disabled { opacity: .6; }
.va-wrap { max-width: 640px; margin: 0 auto; }
.va-day { padding: 12px 16px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.va-day:last-child { border-bottom: 0; }
.va-day .d { font-weight: 600; min-width: 92px; }
.va-day .items { flex: 1; display: grid; gap: 6px; }

/* ---------- auth ---------- */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.auth .card { width: 100%; max-width: 380px; padding: 28px; display: grid; gap: 14px; }
.auth .logo { width: 44px; height: 44px; border-radius: 12px; background: var(--brand); color: #fff; display: grid; place-items: center; font-weight: 700; }

/* ---------- dialog & toast ---------- */
dialog { border: 0; border-radius: 14px; padding: 0; width: min(560px, calc(100vw - 24px)); background: var(--surface); color: var(--text); box-shadow: 0 20px 50px rgba(0,0,0,.25); }
dialog::backdrop { background: rgba(15, 20, 30, .45); }
.modal-head { padding: 16px 20px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; }
.modal-body { padding: 18px 20px; display: grid; gap: 12px; max-height: 70vh; overflow-y: auto; }
.modal-foot { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.modal-foot .right { display: flex; gap: 8px; margin-left: auto; }
.form-error { color: var(--bad); font-size: 14px; min-height: 0; }
#toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(20px); background: #1d2433; color: #fff; padding: 10px 16px; border-radius: 10px; font-size: 14px; opacity: 0; pointer-events: none; transition: .2s; z-index: 100; max-width: calc(100vw - 32px); }
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast.err { background: var(--bad); }

[hidden] { display: none !important; }

/* ---------- month view ---------- */
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.seg .btn { border: 0; border-radius: 0; }
.seg .btn.on { background: var(--brand); color: #fff; }
.month { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; background: var(--border); gap: 1px; }
.mhead { background: var(--surface-2); padding: 8px; font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; text-align: center; }
.mday { background: var(--surface); min-height: 118px; padding: 6px; display: flex; flex-direction: column; gap: 3px; position: relative; }
.mday.out { background: var(--surface-2); }
.mday.out .dnum { color: var(--muted); }
.mday.today { box-shadow: inset 0 0 0 2px var(--accent); }
.mday-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 2px; }
.mday .dnum { font-weight: 600; font-size: 13px; }
.mday.today .dnum { background: var(--accent); color: #fff; border-radius: 999px; padding: 0 7px; }
.mday .dname { display: none; }
.mshift { text-align: left; border: 0; border-left: 3px solid var(--info); background: var(--surface-2); border-radius: 4px; padding: 2px 5px; font-size: 12px; line-height: 1.35; cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; width: 100%; }
.mshift .mt { font-weight: 600; }
.mshift.s-done { border-left-color: var(--ok); }
.mshift.s-working { border-left-color: var(--accent); }
.mshift.s-missed-in, .mshift.s-missed-out { border-left-color: var(--bad); background: var(--bad-bg); }
.mshift.s-cancelled { opacity: .55; text-decoration: line-through; border-left-color: var(--muted); }
.mmore { border: 0; background: none; color: var(--accent); font-size: 12px; text-align: left; padding: 0 5px; cursor: pointer; }
.madd { position: absolute; top: 4px; right: 4px; width: 22px; height: 22px; border-radius: 6px; border: 1px dashed var(--border); background: transparent; color: var(--muted); cursor: pointer; opacity: 0; font-size: 14px; line-height: 1; }
.mday:hover .madd, .madd:focus-visible { opacity: 1; }
.mday:hover .mday-head > .muted { visibility: hidden; }
@media (max-width: 760px) {
  .month { grid-template-columns: 1fr; }
  .mhead { display: none; }
  .mday { min-height: 0; }
  .mday.out { display: none; }
  .mday .dnum { display: none; }
  .mday .dname { display: inline; font-weight: 600; font-size: 13px; }
  .madd { opacity: 1; }
  .mday-head > .muted { display: none; }
  .mday:not(:has(.mshift)) { display: none; }
}
