:root {
  --bg: #f3f5f8;
  --bg-accent: #e8eef2;
  --surface: #ffffff;
  --surface-2: #f8fafb;
  --text: #1b2430;
  --muted: #667085;
  --line: #e4e8ee;
  --teal: #0f766e;
  --teal-dark: #0b5c56;
  --teal-soft: #e6f4f2;
  --gold: #c9a227;
  --gold-soft: #f8efd4;
  --in: #157a4b;
  --in-soft: #e6f6ee;
  --out: #b42318;
  --out-soft: #fdeceb;
  --web: #175cd3;
  --web-soft: #e8f0fe;
  --dev: #6941c6;
  --dev-soft: #f0eaff;
  --shadow: 0 10px 30px rgba(27, 36, 48, .06);
  --shadow-lg: 0 24px 50px rgba(27, 36, 48, .12);
  --radius: 18px;
  --radius-sm: 12px;
  --header-h: 64px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --font: "Sora", "Segoe UI", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font);
  background:
    radial-gradient(1200px 400px at 10% -10%, #ddf3ef 0%, transparent 50%),
    radial-gradient(900px 300px at 110% 0%, #f8efd4 0%, transparent 46%),
    var(--bg);
  color: var(--text);
  min-height: 100dvh;
  line-height: 1.45;
}

img { max-width: 100%; }
a { color: var(--teal); text-decoration: none; }
button, input, select { font: inherit; }

.app-header {
  position: sticky;
  top: 0;
  z-index: 40;
  height: var(--header-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 16px;
  background: rgba(255,255,255,.86);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--line);
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.brand-logo {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  object-fit: cover;
  box-shadow: 0 4px 10px rgba(15,118,110,.25);
  flex: none;
}
.brand-text { min-width: 0; }
.brand-title {
  display: flex;
  align-items: baseline;
  gap: 6px;
  font-weight: 700;
  letter-spacing: -.03em;
  line-height: 1.1;
  white-space: nowrap;
}
.brand-title .bio { color: var(--teal); font-size: 16px; }
.brand-title .time { color: var(--text); font-size: 16px; }
.brand-title .iface {
  color: var(--gold);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .16em;
  text-transform: uppercase;
  padding: 2px 6px;
  border: 1px solid #ead89a;
  border-radius: 999px;
  background: var(--gold-soft);
}
.brand-sub {
  font-size: 11px;
  color: var(--muted);
  margin-top: 1px;
}
.nav {
  display: flex;
  align-items: center;
  gap: 6px;
}
.nav a, .nav .nav-link {
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  padding: 8px 10px;
  border-radius: 10px;
}
.nav a.active, .nav a:hover { color: var(--teal); background: var(--teal-soft); }
.nav .logout { color: #b42318; }
.nav .logout:hover { background: var(--out-soft); }

.page {
  width: min(980px, calc(100% - 24px));
  margin: 18px auto 40px;
  padding-bottom: calc(20px + var(--safe-b));
  animation: rise .45s ease both;
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
}
.card + .card { margin-top: 14px; }
.card h1 {
  margin: 0 0 6px;
  font-size: 22px;
  letter-spacing: -.03em;
}
.muted { color: var(--muted); font-size: 13px; margin: 0; }

label { display: block; font-size: 12px; font-weight: 600; color: var(--muted); margin: 12px 0 6px; }
input[type="text"], input[type="password"], input[type="date"], select {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--text);
  border-radius: 12px;
  padding: 12px 12px;
  outline: none;
  transition: border-color .2s, box-shadow .2s, background .2s;
}
input:focus, select:focus {
  border-color: #99d0ca;
  background: #fff;
  box-shadow: 0 0 0 4px rgba(15,118,110,.12);
}

.btn {
  appearance: none;
  border: 0;
  border-radius: 12px;
  padding: 12px 16px;
  font-weight: 650;
  cursor: pointer;
  transition: transform .15s ease, box-shadow .15s ease, filter .15s ease;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0) scale(.99); }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.btn-gold { background: linear-gradient(180deg, #e0bf55, var(--gold)); color: #3b2d07; width: 100%; margin-top: 16px; box-shadow: 0 8px 16px rgba(201,162,39,.22); }
.btn-in { background: var(--in); color: #fff; flex: 1; }
.btn-out { background: var(--out); color: #fff; flex: 1; }
.btn-ghost { background: #eef1f4; color: var(--text); }
.btn-view {
  background: var(--teal-soft);
  color: var(--teal-dark);
  padding: 8px 12px;
  font-size: 12px;
  border-radius: 999px;
}

.row { display: flex; gap: 10px; }
.filters {
  display: grid;
  grid-template-columns: repeat(4, 1fr) auto;
  gap: 10px;
  margin: 14px 0 8px;
}

.hello {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.status-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 650;
  padding: 6px 10px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
}
.status-chip.live { background: var(--in-soft); color: var(--in); }
.status-chip.off { background: #eef1f4; }

.pill {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .02em;
}
.pill-in { background: var(--in-soft); color: var(--in); }
.pill-out { background: var(--out-soft); color: var(--out); }
.pill-web { background: var(--web-soft); color: var(--web); }
.pill-dev { background: var(--dev-soft); color: var(--dev); }
.pill-yes { background: var(--in-soft); color: var(--in); }
.pill-no { background: #fff4e5; color: #b54708; }

.entry-list { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
.entry {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface-2);
  animation: rise .4s ease both;
}
.entry-main { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.entry-top { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.entry-time { font-weight: 700; font-size: 14px; }
.entry-meta { color: var(--muted); font-size: 12px; }

#captureBox {
  display: none;
  margin-top: 16px;
  padding: 14px;
  border-radius: 16px;
  background: #0f1720;
  color: #e8eef2;
  animation: pop .28s ease;
}
#captureBox .muted { color: #b7c2cc; }
#cam {
  width: 100%;
  max-height: 280px;
  object-fit: cover;
  border-radius: 12px;
  background: #000;
  margin: 8px 0;
}
.preview { width: 100%; border-radius: 12px; }
.capture-actions { display: flex; gap: 8px; margin-top: 10px; }
.capture-actions .btn { flex: 1; margin-top: 0; }

.alert {
  border-radius: 12px;
  padding: 10px 12px;
  margin: 10px 0 0;
  font-size: 13px;
}
.alert-err { background: var(--out-soft); color: var(--out); }

#toastBox {
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: calc(18px + var(--safe-b));
  z-index: 60;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}
.toast {
  pointer-events: auto;
  padding: 12px 14px;
  border-radius: 12px;
  font-size: 14px;
  box-shadow: var(--shadow-lg);
  animation: pop .25s ease;
}
.toast-ok { background: #157a4b; color: #fff; }
.toast-err { background: #a33b3b; color: #fff; }

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(16, 24, 32, .45);
  display: none;
  align-items: flex-end;
  justify-content: center;
  z-index: 80;
  padding: 16px;
}
.modal-backdrop.open { display: flex; animation: fade .2s ease; }
.modal {
  width: min(560px, 100%);
  max-height: min(88dvh, 760px);
  overflow: auto;
  background: #fff;
  border-radius: 22px 22px 16px 16px;
  box-shadow: var(--shadow-lg);
  padding: 18px;
  animation: slideup .28s ease;
}
.modal h2 { margin: 0 0 4px; font-size: 18px; }
.modal-grid { display: grid; gap: 12px; margin-top: 12px; }
.detail {
  background: var(--surface-2);
  border-radius: 14px;
  padding: 12px;
}
.detail b { display: block; font-size: 11px; color: var(--muted); font-weight: 650; margin-bottom: 4px; text-transform: uppercase; letter-spacing: .04em; }
.photo-full { width: 100%; border-radius: 14px; background: #eee; }
.map-thumb, .map-full {
  width: 100%;
  border-radius: 14px;
  overflow: hidden;
  background: #d7e3dc;
  position: relative;
}
.map-thumb { height: 86px; }
.map-full { height: 220px; }
.map-frame { width: 100%; height: 100%; border: 0; }
.map-pin-fallback {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 4px;
  color: var(--teal-dark);
  font-size: 12px;
  font-weight: 650;
}

.install-bar {
  display: none;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px;
  padding: 10px 12px;
  border-radius: 14px;
  background: #fff;
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}
.install-bar.show { display: flex; }
.login-wrap { width: min(420px, calc(100% - 24px)); margin: 48px auto; }
.login-hero { text-align: center; margin-bottom: 16px; }
.login-hero img { width: 56px; height: 56px; border-radius: 16px; box-shadow: var(--shadow); }
.foot-note { text-align: center; color: var(--muted); font-size: 12px; margin-top: 18px; }

@keyframes rise {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}
@keyframes pop {
  from { opacity: 0; transform: translateY(8px) scale(.98); }
  to { opacity: 1; transform: none; }
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideup {
  from { opacity: 0; transform: translateY(24px); }
  to { opacity: 1; transform: none; }
}

@media (max-width: 820px) {
  .filters { grid-template-columns: 1fr 1fr; }
  .brand-sub { display: none; }
  .nav a { padding: 8px 8px; }
}
@media (max-width: 560px) {
  .page { width: calc(100% - 16px); margin-top: 12px; }
  .card { padding: 16px; border-radius: 16px; }
  .filters { grid-template-columns: 1fr; }
  .brand-title .iface { display: none; }
  .nav a span { display: none; }
  .hello { align-items: flex-start; flex-direction: column; }
  .modal { border-radius: 20px 20px 12px 12px; }
}
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
