
:root {
  --bg: #0b1f14; --card: #122a1c; --surface: #183524; --surface2: #1e4030;
  --border: #2a523c; --text: #e8f5ee; --muted: #8fb39a; --primary: #3dd68c;
  --accent: #7ef0b2; --danger: #ff6b6b; --nav-h: 64px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--text); font-family: Outfit, system-ui, sans-serif; min-height: 100%; }
body { padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom)); }
button, input, select, textarea { font: inherit; }
.mono { font-family: "JetBrains Mono", monospace; }
.hidden { display: none !important; }

#toast {
  position: fixed; left: 50%; bottom: calc(var(--nav-h) + 18px); transform: translateX(-50%) translateY(16px);
  background: var(--card); border: 1px solid var(--border); color: var(--text);
  padding: 12px 18px; border-radius: 28px; font-size: 14px; font-weight: 600; z-index: 9999;
  opacity: 0; transition: .25s; pointer-events: none; max-width: 90vw; text-align: center;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast.error { border-color: var(--danger); color: #ffc9c9; }
#toast.success { border-color: var(--primary); color: var(--accent); }
#login-screen { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.login-box { width: 100%; max-width: 380px; background: var(--card); border: 1px solid var(--border); border-radius: 18px; padding: 28px 22px; text-align: center; }
.brand { font-size: 36px; font-weight: 700; letter-spacing: -1.5px; margin-bottom: 6px; }
.brand span { color: var(--primary); }
.login-box p { color: var(--muted); margin: 0 0 22px; font-size: 14px; }
.field { text-align: left; margin-bottom: 14px; }
.field label { display: block; font-size: 11px; font-weight: 700; letter-spacing: .8px; text-transform: uppercase; color: var(--muted); margin-bottom: 6px; }
.field input, .field select, .field textarea {
  width: 100%; background: var(--surface); border: 1.5px solid var(--border); color: var(--text);
  border-radius: 12px; padding: 14px 14px; font-size: 18px; outline: none;
}
.field input:focus, .field select:focus { border-color: var(--primary); }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; width: 100%;
  border: none; border-radius: 12px; padding: 16px 18px; font-size: 16px; font-weight: 700; cursor: pointer;
}
.btn-primary { background: var(--primary); color: #062414; }
.btn-ghost { background: transparent; color: var(--primary); border: 1.5px solid var(--border); }
.btn-danger { background: var(--danger); color: #1a0505; }
.btn-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
#app-header {
  position: sticky; top: 0; z-index: 50; background: rgba(11,31,20,.92); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border); padding: 12px 16px; display: flex; align-items: center; justify-content: space-between;
}
#app-header .title { font-weight: 700; font-size: 18px; }
#app-header .title span { color: var(--primary); }
#app-header .who { font-size: 12px; color: var(--muted); margin-top: 2px; }
#main { padding: 16px; max-width: 640px; margin: 0 auto; }
.view-title { font-size: 20px; font-weight: 700; margin: 0 0 14px; }
.card { background: var(--card); border: 1px solid var(--border); border-radius: 16px; padding: 16px; margin-bottom: 14px; }
.scan-tap {
  border: 2px dashed var(--primary); border-radius: 16px; padding: 28px 16px; text-align: center;
  background: linear-gradient(180deg, rgba(61,214,140,.08), transparent); cursor: pointer; margin-bottom: 12px;
  min-height: 110px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
}
.scan-tap.scanning { border-style: solid; animation: pulse 1s infinite; }
@keyframes pulse { 50% { border-color: var(--accent); } }
.scan-tap .icon { font-size: 28px; }
.scan-tap p { margin: 0; color: var(--muted); font-size: 14px; font-weight: 600; }
.wedge-hint { font-size: 12px; color: var(--muted); margin: 0 0 8px; }
.row-list { display: flex; flex-direction: column; gap: 8px; }
.row-item { display: flex; align-items: center; gap: 10px; background: var(--surface2); border-radius: 12px; padding: 12px; }
.row-item .tag { flex: 1; font-size: 13px; color: var(--accent); word-break: break-all; }
.row-item .wt { color: var(--text); font-size: 14px; font-weight: 600; white-space: nowrap; }
.row-item .x { background: none; border: none; color: var(--muted); font-size: 22px; line-height: 1; cursor: pointer; padding: 4px 8px; }
.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.stat { background: var(--surface); border-radius: 14px; padding: 14px; border: 1px solid var(--border); }
.stat .l { font-size: 11px; text-transform: uppercase; letter-spacing: .7px; color: var(--muted); font-weight: 700; }
.stat .v { font-size: 22px; font-weight: 700; font-family: "JetBrains Mono", monospace; color: var(--primary); margin-top: 4px; }
.nav {
  position: fixed; left: 0; right: 0; bottom: 0; height: calc(var(--nav-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom); background: var(--card); border-top: 1px solid var(--border);
  display: flex; z-index: 60;
}
.nav button {
  flex: 1; background: none; border: none; color: var(--muted); font-size: 10px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .4px; display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 2px; cursor: pointer;
}
.nav button.active { color: var(--primary); }
.nav .ico { font-size: 18px; }
.modal-bg { position: fixed; inset: 0; background: rgba(0,0,0,.72); z-index: 200; display: flex; align-items: flex-end; justify-content: center; padding: 16px; }
.modal { width: 100%; max-width: 420px; background: var(--card); border: 1px solid var(--border); border-radius: 18px 18px 14px 14px; padding: 20px; margin-bottom: env(safe-area-inset-bottom); max-height: 90vh; overflow: auto; }
.modal h3 { margin: 0 0 6px; font-size: 18px; }
.modal .sub { color: var(--muted); font-size: 13px; margin-bottom: 14px; word-break: break-all; }
.unit-row { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; margin-bottom: 12px; }
.unit-row button { padding: 14px; border-radius: 12px; border: 2px solid var(--border); background: var(--surface); color: var(--text); font-weight: 700; cursor: pointer; }
.unit-row button.on { border-color: var(--primary); background: rgba(61,214,140,.15); color: var(--primary); }
.hist-item { display: flex; gap: 10px; align-items: flex-start; }
.hist-item .thumb { width: 56px; height: 56px; border-radius: 10px; object-fit: cover; background: var(--surface); border: 1px solid var(--border); flex-shrink: 0; }
.hist-actions { display: flex; gap: 8px; margin-top: 6px; }
.hist-actions button { padding: 8px 12px; border-radius: 10px; font-size: 13px; font-weight: 700; cursor: pointer; border: 1.5px solid var(--border); background: var(--surface); color: var(--text); }
.day-row { display: flex; justify-content: space-between; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--border); }
.day-row:last-child { border-bottom: none; }
.awake-toggle { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--muted); margin-top: 8px; }
.session-row { display: flex; gap: 8px; align-items: stretch; }
.session-row select { flex: 1; }
.section-label { font-size: 13px; font-weight: 700; color: var(--accent); text-transform: uppercase; letter-spacing: .6px; margin-bottom: 12px; }
.hint { font-size: 12px; color: var(--muted); margin: 8px 0 0; }
.admin-only-badge { font-size: 10px; background: rgba(61,214,140,.15); color: var(--primary); border: 1px solid var(--border); border-radius: 999px; padding: 2px 8px; margin-left: 6px; vertical-align: middle; }
.user-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; background: var(--surface2); border-radius: 12px; padding: 12px; }
.user-row .meta { font-size: 12px; color: var(--muted); }
.user-row .actions { display: flex; gap: 6px; flex-shrink: 0; }
.user-row .actions button { padding: 8px 10px; border-radius: 10px; font-size: 12px; font-weight: 700; cursor: pointer; border: 1.5px solid var(--border); background: var(--surface); color: var(--text); }
.group-head { font-size: 13px; font-weight: 700; color: var(--primary); margin: 12px 0 8px; padding-bottom: 6px; border-bottom: 1px solid var(--border); }
.warn-box { background: rgba(255,107,107,.12); border: 1px solid var(--danger); border-radius: 12px; padding: 10px 12px; color: #ffc9c9; font-size: 13px; margin-bottom: 12px; }
.photo-preview { width: 100%; max-height: 160px; object-fit: cover; border-radius: 12px; margin-bottom: 8px; border: 1px solid var(--border); }
.backup-list { margin-top: 12px; font-size: 12px; color: var(--muted); }
.filters .field { margin-bottom: 10px; }
