@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

:root {
  --bg: #f4f6f8;
  --card: #ffffff;
  --ink: #0f1b2d;
  --muted: #5d6b7e;
  --line: #e2e7ee;
  --brand: #1d4ed8;
  --brand-ink: #ffffff;
  --brand-soft: #e8efff;
  --ok: #15803d;
  --ok-soft: #e8f6ec;
  --warn: #b45309;
  --warn-soft: #fdf3e3;
  --bad: #b91c1c;
  --bad-soft: #fdecec;
  --info: #0369a1;
  --info-soft: #e0f2fe;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(15, 27, 45, .06), 0 4px 16px rgba(15, 27, 45, .05);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d141f;
    --card: #141e2c;
    --ink: #e7edf5;
    --muted: #93a2b6;
    --line: #243246;
    --brand: #60a5fa;
    --brand-ink: #06142e;
    --brand-soft: #13254a;
    --ok: #4ade80;
    --ok-soft: #12301f;
    --warn: #fbbf24;
    --warn-soft: #362a10;
    --bad: #f87171;
    --bad-soft: #3a1717;
    --info: #7dd3fc;
    --info-soft: #0c2a3d;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.5 Inter, system-ui, -apple-system, 'Segoe UI', sans-serif;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5em; letter-spacing: -.01em; }
a { color: var(--brand); }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.num { font-variant-numeric: tabular-nums; }
.hidden { display: none !important; }

/* Botões e campos */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid var(--line); background: var(--card); color: var(--ink);
  padding: 9px 14px; border-radius: 9px; font: inherit; font-weight: 600; cursor: pointer;
  text-decoration: none; white-space: nowrap;
}
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--bad); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.sm { padding: 5px 10px; font-size: 13px; }
.btn:disabled { opacity: .6; cursor: default; }

label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 4px; }
input, select, textarea {
  width: 100%; padding: 9px 11px; border-radius: 9px; border: 1px solid var(--line);
  background: var(--card); color: var(--ink); font: inherit;
}
input:focus, select:focus, textarea:focus, .btn:focus-visible { outline: 2px solid var(--brand); outline-offset: 1px; }
.field { margin-bottom: 14px; }
.hint { font-size: 12px; color: var(--muted); margin-top: 4px; }
.row { display: flex; gap: 12px; flex-wrap: wrap; }
.row > * { flex: 1 1 160px; }
.error { color: var(--bad); font-size: 14px; min-height: 1.2em; margin: 6px 0; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; }

.badge { display: inline-block; padding: 2px 9px; border-radius: 99px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.info { background: var(--info-soft); color: var(--info); }
.badge.neutral { background: var(--bg); color: var(--muted); }

/* Landing */
.landing { max-width: 1080px; margin: 0 auto; padding: 24px 16px 64px; }
.topbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 40px; gap: 12px; }
.logo { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 18px; color: var(--ink); text-decoration: none; }
.logo-mark { width: 32px; height: 32px; border-radius: 9px; background: var(--brand); color: var(--brand-ink); display: grid; place-items: center; font-weight: 800; }
.hero { display: grid; grid-template-columns: 1.1fr .9fr; gap: 40px; align-items: start; }
.hero h1 { font-size: clamp(30px, 5vw, 46px); font-weight: 800; }
.hero p.lead { font-size: 18px; color: var(--muted); max-width: 520px; }
.features { list-style: none; padding: 0; margin: 24px 0 0; display: grid; gap: 12px; }
.features li { display: flex; gap: 10px; }
.features li::before { content: '✓'; color: var(--brand); font-weight: 800; }
.tabs { display: flex; gap: 4px; background: var(--bg); padding: 4px; border-radius: 10px; margin-bottom: 18px; }
.tabs button { flex: 1; border: 0; background: transparent; padding: 8px; border-radius: 7px; font: inherit; font-weight: 600; color: var(--muted); cursor: pointer; }
.tabs button.active { background: var(--card); color: var(--ink); box-shadow: var(--shadow); }
@media (max-width: 820px) { .hero { grid-template-columns: 1fr; } }

/* App */
.shell { display: grid; grid-template-columns: 232px minmax(0, 1fr); min-height: 100vh; }
.shell > div { min-width: 0; }
.side { background: var(--card); border-right: 1px solid var(--line); padding: 20px 14px; display: flex; flex-direction: column; gap: 4px; position: sticky; top: 0; height: 100vh; }
.side .logo { padding: 0 8px 18px; }
.side nav a {
  display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 9px;
  color: var(--muted); text-decoration: none; font-weight: 600;
}
.side nav a:hover { background: var(--bg); color: var(--ink); }
.side nav a.active { background: var(--brand-soft); color: var(--brand); }
.side .foot { margin-top: auto; padding: 12px 8px 0; border-top: 1px solid var(--line); font-size: 13px; }
main { padding: 28px 32px 64px; min-width: 0; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; flex-wrap: wrap; margin-bottom: 20px; }
.page-head h1 { font-size: 24px; margin: 0; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 20px; }
.stat { padding: 16px; }
.stat .k { font-size: 13px; color: var(--muted); font-weight: 600; }
.stat .v { font-size: 26px; font-weight: 800; font-variant-numeric: tabular-nums; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 9px 10px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 700; }
tr.weekend td { background: color-mix(in srgb, var(--bg) 60%, transparent); }
tr.holiday td { background: var(--info-soft); }
td.r, th.r { text-align: right; }

.chip {
  display: inline-block; font: 600 13px/1 Inter, system-ui, sans-serif; font-variant-numeric: tabular-nums;
  padding: 6px 8px; border-radius: 7px; border: 1px solid var(--line); background: var(--card); color: var(--ink); cursor: pointer; margin-right: 4px;
}
.chip.manual { border-style: dashed; border-color: var(--warn); }
.chip.add { color: var(--muted); }
.chip:hover { border-color: var(--brand); }

.totals { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; margin-top: 20px; }
.kv { display: flex; justify-content: space-between; padding: 6px 0; border-bottom: 1px dashed var(--line); }
.kv:last-child { border: 0; }
.kv.total { font-size: 18px; font-weight: 800; border-top: 2px solid var(--ink); border-bottom: 0; margin-top: 6px; padding-top: 10px; }

.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: end; margin-bottom: 16px; }
.toolbar > div { min-width: 180px; }

.sched-row { display: grid; grid-template-columns: 96px repeat(4, minmax(0, 1fr)); gap: 6px; align-items: center; margin-bottom: 6px; }
.sched-row.head span { font-size: 11px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
.sched-row .day { display: flex; gap: 6px; align-items: center; margin: 0; font-size: 13px; cursor: pointer; }
.sched-row .day input { width: auto; }
.sched-row .t { padding: 7px 6px; font-size: 14px; }
.sched-row.off .t { opacity: .35; pointer-events: none; }
h4.step { margin: 18px 0 10px; font-size: 13px; text-transform: uppercase; letter-spacing: .05em; color: var(--brand); }
.month-nav { display: flex; gap: 4px; }
.month-nav .btn { padding: 9px 12px; }
.steps { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; }
.step-card { display: flex; flex-direction: column; align-items: flex-start; }
.step-card p { flex: 1; }
.step-n { width: 34px; height: 34px; border-radius: 50%; background: var(--brand); color: var(--brand-ink); display: grid; place-items: center; font-weight: 800; margin-bottom: 12px; }
.pin-card { text-align: center; background: var(--brand-soft); border-radius: 12px; padding: 18px; margin: 12px 0; word-break: break-all; }
.pin-big { font-size: 48px; font-weight: 800; letter-spacing: .2em; color: var(--brand); font-variant-numeric: tabular-nums; }
details summary { cursor: pointer; }
@media (max-width: 520px) {
  .sched-row { grid-template-columns: 1fr 1fr; }
  .sched-row .day { grid-column: 1 / -1; }
  .sched-row.head { display: none; }
}

.kiosk-link { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.kiosk-link code { background: var(--bg); padding: 6px 10px; border-radius: 7px; font-size: 13px; }

/* Modal */
dialog { border: 0; border-radius: 16px; padding: 0; width: min(640px, calc(100vw - 32px)); background: var(--card); color: var(--ink); box-shadow: 0 20px 60px rgba(0,0,0,.3); }
dialog::backdrop { background: rgba(10, 16, 26, .55); }
dialog form { padding: 22px; max-height: 85vh; overflow: auto; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 18px; flex-wrap: wrap; }
.modal-actions .spacer { flex: 1; }

.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 10px 18px; border-radius: 10px; font-weight: 600; z-index: 50; }

.mobile-nav { display: none; }
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .side { display: none; }
  .mobile-nav { display: flex; gap: 4px; overflow-x: auto; padding: 10px 16px; background: var(--card); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
  .mobile-nav a { padding: 7px 12px; border-radius: 8px; text-decoration: none; color: var(--muted); font-weight: 600; white-space: nowrap; }
  .mobile-nav a.active { background: var(--brand-soft); color: var(--brand); }
  main { padding: 20px 16px 48px; }
}

/* Relógio de ponto */
.kiosk { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.kiosk-box { width: min(420px, 100%); text-align: center; }
.clock { font-size: clamp(56px, 16vw, 84px); font-weight: 800; letter-spacing: -.03em; font-variant-numeric: tabular-nums; line-height: 1; }
.clock-date { color: var(--muted); margin: 6px 0 24px; }
.clock-date::first-letter { text-transform: uppercase; }
.pin-dots { display: flex; gap: 12px; justify-content: center; margin: 18px 0; height: 18px; }
.pin-dots i { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--muted); }
.pin-dots i.on { background: var(--brand); border-color: var(--brand); }
.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.keypad button { font: 700 24px Inter, system-ui, sans-serif; padding: 16px 0; border-radius: 14px; border: 1px solid var(--line); background: var(--card); color: var(--ink); cursor: pointer; }
.keypad button:active { transform: scale(.97); }
.keypad .go { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); font-size: 16px; }
.result { padding: 28px 20px; }
.result .big { font-size: 22px; font-weight: 800; }
.result .time { font-size: 54px; font-weight: 800; font-variant-numeric: tabular-nums; color: var(--brand); }
.result.err .time, .result.err .big { color: var(--bad); }
.marks { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin-top: 12px; }

@media print {
  .side, .mobile-nav, .toolbar, .no-print, .chip.add { display: none !important; }
  .shell { display: block; }
  main { padding: 0; }
  body { background: #fff; color: #000; }
  .card { box-shadow: none; border: 0; padding: 0; }
  .chip { border: 0; padding: 0 4px; }
}
.top-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
@media (max-width: 480px) { .top-actions .ghost { display: none; } }
