:root {
  color-scheme: light;
  --bg: #f5f7fa;
  --panel: #ffffff;
  --line: #d9e0e8;
  --text: #17202a;
  --muted: #667085;
  --accent: #0f766e;
  --accent-dark: #0b5f59;
  --danger: #b42318;
  --warn: #9a6700;
  --shadow: 0 8px 24px rgba(15, 23, 42, 0.08);
}

* {
  box-sizing: border-box;
}

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

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 18px 28px;
  background: rgba(255, 255, 255, 0.94);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(10px);
}

h1,
h2,
h3 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: 24px;
  line-height: 1.2;
}

h2 {
  font-size: 18px;
}

h3 {
  font-size: 17px;
}

.muted {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

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

main {
  max-width: 1280px;
  margin: 0 auto;
  padding: 24px 28px 40px;
}

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

input,
select,
textarea {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  padding: 8px 10px;
}

textarea {
  min-height: 68px;
  resize: vertical;
}

button {
  min-height: 38px;
  border: 1px solid var(--accent);
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  padding: 8px 13px;
  cursor: pointer;
}

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

button.secondary {
  background: #fff;
  color: var(--accent);
}

button.secondary:hover {
  background: #edf7f5;
}

button.danger {
  border-color: var(--danger);
  background: var(--danger);
}

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

.auth-panel {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 360px));
  gap: 18px;
  align-items: start;
}

.auth-form {
  display: grid;
  gap: 14px;
  padding: 18px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

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

.status {
  margin-bottom: 16px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--muted);
}

.status.error {
  border-color: #fecdca;
  color: var(--danger);
  background: #fffbfa;
}

.content {
  display: grid;
  gap: 22px;
}

.branch {
  display: grid;
  gap: 12px;
}

.branch-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
}

.cards {
  display: grid;
  gap: 12px;
}

.card {
  display: grid;
  grid-template-columns: minmax(260px, 1.1fr) minmax(260px, 1fr) minmax(300px, 1.2fr);
  gap: 14px;
  padding: 16px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.field {
  display: grid;
  gap: 4px;
  margin-bottom: 10px;
}

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

.value {
  font-size: 14px;
  line-height: 1.35;
}

.reason {
  padding: 10px;
  border-radius: 6px;
  background: #f8fafc;
  border: 1px solid #e4e7ec;
}

.badges {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 8px;
}

.badge {
  border-radius: 999px;
  padding: 3px 8px;
  background: #eef4ff;
  color: #3538cd;
  font-size: 12px;
}

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

.actions {
  display: grid;
  gap: 10px;
}

.action-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
}

.stats-panel {
  display: grid;
  gap: 14px;
}

.stats-controls {
  display: flex;
  align-items: end;
  gap: 10px;
  flex-wrap: wrap;
}

.stats-controls label {
  width: auto;
}

.stats-controls input {
  width: auto;
}

.stats-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  font-size: 14px;
}

.stats-table th,
.stats-table td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  text-align: right;
}

.stats-table th:first-child,
.stats-table td:first-child {
  text-align: left;
}

.stats-table th {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.stats-table tfoot td {
  border-bottom: none;
  font-weight: 600;
}

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

@media (max-width: 920px) {
  .topbar {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar-actions,
  .auth-panel {
    grid-template-columns: 1fr;
  }

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