:root {
  --bg: #f8fafc;
  --panel: #ffffff;
  --text: #0f172a;
  --muted: #64748b;
  --line: #e4e5e7;
  --primary: #1e293b;
  --accent: #2563eb;
  --ok: #15803d;
  --warn: #b45309;
  --bad: #dc2626;
  font-family: "Segoe UI", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

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

button,
input {
  font: inherit;
}

button {
  min-height: 40px;
  border: 0;
  border-radius: 6px;
  padding: 0 16px;
  color: #fff;
  background: var(--accent);
  cursor: pointer;
  transition: background 180ms ease, transform 180ms ease;
}

button:hover {
  background: #1d4ed8;
}

button:active {
  transform: translateY(1px);
}

button:focus-visible,
input:focus-visible {
  outline: 3px solid rgba(37, 99, 235, 0.28);
  outline-offset: 2px;
}

button.secondary {
  color: var(--primary);
  background: #e2e8f0;
}

.shell {
  min-height: 100vh;
}

.hidden {
  display: none !important;
}

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

.login-panel {
  display: grid;
  width: min(420px, 100%);
  gap: 18px;
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 18px 40px rgba(15, 23, 42, 0.08);
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

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

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

h2 {
  font-size: 18px;
}

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

input {
  min-height: 40px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 12px;
  color: var(--text);
  background: #fff;
}

.error {
  min-height: 18px;
  margin: 0;
  color: var(--bad);
  font-size: 13px;
}

.app-view {
  display: grid;
  gap: 16px;
  padding: 18px;
}

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

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

.metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.metrics article {
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

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

.metrics strong {
  display: block;
  margin-top: 6px;
  font-size: 30px;
  line-height: 1;
}

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

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

.table-head p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

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

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

th {
  position: sticky;
  top: 0;
  z-index: 1;
  color: #334155;
  background: #f1f5f9;
  font-size: 12px;
  font-weight: 700;
}

tbody tr:hover {
  background: #f8fafc;
}

.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.badge {
  display: inline-block;
  margin: 0 4px 4px 0;
  padding: 3px 7px;
  border-radius: 999px;
  color: #334155;
  background: #eef2f7;
  white-space: nowrap;
}

.kind-badge {
  display: inline-flex;
  min-width: 44px;
  justify-content: center;
  border-radius: 999px;
  padding: 3px 8px;
  color: #075985;
  background: #e0f2fe;
  font-weight: 700;
}

.problem-wrap .table-head {
  border-bottom-color: #fecaca;
}

.problem-wrap h2 {
  color: #991b1b;
}

.problem-wrap .kind-badge {
  color: #991b1b;
  background: #fee2e2;
}

.documents-table td:nth-child(5),
.documents-table td:nth-child(6),
.documents-table td:nth-child(7) {
  max-width: 320px;
  overflow-wrap: anywhere;
}

.account-title {
  font-weight: 700;
}

.account-error {
  color: var(--bad);
}

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

.empty-state {
  padding: 28px 16px;
  color: var(--muted);
  text-align: center;
}

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

  .metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .table-wrap {
    overflow-x: auto;
  }

  table {
    min-width: 1180px;
  }

  .documents-table {
    min-width: 1040px;
  }
}

@media (max-width: 520px) {
  .app-view {
    padding: 10px;
  }

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