:root {
  --bg: #0f172a;
  --surface: #1e293b;
  --text: #e2e8f0;
  --muted: #94a3b8;
  --accent: #38bdf8;
  --accent-2: #818cf8;
  --danger: #ef4444;
  --success: #22c55e;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Ubuntu, Cantarell, Noto Sans, Helvetica, Arial, "Apple Color Emoji", "Segoe UI Emoji";
  background: var(--bg);
  color: var(--text);
  line-height: 1.45;
}

.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 24px;
}

h1 { margin: 0 0 8px; font-size: 24px; }
h2 { margin: 24px 0 12px; font-size: 20px; }

.muted { color: var(--muted); }

a { color: var(--accent); text-decoration: none; cursor: pointer; }
a:hover { text-decoration: underline; }

.nav {
  display: flex;
  gap: 16px;
  margin-bottom: 24px;
  align-items: center;
  flex-wrap: wrap;
}
.nav-sep {
  color: #475569;
  user-select: none;
}

.card {
  background: var(--surface);
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 20px;
}

label {
  display: block;
  margin: 12px 0 6px;
  font-weight: 500;
}

input[type="text"],
input[type="number"],
input[type="search"],
textarea,
select {
  width: 100%;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid #334155;
  background: #0b1220;
  color: var(--text);
  font-size: 15px;
}

textarea { min-height: 100px; resize: vertical; }

.row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

@media (max-width: 640px) {
  .row { grid-template-columns: 1fr; }
}

.actions {
  display: flex;
  gap: 10px;
  margin-top: 16px;
  flex-wrap: wrap;
}

button {
  padding: 10px 16px;
  border-radius: 8px;
  border: none;
  background: var(--accent);
  color: #0f172a;
  font-weight: 600;
  cursor: pointer;
}

button.secondary { background: #334155; color: var(--text); }
button.danger { background: var(--danger); color: #fff; }
button:hover { opacity: .92; }

.badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}

.badge-free { background: #14532d; color: #86efac; }
.badge-premium { background: #3b0764; color: #d8b4fe; }

/* Device source badges */
.badge-device-phone { background: #334155; color: #94a3b8; }
.badge-device-external { background: #14532d; color: #86efac; }

/* Score formula banner in session detail modal */
.score-formula-banner {
  padding: 12px 16px;
  border-radius: 10px;
  margin-bottom: 16px;
}
.score-formula-banner.formula-phone {
  background: #1e293b;
  border: 1px solid #334155;
}
.score-formula-banner.formula-external {
  background: #052e16;
  border: 1px solid #14532d;
}

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 12px; border-bottom: 1px solid #334155; }
th { color: var(--muted); font-weight: 500; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; }

.empty { color: var(--muted); padding: 24px 0; }

.flash { padding: 12px 16px; border-radius: 8px; margin-bottom: 16px; }
.flash-success { background: #064e3b; color: #86efac; }
.flash-error { background: #450a0a; color: #fca5a5; }
.flash-info { background: #1e3a5f; color: #93c5fd; }

/* Modal wrapper: centers content over overlay */
.modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Modal overlay for restore / system actions */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 1000;
}

.modal-content {
  position: relative;
  z-index: 1001;
  background: var(--surface);
  border-radius: 12px;
  padding: 24px;
  max-width: 540px;
  width: 90%;
  max-height: 80vh;
  overflow-y: auto;
}

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
}

.page-header h1 { margin: 0 0 4px; }
.page-header p { margin: 0; }

.header-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 8px;
}

.header-bar h1 { margin: 0; }

.search-bar {
  display: flex;
  align-items: center;
  gap: 12px;
}

.search-bar input {
  width: 280px;
}

.tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}

.tab {
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  background: #334155;
  color: var(--text);
}

.tab.active {
  background: var(--accent);
  color: #0f172a;
}

.upload-box {
  border: 2px dashed #334155;
  border-radius: 12px;
  padding: 40px;
  text-align: center;
  color: var(--muted);
  cursor: pointer;
}

.upload-box:hover {
  border-color: var(--accent);
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

@media (max-width: 720px) {
  .stats-grid { grid-template-columns: 1fr; }
}

.stat-card {
  background: var(--surface);
  border-radius: 12px;
  padding: 20px;
}

.stat-card .label {
  font-size: 14px;
  color: var(--muted);
}

.stat-card .value {
  font-size: 32px;
  font-weight: 700;
  margin-top: 4px;
}

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.tag {
  background: #334155;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 13px;
}
