:root {
  color-scheme: light;
  --ink: #17211d;
  --muted: #60706a;
  --line: #dbe7e2;
  --soft: #f4f8f6;
  --softer: #eef5f2;
  --panel: #ffffff;
  --brand: #087264;
  --brand-dark: #075b50;
  --accent: #b8324b;
  --warn: #a46909;
  --shadow: 0 12px 28px rgba(23, 33, 29, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--soft);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.auth-gate {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: linear-gradient(145deg, #0c3f37, #072a25);
}

.auth-card {
  width: min(460px, 100%);
  padding: 32px;
  border-radius: 18px;
  background: var(--panel);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.25);
}

.auth-card h1 {
  margin: 0 0 12px;
}

.auth-card p:not(.eyebrow) {
  color: var(--muted);
  line-height: 1.55;
}

.auth-card .primary-button {
  width: 100%;
  margin-top: 12px;
}

.auth-message {
  min-height: 1.4em;
  margin: 14px 0 0;
  font-size: 0.85rem;
}

.auth-message.error {
  color: var(--accent) !important;
}

body.admin-ready .auth-gate {
  display: none;
}

button,
input,
textarea {
  font: inherit;
}

button {
  border: 0;
  border-radius: 7px;
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.app-shell {
  display: none;
  grid-template-columns: 280px minmax(0, 1fr);
  min-height: 100vh;
}

body.admin-ready .app-shell {
  display: grid;
}

.empty-copy {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.sidebar {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 32px;
  padding: 28px;
  background: #0c3f37;
  color: #ffffff;
}

.sidebar h1,
.topbar h2,
.panel-header h3,
.detail-heading h3,
.audit-panel h3,
.detail-section h4 {
  margin: 0;
}

.sidebar h1 {
  font-size: 2rem;
}

.sidebar-copy {
  color: #cde5de;
  line-height: 1.5;
}

.eyebrow {
  margin: 0 0 6px;
  color: #0b7f70;
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.sidebar .eyebrow {
  color: #9dd8ca;
}

.nav-list {
  display: grid;
  gap: 8px;
}

.nav-item {
  border-radius: 7px;
  color: #e9f8f4;
  padding: 12px 14px;
  text-decoration: none;
}

.nav-item.active,
.nav-item:hover {
  background: rgba(255, 255, 255, 0.14);
}

.admin-lock {
  align-items: center;
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 8px;
  display: flex;
  gap: 12px;
  padding: 14px;
}

.admin-lock span:last-child {
  color: #cde5de;
  display: block;
  font-size: 0.84rem;
  margin-top: 2px;
}

.status-dot {
  background: #75e0aa;
  border-radius: 50%;
  box-shadow: 0 0 0 5px rgba(117, 224, 170, 0.18);
  height: 10px;
  width: 10px;
}

.main-content {
  display: grid;
  gap: 22px;
  padding: 28px;
}

.topbar {
  align-items: center;
  display: flex;
  justify-content: space-between;
  gap: 18px;
}

.topbar h2 {
  font-size: clamp(1.7rem, 4vw, 2.5rem);
}

.topbar-actions,
.filter-row,
.action-grid,
.section-heading {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.primary-button,
.secondary-button,
.filter-button,
.action-grid button,
.section-heading button,
.device-row button {
  min-height: 38px;
  padding: 0 14px;
}

.primary-button {
  background: var(--brand);
  color: #ffffff;
}

.primary-button:hover {
  background: var(--brand-dark);
}

.secondary-button,
.filter-button,
.section-heading button,
.device-row button {
  background: #ffffff;
  border: 1px solid var(--line);
  color: var(--ink);
}

.filter-button.active {
  background: var(--brand);
  color: #ffffff;
}

.privacy-strip {
  background: #e6f4ef;
  border: 1px solid #bfdfd5;
  border-radius: 8px;
  color: #174c43;
  padding: 14px 16px;
}

.metrics-grid {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.metrics-grid article,
.user-panel,
.detail-panel,
.audit-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.metrics-grid article {
  display: grid;
  gap: 6px;
  padding: 18px;
}

.metrics-grid span,
.usage-grid span {
  color: var(--muted);
  font-size: 0.85rem;
}

.metrics-grid strong {
  font-size: 1.9rem;
}

.workspace-grid {
  align-items: start;
  display: grid;
  gap: 18px;
  grid-template-columns: minmax(0, 1fr) 390px;
}

.user-panel,
.detail-panel,
.audit-panel {
  overflow: hidden;
}

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

.panel-header p {
  color: var(--muted);
  margin: 4px 0 0;
}

.search-box {
  display: grid;
  gap: 5px;
  min-width: min(260px, 100%);
}

.search-box span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
}

.search-box input,
textarea {
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--ink);
  outline-color: var(--brand);
  padding: 10px 12px;
  width: 100%;
}

.filter-row {
  border-bottom: 1px solid var(--line);
  padding: 14px 18px;
}

.table-wrap {
  overflow-x: auto;
}

table {
  border-collapse: collapse;
  min-width: 640px;
  width: 100%;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 14px 18px;
  text-align: left;
  vertical-align: middle;
}

th {
  color: var(--muted);
  font-size: 0.78rem;
  text-transform: uppercase;
}

tbody tr {
  cursor: pointer;
}

tbody tr:hover,
tbody tr.selected {
  background: var(--softer);
}

.user-name {
  display: grid;
  gap: 2px;
}

.user-name span {
  color: var(--muted);
  font-size: 0.85rem;
}

.badge,
.tier-pill {
  border-radius: 999px;
  display: inline-flex;
  font-size: 0.78rem;
  font-weight: 800;
  justify-content: center;
  min-width: 78px;
  padding: 5px 10px;
  text-transform: capitalize;
}

.badge.active,
.badge.trial,
.tier-pill.pro,
.tier-pill.max {
  background: #daf3e7;
  color: #0b5f4e;
}

.badge.past_due {
  background: #fff1ce;
  color: var(--warn);
}

.badge.revoked,
.danger-button {
  background: #ffe4e8;
  color: var(--accent);
}

.badge.free,
.tier-pill.free {
  background: #edf1ef;
  color: #51635d;
}

.detail-panel {
  min-height: 520px;
  position: sticky;
  top: 20px;
}

.empty-state {
  padding: 26px;
}

.empty-state p,
.detail-heading p,
.detail-list,
.detail-section p {
  color: var(--muted);
}

.detail-heading {
  align-items: start;
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 22px;
}

.detail-heading p {
  margin: 4px 0 0;
}

.detail-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin: 0;
  padding: 18px 22px;
}

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

.detail-list dt {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.detail-list dd {
  margin: 5px 0 0;
}

.action-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  padding: 0 22px 18px;
}

.license-control {
  display: grid;
  gap: 7px;
  padding: 0 22px 14px;
}

.license-control label {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.license-control input {
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  font: inherit;
  padding: 10px 12px;
}

.license-control p,
.billing-warning {
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.45;
  margin: 0;
}

.billing-warning {
  padding: 0 22px 18px;
}

.action-grid button {
  background: var(--brand);
  color: #ffffff;
}

.action-grid .danger-button {
  background: #ffe4e8;
  color: var(--accent);
}

.detail-section {
  border-top: 1px solid var(--line);
  padding: 18px 22px;
}

.section-heading {
  justify-content: space-between;
}

.device-list {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

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

.device-row strong {
  display: block;
}

.device-row span {
  color: var(--muted);
  display: block;
  font-size: 0.84rem;
  margin-top: 2px;
}

.usage-grid {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-top: 14px;
}

.usage-grid div {
  background: var(--soft);
  border-radius: 8px;
  padding: 12px;
}

.usage-grid strong {
  display: block;
  margin-top: 4px;
}

.audit-panel {
  margin-bottom: 28px;
}

.audit-list {
  display: grid;
  gap: 10px;
  list-style: none;
  margin: 0;
  padding: 18px;
}

.audit-list li {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
}

.audit-list span {
  color: var(--muted);
  display: block;
  font-size: 0.85rem;
  margin-top: 3px;
}

@media (max-width: 1100px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
  }

  .workspace-grid {
    grid-template-columns: 1fr;
  }

  .detail-panel {
    position: static;
  }
}

@media (max-width: 720px) {
  .main-content,
  .sidebar {
    padding: 18px;
  }

  .topbar,
  .panel-header {
    align-items: stretch;
    flex-direction: column;
  }

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

  .detail-list,
  .action-grid,
  .usage-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 460px) {
  .metrics-grid {
    grid-template-columns: 1fr;
  }
}
