/* Nebula PC Attendance */
:root {
  --purple: #9b5cff; --blue: #4fa9ff; --pink: #ff5cc8; --cyan: #5cf0ff; --ink: #050510;
  --bg: #07071a; --panel: #10102a; --panel-2: #16163a; --line: #26264d; --line-2: #34346a;
  --text: #ecebff; --muted: #a3a1c9; --faint: #6f6d96;
  --ok: #3ee39b; --warn: #ffc65c; --bad: #ff6b81;
  --radius: 16px; --radius-sm: 10px;
  --font: 'Space Grotesk', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: var(--font); color: var(--text); background: var(--bg); font-size: 16px; line-height: 1.45;
  background-image: radial-gradient(1200px 600px at 85% -10%, rgba(155, 92, 255, .18), transparent 60%),
                    radial-gradient(900px 500px at -10% 10%, rgba(79, 169, 255, .12), transparent 60%);
  background-attachment: fixed; min-height: 100vh; -webkit-font-smoothing: antialiased;
}
a { color: var(--blue); }
button, input, select, textarea { font: inherit; color: inherit; }
.mono, .time { font-family: var(--mono); font-variant-numeric: tabular-nums; }
[hidden] { display: none !important; }

/* Layout */
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 12px; padding: 12px 16px;
  background: rgba(7, 7, 26, .82); backdrop-filter: blur(12px); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; letter-spacing: .06em; text-decoration: none; color: var(--text); }
.brand .mark { width: 28px; height: 28px; border-radius: 8px; background: linear-gradient(135deg, var(--purple), var(--blue)); display: grid; place-items: center; font-size: 14px; color: #fff; box-shadow: 0 0 18px rgba(155,92,255,.5); }
.brand small { font-weight: 500; letter-spacing: .02em; color: var(--muted); }
.brand b span { color: var(--purple); }
.topbar .spacer { flex: 1; }
.wrap { max-width: 1440px; margin: 0 auto; padding: 16px; }
.narrow { max-width: 560px; margin: 0 auto; }

.card { background: linear-gradient(180deg, var(--panel-2), var(--panel)); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.card + .card, .stack > * + * { margin-top: 14px; }
.card h2, .card h3 { margin: 0 0 10px; font-size: 1.05rem; letter-spacing: .01em; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: .85rem; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.between { justify-content: space-between; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.grid2 > *, .grid3 > *, .filters > * { min-width: 0; }
input, select, textarea { min-width: 0; max-width: 100%; }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid var(--line-2); background: var(--panel-2);
  color: var(--text); padding: 10px 16px; border-radius: var(--radius-sm); font-weight: 600; cursor: pointer; text-decoration: none; min-height: 44px; white-space: nowrap; }
.btn:hover { border-color: var(--purple); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.primary { background: linear-gradient(135deg, var(--purple), #7b5cff 50%, var(--blue)); border: 0; color: #fff; }
.btn.danger { border-color: rgba(255,107,129,.5); color: var(--bad); }
.btn.ghost { background: transparent; }
.btn.sm { min-height: 34px; padding: 6px 12px; font-size: .88rem; }
.btn.block { width: 100%; }
.linkbtn { background: none; border: 0; color: var(--blue); cursor: pointer; padding: 0; font-weight: 600; }

.clock-btn { width: 100%; min-height: 96px; border-radius: 22px; border: 0; font-size: 1.5rem; font-weight: 700; letter-spacing: .02em; cursor: pointer; color: #fff;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; transition: transform .08s ease, filter .2s; }
.clock-btn small { font-size: .85rem; font-weight: 500; opacity: .85; }
.clock-btn:active:not(:disabled) { transform: scale(.985); }
.clock-btn.start { background: linear-gradient(135deg, #18b47a, #1fcf9a 60%, #29d7c8); box-shadow: 0 10px 40px rgba(62,227,155,.25); }
.clock-btn.end { background: linear-gradient(135deg, #ff5c7a, var(--pink)); box-shadow: 0 10px 40px rgba(255,92,200,.25); }
.clock-btn:disabled { filter: saturate(.4) brightness(.8); cursor: progress; }

/* Status */
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; font-size: .8rem; font-weight: 600; border: 1px solid var(--line-2); white-space: nowrap; }
.pill .dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.pill.in { color: var(--ok); border-color: rgba(62,227,155,.4); background: rgba(62,227,155,.08); }
.pill.in .dot { box-shadow: 0 0 10px var(--ok); animation: pulse 1.6s infinite; }
.pill.out { color: var(--muted); }
.pill.warn { color: var(--warn); border-color: rgba(255,198,92,.4); background: rgba(255,198,92,.08); }
.pill.bad { color: var(--bad); border-color: rgba(255,107,129,.4); background: rgba(255,107,129,.08); }
.pill.ok { color: var(--ok); border-color: rgba(62,227,155,.4); }
.pill.demo { color: var(--pink); border-color: rgba(255,92,200,.5); background: rgba(255,92,200,.08); }
@keyframes pulse { 50% { opacity: .35; } }

.big-time { font-family: var(--mono); font-size: 2.6rem; font-weight: 600; letter-spacing: -.02em; line-height: 1.1; }
.elapsed { font-family: var(--mono); font-size: 1.9rem; font-weight: 600; color: var(--ok); }
.stat { background: rgba(255,255,255,.02); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 10px 12px; }
.stat .k { font-size: .75rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.stat .v { font-family: var(--mono); font-size: 1.25rem; font-weight: 600; margin-top: 2px; }
.stat.net .v { color: var(--cyan); }

/* Alerts & toasts */
.alert { border-radius: var(--radius-sm); padding: 12px 14px; border: 1px solid var(--line-2); background: var(--panel-2); }
.alert.error { border-color: rgba(255,107,129,.5); background: rgba(255,107,129,.08); }
.alert.warn { border-color: rgba(255,198,92,.5); background: rgba(255,198,92,.07); }
.alert.ok { border-color: rgba(62,227,155,.5); background: rgba(62,227,155,.07); }
.alert.info { border-color: rgba(79,169,255,.45); background: rgba(79,169,255,.07); }
.alert b { display: block; margin-bottom: 2px; }
.toast-host { position: fixed; left: 50%; bottom: 84px; transform: translateX(-50%); z-index: 100; display: grid; gap: 8px; width: min(92vw, 440px); }
.toast { padding: 12px 16px; border-radius: 12px; background: #1d1d45; border: 1px solid var(--line-2); box-shadow: 0 10px 30px rgba(0,0,0,.5); animation: rise .2s ease; }
.toast.ok { border-color: rgba(62,227,155,.6); }
.toast.error { border-color: rgba(255,107,129,.6); }
@keyframes rise { from { transform: translateY(8px); opacity: 0; } }

/* Lists & tables */
.list { list-style: none; margin: 0; padding: 0; }
.list > li { padding: 12px 0; border-top: 1px solid var(--line); }
.list > li:first-child { border-top: 0; }
.shift-line { display: flex; justify-content: space-between; gap: 10px; font-family: var(--mono); font-size: .95rem; }
.day { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 12px 14px; background: rgba(255,255,255,.015); }
.day + .day { margin-top: 10px; }
.day-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.day-totals { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-top: 8px; font-family: var(--mono); font-size: .9rem; }
.day-totals span { color: var(--muted); font-family: var(--font); font-size: .75rem; display: block; }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius-sm); }
table { width: 100%; border-collapse: collapse; font-size: .92rem; }
th, td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: .74rem; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); font-weight: 600; background: rgba(255,255,255,.02); white-space: nowrap; }
td.num, th.num { text-align: right; font-family: var(--mono); white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
tr.sub td { background: rgba(255,255,255,.012); font-size: .88rem; }

/* Forms */
label.f { display: block; font-size: .85rem; color: var(--muted); margin-bottom: 12px; }
label.f > span { display: block; margin-bottom: 5px; }
input[type=text], input[type=email], input[type=number], input[type=date], input[type=datetime-local], select, textarea {
  width: 100%; background: #0b0b22; border: 1px solid var(--line-2); border-radius: var(--radius-sm); padding: 11px 12px; color: var(--text); min-height: 46px; }
input:focus, select:focus, textarea:focus, .btn:focus-visible, .clock-btn:focus-visible { outline: 2px solid var(--purple); outline-offset: 2px; }
textarea { min-height: 84px; resize: vertical; }
.code-input { font-family: var(--mono); font-size: 1.8rem; letter-spacing: .5em; text-align: center; }
.check { display: inline-flex; align-items: center; gap: 8px; color: var(--text); font-size: .92rem; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--purple); }

/* Tabs */
.tabbar { position: fixed; bottom: 0; left: 0; right: 0; z-index: 20; display: grid; grid-template-columns: repeat(3, 1fr);
  background: rgba(7,7,26,.92); backdrop-filter: blur(12px); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
.tabbar button { background: none; border: 0; color: var(--muted); padding: 12px 4px 14px; font-weight: 600; font-size: .85rem; cursor: pointer; }
.tabbar button[aria-selected=true] { color: var(--text); box-shadow: inset 0 2px 0 var(--purple); }
.has-tabbar { padding-bottom: 90px; }
.tabs { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
.tabs button { background: transparent; border: 1px solid transparent; color: var(--muted); padding: 8px 14px; border-radius: 999px; font-weight: 600; cursor: pointer; white-space: nowrap; min-height: 38px; }
.tabs button[aria-selected=true] { color: var(--text); background: var(--panel-2); border-color: var(--line-2); }
.badge { display: inline-block; min-width: 20px; padding: 1px 6px; border-radius: 999px; background: var(--pink); color: #fff; font-size: .72rem; text-align: center; margin-left: 4px; }

/* Modal */
dialog { border: 1px solid var(--line-2); border-radius: var(--radius); background: var(--panel); color: var(--text); padding: 0; width: min(560px, calc(100vw - 32px)); max-height: calc(100vh - 32px); }
dialog::backdrop { background: rgba(2,2,12,.7); backdrop-filter: blur(3px); }
dialog .d-head { padding: 16px 18px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; }
dialog .d-head h3 { margin: 0; }
dialog .d-body { padding: 16px 18px; overflow-y: auto; }
dialog .d-foot { padding: 12px 18px; border-top: 1px solid var(--line); display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; }

/* States */
.empty { text-align: center; padding: 28px 12px; color: var(--muted); }
.skeleton { background: linear-gradient(90deg, var(--panel-2), #1f1f48, var(--panel-2)); background-size: 200% 100%; animation: shimmer 1.2s infinite; border-radius: 8px; height: 18px; }
@keyframes shimmer { to { background-position: -200% 0; } }
.spinner { width: 18px; height: 18px; border: 2px solid rgba(255,255,255,.3); border-top-color: #fff; border-radius: 50%; animation: spin .8s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Success sheet */
.sheet-ok { text-align: center; }
.sheet-ok .tick { width: 64px; height: 64px; border-radius: 50%; margin: 6px auto 10px; display: grid; place-items: center; font-size: 30px; background: rgba(62,227,155,.12); color: var(--ok); border: 1px solid rgba(62,227,155,.5); }

/* Login */
.login { min-height: calc(100vh - 60px); display: grid; place-items: center; padding: 24px 16px; }
.login .card { width: 100%; max-width: 420px; padding: 26px; }
.login h1 { font-size: 1.6rem; margin: 0 0 4px; }

/* Admin */
.admin-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.kpi { padding: 14px 16px; }
.kpi .v { font-family: var(--mono); font-size: 1.8rem; font-weight: 600; }
.filters { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; align-items: end; }
.filters label.f { margin: 0; }
#map { height: 380px; border-radius: var(--radius-sm); border: 1px solid var(--line); background: #0b0b22; }
.leaflet-container { font-family: var(--font); }
pre.json { white-space: pre-wrap; word-break: break-word; font-family: var(--mono); font-size: .78rem; background: #0b0b22; border: 1px solid var(--line); border-radius: 8px; padding: 8px; margin: 6px 0 0; max-height: 220px; overflow: auto; }
.diff { font-family: var(--mono); font-size: .82rem; }
.diff del { color: var(--bad); text-decoration: line-through; }
.diff ins { color: var(--ok); text-decoration: none; }

@media (max-width: 860px) {
  .admin-grid { grid-template-columns: repeat(2, 1fr); }
  .hide-sm { display: none; }
}
@media (max-width: 520px) {
  .grid2 { grid-template-columns: 1fr; }
}
@media (max-width: 420px) {
  .big-time { font-size: 2.2rem; }
  .grid3 { grid-template-columns: 1fr 1fr 1fr; gap: 6px; }
  .stat { padding: 8px; }
  .stat .v { font-size: 1.05rem; }
  .brand small { display: none; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
