:root {
  --bg: #eef2f5;
  --surface: #ffffff;
  --surface-soft: #f7f9fb;
  --line: #dbe4ec;
  --line-soft: #edf2f6;
  --text: #24313d;
  --muted: #728294;
  --blue: #2fc6f6;
  --blue-deep: #17a7dc;
  --blue-soft: #e9f8fe;
  --green: #18a058;
  --green-soft: #e8f7ef;
  --red: #d54848;
  --red-soft: #fdeeee;
  --amber: #b7791f;
  --amber-soft: #fff5df;
  --shadow: 0 1px 2px rgba(34, 60, 80, .08);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  font-size: 14px;
  line-height: 1.45;
}

a {
  color: #1876d1;
  text-decoration: none;
}

a:hover {
  color: #0b62b3;
  text-decoration: underline;
}

.app-shell {
  min-height: 100%;
}

.nav {
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 12px;
  padding: 6px;
}

.nav-item {
  align-items: center;
  border-radius: 7px;
  color: var(--text);
  display: inline-flex;
  font-weight: 600;
  min-height: 34px;
  padding: 7px 12px;
  text-decoration: none;
}

.nav-item:hover {
  background: var(--surface-soft);
  color: var(--blue-deep);
  text-decoration: none;
}

.nav-item.is-active {
  background: var(--blue);
  color: #fff;
  text-decoration: none;
}

.workspace {
  min-width: 0;
  padding: 14px 16px 24px;
}

.topbar {
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  display: flex;
  gap: 16px;
  justify-content: space-between;
  margin-bottom: 14px;
  min-height: 66px;
  padding: 12px 14px;
}

.topbar h1 {
  font-size: 22px;
  font-weight: 650;
  letter-spacing: 0;
  line-height: 1.15;
  margin: 0;
}

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

.period-form {
  align-items: center;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 7px;
  display: flex;
  flex: 0 0 auto;
  gap: 8px;
  padding: 7px;
}

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

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

input,
select,
textarea {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--text);
}

input[type="month"],
input[type="date"],
input[type="number"],
input:not([type]),
select {
  min-height: 34px;
  padding: 6px 8px;
}

textarea {
  min-height: 90px;
  padding: 8px;
  resize: vertical;
}

button {
  background: var(--blue);
  border: 0;
  border-radius: 6px;
  color: #fff;
  cursor: pointer;
  font-weight: 700;
  min-height: 34px;
  padding: 7px 13px;
}

button:hover {
  background: var(--blue-deep);
}

.button-secondary,
.button-link {
  align-items: center;
  border-radius: 6px;
  display: inline-flex;
  font-weight: 700;
  min-height: 34px;
  padding: 7px 12px;
  text-decoration: none;
}

.button-secondary {
  background: var(--surface-soft);
  border: 1px solid var(--line);
  color: var(--text);
}

.button-secondary:hover,
.button-link:hover {
  text-decoration: none;
}

.button-link {
  background: var(--blue);
  color: #fff;
}

.button-link:hover {
  background: var(--blue-deep);
  color: #fff;
}

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

.button-danger:hover {
  background: #b83131;
}

.metric-grid {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(4, minmax(190px, 1fr));
  margin-bottom: 12px;
}

.metric,
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.metric {
  min-height: 104px;
  padding: 14px;
  position: relative;
}

.metric::before {
  background: var(--blue);
  border-radius: 8px 8px 0 0;
  content: "";
  height: 3px;
  left: -1px;
  position: absolute;
  right: -1px;
  top: -1px;
}

.metric-label {
  color: var(--muted);
  display: block;
  font-size: 12px;
  font-weight: 650;
  margin-bottom: 8px;
}

.metric strong {
  display: block;
  font-size: 23px;
  font-weight: 700;
  line-height: 1.15;
  white-space: nowrap;
}

.metric small {
  color: var(--muted);
  display: block;
  margin-top: 8px;
}

.positive {
  color: var(--green);
}

.negative {
  color: var(--red);
}

.split {
  display: grid;
  gap: 12px;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  margin-bottom: 12px;
}

.panel {
  overflow: auto;
}

.panel-head {
  align-items: center;
  background: var(--surface-soft);
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  min-height: 43px;
  padding: 0 13px;
}

.panel-head h2 {
  font-size: 15px;
  font-weight: 650;
  margin: 0;
}

.panel-head a {
  font-size: 13px;
  font-weight: 600;
}

.account-list {
  display: grid;
}

.account-row {
  align-items: center;
  border-bottom: 1px solid var(--line-soft);
  display: flex;
  gap: 12px;
  justify-content: space-between;
  min-height: 45px;
  padding: 0 13px;
}

.account-row:last-child {
  border-bottom: 0;
}

.account-row strong {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

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

.split .table {
  min-width: 620px;
}

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

.table th:first-child,
.table td:first-child {
  white-space: nowrap;
}

.table th {
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.2;
  white-space: nowrap;
}

.table tbody tr:hover {
  background: #fbfdff;
}

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

.table.compact td {
  padding: 8px 12px;
}

.actions {
  text-align: right !important;
  white-space: nowrap;
}

.num {
  font-variant-numeric: tabular-nums;
  text-align: right !important;
  white-space: nowrap;
}

.badge,
.status {
  align-items: center;
  border-radius: 999px;
  display: inline-flex;
  font-size: 12px;
  font-weight: 650;
  line-height: 1.2;
  min-height: 22px;
  padding: 3px 8px;
  white-space: nowrap;
}

.badge.income {
  background: var(--green-soft);
  color: #167d45;
}

.badge.expense {
  background: var(--red-soft);
  color: #b83131;
}

.status {
  background: #eef3f8;
  color: #52657a;
}

.status.paid,
.status.won {
  background: var(--green-soft);
  color: #167d45;
}

.status.pending,
.status.active,
.status.delayed {
  background: var(--amber-soft);
  color: var(--amber);
}

.status.lost {
  background: var(--red-soft);
  color: #b83131;
}

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

.editor,
.danger-zone {
  margin: 0 0 12px;
}

.form-panel {
  padding: 14px;
}

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

.form-grid label {
  display: grid;
  gap: 6px;
}

.form-grid label span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.form-wide {
  grid-column: 1 / -1;
}

.form-actions {
  align-items: center;
  border-top: 1px solid var(--line-soft);
  display: flex;
  gap: 8px;
  justify-content: flex-start;
  margin-top: 14px;
  padding-top: 14px;
}

.danger-zone {
  text-align: right;
}

@media (max-width: 1180px) {
  .metric-grid {
    grid-template-columns: repeat(2, minmax(190px, 1fr));
  }
}

@media (max-width: 980px) {
  .nav-item {
    font-size: 13px;
    min-width: 0;
  }

  .workspace {
    padding: 12px;
  }

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

  .topbar {
    align-items: stretch;
    flex-direction: column;
  }

  .period-form {
    align-self: flex-start;
  }

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

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

  .period-form {
    align-self: stretch;
  }

  .period-form input {
    min-width: 0;
    width: 100%;
  }
}
