*,
*::before,
*::after {
  box-sizing: border-box;
}

:root {
  --bg: #0b1220;
  --bg-2: #111827;
  --card: #1a2436;
  --line: #2a3650;
  --text: #f8fafc;
  --muted: #94a3b8;
  --amber: #f59e0b;
  --amber-2: #d97706;
  --green: #22c55e;
  --red: #f43f5e;
  --blue: #38bdf8;
  --radius: 14px;
  --tap: 48px;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
}

body {
  padding: env(safe-area-inset-top) env(safe-area-inset-right)
    env(safe-area-inset-bottom) env(safe-area-inset-left);
}

#app {
  max-width: 560px;
  margin: 0 auto;
  min-height: 100vh;
}

.screen {
  padding: 20px 16px 32px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 28px;
}

.brand img {
  width: 44px;
  height: 44px;
}

.brand h1 {
  margin: 0;
  font-size: 1.35rem;
  letter-spacing: 0.02em;
}

.brand p {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 0.85rem;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
}

label {
  display: block;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 6px;
}

input[type="text"],
input[type="number"],
input[type="search"] {
  width: 100%;
  height: var(--tap);
  border: 1px solid var(--line);
  background: var(--bg-2);
  color: var(--text);
  border-radius: 10px;
  padding: 0 12px;
  font-size: 1.05rem;
  outline: none;
}

input:focus {
  border-color: var(--amber);
  box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.2);
}

.row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.field {
  margin-bottom: 12px;
}

.btn {
  width: 100%;
  min-height: var(--tap);
  border: 0;
  border-radius: 12px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--amber);
  color: #111827;
}

.btn-green {
  background: var(--green);
  color: #052e16;
}

.btn-ghost {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--line);
}

.btn-danger {
  background: #3f1d27;
  color: #fecdd3;
  border: 1px solid #9f1239;
}

.btn-blue {
  background: #0e7490;
  color: white;
}

.actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 12px;
}

.header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 16px;
}

.header h1 {
  margin: 0;
  font-size: 1.25rem;
}

.header .who {
  color: var(--muted);
  font-size: 0.9rem;
  margin-top: 4px;
}

.link {
  background: none;
  border: 0;
  color: var(--blue);
  font-size: 0.85rem;
  cursor: pointer;
  padding: 0;
}

.combo {
  position: relative;
}

.dropdown {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 4px);
  background: #0f172a;
  border: 1px solid var(--line);
  border-radius: 10px;
  max-height: 220px;
  overflow: auto;
  z-index: 20;
  display: none;
}

.dropdown.open {
  display: block;
}

.dropdown button {
  width: 100%;
  text-align: left;
  background: none;
  border: 0;
  color: var(--text);
  padding: 12px;
  font-size: 0.98rem;
  cursor: pointer;
}

.dropdown button:hover,
.dropdown button.active {
  background: #1e293b;
  color: var(--amber);
}

.hint {
  color: var(--muted);
  font-size: 0.82rem;
  margin: 8px 0 0;
}

.file-btn {
  position: relative;
  overflow: hidden;
}

.file-btn input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.stats {
  display: flex;
  gap: 8px;
  margin: 12px 0;
}

.stat {
  flex: 1;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px;
  text-align: center;
}

.stat strong {
  display: block;
  font-size: 1.2rem;
}

.stat span {
  color: var(--muted);
  font-size: 0.75rem;
}

.list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 12px;
}

.item {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
}

.item-top {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: flex-start;
}

.pn {
  font-weight: 700;
  font-size: 1.02rem;
  word-break: break-all;
}

.meta {
  color: var(--muted);
  font-size: 0.9rem;
  margin-top: 4px;
}

.item-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

.tiny {
  min-height: 36px;
  width: auto;
  padding: 0 12px;
  font-size: 0.82rem;
}

.empty {
  text-align: center;
  color: var(--muted);
  padding: 28px 8px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  background: #ecfccb;
  color: #14532d;
  padding: 10px 16px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 0.9rem;
  z-index: 50;
  display: none;
}

.toast.show {
  display: block;
}

.editing {
  outline: 2px solid var(--amber);
}

.footer-note {
  text-align: center;
  color: var(--muted);
  font-size: 0.75rem;
  margin-top: 18px;
}

.live-pill {
  display: inline-block;
  margin-left: 8px;
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  padding: 2px 8px;
  border-radius: 999px;
  background: #1e293b;
  color: var(--muted);
  vertical-align: middle;
}

.live-pill.on {
  background: #14532d;
  color: #bbf7d0;
}

.live-pill.off {
  background: #4c0519;
  color: #fecdd3;
}

.admin-body #admin-app {
  max-width: 1080px;
  margin: 0 auto;
}

.admin-screen {
  padding: 20px 16px 40px;
}

.admin-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

select {
  width: 100%;
  height: var(--tap);
  border: 1px solid var(--line);
  background: var(--bg-2);
  color: var(--text);
  border-radius: 10px;
  padding: 0 12px;
  font-size: 1rem;
}

.user-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 10px;
  margin-top: 8px;
}

.user-chip {
  display: flex;
  gap: 10px;
  align-items: center;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px;
}

.user-chip .dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #64748b;
  flex-shrink: 0;
}

.user-chip.live {
  border-color: #166534;
}

.user-chip.live .dot {
  background: #22c55e;
  box-shadow: 0 0 0 4px rgba(34, 197, 94, 0.2);
}

.table-wrap {
  overflow: auto;
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}

.admin-table th,
.admin-table td {
  text-align: left;
  padding: 10px 8px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

.admin-table th {
  color: var(--muted);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.admin-body .stats {
  margin-bottom: 12px;
}
