:root {
  color-scheme: light;
  --bg: #f5f7fa;
  --panel: #ffffff;
  --panel-strong: #17202a;
  --text: #1f2933;
  --muted: #65758b;
  --line: #d9e1ea;
  --accent: #146c5f;
  --accent-strong: #0f4f46;
  --accent-soft: #dff2ee;
  --warning: #a15c10;
  --blue: #2454a6;
  --shadow: 0 18px 50px rgba(34, 47, 62, 0.1);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
}

body {
  min-height: 100%;
  margin: 0;
  background:
    linear-gradient(135deg, rgba(20, 108, 95, 0.11), transparent 34%),
    linear-gradient(315deg, rgba(36, 84, 166, 0.11), transparent 32%),
    var(--bg);
  color: var(--text);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 32px 0;
}

.page-header,
.section-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
}

.page-header {
  margin-bottom: 24px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 750;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  color: var(--panel-strong);
  line-height: 1.08;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(2rem, 4vw, 4.5rem);
}

h2 {
  font-size: 1.35rem;
}

.today-badge {
  display: grid;
  gap: 4px;
  min-width: 190px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
  text-align: right;
}

.today-badge span,
.forecast-main span,
dt {
  color: var(--muted);
  font-size: 0.82rem;
}

.today-badge strong {
  color: var(--panel-strong);
  font-size: 1rem;
}

.overview {
  display: grid;
  grid-template-columns: minmax(0, 0.95fr) minmax(340px, 1.05fr);
  gap: 20px;
  align-items: stretch;
}

.settings-panel,
.forecast-panel,
.ledger-panel {
  border: 1px solid rgba(217, 225, 234, 0.9);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: var(--shadow);
}

.settings-panel {
  display: grid;
  gap: 16px;
  padding: 20px;
}

.field {
  display: grid;
  gap: 8px;
}

.field span {
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 650;
}

input {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--text);
  padding: 10px 12px;
  outline: none;
  transition:
    border-color 0.16s ease,
    box-shadow 0.16s ease;
}

input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(20, 108, 95, 0.14);
}

.sync-status {
  margin: 0;
  min-height: 32px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  color: var(--muted);
  background: #fbfcfe;
  font-size: 0.86rem;
  font-weight: 650;
}

.sync-status[data-status="ok"] {
  border-color: rgba(20, 108, 95, 0.28);
  color: var(--accent-strong);
  background: var(--accent-soft);
}

.sync-status[data-status="warn"] {
  border-color: rgba(161, 92, 16, 0.3);
  color: var(--warning);
  background: #fff8ed;
}

.entry-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto;
  gap: 12px;
  align-items: end;
  padding-top: 4px;
}

.primary-button,
.secondary-button {
  min-height: 44px;
  border-radius: 8px;
  border: 1px solid transparent;
  padding: 0 16px;
  font-weight: 750;
  transition:
    transform 0.16s ease,
    border-color 0.16s ease,
    background 0.16s ease;
}

.primary-button {
  background: var(--accent);
  color: #ffffff;
}

.primary-button:hover {
  background: var(--accent-strong);
}

.secondary-button {
  background: #ffffff;
  color: var(--panel-strong);
  border-color: var(--line);
}

.secondary-button:hover {
  border-color: var(--accent);
}

.primary-button:active,
.secondary-button:active {
  transform: translateY(1px);
}

.forecast-panel {
  display: grid;
  gap: 20px;
  padding: 22px;
}

.forecast-main {
  display: grid;
  gap: 8px;
}

.forecast-main strong {
  color: var(--panel-strong);
  font-size: clamp(2.6rem, 6vw, 5.3rem);
  line-height: 0.95;
  letter-spacing: 0;
}

.forecast-main small {
  color: var(--muted);
  font-size: 1rem;
}

.progress-track {
  height: 14px;
  overflow: hidden;
  border-radius: 999px;
  background: #e9eef4;
}

.progress-fill {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), var(--blue));
  transition: width 0.22s ease;
}

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

.stats-grid div {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fbfcfe;
}

dt {
  margin: 0 0 6px;
}

dd {
  margin: 0;
  color: var(--panel-strong);
  font-size: 1.05rem;
  font-weight: 760;
  overflow-wrap: anywhere;
}

.ledger-panel {
  margin-top: 20px;
  padding: 20px;
}

.table-wrap {
  max-height: 54vh;
  margin-top: 16px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

table {
  width: 100%;
  border-collapse: collapse;
}

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

thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f8fafc;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 760;
}

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

tbody tr.is-today {
  background: var(--accent-soft);
}

td:first-child {
  min-width: 160px;
  color: var(--panel-strong);
  font-weight: 700;
}

td:nth-child(2) {
  width: 240px;
}

td:nth-child(3) {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.daily-input {
  min-width: 140px;
}

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

@media (max-width: 860px) {
  .app-shell {
    width: min(100% - 24px, 720px);
    padding: 20px 0;
  }

  .page-header,
  .section-heading,
  .overview,
  .entry-row,
  .stats-grid {
    grid-template-columns: 1fr;
  }

  .page-header,
  .section-heading {
    display: grid;
    align-items: stretch;
  }

  .today-badge {
    min-width: 0;
    text-align: left;
  }

  .entry-row {
    display: grid;
  }

  .primary-button,
  .secondary-button {
    width: 100%;
  }

  th,
  td {
    padding: 10px;
  }

  td:first-child {
    min-width: 128px;
  }

  td:nth-child(2) {
    width: 180px;
  }
}

@media (max-width: 560px) {
  .table-wrap {
    max-height: none;
  }

  table,
  thead,
  tbody,
  tr,
  th,
  td {
    display: block;
  }

  thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
  }

  tbody tr {
    display: grid;
    gap: 8px;
    padding: 12px;
    border-bottom: 1px solid var(--line);
  }

  tbody tr:last-child {
    border-bottom: 0;
  }

  td {
    width: 100%;
    min-width: 0;
    border: 0;
    padding: 0;
  }

  td:nth-child(2) {
    width: 100%;
  }

  td:nth-child(3)::before {
    content: "Доля долга: ";
    color: var(--muted);
    font-weight: 650;
  }
}
