:root {
  --bg: #111111;
  --surface: #181818;
  --border: #2a2a2a;
  --text: #ececec;
  --muted: #737373;
  --accent: #ececec;
  --green: #4ade80;
  --red: #f87171;
  --amber: #fbbf24;
  --radius: 6px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, monospace;
}

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

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }
.screen { min-height: 100vh; }

/* Login */
#login-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.login-card {
  width: 100%;
  max-width: 340px;
}

.login-card h1 {
  font-size: 1.125rem;
  font-weight: 500;
  letter-spacing: -0.02em;
  margin-bottom: 4px;
}

.login-card .tagline {
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 32px;
}

#login-form label {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 6px;
  margin-top: 16px;
}

#login-form label:first-of-type { margin-top: 0; }

input, select {
  width: 100%;
  padding: 8px 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
}

input:focus, select:focus {
  outline: none;
  border-color: #444;
}

input::placeholder { color: #555; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  background: var(--surface);
  color: var(--text);
  transition: background 0.12s, border-color 0.12s;
}

.btn:hover { background: #222; border-color: #444; }
.btn-primary { background: var(--text); color: var(--bg); border-color: var(--text); }
.btn-primary:hover { background: #ccc; border-color: #ccc; }
.btn-ghost { background: transparent; color: var(--muted); }
.btn-ghost:hover { color: var(--text); background: transparent; border-color: #444; }
.btn-warning { color: var(--amber); border-color: #3d3420; }
.btn-warning:hover { background: #1f1a0f; }
.btn-danger { color: var(--red); border-color: #3d2020; }
.btn-danger:hover { background: #1f0f0f; }
.btn-sm { padding: 5px 10px; font-size: 12px; }
#login-form .btn { width: 100%; margin-top: 24px; }

.error { color: var(--red); font-size: 13px; margin-top: 12px; }
.success { color: var(--green); font-size: 13px; margin-top: 12px; }

/* Header */
.header {
  display: flex;
  align-items: center;
  gap: 32px;
  padding: 0 24px;
  height: 48px;
  border-bottom: 1px solid var(--border);
}

.logo {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  letter-spacing: -0.01em;
  white-space: nowrap;
}

.logo span { color: var(--muted); font-weight: 400; }

.tabs {
  display: flex;
  gap: 0;
  flex: 1;
  height: 100%;
}

.tab {
  padding: 0 16px;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--muted);
  font-family: inherit;
  font-size: 13px;
  font-weight: 400;
  cursor: pointer;
  height: 100%;
  margin-bottom: -1px;
  transition: color 0.12s;
}

.tab:hover { color: var(--text); }
.tab.active { color: var(--text); border-bottom-color: var(--text); }

.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.user-badge {
  font-size: 12px;
  color: var(--muted);
  font-family: var(--mono);
}

/* Content */
.content {
  max-width: 960px;
  margin: 0 auto;
  padding: 32px 24px 64px;
}

.page-title {
  font-size: 15px;
  font-weight: 500;
  margin-bottom: 4px;
  letter-spacing: -0.01em;
}

.subtitle {
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 28px;
}

.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* Stats */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--surface);
  padding: 16px 18px;
}

.stat-label {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 4px;
}

.stat-value {
  font-size: 22px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}

.status-breakdown {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.status-breakdown h3 {
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.status-bars { padding: 4px 0; }

.status-bar-row {
  display: grid;
  grid-template-columns: 80px 1fr 56px;
  align-items: center;
  gap: 12px;
  padding: 8px 16px;
  border-bottom: 1px solid var(--border);
}

.status-bar-row:last-child { border-bottom: none; }

.status-bar-label {
  font-size: 12px;
  color: var(--muted);
  font-family: var(--mono);
}

.status-bar-track {
  height: 3px;
  background: var(--border);
  border-radius: 1px;
  overflow: hidden;
}

.status-bar-fill {
  height: 100%;
  background: var(--muted);
  border-radius: 1px;
}

.status-bar-count {
  text-align: right;
  font-size: 12px;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  font-family: var(--mono);
}

/* Search */
.search-bar {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
}

.search-bar input { flex: 1; }

/* User result */
.user-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin: 28px 0 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

.user-header h3 {
  font-size: 15px;
  font-weight: 500;
  font-family: var(--mono);
}

.badge {
  display: inline-block;
  margin-left: 10px;
  font-size: 11px;
  font-family: var(--mono);
  color: var(--muted);
}

.badge.ACTIVE { color: var(--green); }
.badge.DISABLED { color: var(--red); }
.badge.LIMITED { color: var(--amber); }

.panels-grid {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.panel {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.panel h4 {
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.panel-body { padding: 16px; }

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.panel-header h4 {
  padding: 0;
  border: none;
  background: none;
}

.panel-wide .panel-body,
.panel:not(.panel-wide) > :not(h4):not(.panel-header) {
  padding: 16px;
}

.info-list {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 6px 16px;
}

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

.info-list dd {
  font-size: 13px;
  word-break: break-all;
  font-family: var(--mono);
  font-size: 12px;
}

.edit-form {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px 20px;
  padding: 16px;
}

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

.edit-form .btn {
  grid-column: 1 / -1;
  justify-self: start;
  margin-top: 4px;
}

.panel .btn-sm { margin: 0 16px 16px; }

.devices-list { padding: 0; }

.device-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
}

.device-card:last-child { border-bottom: none; }

.device-info { font-size: 13px; }
.device-info strong {
  display: block;
  font-weight: 500;
  font-size: 13px;
  margin-bottom: 2px;
}

.device-info span {
  color: var(--muted);
  font-size: 11px;
  font-family: var(--mono);
}

.empty-note {
  padding: 16px;
  color: var(--muted);
  font-size: 13px;
}

.toast {
  position: fixed;
  bottom: 20px;
  right: 20px;
  padding: 10px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 13px;
  z-index: 100;
}

.toast.error { border-color: #3d2020; color: var(--red); }
.toast.success { border-color: #1a3d20; color: var(--green); }

@media (max-width: 640px) {
  .header { gap: 16px; padding: 0 16px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .edit-form { grid-template-columns: 1fr; }
  .info-list { grid-template-columns: 1fr; }
  .search-bar { flex-direction: column; }
}
