:root {
  color-scheme: light;
  --bg: #f4f6f5;
  --surface: #ffffff;
  --surface-alt: #eef4f2;
  --ink: #17211d;
  --muted: #65736d;
  --line: #d7dfdc;
  --accent: #0f5f4a;
  --accent-strong: #0a4436;
  --blue: #2f5f9f;
  --warning: #b75f16;
  --danger: #b13636;
  --shadow: 0 10px 30px rgba(26, 39, 34, 0.08);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--ink);
}

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

button {
  min-height: 44px;
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: #ffffff;
  cursor: pointer;
  font-weight: 700;
}

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

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

input,
select,
textarea {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--ink);
  padding: 10px 12px;
}

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

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
}

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

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 72px;
  padding: 12px 16px;
  background: rgba(244, 246, 245, 0.94);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(12px);
}

.brand,
.session,
.panel-heading,
.minimum,
.row-main,
.row-meta {
  display: flex;
  align-items: center;
}

.brand {
  min-width: 0;
  gap: 10px;
}

.brand img {
  flex: 0 0 auto;
  border-radius: 8px;
}

.brand h1,
.panel h2,
.auth-panel h2 {
  margin: 0;
  font-size: 1.2rem;
  line-height: 1.2;
}

.eyebrow {
  margin: 0 0 3px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
}

.session {
  gap: 8px;
}

.status-pill {
  max-width: 38vw;
  min-height: 32px;
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  background: var(--surface-alt);
  color: var(--accent-strong);
  padding: 6px 10px;
  font-size: 0.8rem;
  font-weight: 800;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.status-pill.is-error {
  background: #f8e7e7;
  color: var(--danger);
}

.icon-button {
  width: 44px;
  padding: 0;
}

main {
  width: min(1180px, 100%);
  margin: 0 auto;
  padding: 16px;
}

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

.auth-panel {
  display: grid;
  gap: 18px;
  padding: 18px;
}

.telegram-login {
  min-height: 46px;
}

.inline-form,
.form-grid {
  display: grid;
  gap: 12px;
}

.workspace {
  display: grid;
  gap: 16px;
}

.is-hidden {
  display: none !important;
}

.tabs {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 6px;
  min-height: 48px;
  overflow-x: auto;
}

.tab {
  min-width: 104px;
  min-height: 44px;
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--muted);
  padding: 0 10px;
}

.tab.is-active {
  background: var(--accent);
  border-color: var(--accent);
  color: #ffffff;
}

.view {
  display: none;
}

.view.is-active {
  display: grid;
  gap: 16px;
}

.summary-band {
  display: grid;
  gap: 18px;
  padding: 22px;
  border-radius: 8px;
  background: #123f34;
  color: #ffffff;
}

.summary-band .eyebrow,
.summary-band .minimum span {
  color: #bcd3ca;
}

.money-xl {
  margin: 0;
  font-size: clamp(2.2rem, 10vw, 5.2rem);
  line-height: 0.95;
  font-weight: 850;
  overflow-wrap: anywhere;
}

.minimum {
  align-items: flex-start;
  justify-content: space-between;
  gap: 6px;
  flex-direction: column;
}

.minimum strong {
  font-size: 1.45rem;
}

.content-grid {
  display: grid;
  gap: 16px;
}

.panel {
  display: grid;
  gap: 14px;
  padding: 16px;
}

.panel-heading {
  justify-content: space-between;
  gap: 12px;
}

.panel-heading button {
  min-width: 96px;
  padding: 0 12px;
}

.muted {
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 700;
}

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

.event-list,
.table-list,
.timeline-list {
  margin: 0;
  padding: 0;
}

.event-list {
  display: grid;
  gap: 10px;
  list-style: none;
  counter-reset: event;
}

.event-list li,
.table-row,
.timeline-row {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfc;
}

.event-list li {
  counter-increment: event;
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr);
  gap: 10px;
  padding: 12px;
}

.event-list li::before {
  content: counter(event);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 999px;
  background: #e2f0eb;
  color: var(--accent);
  font-size: 0.82rem;
  font-weight: 800;
}

.event-title,
.row-title {
  color: var(--ink);
  font-weight: 800;
  overflow-wrap: anywhere;
}

.event-meta,
.row-subtitle {
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.88rem;
}

.chart-panel canvas {
  width: 100%;
  height: min(46vw, 280px);
  min-height: 210px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.table-list,
.timeline-list {
  display: grid;
  gap: 8px;
}

.table-row,
.timeline-row {
  display: grid;
  gap: 8px;
  padding: 12px;
}

.row-main,
.row-meta {
  justify-content: space-between;
  gap: 12px;
}

.row-amount {
  color: var(--accent-strong);
  font-weight: 850;
  white-space: nowrap;
}

.row-amount.is-negative {
  color: var(--danger);
}

.row-tag {
  border-radius: 999px;
  background: #eef1f5;
  color: var(--blue);
  padding: 4px 8px;
  font-size: 0.78rem;
  font-weight: 800;
}

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

@media (min-width: 720px) {
  main {
    padding: 22px;
  }

  .summary-band {
    grid-template-columns: minmax(0, 1fr) 220px;
    align-items: end;
  }

  .content-grid {
    grid-template-columns: minmax(0, 1.2fr) minmax(300px, 0.8fr);
  }

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

  .form-grid button {
    align-self: end;
  }

  .quick-entry .form-grid {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }

  .quick-entry label:nth-child(2) {
    grid-column: span 2;
  }

  .quick-entry button {
    grid-column: span 1;
  }
}
