:root {
  --bg: #0a0c0f;
  --surface: #12161b;
  --surface-2: #171c22;
  --line: #222932;
  --text: #e9edf2;
  --muted: #8a95a3;
  --accent: #4da3ff;
  --accent-soft: rgba(77, 163, 255, 0.14);
  --ok: #45d18a;
  --danger: #ff6b6b;
  --warn: #f0b429;
  --radius: 16px;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.4;
  overscroll-behavior: none;
}

body {
  min-height: 100vh;
  background:
    radial-gradient(900px 420px at 100% -10%, rgba(77, 163, 255, 0.12), transparent 70%),
    radial-gradient(600px 300px at -10% 0%, rgba(69, 209, 138, 0.07), transparent 70%),
    var(--bg);
}

.app {
  max-width: 620px;
  margin: 0 auto;
  padding: 14px 14px calc(86px + env(safe-area-inset-bottom));
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 6px 2px 16px;
}

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

.logo {
  width: 30px;
  height: 30px;
  border-radius: 9px;
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 15px;
  color: #061422;
  background: linear-gradient(135deg, #4da3ff, #45d18a);
}

.brand-text {
  font-weight: 700;
  letter-spacing: 1.6px;
  font-size: 13px;
  color: #cfd8e3;
}

.who {
  color: var(--muted);
  font-size: 13px;
  max-width: 48%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.screen {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.card {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.018), transparent), var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 15px;
}

.card-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-weight: 600;
  font-size: 14px;
  margin-bottom: 12px;
}

.card-title .sub {
  color: var(--muted);
  font-weight: 400;
  font-size: 12px;
}

.hero {
  padding: 18px;
}

.hero-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.hero-title {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.2px;
}

.hero-sub {
  color: var(--muted);
  font-size: 13px;
  margin-top: 4px;
}

.badge {
  font-size: 11px;
  font-weight: 600;
  padding: 5px 10px;
  border-radius: 20px;
  background: var(--surface-2);
  color: var(--muted);
  white-space: nowrap;
}

.badge.on {
  color: var(--ok);
  background: rgba(69, 209, 138, 0.12);
}

.badge.warn {
  color: var(--warn);
  background: rgba(240, 180, 41, 0.12);
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 14px;
}

.metric {
  background: var(--surface-2);
  border-radius: 12px;
  padding: 11px 10px;
  text-align: center;
}

.metric b {
  display: block;
  font-size: 19px;
  font-weight: 700;
}

.metric span {
  color: var(--muted);
  font-size: 11px;
}

.row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}

.row:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.row:first-of-type {
  padding-top: 0;
}

.row .label {
  color: var(--muted);
  font-size: 13px;
}

.row .value {
  font-size: 13px;
  text-align: right;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 62%;
}

.toggle-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}

.toggle-row:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.toggle-row:first-child {
  padding-top: 0;
}

.toggle-info {
  flex: 1;
  min-width: 0;
}

.toggle-info b {
  display: block;
  font-size: 14px;
  font-weight: 600;
}

.toggle-info span {
  color: var(--muted);
  font-size: 12px;
}

.switch {
  width: 46px;
  height: 27px;
  border-radius: 16px;
  background: #262e38;
  position: relative;
  flex: none;
  border: none;
  padding: 0;
  transition: background 0.18s ease;
}

.switch::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 21px;
  height: 21px;
  border-radius: 50%;
  background: #7d8896;
  transition: transform 0.18s ease, background 0.18s ease;
}

.switch.on {
  background: rgba(69, 209, 138, 0.22);
}

.switch.on::after {
  transform: translateX(19px);
  background: var(--ok);
}

button {
  font-family: inherit;
}

.primary, .ghost, .danger {
  width: 100%;
  border: none;
  border-radius: 12px;
  padding: 13px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s ease, transform 0.05s ease;
}

.primary {
  background: var(--accent);
  color: #04101f;
}

.primary:active {
  transform: scale(0.99);
}

.primary:disabled {
  background: #23303d;
  color: #6b7987;
}

.ghost {
  background: transparent;
  border: 1px solid var(--line);
  color: #b9c3cf;
}

.danger {
  background: rgba(255, 107, 107, 0.12);
  color: var(--danger);
}

.mini-btn {
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: #cfd8e3;
  border-radius: 10px;
  padding: 8px 12px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.list-item {
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}

.list-item:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.list-item:first-child {
  padding-top: 0;
}

.list-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}

.list-title {
  font-weight: 600;
  font-size: 14px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.list-meta {
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.list-text {
  color: #b6c0cc;
  font-size: 13px;
  margin-top: 5px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.item-actions {
  display: flex;
  gap: 8px;
  margin-top: 9px;
}

.empty {
  color: var(--muted);
  font-size: 13px;
  padding: 8px 0 2px;
}

.field {
  margin-bottom: 12px;
}

.field label {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 6px;
}

input, textarea, select {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 11px;
  color: var(--text);
  padding: 12px;
  font-size: 15px;
  font-family: inherit;
  outline: none;
}

input:focus, textarea:focus, select:focus {
  border-color: var(--accent);
}

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

.tabs {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  display: flex;
  justify-content: center;
  gap: 2px;
  padding: 8px 8px calc(8px + env(safe-area-inset-bottom));
  background: rgba(10, 12, 15, 0.92);
  backdrop-filter: blur(14px);
  border-top: 1px solid var(--line);
}

.tab {
  flex: 1;
  max-width: 120px;
  background: none;
  border: none;
  color: var(--muted);
  font-size: 11px;
  font-weight: 500;
  padding: 6px 2px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  cursor: pointer;
}

.tab.active {
  color: var(--accent);
}

.tab svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.tab.active svg {
  stroke: var(--accent);
}

.sheet {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.sheet.hidden {
  display: none;
}

.sheet-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
}

.sheet-panel {
  position: relative;
  width: 100%;
  max-width: 620px;
  max-height: 88vh;
  overflow-y: auto;
  background: var(--surface);
  border-radius: 20px 20px 0 0;
  padding: 16px 16px calc(20px + env(safe-area-inset-bottom));
  animation: slide-up 0.22s ease;
}

@keyframes slide-up {
  from { transform: translateY(30px); opacity: 0.6; }
  to { transform: translateY(0); opacity: 1; }
}

.sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: 600;
  margin-bottom: 14px;
}

.icon-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(86px + env(safe-area-inset-bottom));
  transform: translateX(-50%) translateY(10px);
  background: #232b34;
  color: #e9edf2;
  border: 1px solid #2f3944;
  padding: 10px 16px;
  border-radius: 12px;
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 60;
  max-width: 86%;
  text-align: center;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.toast.error {
  border-color: rgba(255, 107, 107, 0.4);
  color: #ffb3b3;
}

.skeleton {
  background: linear-gradient(90deg, #14191f, #1b2129, #14191f);
  background-size: 200% 100%;
  animation: shimmer 1.2s infinite;
  border-radius: 10px;
  height: 14px;
}

@keyframes shimmer {
  from { background-position: 200% 0; }
  to { background-position: -200% 0; }
}

.notice {
  color: var(--muted);
  font-size: 12px;
  margin-top: 10px;
  line-height: 1.5;
}

.blocked {
  text-align: center;
  padding: 60px 20px;
}

.blocked h2 {
  font-size: 19px;
  margin: 0 0 8px;
}

.blocked p {
  color: var(--muted);
  font-size: 13px;
  margin: 0;
}

.subhead {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 2px 0 4px;
}

.back-btn {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  display: grid;
  place-items: center;
  cursor: pointer;
  flex: none;
}

.back-btn svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.subhead-title {
  font-size: 17px;
  font-weight: 700;
}

.menu-list {
  display: flex;
  flex-direction: column;
}

.menu-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
  background: none;
  border-left: none;
  border-right: none;
  border-top: none;
  color: var(--text);
  font-size: 15px;
  text-align: left;
  width: 100%;
  cursor: pointer;
}

.menu-item:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.menu-item:first-child {
  padding-top: 0;
}

.menu-icon {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: var(--surface-2);
  display: grid;
  place-items: center;
  flex: none;
  color: var(--accent);
}

.menu-icon svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.menu-text {
  flex: 1;
  min-width: 0;
}

.menu-text b {
  display: block;
  font-weight: 600;
  font-size: 14px;
}

.menu-text span {
  color: var(--muted);
  font-size: 12px;
}

.chevron {
  color: #56616e;
  font-size: 18px;
  line-height: 1;
}

.search {
  margin-bottom: 10px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 11px;
  color: var(--text);
  padding: 10px 12px;
  font-size: 14px;
  width: 100%;
}

.bars {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  height: 120px;
  padding-top: 6px;
}

.bar-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  height: 100%;
  justify-content: flex-end;
}

.bar {
  width: 100%;
  max-width: 30px;
  border-radius: 7px 7px 3px 3px;
  background: linear-gradient(180deg, #4da3ff, rgba(77, 163, 255, 0.35));
  min-height: 4px;
}

.bar-label {
  color: var(--muted);
  font-size: 10px;
}

.admin-user {
  padding: 11px 0;
  border-bottom: 1px solid var(--line);
}

.admin-user:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.admin-user:first-child {
  padding-top: 0;
}

.admin-user-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-size: 13px;
}

.admin-user-head b {
  font-weight: 600;
}

.admin-user-meta {
  color: var(--muted);
  font-size: 12px;
  margin-top: 3px;
}

.chip-row {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.chip {
  font-size: 11px;
  color: var(--muted);
  background: var(--surface-2);
  border-radius: 20px;
  padding: 4px 9px;
}

.hidden {
  display: none !important;
}
