@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

:root {
  color-scheme: dark;
  --bg: #09090b;
  --panel: #18181b;
  --panel-muted: #27272a;
  --text: #fafafa;
  --muted: #a1a1aa;
  --border: #27272a;
  --accent: #3b82f6;
  --accent-dark: #2563eb;
  --success: #22c55e;
  --warning: #f59e0b;
  --danger: #ef4444;
  --danger-soft: rgba(239, 68, 68, 0.1);
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  --radius-lg: 16px;
  --radius-md: 10px;
  --radius-sm: 8px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.layout {
  max-width: 1280px;
  margin: 0 auto;
  padding: 28px 20px 48px;
}

.topbar,
.login-card,
.panel,
.stat-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  padding: 22px 24px;
  margin-bottom: 20px;
  align-items: flex-start;
}

.brand-eyebrow {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 8px;
}

h1,
h2,
h3,
p {
  margin: 0;
}

.page-title {
  font-size: 30px;
  line-height: 1.1;
  margin-bottom: 8px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.page-subtitle,
.muted,
.hint,
.subline {
  color: var(--muted);
  font-size: 14px;
}

.topbar-actions {
  display: flex;
  gap: 16px;
  align-items: flex-end;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.action-group {
  display: flex;
  gap: 10px;
}

.api-box {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 280px;
  width: 100%;
  max-width: 340px;
}

.api-box label,
.field label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 2px;
}

.api-row,
.field {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.api-controls {
  display: flex;
  gap: 10px;
}

input,
textarea {
  width: 100%;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--bg);
  height: 40px;
  padding: 0 14px;
  color: var(--text);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

input:focus,
textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

textarea {
  min-height: 96px;
  height: auto;
  padding: 10px 14px;
  resize: vertical;
}

.btn {
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  height: 40px;
  padding: 0 16px;
  font-weight: 600;
  font-size: 14px;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
}

.btn:hover {
  transform: translateY(-2px);
  filter: brightness(1.15);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.btn:active {
  transform: translateY(0);
  box-shadow: none;
}

.btn:disabled {
  cursor: wait;
  opacity: 0.65;
  transform: none;
  filter: none;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
}

.btn-secondary {
  background: var(--panel-muted);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-success {
  background: rgba(34, 197, 94, 0.15);
  color: var(--success);
}

.btn-warning {
  background: rgba(245, 158, 11, 0.15);
  color: var(--warning);
}

.btn-danger {
  background: var(--danger-soft);
  color: var(--danger);
}

.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
}

.login-card {
  width: min(460px, 100%);
  padding: 32px 28px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.login-grid {
  display: grid;
  gap: 16px;
}

.stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}

.stat-card {
  padding: 22px 24px;
}

.stat-card .label {
  color: var(--muted);
  font-size: 14px;
  margin-bottom: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.stat-card .value {
  font-size: 40px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.panel {
  overflow: hidden;
}

.panel-header {
  padding: 22px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
}

.panel-header h2 {
  font-size: 20px;
  font-weight: 600;
  margin-bottom: 4px;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}

th {
  font-size: 12px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  background: var(--panel);
  font-weight: 600;
  border-bottom: 2px solid var(--border);
}

tr:last-child td {
  border-bottom: 0;
}

tr:hover td {
  background: rgba(255, 255, 255, 0.02);
}

.user-block,
.device-block {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.user-title,
.device-title {
  font-size: 15px;
  font-weight: 600;
}

.message-preview {
  margin-top: 10px;
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  background: rgba(59, 130, 246, 0.08);
  border: 1px solid rgba(59, 130, 246, 0.2);
}

.message-preview strong {
  display: block;
  margin-bottom: 4px;
  color: var(--accent);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.message-preview p {
  line-height: 1.5;
  font-size: 14px;
  color: var(--text);
}

.status-stack,
.cell-stack {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.05em;
}

.status-active {
  background: rgba(34, 197, 94, 0.15);
  color: var(--success);
}

.status-pending {
  background: rgba(245, 158, 11, 0.15);
  color: var(--warning);
}

.status-revoked,
.status-inactive {
  background: rgba(239, 68, 68, 0.15);
  color: var(--danger);
}

.action-stack {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 160px;
}

.notice {
  margin-bottom: 18px;
  padding: 14px 18px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--panel-muted);
  font-size: 14px;
  font-weight: 500;
}

.notice.success {
  border-color: rgba(34, 197, 94, 0.3);
  background: rgba(34, 197, 94, 0.1);
  color: #4ade80;
}

.notice.error {
  border-color: rgba(239, 68, 68, 0.3);
  background: rgba(239, 68, 68, 0.1);
  color: #f87171;
}

.empty-state {
  padding: 48px 24px;
  text-align: center;
  color: var(--muted);
  font-size: 15px;
}

@media (max-width: 980px) {
  .stats {
    grid-template-columns: 1fr;
  }

  .topbar {
    flex-direction: column;
  }

  .topbar-actions,
  .api-controls {
    width: 100%;
    justify-content: flex-start;
  }

  .action-group {
    width: 100%;
    justify-content: flex-start;
  }

  .api-box {
    min-width: 0;
    max-width: 100%;
    width: 100%;
  }
}

