:root {
  --bg: #f5f7fa;
  --panel: #ffffff;
  --text: #121826;
  --muted: #667085;
  --line: #d8dee8;
  --field: #ffffff;
  --accent: #0f766e;
  --danger: #b42318;
  --warning: #b54708;
  --success: #067647;
  --shadow: 0 16px 38px rgba(18, 24, 38, 0.08);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px clamp(16px, 4vw, 42px);
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(12px);
}

.topbar h1,
.panel h2 {
  margin: 0;
}

.topbar h1 {
  font-size: 1.24rem;
}

.topbar-actions,
.panel-title,
.form-grid,
.grid {
  display: flex;
  gap: 10px;
}

.topbar-actions,
.panel-title {
  align-items: center;
  justify-content: space-between;
}

.shell {
  width: min(1280px, calc(100% - 28px));
  margin: 0 auto;
  padding: 18px 0 42px;
}

.hidden {
  display: none !important;
}

.dashboard,
form {
  display: grid;
  gap: 14px;
}

.grid {
  display: grid;
  grid-template-columns: minmax(320px, 0.95fr) minmax(360px, 1.05fr);
}

.panel,
.metric {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.panel {
  padding: 18px;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 12px;
}

.metric {
  padding: 16px;
}

.metric strong {
  display: block;
  font-size: 1.8rem;
}

.metric span,
.muted {
  color: var(--muted);
}

.eyebrow {
  margin: 0 0 4px;
  color: #2563eb;
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
}

.form-grid {
  display: grid;
  gap: 10px;
}

.form-grid.two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

input,
select {
  width: 100%;
  min-height: 40px;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--field);
  color: var(--text);
  font: inherit;
}

input:focus,
select:focus {
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.14);
  outline: none;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 0 14px;
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  background: var(--accent);
  color: #ffffff;
  font: inherit;
  font-weight: 800;
  text-decoration: none;
  cursor: pointer;
}

.button.secondary {
  border-color: var(--line);
  background: #eef2f7;
  color: var(--text);
}

.table-wrap {
  overflow: auto;
}

table {
  width: 100%;
  min-width: 780px;
  border-collapse: collapse;
  font-size: 0.88rem;
}

th,
td {
  padding: 10px 11px;
  border-bottom: 1px solid var(--line);
  text-align: left;
}

th {
  background: #eef2f7;
  color: var(--muted);
  font-size: 0.72rem;
  text-transform: uppercase;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.status-active {
  border-color: color-mix(in srgb, var(--success) 40%, transparent);
  color: var(--success);
}

.status-inactive {
  border-color: color-mix(in srgb, var(--danger) 34%, transparent);
  color: var(--danger);
}

.usage-list {
  display: grid;
  gap: 8px;
  max-height: 340px;
  overflow: auto;
}

.usage-item {
  display: grid;
  gap: 3px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fbfcfe;
}

.usage-item strong {
  font-size: 0.9rem;
}

.usage-item span {
  color: var(--muted);
  font-size: 0.78rem;
}

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 30;
  max-width: min(420px, calc(100vw - 32px));
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--text);
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
  transition: opacity 0.16s ease, transform 0.16s ease;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 900px) {
  .topbar,
  .panel-title {
    align-items: flex-start;
    flex-direction: column;
  }

  .topbar-actions,
  .grid,
  .form-grid.two {
    grid-template-columns: 1fr;
    width: 100%;
  }
}
