:root {
  --bg: #081220;
  --bg-accent: #0d1c2f;
  --surface: #0f1d32;
  --surface-2: #122843;
  --surface-3: #0b1629;
  --border: #294666;
  --border-soft: #203a58;
  --text: #ecf3fb;
  --muted: #9cb0c8;
  --primary: #16a5a5;
  --primary-strong: #0e8d8d;
  --ok: #1fbf75;
  --warn: #d4a028;
  --bad: #e14a4a;
  --shadow: 0 14px 32px rgba(0, 0, 0, 0.28);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "IBM Plex Sans", "Trebuchet MS", "Segoe UI", Tahoma, sans-serif;
  color: var(--text);
  background:
    radial-gradient(1200px 700px at 90% -10%, #17446a 0%, transparent 60%),
    radial-gradient(1000px 520px at -10% 0%, #153556 0%, transparent 55%),
    linear-gradient(180deg, var(--bg-accent) 0%, var(--bg) 100%);
}

.login-page {
  min-height: 100vh;
}

.login-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.login-card {
  width: min(460px, 95vw);
  background: linear-gradient(180deg, var(--surface-2) 0%, var(--surface) 100%);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 22px;
  display: grid;
  gap: 10px;
  box-shadow: var(--shadow);
}

.error-text {
  color: #ffc2c2;
  min-height: 18px;
  margin: 0;
  font-size: 12px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-soft);
  background: rgba(8, 17, 31, 0.92);
  backdrop-filter: blur(8px);
}

h1,
h2 {
  margin: 0;
}

h1 {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 0.02em;
}

h2 {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.03em;
}

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

.status-wrap {
  display: flex;
  gap: 8px;
  align-items: center;
  font-size: 13px;
  color: #c6d4e4;
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  display: inline-block;
}

.dot-off {
  background: var(--bad);
  box-shadow: 0 0 10px rgba(225, 74, 74, 0.6);
}

.dot-on {
  background: var(--ok);
  box-shadow: 0 0 10px rgba(31, 191, 117, 0.55);
}

.layout {
  width: min(1700px, 100%);
  margin: 0 auto;
  display: grid;
  gap: 16px;
  padding: 18px;
}

.card {
  background: linear-gradient(180deg, var(--surface) 0%, var(--surface-3) 100%);
  border: 1px solid var(--border-soft);
  border-radius: 14px;
  padding: 14px;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.2);
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border-bottom: 1px solid var(--border-soft);
  padding-bottom: 10px;
}

.card-head h2 {
  margin: 0;
}

.card-body {
  padding-top: 10px;
}

.card-collapsed .card-body {
  display: none;
}

.card-collapse-btn {
  border: 1px solid var(--border);
  background: #0c1b30;
  color: #cfdeee;
  border-radius: 999px;
  padding: 5px 10px;
  cursor: pointer;
  font-size: 11px;
  letter-spacing: 0.03em;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: 0.2s ease;
}

.card-collapse-btn:hover {
  border-color: #3d6188;
  background: #10213a;
}

.card-collapsed .card-collapse-icon {
  transform: rotate(-90deg);
}

.card-collapse-icon {
  display: inline-block;
  transition: transform 0.2s ease;
}

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

.row.wrap {
  flex-wrap: wrap;
}

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

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

label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
}

input,
textarea,
select {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 9px;
  padding: 9px 10px;
  font-size: 13px;
  outline: none;
}

input:focus,
textarea:focus,
select:focus {
  border-color: #4bc9c9;
  box-shadow: 0 0 0 1px #4bc9c9;
}

.inline {
  display: grid;
  grid-template-columns: 1fr 110px;
  gap: 6px;
}

.btn {
  border: 1px solid var(--border);
  background: #0a1729;
  color: var(--text);
  border-radius: 9px;
  padding: 8px 11px;
  cursor: pointer;
  font-size: 12px;
  transition: 0.2s ease;
}

.btn:hover {
  border-color: #3f638a;
  background: #0c1e34;
}

.btn-primary {
  background: linear-gradient(180deg, var(--primary) 0%, var(--primary-strong) 100%);
  border-color: var(--primary-strong);
  color: #ecffff;
}

.btn-primary:hover {
  filter: brightness(1.05);
}

.btn-danger {
  background: #6b1e1e;
  border-color: #8b2727;
}

.btn-warning {
  background: #6a4b13;
  border-color: #8a631b;
}

.btn-sm {
  padding: 6px 9px;
  font-size: 11px;
}

.chk {
  flex-direction: row;
  align-items: center;
  gap: 6px;
}

.cards-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(130px, 1fr));
  gap: 10px;
}

.mini-card {
  background: linear-gradient(180deg, #0c1a2f 0%, #0a1526 100%);
  border: 1px solid var(--border-soft);
  border-radius: 11px;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.mini-card .k {
  color: var(--muted);
  font-size: 11px;
}

.mini-card .v {
  font-size: 19px;
  font-weight: 700;
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--border-soft);
  border-radius: 11px;
  margin-top: 10px;
}

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

th,
td {
  border-bottom: 1px solid #19324d;
  padding: 8px;
  text-align: left;
  font-size: 12px;
  vertical-align: top;
}

th {
  position: sticky;
  top: 0;
  background: #0a182b;
  color: #c7d7e9;
  z-index: 1;
}

tr:nth-child(even) td {
  background: rgba(12, 28, 46, 0.45);
}

.tag {
  display: inline-block;
  font-size: 10px;
  border-radius: 999px;
  padding: 2px 8px;
  border: 1px solid transparent;
  letter-spacing: 0.02em;
}

.tag-ok {
  color: #8ff0c2;
  border-color: #1b7f56;
  background: #073525;
}

.tag-bad {
  color: #ffbbbb;
  border-color: #a72f2f;
  background: #3e1313;
}

.tag-warn {
  color: #ffe29a;
  border-color: #9b6d11;
  background: #3d2a09;
}

.tag-neutral {
  color: #d9e7f7;
  border-color: #486a90;
  background: #10233a;
}

.amount {
  font-weight: 700;
  white-space: nowrap;
}

.amount-positive {
  color: #8ff0c2;
}

.amount-negative {
  color: #ffb3b3;
}

.amount-flat {
  color: #d9e7f7;
}

.muted-inline {
  color: var(--muted);
  font-size: 11px;
}

.json-box {
  margin-top: 10px;
  background: #061221;
  border: 1px solid var(--border-soft);
  border-radius: 10px;
  padding: 10px;
  overflow: auto;
  font-size: 12px;
}

details.dropdown,
details.action-dropdown {
  background: #09192d;
  border: 1px solid var(--border-soft);
  border-radius: 9px;
  padding: 6px 8px;
}

details.dropdown > summary,
details.action-dropdown > summary {
  cursor: pointer;
  color: #cddced;
  font-size: 12px;
  user-select: none;
}

.ops-box {
  margin-top: 8px;
  border: 1px solid #223d5d;
  border-radius: 9px;
  padding: 8px;
  background: #061120;
}

.ops-metrics {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 8px;
}

.ops-chip {
  border: 1px solid #2c4f76;
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 11px;
  color: #cadaed;
}

.action-menu {
  display: grid;
  gap: 6px;
  margin-top: 8px;
}

.action-menu .btn {
  width: 100%;
  text-align: left;
}

.footer {
  position: sticky;
  bottom: 0;
  padding: 10px 16px;
  border-top: 1px solid var(--border-soft);
  background: rgba(8, 17, 31, 0.9);
}

#toast {
  font-size: 12px;
  color: #a8bdd5;
}

@media (max-width: 1400px) {
  .cards-grid {
    grid-template-columns: repeat(4, minmax(120px, 1fr));
  }
}

@media (max-width: 1200px) {
  .grid-3 {
    grid-template-columns: 1fr;
  }

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

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

  .cards-grid {
    grid-template-columns: repeat(2, minmax(120px, 1fr));
  }

  .layout {
    padding: 12px;
  }
}
