:root {
  color-scheme: light;
  --bg: #f4f6f8;
  --panel: #ffffff;
  --ink: #17202a;
  --muted: #667085;
  --line: #d7dde5;
  --line-soft: #e8edf3;
  --primary: #0f766e;
  --primary-dark: #0b5f59;
  --primary-soft: #e7f5f2;
  --danger: #b42318;
  --danger-soft: #fff1f0;
  --warning: #a15c07;
  --warning-soft: #fff7e6;
  --nav: #1f2a37;
  --shadow: 0 14px 34px rgba(16, 24, 40, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, "Segoe UI", "Microsoft YaHei", Arial, sans-serif;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  min-height: 38px;
  border: 0;
  border-radius: 7px;
  padding: 0 13px;
  cursor: pointer;
  font-weight: 700;
  white-space: nowrap;
}

.button-like {
  display: inline-flex;
  align-items: center;
  min-height: 38px;
  border-radius: 7px;
  padding: 0 13px;
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
}

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

input,
select,
textarea {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--ink);
  padding: 9px 10px;
  outline: none;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.14);
}

textarea {
  resize: vertical;
}

label {
  display: grid;
  gap: 6px;
  color: #344054;
  font-size: 14px;
  font-weight: 700;
}

.primary {
  background: var(--primary);
  color: white;
}

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

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

.secondary:hover {
  background: #f8fafc;
}

.ghost {
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: transparent;
  color: #d7dee8;
}

.danger {
  border: 1px solid #f3b8b2;
  background: var(--danger-soft);
  color: var(--danger);
}

.full {
  width: 100%;
}

.muted {
  color: var(--muted);
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--primary);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.hidden {
  display: none !important;
}

.stack {
  display: grid;
  gap: 14px;
}

.auth-shell,
.client-shell {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 24px;
}

.auth-panel,
.code-panel {
  width: min(520px, 100%);
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  padding: 28px;
}

.auth-panel h1,
.code-panel h1,
.topbar h1 {
  margin: 0;
  line-height: 1.15;
}

.alert {
  border: 1px solid #fed7aa;
  border-radius: 7px;
  background: #fff7ed;
  color: #9a3412;
  padding: 12px;
}

.notice {
  position: fixed;
  top: 18px;
  right: 18px;
  z-index: 100;
  width: min(420px, calc(100vw - 36px));
  border: 1px solid #a7f3d0;
  border-radius: 8px;
  background: #ecfdf5;
  box-shadow: var(--shadow);
  color: #065f46;
  padding: 13px 14px;
  font-weight: 800;
}

.notice[data-type="error"] {
  border-color: #fecaca;
  background: #fff1f0;
  color: #991b1b;
}

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

.sidebar {
  position: sticky;
  top: 0;
  display: grid;
  height: 100vh;
  align-content: start;
  gap: 22px;
  background: var(--nav);
  color: #f8fafc;
  padding: 22px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-bottom: 6px;
}

.brand-mark {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 7px;
  background: #10b981;
  color: #06231d;
  font-weight: 900;
}

.brand small {
  display: block;
  color: #a7b4c5;
}

.nav-tabs {
  display: grid;
  gap: 6px;
}

.nav-tabs button {
  justify-content: start;
  border: 1px solid transparent;
  background: transparent;
  color: #d7dee8;
  text-align: left;
}

.nav-tabs button:hover {
  background: rgba(255, 255, 255, 0.06);
}

.nav-tabs button.active {
  border-color: rgba(16, 185, 129, 0.3);
  background: rgba(16, 185, 129, 0.15);
  color: #ffffff;
}

.workspace {
  min-width: 0;
  padding: 28px;
}

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

.topbar p,
.section-header p,
.toolbar p {
  margin: 5px 0 0;
  color: var(--muted);
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: grid;
  gap: 18px;
}

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

.grid.two {
  grid-template-columns: minmax(310px, 390px) minmax(0, 1fr);
}

.accounts-layout {
  display: grid;
  grid-template-columns: minmax(310px, 380px) minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.list-area {
  display: grid;
  gap: 14px;
  min-width: 0;
}

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

.metric,
.panel,
.table-wrap {
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.03);
}

.metric {
  padding: 16px;
}

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

.metric strong {
  display: block;
  margin-top: 8px;
  font-size: 28px;
}

.panel {
  padding: 18px;
}

.form-panel {
  position: sticky;
  top: 20px;
}

.panel h2,
.toolbar h2,
.section-header h2 {
  margin: 0;
  font-size: 18px;
}

.section-header {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.section-header.compact {
  align-items: center;
}

.section-header.compact span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.toolbar {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 14px;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: var(--panel);
  padding: 16px;
}

.toolbar-actions {
  display: flex;
  align-items: end;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 10px;
  width: min(900px, 100%);
}

.toolbar-actions > button {
  flex: 0 0 auto;
}

.search-box {
  flex: 1 1 190px;
  width: min(360px, 100%);
}

.compact-filter {
  flex-basis: 230px;
  width: min(260px, 100%);
}

.inline-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.empty-state {
  display: grid;
  gap: 10px;
  align-items: start;
  background: #f7fbff;
}

.empty-state p {
  margin: 0;
  color: var(--muted);
}

.empty-state button {
  width: fit-content;
}

.empty-line {
  padding: 18px;
  color: var(--muted);
  text-align: center;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.actions.split {
  justify-content: space-between;
}

.actions.right {
  justify-content: flex-end;
}

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

.compact-action {
  min-height: 34px;
  padding: 0 12px;
}

.more-actions {
  position: relative;
}

.more-actions summary {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: white;
  color: #253044;
  padding: 0 12px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 800;
  list-style: none;
  white-space: nowrap;
}

.more-actions summary::-webkit-details-marker {
  display: none;
}

.more-menu {
  display: grid;
  width: 112px;
  gap: 8px;
  margin-top: 8px;
}

.more-menu button {
  width: 100%;
}

.token-chip {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  margin: 4px 8px 0 0;
  border: 1px solid #d9e5ef;
  border-radius: 7px;
  background: #f8fafc;
  color: #475467;
  padding: 0 7px;
  font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.quick-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.copy-list {
  display: grid;
  max-height: 280px;
  gap: 10px;
  overflow: auto;
  padding-right: 4px;
}

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

.copy-item strong {
  display: block;
  margin-bottom: 5px;
}

.copy-item pre {
  margin: 0;
  color: #475467;
  font-family: inherit;
  font-size: 12px;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
}

.link-details {
  display: grid;
  gap: 8px;
}

.link-details summary {
  cursor: pointer;
  color: var(--primary);
  font-weight: 800;
}

.import-box {
  display: grid;
  gap: 12px;
  margin-top: 18px;
  border-top: 1px solid var(--line-soft);
  padding-top: 16px;
}

.import-box p {
  margin: 0;
}

.import-result {
  display: grid;
  gap: 8px;
}

.import-summary {
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: #f8fafc;
  padding: 12px;
}

.failure-list {
  display: grid;
  max-height: 180px;
  gap: 6px;
  margin-top: 10px;
  overflow: auto;
  color: var(--danger);
  font-size: 13px;
}

.failure-list p {
  margin: 0;
}

.table-section {
  padding: 0;
  overflow: hidden;
}

.table-section .section-header {
  padding: 14px 16px 0;
}

.table-wrap {
  overflow: auto;
}

.table-wrap.embedded {
  border: 0;
  border-radius: 0;
  box-shadow: none;
}

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

#tab-tokens table {
  min-width: 960px;
}

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

th {
  background: #f8fafc;
  color: #526074;
  font-size: 12px;
  text-transform: uppercase;
}

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

.tag,
.pill {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  border-radius: 999px;
  padding: 0 10px;
  background: #e7ebf0;
  color: #344054;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.tag.active,
.pill.good {
  background: #dcfce7;
  color: #166534;
}

.tag.blocked {
  background: var(--warning-soft);
  color: var(--warning);
}

.tag.pending,
.tag.warning {
  background: var(--warning-soft);
  color: var(--warning);
}

.tag.sent,
.tag.healthy {
  background: #dcfce7;
  color: #166534;
}

.tag.revoked,
.tag.archived,
.tag.bad,
.pill.bad {
  background: #fee2e2;
  color: #991b1b;
}

.reminder-list {
  display: grid;
  gap: 7px;
  margin: 12px 0;
}

.reminder-list p {
  margin: 0;
}

.reminder-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  border-top: 1px solid var(--line-soft);
  padding-top: 8px;
}

.reminder-item button {
  min-height: 30px;
  padding: 0 10px;
}

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

.setting-card {
  display: grid;
  align-content: start;
  gap: 12px;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: #fbfcfe;
  padding: 14px;
}

.setting-card p {
  margin: 0;
}

.check-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
}

.check-row input {
  width: 18px;
  min-height: 18px;
}

.client-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}

.code-box {
  display: grid;
  gap: 14px;
  margin-top: 18px;
  border: 1px solid #cfe8e5;
  border-radius: 8px;
  background: #f6fbfa;
  padding: 18px;
  text-align: center;
}

.code-box.waiting {
  border-color: var(--line);
  background: #f8fafc;
}

.watermark-text {
  min-height: 20px;
  margin: 12px 0 0;
  color: #7c8798;
  font-size: 12px;
  text-align: center;
  word-break: break-word;
}

.code-label {
  color: var(--muted);
  font-size: 13px;
}

#codeValue {
  font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
  font-size: 52px;
  line-height: 1;
  letter-spacing: 0;
}

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

.meter {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: #dbe4ee;
}

.meter span {
  display: block;
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: var(--primary);
  transition: width 0.2s ease;
}

dialog {
  width: min(720px, calc(100vw - 32px));
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 20px;
}

dialog::backdrop {
  background: rgba(15, 23, 42, 0.38);
}

.dialog-body {
  display: grid;
  gap: 14px;
}

.dialog-body h2 {
  margin: 0;
}

@media (max-width: 1050px) {
  .accounts-layout,
  .grid.two,
  .metric-grid,
  .settings-grid {
    grid-template-columns: 1fr;
  }

  .form-panel {
    position: static;
  }
}

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

  .sidebar {
    position: static;
    height: auto;
  }

  .nav-tabs {
    grid-template-columns: repeat(3, 1fr);
  }

  .nav-tabs button {
    padding: 0 8px;
    text-align: center;
  }

  .workspace {
    padding: 18px;
  }

  .topbar,
  .toolbar,
  .toolbar-actions {
    display: grid;
  }

  .search-box {
    width: 100%;
  }
}

@media (max-width: 520px) {
  .auth-panel,
  .code-panel {
    padding: 20px;
  }

  #codeValue {
    font-size: 42px;
  }

  .inline-fields {
    grid-template-columns: 1fr;
  }
}
