:root {
  color-scheme: dark;
  --bg: #0f1113;
  --panel: #171a1d;
  --panel-2: #1d2126;
  --panel-3: #222830;
  --text: #f5f7f8;
  --muted: #9aa4af;
  --line: #313840;
  --green: #4fd18b;
  --green-2: #295d43;
  --danger: #e06d6d;
  --warn: #d8b25f;
  --shadow: 0 10px 28px rgba(0, 0, 0, 0.24);
  --panel-h: 600px;
  --radius-lg: 14px;
  --radius-md: 10px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--text); }
body { line-height: 1.5; }
button, input, select { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .7; }
a { color: inherit; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.strong { font-weight: 600; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.grow { flex: 1; }

.app-shell {
  width: min(1360px, calc(100vw - 24px));
  margin: 0 auto;
  padding: 16px 0 40px;
}

.login-shell {
  min-height: calc(100vh - 48px);
  display: grid;
  place-items: center;
}

.login-card {
  width: min(460px, 100%);
  background: linear-gradient(180deg, rgba(34,40,48,.98), rgba(23,26,29,.98));
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 28px;
  box-shadow: var(--shadow);
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--green);
  margin-bottom: 2px;
}

h1, h2 {
  margin: 0;
}

h1 { font-size: 22px; margin-bottom: 0; }
h2 { font-size: 17px; }

.stack {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.field, .compact-field, .search-box {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.field span, .compact-field span, .search-box span, .form-title, .subsection-title, .stat-label {
  font-size: 13px;
  color: var(--muted);
}

input, select {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  border-radius: 10px;
  padding: 10px 12px;
  outline: none;
}

input:focus, select:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(79, 209, 139, .16);
}

button {
  border: 1px solid transparent;
  background: var(--green);
  color: #08110c;
  border-radius: 10px;
  padding: 9px 13px;
  font-weight: 700;
}

button.secondary {
  background: #dfe5ea;
  color: #101417;
}

button.ghost {
  background: transparent;
  color: var(--text);
  border-color: var(--line);
}

button.mini {
  padding: 6px 9px;
  border-radius: 8px;
  font-size: 11px;
}

button.mini.secondary { background: #dfe5ea; color: #101417; }
button.mini.ghost { background: transparent; color: var(--text); border-color: var(--line); }
button.mini.danger, button.danger { background: rgba(224, 109, 109, .14); color: #ffd0d0; border-color: rgba(224, 109, 109, .34); }

.error {
  min-height: 24px;
  margin: 4px 0 0;
  color: var(--danger);
}

.topbar, .panel, .stat-card, .form-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
}

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

.compact-topbar {
  min-height: 80px;
  padding: 12px 18px;
}

.compact-topbar-left {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
}

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

.current-user-badge {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: 0 16px;
  color: var(--text);
  font-size: 13px;
  white-space: nowrap;
}

.session-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  padding: 3px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.02);
}

.session-pill-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  padding: 0 18px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,.08);
  background: rgba(255,255,255,.04);
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
}

.session-pill-button:hover {
  background: rgba(255,255,255,.08);
}

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

.stat-card {
  padding: 14px;
}

.stat-value {
  font-size: 28px;
  line-height: 1.1;
  font-weight: 800;
  margin-top: 6px;
}

.stat-foot {
  margin-top: 6px;
  font-size: 12px;
}

.main-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.7fr) minmax(300px, .9fr);
  gap: 14px;
  margin-bottom: 14px;
}

.split-column {
  display: grid;
  grid-template-rows: var(--panel-h) var(--panel-h);
  gap: 14px;
}

.single-column {
  display: block;
}

.panel {
  padding: 14px;
}

.tall-panel {
  height: calc(var(--panel-h) * 2 + 14px);
  min-height: calc(var(--panel-h) * 2 + 14px);
}

.fixed-panel {
  height: var(--panel-h);
  min-height: var(--panel-h);
}

.compact-panel {
  overflow: hidden;
}

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

.two-column-forms {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.account-management-stack {
  display: flex;
  flex-direction: column;
  height: calc(100% - 56px);
  min-height: 0;
}

.register-inline-card {
  background: var(--panel-2);
  gap: 10px;
  padding-top: 12px;
  padding-bottom: 12px;
}

.register-inline-grid {
  display: grid;
  grid-template-columns: minmax(180px, 1.2fr) minmax(180px, 1fr) minmax(180px, 1.2fr) auto;
  gap: 12px;
  align-items: end;
}

.domain-inline-field select option {
  direction: ltr;
}

.submit-field {
  justify-content: flex-end;
}

.fill-grid {
  height: calc(100% - 56px);
}

.form-card {
  padding: 14px;
  background: var(--panel-2);
}

.compact-card {
  min-height: 100%;
}

.toolbar-line, .history-filters {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: end;
}

.compact-toolbar {
  margin-bottom: 8px;
}

.meta-line {
  margin: 8px 0 8px;
  font-size: 12px;
}

.records-table {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-bottom: 14px;
}

.table-head, .table-row, .history-row {
  display: grid;
  gap: 12px;
  align-items: center;
}

.account-row {
  grid-template-columns: 1.55fr .8fr .85fr .85fr .8fr 1.55fr;
}

.history-row {
  grid-template-columns: 1.3fr .7fr 1fr 1.6fr .8fr .6fr;
}

.table-head {
  padding: 0 10px 6px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .08em;
}

.sticky-table-head {
  margin-bottom: 8px;
  padding-top: 2px;
  background: var(--panel);
}

.table-row {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel-2);
}

.table-row.is-selected {
  border-color: var(--green);
  box-shadow: 0 0 0 1px rgba(79,209,139,.28) inset;
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}

.badge-success, .status-ok, .tone-success {
  color: #b6ffd8;
  background: rgba(79, 209, 139, .16);
}

.badge-danger, .status-bad, .tone-danger {
  color: #ffd0d0;
  background: rgba(224, 109, 109, .16);
}

.tone-warn {
  color: #ffe4ad;
  background: rgba(216, 178, 95, .15);
}

.tone-neutral {
  color: #d7dee7;
  background: rgba(255,255,255,.06);
}

.pill-list {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.pill {
  background: rgba(79, 209, 139, .14);
  color: #cbffdf;
  border: 1px solid rgba(79, 209, 139, .24);
}

.code-block {
  margin: 0;
  padding: 12px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #0d0f12;
  color: #d8dee7;
  white-space: pre-wrap;
  word-break: break-word;
  overflow: auto;
  font-size: 12px;
}

.code-block.small { min-height: 96px; }
.detail-json { max-height: 480px; }
.empty-state { color: var(--muted); }
.error-state { color: #ffd0d0; }
.success-state { color: #d8dee7; }
.empty-inline, .empty-table {
  color: var(--muted);
  padding: 14px;
  border: 1px dashed var(--line);
  border-radius: 10px;
}

.selected-account-box {
  border: 1px dashed var(--line);
  border-radius: 10px;
  padding: 10px;
  background: rgba(255,255,255,.02);
}

.selected-account {
  margin-top: 4px;
  font-weight: 600;
}

.operation-status {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel-2);
  height: 100%;
}

.fill-card {
  height: 100%;
}

.grow-block {
  flex: 1;
  min-height: 0;
}

.scroll-frame {
  min-height: 0;
  height: calc(100% - 92px);
  overflow: auto;
  padding-right: 4px;
  padding-bottom: 12px;
}

.account-scroll-frame {
  height: calc(100% - 108px);
}

.merged-account-scroll-frame {
  flex: 1;
  min-height: 0;
  height: auto;
}

.history-scroll-frame {
  height: calc(100% - 112px);
}

.operation-status-head,
.operation-status-meta {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.operation-status-code {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 52px;
  padding: 4px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
}

.subsection + .subsection { margin-top: 14px; }
.history-panel { margin-bottom: 14px; }
.detail-dock { margin-top: 14px; }
.sticky-panel { position: sticky; top: 14px; }

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(5, 8, 11, .72);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 1000;
}

.modal-card {
  width: min(560px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
  padding: 18px;
}

.modal-head {
  margin-bottom: 16px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.copy-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
}

@media (max-width: 1100px) {
  .summary-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .main-grid { grid-template-columns: 1fr; }
  .sticky-panel { position: static; }
  .two-column-forms { grid-template-columns: 1fr; }
  .register-inline-grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 780px) {
  .app-shell { width: min(100vw - 20px, 1440px); padding-top: 10px; }
  .summary-grid { grid-template-columns: 1fr; }
  .topbar { flex-direction: column; }
  .account-row, .history-row, .register-inline-grid { grid-template-columns: 1fr; }
  .table-head { display: none; }
}
