*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0f1724;
  --bg-card: #1a2332;
  --bg-input: #243044;
  --border: #2a3a4e;
  --text: #e2e8f0;
  --text-muted: #8899aa;
  --primary: #22c55e;
  --primary-hover: #16a34a;
  --danger: #ef4444;
  --accent: #3b82f6;
  --radius: 12px;
  --nav-height: 64px;
  --topbar-height: 56px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
  user-select: none;
}

input, button, textarea {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

.app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100dvh;
  position: relative;
}

.page {
  display: none;
  padding-bottom: var(--nav-height);
}
.page.active { display: block; }

.topbar {
  height: var(--topbar-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar h1 { font-size: 18px; font-weight: 600; }

.content { padding: 16px; }

.auth-container {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px 24px;
}
.logo { font-size: 24px; font-weight: 700; margin-bottom: 24px; color: var(--primary); }

.auth-tabs { display: flex; gap: 0; width: 100%; margin-bottom: 24px; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--border); }
.auth-tabs .tab {
  flex: 1; padding: 10px; text-align: center; background: var(--bg-card); border: none;
  cursor: pointer; font-size: 14px; color: var(--text-muted); transition: all 0.15s;
}
.auth-tabs .tab.active { background: var(--primary); color: #0f1724; font-weight: 600; }

.auth-form { display: none; width: 100%; flex-direction: column; gap: 12px; }
.auth-form.active { display: flex; }
.auth-form input {
  width: 100%; padding: 12px 16px; background: var(--bg-input, var(--bg-card));
  border: 1px solid var(--border); border-radius: var(--radius); outline: none;
}
.auth-form input:focus { border-color: var(--primary); }

.auth-error { color: var(--danger); font-size: 13px; min-height: 20px; text-align: center; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; padding: 12px 20px;
  border-radius: var(--radius); border: none; cursor: pointer; font-weight: 600; font-size: 15px;
  transition: background 0.15s, opacity 0.15s;
}
.btn-primary { background: var(--primary); color: #0f1724; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-icon {
  width: 36px; height: 36px; display: flex; align-items: center; justify-content: center;
  background: none; border: none; cursor: pointer; font-size: 18px; color: var(--text-muted);
  border-radius: 50%;
}
.btn-icon:hover { background: var(--bg-card); }

.bottom-nav {
  position: fixed; bottom: 0; left: 50%; transform: translateX(-50%); width: 100%; max-width: 480px;
  height: var(--nav-height); display: flex; background: var(--bg-card);
  border-top: 1px solid var(--border); z-index: 10;
}
.nav-btn {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: none; border: none; cursor: pointer; color: var(--text-muted); gap: 2px;
  transition: color 0.15s;
}
.nav-btn.active { color: var(--primary); }
.nav-icon { font-size: 22px; }
.nav-label { font-size: 11px; }

.date-header { text-align: center; font-size: 14px; color: var(--text-muted); margin-bottom: 16px; }

.stat-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 20px; }
.stat-card {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px; display: flex; flex-direction: column; gap: 4px;
}
.stat-card .stat-icon { font-size: 20px; }
.stat-card .stat-label { font-size: 12px; color: var(--text-muted); }
.stat-card .stat-value { font-size: 20px; font-weight: 700; }
.stat-card .stat-unit { font-size: 12px; color: var(--text-muted); }

.chart-container { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; }
.chart-container h2 { font-size: 14px; font-weight: 600; margin-bottom: 12px; color: var(--text-muted); }
.chart-container canvas { max-height: 220px; }

.log-form { display: flex; flex-direction: column; gap: 12px; }
.log-form label { font-size: 13px; color: var(--text-muted); font-weight: 600; }
.log-form input {
  width: 100%; padding: 12px 16px; background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); outline: none;
}
.log-form input:focus { border-color: var(--primary); }
#log-status { color: var(--primary); font-size: 13px; text-align: center; min-height: 20px; }
#log-status:not(:empty) { padding: 8px; background: rgba(34,197,94,0.1); border-radius: var(--radius); }

.profile-card {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px; display: flex; flex-direction: column; gap: 16px;
}
.profile-field { display: flex; flex-direction: column; gap: 4px; }
.profile-field .label { font-size: 12px; color: var(--text-muted); text-transform: uppercase; }
.profile-field .value { font-size: 15px; }
.profile-field .value.mono { font-family: 'Courier New', monospace; font-size: 13px; word-break: break-all; }

.api-help { background: rgba(59,130,246,0.1); border: 1px solid var(--accent); border-radius: var(--radius); padding: 14px; }
.api-help h3 { font-size: 14px; margin-bottom: 8px; color: var(--accent); }
.api-help p { font-size: 13px; color: var(--text-muted); margin-bottom: 8px; }

.code-block {
  background: var(--bg); border: 1px solid var(--border); border-radius: 8px;
  padding: 12px; font-size: 11px; font-family: 'Courier New', monospace;
  white-space: pre-wrap; word-break: break-all; color: var(--text); overflow-x: auto;
}

.notification-control { display: flex; flex-direction: column; gap: 8px; }
.notification-control h3 { font-size: 14px; color: var(--primary); }
.notification-control input {
  width: 80px; padding: 8px 12px; background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); outline: none; text-align: center;
}
.notification-control input:focus { border-color: var(--primary); }
#notif-status { color: var(--primary); font-size: 13px; min-height: 20px; }

.toast {
  position: fixed; top: 20px; left: 50%; transform: translateX(-50%); z-index: 100;
  padding: 10px 20px; border-radius: var(--radius); font-size: 13px; font-weight: 600;
  opacity: 0; transition: opacity 0.3s;
}
.toast.show { opacity: 1; }
.toast.success { background: var(--primary); color: #0f1724; }
.toast.error { background: var(--danger); color: white; }

@media (min-width: 480px) {
  .app { border-left: 1px solid var(--border); border-right: 1px solid var(--border); }
}