:root {
  color-scheme: light;
  --bg: #f4f5f7;
  --panel: #ffffff;
  --panel-2: #ebedf1;
  --text: #171915;
  --muted: #687064;
  --line: #d7dccf;
  --line-strong: #adb6a5;
  --accent: #168a75;
  --accent-2: #7048e8;
  --accent-3: #df7b2f;
  --danger: #d63f3f;
  --good: #23894f;
  --soft-accent: rgba(22, 138, 117, 0.14);
  --soft-purple: rgba(112, 72, 232, 0.13);
  --soft-orange: rgba(223, 123, 47, 0.14);
  --soft-red: rgba(214, 63, 63, 0.12);
  --shadow: 0 18px 50px rgba(21, 25, 18, 0.1);
  --focus: 0 0 0 3px rgba(22, 138, 117, 0.24);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #11120f;
  --panel: #191b16;
  --panel-2: #24261f;
  --text: #f1f3eb;
  --muted: #a4aa9d;
  --line: #33372d;
  --line-strong: #606856;
  --accent: #39d0b6;
  --accent-2: #a77cff;
  --accent-3: #ff9b4a;
  --danger: #ff5a5a;
  --good: #62df8e;
  --soft-accent: rgba(57, 208, 182, 0.15);
  --soft-purple: rgba(167, 124, 255, 0.14);
  --soft-orange: rgba(255, 155, 74, 0.14);
  --soft-red: rgba(255, 90, 90, 0.13);
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.32);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

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

body {
  margin: 0;
  background:
    linear-gradient(135deg, color-mix(in srgb, var(--accent) 8%, transparent), transparent 28rem),
    linear-gradient(315deg, color-mix(in srgb, var(--accent-2) 8%, transparent), transparent 34rem),
    var(--bg);
  color: var(--text);
}

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

button {
  cursor: pointer;
}

button:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible {
  outline: none;
  box-shadow: var(--focus);
}

svg {
  width: 18px;
  height: 18px;
  stroke-width: 2.2;
}

.lock-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.lock-panel {
  width: min(430px, 100%);
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: color-mix(in srgb, var(--panel) 94%, transparent);
  box-shadow: var(--shadow);
}

.lock-panel.shake {
  animation: shake 160ms linear 0s 2;
}

.product-mark,
.rail-head {
  display: flex;
  align-items: center;
  gap: 10px;
}

.product-mark span,
.logo {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  color: #ffffff;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  font-weight: 900;
}

.overline {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 900;
  text-transform: uppercase;
}

.lock-panel .overline {
  margin-top: 26px;
}

.lock-panel h1 {
  margin: 0;
  font-size: clamp(2.2rem, 8vw, 4.2rem);
  line-height: 0.95;
}

.pin-dots {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin: 28px 0 12px;
}

.pin-dots span {
  width: 14px;
  height: 14px;
  border: 2px solid var(--line-strong);
  border-radius: 50%;
}

.pin-dots span.active {
  border-color: var(--accent);
  background: var(--accent);
}

.lock-error {
  min-height: 22px;
  margin: 0 0 16px;
  color: var(--danger);
  text-align: center;
}

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

.pin-pad button,
.primary-btn,
.secondary-btn,
.icon-btn,
.icon-text,
.tabs button,
.chip {
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  background: var(--panel);
}

.pin-pad button {
  min-height: 58px;
  font-size: 1.15rem;
  font-weight: 900;
}

.pin-pad button:hover,
.secondary-btn:hover,
.icon-btn:hover,
.icon-text:hover,
.tabs button:hover,
.month-button:hover {
  border-color: var(--line-strong);
  background: var(--panel-2);
}

.shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 268px minmax(0, 1fr) 340px;
  gap: 18px;
  padding: 18px;
}

.rail,
.editor,
.workspace {
  min-width: 0;
}

.rail,
.editor {
  align-self: start;
  position: sticky;
  top: 18px;
  max-height: calc(100vh - 36px);
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: color-mix(in srgb, var(--panel) 92%, transparent);
  box-shadow: 0 10px 28px rgba(21, 25, 18, 0.06);
}

.rail {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 14px;
}

.rail-head strong,
.rail-head span {
  display: block;
}

.rail-head span {
  color: var(--muted);
  font-size: 0.82rem;
}

.primary-btn,
.secondary-btn,
.icon-text,
.icon-btn {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 12px;
  font-weight: 850;
}

.primary-btn {
  border-color: transparent;
  color: #ffffff;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
}

.primary-btn:hover {
  filter: saturate(1.08);
}

.secondary-btn {
  background: var(--panel);
}

.icon-btn {
  width: 42px;
  padding: 0;
}

.month-list {
  display: grid;
  gap: 8px;
}

.month-button {
  width: 100%;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  background: transparent;
  text-align: left;
}

.month-button.active {
  border-color: var(--accent);
  background: var(--soft-accent);
}

.month-button strong,
.month-button span {
  display: block;
}

.month-button span {
  color: var(--muted);
  font-size: 0.82rem;
}

.month-count {
  padding: 3px 7px;
  border-radius: 6px;
  color: var(--muted);
  background: var(--panel-2);
  font-size: 0.78rem;
  font-weight: 900;
}

.rail-foot {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: auto;
}

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

.workspace-head {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: flex-start;
  min-height: 142px;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(135deg, var(--soft-accent), transparent 48%),
    linear-gradient(315deg, var(--soft-purple), transparent 42%),
    var(--panel);
}

.workspace-head h1 {
  margin: 0;
  font-size: clamp(2.2rem, 7vw, 5.2rem);
  line-height: 0.9;
}

.headline {
  max-width: 780px;
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 1.05rem;
  line-height: 1.45;
}

.head-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.save-state {
  min-width: 94px;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  background: var(--panel);
  font-size: 0.82rem;
  font-weight: 900;
  text-align: center;
}

.save-state.saving {
  color: var(--accent-3);
  background: var(--soft-orange);
}

.save-state.saved {
  color: var(--good);
  background: color-mix(in srgb, var(--good) 14%, transparent);
}

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

.metric {
  min-height: 118px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.metric span {
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 850;
  text-transform: uppercase;
}

.metric strong {
  font-size: clamp(1.55rem, 4vw, 2.2rem);
  line-height: 1;
}

.toolbar {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto auto;
  gap: 10px;
  align-items: center;
}

.search-field {
  min-height: 44px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.search-field input {
  width: 100%;
  border: 0;
  outline: 0;
  color: var(--text);
  background: transparent;
}

.tabs {
  display: flex;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.tabs button {
  min-height: 34px;
  padding: 0 10px;
  font-weight: 850;
}

.tabs button.active {
  border-color: transparent;
  color: var(--panel);
  background: var(--text);
}

.board {
  display: grid;
  gap: 14px;
}

.empty {
  display: grid;
  place-items: center;
  min-height: 290px;
  padding: 28px;
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  color: var(--muted);
  background: color-mix(in srgb, var(--panel) 74%, transparent);
  text-align: center;
}

.empty h2 {
  margin: 0 0 8px;
  color: var(--text);
  font-size: 1.8rem;
}

.section-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: color-mix(in srgb, var(--panel) 94%, transparent);
}

.section-top {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
  padding: 14px;
  border-bottom: 1px solid var(--line);
}

.section-top h2 {
  margin: 0;
  font-size: clamp(1.35rem, 3vw, 2rem);
  line-height: 1.1;
}

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

.section-actions,
.row-actions {
  display: flex;
  gap: 6px;
}

.item-table {
  display: grid;
}

.item-row {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr) auto auto;
  gap: 10px;
  align-items: center;
  min-height: 64px;
  padding: 10px 14px;
  border-top: 1px solid color-mix(in srgb, var(--line) 70%, transparent);
}

.item-row:first-child {
  border-top: 0;
}

.item-row.done .item-title {
  color: var(--muted);
  text-decoration: line-through;
}

.round-check {
  width: 28px;
  height: 28px;
  display: grid;
  place-content: center;
  appearance: none;
  border: 2px solid var(--line-strong);
  border-radius: 50%;
  background: transparent;
}

.round-check::before {
  content: "";
  width: 12px;
  height: 12px;
  border-radius: 50%;
  transform: scale(0);
  transition: transform 120ms ease;
  background: var(--accent);
}

.round-check:checked {
  border-color: var(--accent);
}

.round-check:checked::before {
  transform: scale(1);
}

.item-title {
  display: block;
  overflow-wrap: anywhere;
  font-weight: 850;
  line-height: 1.25;
}

.item-note {
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.35;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.chip {
  min-height: 24px;
  display: inline-flex;
  align-items: center;
  padding: 2px 7px;
  font-size: 0.78rem;
  font-weight: 900;
}

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

.chip.purple {
  color: var(--accent-2);
  background: var(--soft-purple);
}

.chip.orange {
  color: var(--accent-3);
  background: var(--soft-orange);
}

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

.chip.green {
  color: var(--good);
  background: color-mix(in srgb, var(--good) 14%, transparent);
}

.amount {
  padding: 5px 8px;
  border-radius: 6px;
  color: var(--muted);
  background: var(--panel-2);
  font-weight: 900;
  white-space: nowrap;
}

.editor {
  padding: 14px;
}

.editor h2 {
  margin: 0 0 12px;
  font-size: 1.25rem;
}

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

.editor label,
.modal label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 850;
}

.editor input,
.editor textarea,
.editor select,
.modal input {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  color: var(--text);
  background: var(--panel);
}

.editor textarea {
  min-height: 92px;
  resize: vertical;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.danger-btn {
  min-height: 42px;
  border: 1px solid var(--danger);
  border-radius: 8px;
  color: var(--danger);
  background: var(--soft-red);
  font-weight: 900;
}

.check-line {
  display: flex !important;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 8px !important;
}

.check-line input {
  width: 18px;
  min-height: 18px;
  accent-color: var(--accent);
}

.modal {
  width: min(480px, calc(100% - 24px));
  border: 0;
  border-radius: 8px;
  padding: 0;
  color: var(--text);
  background: transparent;
}

.modal::backdrop {
  background: rgba(0, 0, 0, 0.55);
}

.modal-card {
  display: grid;
  gap: 14px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.modal-head,
.modal-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 0;
  padding: 0;
}

.modal-head h2 {
  margin: 0;
}

.modal-actions {
  justify-content: flex-end;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  max-width: min(420px, calc(100vw - 36px));
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  background: var(--panel);
  box-shadow: var(--shadow);
  transform: translateY(120%);
  opacity: 0;
  transition: transform 180ms ease, opacity 180ms ease;
  z-index: 20;
}

.toast.show {
  transform: translateY(0);
  opacity: 1;
}

@keyframes shake {
  0%,
  100% {
    transform: translateX(0);
  }
  50% {
    transform: translateX(8px);
  }
}

@media (max-width: 1180px) {
  .shell {
    grid-template-columns: 230px minmax(0, 1fr);
  }

  .editor {
    position: static;
    grid-column: 1 / -1;
    max-height: none;
  }
}

@media (max-width: 840px) {
  .shell {
    grid-template-columns: 1fr;
    padding: 12px;
  }

  .rail {
    position: static;
    max-height: none;
  }

  .month-list {
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  }

  .workspace-head {
    display: grid;
    padding: 18px;
  }

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

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

  .tabs {
    overflow-x: auto;
  }

  .tabs button {
    flex: 0 0 auto;
  }
}

@media (max-width: 560px) {
  .lock-screen {
    padding: 14px;
  }

  .lock-panel {
    padding: 20px;
  }

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

  .item-row {
    grid-template-columns: 34px minmax(0, 1fr) auto;
  }

  .row-actions {
    grid-column: 2 / -1;
    justify-content: flex-start;
  }

  .amount {
    justify-self: end;
  }
}
