:root {
  --bg: #f4f1ea;
  --bg-soft: #fbf8f2;
  --panel: rgba(255, 252, 247, 0.88);
  --panel-strong: #fffdf9;
  --line: rgba(89, 70, 51, 0.12);
  --text: #2d241d;
  --muted: #7a6b5e;
  --accent: #1f6f5f;
  --accent-soft: #dff1ec;
  --warn: #c7683c;
  --warn-soft: #fde8dd;
  --danger: #a53d3d;
  --danger-soft: #fde1e1;
  --success: #2f7e52;
  --success-soft: #e0f2e6;
  --shadow: 0 20px 50px rgba(76, 55, 37, 0.12);
  --radius-lg: 28px;
  --radius-md: 20px;
  --radius-sm: 14px;
  --sidebar-width: 280px;
  --sidebar-collapsed-width: 92px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  font-family: "Manrope", sans-serif;
  background:
    radial-gradient(circle at top left, rgba(31, 111, 95, 0.15), transparent 30%),
    radial-gradient(circle at top right, rgba(199, 104, 60, 0.12), transparent 24%),
    linear-gradient(180deg, #f8f5ef 0%, var(--bg) 100%);
  color: var(--text);
}

body {
  min-height: 100vh;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-width) 1fr;
  min-height: 100vh;
  transition: grid-template-columns 0.25s ease;
}

body.sidebar-collapsed .app-shell {
  grid-template-columns: var(--sidebar-collapsed-width) 1fr;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 28px 20px;
  background: rgba(39, 31, 24, 0.95);
  color: #fff6ec;
  backdrop-filter: blur(18px);
  overflow: hidden;
  transition: padding 0.25s ease, width 0.25s ease;
  position: sticky;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 34px;
}

.brand-copy {
  min-width: 0;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.brand strong {
  display: block;
  font-size: 1rem;
}

.brand p {
  margin: 2px 0 0;
  color: rgba(255, 246, 236, 0.72);
  font-size: 0.92rem;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  border-radius: 16px;
  background: linear-gradient(135deg, #ffddbd, #f1a970);
  color: #3a2717;
  font-weight: 800;
  letter-spacing: 0.08em;
  flex: 0 0 52px;
}

.sidebar-toggle {
  margin-left: auto;
  width: 38px;
  height: 38px;
  border: 1px solid rgba(255, 246, 236, 0.14);
  border-radius: 12px;
  background: rgba(255, 246, 236, 0.08);
  color: #fff6ec;
  display: grid;
  place-items: center;
  transition: background 0.2s ease, transform 0.2s ease;
}

.sidebar-toggle:hover {
  background: rgba(255, 246, 236, 0.16);
}

.menu {
  display: grid;
  gap: 10px;
}

.menu-item {
  width: 100%;
  padding: 14px 16px;
  border: 0;
  border-radius: 16px;
  background: transparent;
  color: rgba(255, 246, 236, 0.82);
  text-align: left;
  transition: 0.2s ease;
  white-space: nowrap;
  overflow: hidden;
}

.menu-item-text {
  display: inline-block;
  transition: opacity 0.18s ease, transform 0.18s ease;
}

.menu-item:hover,
.menu-item.is-active {
  background: rgba(255, 246, 236, 0.1);
  color: #ffffff;
  transform: translateX(2px);
}

body.sidebar-collapsed .sidebar,
.sidebar.collapsed {
  padding-inline: 14px;
}

body.sidebar-collapsed .brand,
.sidebar.collapsed .brand {
  justify-content: flex-end;
  min-height: 52px;
  margin-bottom: 0;
}

body.sidebar-collapsed .brand-copy,
body.sidebar-collapsed .brand-mark,
body.sidebar-collapsed .menu,
body.sidebar-collapsed .menu-item-text,
.sidebar.collapsed .brand-copy,
.sidebar.collapsed .brand-mark,
.sidebar.collapsed .menu,
.sidebar.collapsed .menu-item-text {
  opacity: 0;
  transform: translateX(-8px);
  pointer-events: none;
  visibility: hidden;
}

body.sidebar-collapsed .brand-copy,
body.sidebar-collapsed .brand-mark,
body.sidebar-collapsed .menu,
.sidebar.collapsed .brand-copy,
.sidebar.collapsed .brand-mark,
.sidebar.collapsed .menu {
  width: 0;
  height: 0;
  overflow: hidden;
  margin: 0;
  padding: 0;
  border: 0;
}

body.sidebar-collapsed .sidebar-toggle,
.sidebar.collapsed .sidebar-toggle {
  position: absolute;
  top: 22px;
  left: 50%;
  right: auto;
  transform: translateX(-50%);
}

.content {
  padding: 28px;
  min-width: 0;
  transition: width 0.25s ease, padding 0.25s ease;
}

.topbar {
  margin-bottom: 22px;
}

.topbar-row {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 20px;
}

.topbar h1 {
  margin: 0;
  font-size: clamp(1.8rem, 4vw, 2.6rem);
}

.subtitle {
  margin: 6px 0 0;
  color: var(--muted);
}

.toolbar {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  flex-wrap: wrap;
  padding: 18px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.month-filter {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding-bottom: 6px;
  scrollbar-width: thin;
  white-space: nowrap;
}

.month-filter::-webkit-scrollbar {
  display: none;
}

.month-chip {
  border: 1px solid var(--line);
  background: #fff8ef;
  color: var(--muted);
  padding: 10px 14px;
  border-radius: 999px;
  white-space: nowrap;
  transition: 0.2s ease;
}

.month-chip.is-active,
.month-chip:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: #f8fffc;
}

.toolbar-actions {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

.sync-button,
.save-button {
  border: 0;
  border-radius: 999px;
  padding: 12px 20px;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(135deg, #1f6f5f, #2e8f7b);
  box-shadow: 0 14px 24px rgba(31, 111, 95, 0.22);
}

.ghost-button {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 12px 18px;
  font-weight: 700;
  background: rgba(255, 252, 247, 0.72);
  color: var(--text);
}

.export-button {
  background: linear-gradient(135deg, rgba(17, 32, 49, 0.08), rgba(29, 138, 112, 0.08));
  border-color: rgba(17, 32, 49, 0.12);
}

.sync-button:disabled {
  opacity: 0.7;
  cursor: wait;
}

.sync-status {
  min-width: 220px;
}

.sync-label {
  display: block;
  font-size: 0.82rem;
  color: var(--muted);
}

.sync-status strong {
  display: block;
  margin-top: 4px;
}

.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 22px;
  align-items: stretch;
}

.card {
  min-width: 0;
  padding: 20px 18px;
  display: grid;
  grid-template-rows: auto minmax(72px, auto) minmax(40px, auto);
  align-items: start;
  text-align: center;
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
  background: var(--panel);
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
}

.card::after {
  content: "";
  position: absolute;
  inset: auto -14% -32% auto;
  width: 110px;
  height: 110px;
  border-radius: 50%;
  opacity: 0.18;
  filter: blur(8px);
}

.card-accent::after { background: #1d8a70; }
.card-success::after { background: #3aa76d; }
.card-danger::after { background: #cb5a52; }
.card-amber::after { background: #d39a35; }
.card-neutral::after { background: #7d7f8a; }
.card-ink::after { background: #27364b; }

.card-label {
  font-size: 0.92rem;
  color: var(--muted);
  position: relative;
  z-index: 1;
  display: block;
  min-height: 2.8em;
  text-align: center;
  line-height: 1.35;
}

.card-value {
  margin: 10px 0 0;
  font-size: inherit;
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.15;
  position: relative;
  z-index: 1;
  width: 100%;
  min-height: 72px;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.value-currency {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--muted);
  align-self: center;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.value-number {
  display: block;
  max-width: 100%;
  font-size: clamp(1.75rem, 2vw, 2.25rem);
  font-weight: 800;
  letter-spacing: -0.04em;
  line-height: 1.05;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card-hint {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.3;
  min-height: 40px;
  position: relative;
  z-index: 1;
  text-align: center;
}

.analytics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 18px;
  margin-bottom: 22px;
}

.insight-panel {
  min-height: 100%;
}

.donut-layout {
  display: grid;
  grid-template-columns: minmax(220px, 240px) 1fr;
  gap: 22px;
  align-items: center;
}

.donut-frame {
  display: grid;
  place-items: center;
  padding: 18px;
  border-radius: 28px;
  background:
    radial-gradient(circle at top, rgba(255, 255, 255, 0.9), rgba(250, 246, 239, 0.9) 58%, rgba(238, 231, 220, 0.95)),
    linear-gradient(180deg, rgba(255, 255, 255, 0.7), rgba(244, 239, 231, 0.85));
  border: 1px solid rgba(96, 77, 53, 0.08);
}

.donut-chart {
  width: 208px;
  height: 208px;
  border-radius: 50%;
  background:
    radial-gradient(circle at center, rgba(255, 255, 255, 0) 58%, rgba(255, 255, 255, 0.32) 58.5%, rgba(255, 255, 255, 0) 60%),
    conic-gradient(from -90deg, var(--chart));
  display: grid;
  place-items: center;
  margin: 0 auto;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.45), 0 18px 34px rgba(24, 28, 32, 0.08);
  position: relative;
}

.donut-chart::after {
  content: "";
  position: absolute;
  inset: 8px;
  border-radius: 50%;
  box-shadow: inset 0 14px 18px rgba(255, 255, 255, 0.25);
  pointer-events: none;
}

.donut-center {
  width: 146px;
  height: 146px;
  border-radius: 50%;
  background: linear-gradient(180deg, rgba(255, 254, 251, 0.98), rgba(245, 241, 234, 0.98));
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 6px;
  padding: 14px 12px;
  box-shadow: 0 10px 24px rgba(20, 27, 31, 0.08), inset 0 0 0 1px rgba(255, 255, 255, 0.7);
}

.donut-center > span {
  font-size: 0.62rem;
  color: var(--muted);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  line-height: 1.15;
}

.donut-center-value {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  width: 100%;
  max-width: 100%;
}

.donut-center-currency {
  font-size: 0.66rem;
  color: var(--muted);
  font-weight: 800;
  letter-spacing: 0.08em;
  line-height: 1;
}

.donut-center-number {
  display: block;
  width: 100%;
  max-width: 100%;
  font-size: clamp(0.8rem, 1.15vw, 1.02rem);
  line-height: 1;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.04em;
  white-space: nowrap;
  text-align: center;
  overflow: hidden;
  text-overflow: clip;
}

.legend-list,
.bars-list,
.spotlight-list {
  display: grid;
  gap: 12px;
}

.legend-item {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 14px 16px;
  border-radius: 18px;
  background: linear-gradient(180deg, rgba(255, 254, 251, 0.95), rgba(244, 240, 233, 0.95));
  border: 1px solid rgba(96, 77, 53, 0.08);
  box-shadow: 0 10px 20px rgba(36, 40, 44, 0.04);
}

.legend-item strong,
.bar-labels strong,
.spotlight-card strong {
  display: block;
}

.legend-item p,
.spotlight-card p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.88rem;
}

.legend-item > div {
  flex: 1;
  min-width: 0;
}

.legend-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.legend-head span {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.legend-item small {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 0.8rem;
}

.legend-item p,
.bar-labels span,
.spotlight-value,
.pill,
.sync-status strong {
  font-variant-numeric: tabular-nums;
}

.legend-dot {
  flex: 0 0 12px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  margin-top: 7px;
  box-shadow: 0 0 0 6px rgba(255, 255, 255, 0.8);
}

.legend-dot.accent { background: #1d8a70; }
.legend-dot.success { background: #3aa76d; }
.legend-dot.danger { background: #cb5a52; }
.legend-dot.amber { background: #d39a35; }
.legend-dot.neutral { background: #7d7f8a; }
.legend-dot.ink { background: #27364b; }

.bar-row {
  display: grid;
  gap: 8px;
}

.bar-labels {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
}

.bar-labels span {
  color: var(--muted);
  font-size: 0.88rem;
  text-align: right;
  white-space: nowrap;
}

.bar-track {
  position: relative;
  overflow: hidden;
  width: 100%;
  height: 12px;
  border-radius: 999px;
  background: #efe7dd;
}

.bar-fill {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #1d8a70 0%, #2f7e52 50%, #d39a35 100%);
}

.spotlight-card {
  padding: 14px 16px;
  border-radius: 18px;
  background: linear-gradient(180deg, rgba(255, 254, 251, 0.95), rgba(244, 240, 233, 0.95));
  border: 1px solid rgba(89, 70, 51, 0.1);
}

.spotlight-label {
  display: inline-flex;
  margin-bottom: 10px;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #49586d;
}

.spotlight-value {
  margin-top: 12px;
  font-size: 1.15rem;
  font-weight: 800;
  color: #112031;
  text-align: right;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 22px;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: flex-start;
  margin-bottom: 18px;
}

.list-controls {
  display: grid;
  grid-template-columns: minmax(160px, 220px) minmax(220px, 1fr) auto;
  gap: 12px;
  align-items: end;
  margin: 0 0 18px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 253, 249, 0.72);
}

.control-field {
  display: grid;
  gap: 7px;
  min-width: 0;
}

.control-field span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.control-field select,
.control-field input {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel-strong);
  color: var(--text);
  padding: 0 13px;
}

.copy-list-button {
  min-height: 44px;
  white-space: nowrap;
}

.panel-head-metrics {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}

.panel-head h2 {
  margin: 0;
}

.panel-head p {
  margin: 6px 0 0;
  color: var(--muted);
}

.pill {
  padding: 10px 14px;
  border-radius: 999px;
  background: #f2ebe0;
  color: var(--text);
  font-weight: 700;
}

.pill.danger {
  background: var(--danger-soft);
  color: var(--danger);
}

.pill.success {
  background: var(--success-soft);
  color: var(--success);
}

.pill.accent {
  background: var(--accent-soft);
  color: var(--accent);
}

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

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

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

.data-table th:last-child,
.data-table td:last-child {
  text-align: right;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

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

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

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 10px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 800;
}

.badge.pending {
  background: #efe4d2;
  color: #825518;
}

.badge.paid {
  background: var(--success-soft);
  color: var(--success);
}

.badge.partial {
  background: #fce7bf;
  color: #8b6208;
}

.badge.overdue {
  background: var(--danger-soft);
  color: var(--danger);
}

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

.view {
  display: none;
}

.view.is-visible {
  display: block;
}

.settings-panel {
  max-width: 760px;
}

.log-list {
  display: grid;
  gap: 12px;
}

.log-entry {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 253, 249, 0.84);
}

.log-entry-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin-bottom: 8px;
}

.log-entry-title {
  font-weight: 800;
}

.log-entry-time {
  color: var(--muted);
  font-size: 0.88rem;
}

.log-entry-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}

.log-chip {
  padding: 6px 10px;
  border-radius: 999px;
  background: #f2ebe0;
  color: var(--text);
  font-size: 0.8rem;
  font-weight: 700;
}

.log-chip.error {
  background: var(--danger-soft);
  color: var(--danger);
}

.log-chip.success {
  background: var(--success-soft);
  color: var(--success);
}

.log-chip.info {
  background: var(--accent-soft);
  color: var(--accent);
}

.log-entry pre {
  margin: 0;
  padding: 14px;
  overflow: auto;
  border-radius: 14px;
  background: #2a241f;
  color: #f6efe4;
  font-size: 0.83rem;
  white-space: pre-wrap;
  word-break: break-word;
}

.settings-form {
  display: grid;
  gap: 18px;
}

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

.field span {
  font-weight: 700;
}

.field input {
  border: 1px solid var(--line);
  background: var(--panel-strong);
  border-radius: 16px;
  padding: 14px 16px;
  color: var(--text);
}

.settings-note {
  padding: 16px;
  border-radius: 18px;
  background: #fff1dc;
  color: #6f4c18;
  border: 1px solid rgba(111, 76, 24, 0.14);
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  padding: 14px 18px;
  border-radius: 16px;
  background: rgba(39, 31, 24, 0.92);
  color: #fff6ec;
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
  transition: 0.2s ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.skeleton-card, .skeleton-chart {
  background: linear-gradient(90deg, #e8e8e8 25%, #f5f5f5 50%, #e8e8e8 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
  border-radius: 8px;
}

.skeleton-card { height: 96px; }

.skeleton-chart { height: 220px; }

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.menu-toggle {
  display: none;
  width: 46px;
  height: 46px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 252, 247, 0.82);
}

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

@media (max-width: 920px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  body.sidebar-collapsed .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: min(82vw, 300px);
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    z-index: 20;
  }

  .sidebar.is-open {
    transform: translateX(0);
  }

  .sidebar-toggle {
    display: none;
  }

  .menu-toggle {
    display: inline-grid;
    place-items: center;
  }

  .content {
    padding: 20px;
  }

  .list-controls {
    grid-template-columns: 1fr;
  }

}

@media (max-width: 640px) {
  .content {
    padding: 16px;
  }

  .toolbar,
  .panel {
    padding: 16px;
    border-radius: 22px;
  }

  .topbar-row {
    align-items: flex-start;
  }

  .data-table th:nth-child(2),
  .data-table td:nth-child(2) {
    display: none;
  }
}
