:root {
  --bg: #0a0a0a;
  --surface: #17171a;
  --surface-2: #201f22;
  --border: #33333333;
  --border-strong: #47474a;
  --text: #f7f7f8;
  --text-muted: #9c9c9f;
  --accent: #ef3924;
  --accent-text: #ffffff;
  --warn: #f5a623;
  --danger: #ef3924;
  --radius: 10px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-tap-highlight-color: transparent;
}

body {
  padding: 12px;
  padding-bottom: 80px;
}

h1 { font-size: 18px; font-weight: 600; margin: 0; }

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

.tabs {
  display: flex;
  gap: 6px;
  background: var(--surface);
  padding: 4px;
  border-radius: var(--radius);
}

.tab-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
}

.tab-btn.active {
  background: var(--surface-2);
  color: var(--text);
}

.search-wrap {
  position: relative;
  margin-bottom: 10px;
  display: flex;
  gap: 8px;
}

.search-wrap input[type="search"] { flex: 1; }

.camera-btn {
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  font-size: 20px;
  padding: 0 16px;
  color: var(--text);
}

.camera-btn:active { border-color: var(--accent); }

.pl-card {
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 14px;
}

.pl-card h2 { font-size: 15px; margin: 0 0 10px; font-weight: 600; }
.pl-card .pl-note { font-size: 13px; color: var(--text-muted); margin: 8px 0; }
.pl-card .pl-flag-note { font-size: 13px; color: var(--warn); margin: 8px 0; }

.pl-actions { display: flex; gap: 8px; margin-top: 12px; }

.pl-btn {
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  color: var(--text);
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 15px;
  font-weight: 500;
}

.pl-btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-text);
}

input.pl-name {
  width: 140px;
  height: 44px;
  background: var(--surface-2);
  border: 1px solid transparent;
  border-radius: 8px;
  color: var(--text);
  font-size: 14px;
  padding: 0 8px;
}

input.pl-name.warn { border-color: var(--warn); color: var(--warn); }

.pl-status { font-size: 14px; margin-top: 10px; }
.pl-status.ok { color: #22c55e; }
.pl-status.err { color: var(--danger); }

.spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid var(--border-strong);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  vertical-align: -3px;
  margin-right: 8px;
}

@keyframes spin { to { transform: rotate(360deg); } }

input[type="text"], input[type="search"] {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  color: var(--text);
  font-size: 16px;
  padding: 12px 14px;
  border-radius: var(--radius);
}

input[type="text"]:focus, input[type="search"]:focus {
  outline: none;
  border-color: var(--accent);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand img {
  height: 32px;
  width: auto;
}

.search-results {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  margin-top: 4px;
  max-height: 260px;
  overflow-y: auto;
  z-index: 20;
}

.search-result-row {
  padding: 12px 14px;
  font-size: 15px;
  border-bottom: 1px solid var(--border);
}

.search-result-row:last-child { border-bottom: none; }
.search-result-row:active { background: var(--surface); }
.search-result-row.add-new { color: var(--accent); font-weight: 500; }

.session-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 14px;
}

.chip {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  padding: 6px 8px 6px 12px;
  font-size: 13px;
}

.chip button {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 16px;
  line-height: 1;
  padding: 2px;
}

.empty-hint {
  color: var(--text-muted);
  font-size: 14px;
  padding: 24px 4px;
  text-align: center;
}

.grid-wrap {
  overflow-x: auto;
  border-radius: var(--radius);
  border: 1px solid var(--border-strong);
}

table.grid {
  border-collapse: collapse;
  width: 100%;
  min-width: 480px;
}

table.grid th, table.grid td {
  border-bottom: 1px solid var(--border);
  padding: 0;
  text-align: left;
}

table.grid thead th {
  background: var(--surface);
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 500;
  padding: 10px 8px;
  position: sticky;
  top: 0;
  white-space: nowrap;
}

table.grid thead th:first-child {
  position: sticky;
  left: 0;
  z-index: 2;
  background: var(--surface);
}

table.grid td.name-cell {
  background: var(--surface);
  padding: 12px 10px;
  font-size: 14px;
  position: sticky;
  left: 0;
  white-space: nowrap;
  font-weight: 500;
}

table.grid td.value-cell { padding: 4px; }

input.cell-input {
  width: 100px;
  height: 44px;
  background: var(--surface-2);
  border: 1px solid transparent;
  border-radius: 8px;
  color: var(--text);
  font-size: 15px;
  text-align: center;
  padding: 0 2px;
}

.cell-input:focus {
  outline: none;
  border-color: var(--accent);
}

.cell-input.warn {
  border-color: var(--warn);
  color: var(--warn);
}

.cell-input.saved {
  border-color: #22c55e55;
}

.fab {
  position: fixed;
  bottom: 20px;
  right: 20px;
  background: var(--accent);
  color: var(--accent-text);
  border: none;
  border-radius: 999px;
  width: 56px;
  height: 56px;
  font-size: 24px;
  box-shadow: 0 4px 14px #0006;
}

a.admin-link {
  color: var(--text-muted);
  font-size: 12px;
  text-decoration: none;
}
