:root {
  color-scheme: light;
  --bg: #eef3f6;
  --panel: #ffffff;
  --line: #dbe3ed;
  --text: #18212f;
  --muted: #637083;
  --brand: #116466;
  --accent: #d9b44a;
  --danger: #b42318;
  --ok: #16794c;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background: var(--bg);
}

.login {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

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

aside {
  background: #12343b;
  color: white;
  padding: 24px;
  position: sticky;
  top: 0;
  height: 100vh;
}

main {
  padding: 28px;
  min-width: 0;
}

h1, h2, h3 { margin: 0; letter-spacing: 0; }
h1 { font-size: 28px; }
h2 { font-size: 20px; margin-bottom: 14px; }
p { color: var(--muted); }
.muted { color: var(--muted); font-size: 12px; }

.brand {
  font-size: 18px;
  font-weight: 800;
  margin-bottom: 28px;
}

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

.nav a, .nav button {
  color: white;
  text-decoration: none;
  border: 0;
  background: transparent;
  text-align: left;
  font: inherit;
  padding: 10px 12px;
  border-radius: 6px;
  cursor: pointer;
}

.nav a:hover, .nav button:hover,
.nav a.active {
  background: rgba(255,255,255,.14);
}

.nav a.active {
  box-shadow: inset 3px 0 0 var(--accent);
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  box-shadow: 0 10px 30px rgba(18,52,59,.05);
}

.login .panel {
  width: min(440px, 100%);
}

.grid {
  display: grid;
  gap: 16px;
}

.grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid.admin-split { grid-template-columns: minmax(420px, 1.4fr) minmax(260px, .6fr); }

.metric strong {
  display: block;
  font-size: 30px;
  line-height: 1.1;
}

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

form {
  display: grid;
  gap: 12px;
}

label {
  display: grid;
  gap: 6px;
  font-size: 13px;
  color: var(--muted);
}

input, select {
  width: 100%;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 12px;
  font: inherit;
  color: var(--text);
  background: white;
}

button {
  height: 42px;
  border: 0;
  border-radius: 6px;
  padding: 0 14px;
  font: inherit;
  font-weight: 700;
  background: var(--brand);
  color: white;
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: .55;
}

button.secondary {
  background: #e8eef3;
  color: var(--text);
}

button.tiny {
  height: 30px;
  padding: 0 10px;
  margin-top: 8px;
  font-size: 12px;
}

.row {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 20px;
}

.topbar p {
  margin: 6px 0 0;
}

.topbar.in-panel {
  margin-bottom: 0;
}

.code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  color: var(--text);
}

.code-block {
  margin: 12px 0 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0f1f24;
  color: #eef7f4;
  overflow-x: auto;
  white-space: pre;
  font: 12px/1.55 ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

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

th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  white-space: nowrap;
}

td { min-width: 120px; }

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 2px 8px;
  border-radius: 999px;
  background: #e8eef3;
  font-size: 12px;
  font-weight: 700;
}

.badge.sent, .badge.active { color: var(--ok); background: #e8f5ee; }
.badge.failed, .badge.inactive { color: var(--danger); background: #fae9e7; }
.badge.queued, .badge.processing { color: #8a6100; background: #fff4d6; }

.notice {
  white-space: pre-wrap;
  border: 1px solid var(--line);
  background: #fbfcfd;
  padding: 12px;
  border-radius: 6px;
  color: var(--muted);
  font-size: 13px;
}

canvas {
  width: 100%;
  height: 260px;
  display: block;
}

.section { margin-top: 18px; }

.admin-view[hidden],
.company-view[hidden] { display: none; }

.mini-metrics {
  display: grid;
  gap: 12px;
}

.mini-metrics div {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #fbfcfd;
}

.mini-metrics strong {
  display: block;
  font-size: 28px;
}

.mini-metrics span {
  color: var(--muted);
  font-size: 13px;
}

.credential-box,
.credential-card {
  display: grid;
  gap: 12px;
}

.credential-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #fbfcfd;
}

.credential-card strong {
  font-size: 18px;
  word-break: break-word;
}

.credential-card small {
  color: var(--muted);
}

.activity-list {
  display: grid;
  gap: 10px;
}

.activity-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  align-items: start;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fbfcfd;
}

.activity-item strong,
.activity-item span,
.activity-item small {
  display: block;
}

.activity-item span,
.activity-item small,
.activity-item time {
  color: var(--muted);
  font-size: 12px;
}

.activity-item small {
  margin-top: 4px;
  word-break: break-word;
}

@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  aside { position: static; height: auto; }
  .grid.cols-2, .grid.cols-3, .grid.cols-4, .grid.admin-split { grid-template-columns: 1fr; }
  .topbar { align-items: flex-start; flex-direction: column; }
  .activity-item { grid-template-columns: 1fr; }
}
