:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --panel: #ffffff;
  --ink: #1d2430;
  --muted: #667085;
  --line: #d8dee8;
  --accent: #0f766e;
  --accent-strong: #115e59;
  --warn: #9a3412;
  --ok: #166534;
  --soft: #eef7f5;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
}

button,
input {
  font: inherit;
}

button {
  min-height: 42px;
  border: 0;
  border-radius: 8px;
  padding: 0 16px;
  background: var(--accent);
  color: white;
  cursor: pointer;
}

button:hover {
  background: var(--accent-strong);
}

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

button.secondary {
  border: 1px solid var(--line);
  background: white;
  color: var(--ink);
}

input {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  background: white;
  color: var(--ink);
}

input[type="checkbox"] {
  width: 18px;
  min-height: 18px;
  accent-color: var(--accent);
}

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

.shell {
  width: min(1120px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 32px 0;
}

.professional-shell {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 64px;
  padding: 0 clamp(20px, 5vw, 56px);
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}

.professional-shell h1 {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
}

.professional-main {
  display: grid;
  min-height: calc(100vh - 64px);
  align-content: start;
}

.shell.narrow {
  width: min(760px, calc(100vw - 32px));
}

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

.topbar h1,
.panel h2,
.mini-card h3 {
  margin: 0;
}

.topbar p {
  margin: 6px 0 0;
  color: var(--muted);
}

.text-link {
  display: inline-block;
  margin-bottom: 8px;
  color: var(--accent);
  font-size: 0.9rem;
  font-weight: 700;
  text-decoration: none;
}

.status-pill {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 12px;
  background: white;
  color: var(--muted);
  font-size: 0.9rem;
}

.grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(340px, 0.8fr);
  gap: 20px;
  align-items: start;
}

.choice-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.choice-card {
  display: grid;
  gap: 8px;
  min-height: 148px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  background: var(--panel);
  color: var(--ink);
  text-decoration: none;
}

.choice-card:hover {
  border-color: #9fd3ca;
  background: var(--soft);
}

.choice-card strong {
  font-size: 1.2rem;
}

.choice-card span:last-child {
  color: var(--muted);
}

.panel,
.mini-card,
.notice {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.panel {
  padding: 20px;
}

.panel-heading {
  margin-bottom: 16px;
}

.eyebrow {
  display: block;
  margin-bottom: 4px;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.mini-apps,
.stack {
  display: grid;
  gap: 12px;
}

.login-panel {
  display: grid;
  min-height: min(520px, calc(100vh - 160px));
  place-items: center;
}

.login-card {
  display: grid;
  width: min(440px, 100%);
  gap: 18px;
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 18px 50px rgb(29 36 48 / 0.08);
  justify-items: center;
}

.login-card h2 {
  margin: 0;
  font-size: 1.35rem;
}

.login-card button {
  width: min(260px, 100%);
}

.login-card .notice {
  width: 100%;
  margin: 0;
  text-align: center;
}

.account-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  justify-content: flex-end;
}

.account-email {
  color: var(--muted);
  font-size: 0.9rem;
}

.mini-card {
  display: grid;
  gap: 12px;
  padding: 16px;
}

.mini-card p {
  margin: 0;
  color: var(--muted);
}

.mini-card.unlocked {
  background: var(--soft);
  border-color: #9fd3ca;
}

.code-box {
  display: grid;
  gap: 4px;
  border-radius: 8px;
  padding: 12px;
  background: #111827;
  color: white;
}

.code-box strong {
  font-size: 1.3rem;
  letter-spacing: 0.08em;
}

.device-empty {
  display: grid;
  gap: 8px;
  min-height: 160px;
  place-items: center;
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 28px;
  color: var(--muted);
  text-align: center;
}

.device-empty strong {
  color: var(--ink);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: clamp(1.1rem, 4vw, 1.45rem);
}

.device-empty p {
  margin: 0;
}

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

.notice {
  margin-bottom: 14px;
  padding: 12px;
}

.notice.ok {
  border-color: #bbf7d0;
  background: #f0fdf4;
  color: var(--ok);
}

.notice.warn {
  border-color: #fed7aa;
  background: #fff7ed;
  color: var(--warn);
}

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

.row.between {
  justify-content: space-between;
}

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

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
}

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

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

th {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

tbody tr:last-child td,
tbody tr:last-child th {
  border-bottom: 0;
}

.code-cell {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 0.92rem;
  font-weight: 700;
}

.status-cell {
  font-weight: 700;
}

.status-cell.pending {
  color: #854d0e;
}

.status-cell.approved {
  color: var(--ok);
}

.status-cell.closed,
.status-cell.expired {
  color: var(--muted);
}

.actions-cell {
  display: flex;
  gap: 8px;
  align-items: center;
  min-width: 190px;
}

.permission-cell {
  text-align: center;
}

.permission-head,
.actions-head,
.device-actions-cell {
  text-align: center;
}

.device-actions-cell button {
  min-height: 34px;
}

button.danger {
  color: #991b1b;
}

.empty-state {
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 22px;
  color: var(--muted);
  text-align: center;
}

.hidden {
  display: none !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 820px) {
  .grid,
  .choice-grid {
    grid-template-columns: 1fr;
  }

  .topbar {
    display: grid;
  }

  .toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .account-bar {
    justify-content: flex-start;
  }
}
