*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  font-family: var(--font);
  font-size: var(--fs);
  line-height: 1.45;
  color: var(--text);
  background: var(--bg);
  background-image: var(--bg-grad);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overscroll-behavior-y: none;
}

h1,
h2,
h3,
h4,
p,
figure {
  margin: 0;
  font-weight: 600;
}

h1 {
  font-size: 1.05rem;
}
h2 {
  font-size: 0.94rem;
}
h3 {
  font-size: 0.86rem;
}

ul,
ol {
  margin: 0;
  padding: 0;
  list-style: none;
}

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

a {
  color: var(--accent-ink);
  text-decoration: none;
}

::selection {
  background: var(--accent-soft);
}

svg {
  display: block;
}

.ico {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  width: 16px;
  height: 16px;
}
.ico svg {
  width: 100%;
  height: 100%;
}
.ico-sm {
  width: 14px;
  height: 14px;
}
.ico-lg {
  width: 20px;
  height: 20px;
}
.ico-xl {
  width: 26px;
  height: 26px;
}

/* ---------- scrollbar ---------- */
.thin-scroll {
  scrollbar-width: thin;
  scrollbar-color: #ded6ea transparent;
  overflow: auto;
}
.thin-scroll::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
.thin-scroll::-webkit-scrollbar-thumb {
  background: #ded6ea;
  border-radius: 99px;
}
.thin-scroll::-webkit-scrollbar-track {
  background: transparent;
}

/* ---------- text helpers ---------- */
.muted {
  color: var(--text-2);
}
.faint {
  color: var(--text-3);
}
.num {
  font-family: var(--font-num);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}
.t-sm {
  font-size: var(--fs-sm);
}
.t-xs {
  font-size: var(--fs-xs);
}
.bold {
  font-weight: 650;
}
.nowrap {
  white-space: nowrap;
}
.ellipsis {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}
.grow {
  flex: 1 1 auto;
  min-width: 0;
}
.row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.row-tight {
  gap: 6px;
}
.col {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}
.spread {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-width: 0;
}
.wrap {
  flex-wrap: wrap;
}
.center {
  align-items: center;
}
.hidden {
  display: none !important;
}
.upper {
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* ---------- buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 30px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-size: var(--fs-sm);
  font-weight: 550;
  cursor: pointer;
  transition: background 0.16s ease, border-color 0.16s ease, color 0.16s ease, transform 0.1s ease;
  white-space: nowrap;
  user-select: none;
}
.btn:hover {
  background: var(--surface-2);
  border-color: var(--line);
}
.btn:active {
  transform: translateY(0.5px);
}
.btn:focus-visible {
  outline: 2px solid var(--accent-ring);
  outline-offset: 1px;
}
.btn[disabled] {
  opacity: 0.5;
  cursor: not-allowed;
}
.btn-primary {
  background: var(--accent);
  border-color: transparent;
  color: #fff;
  box-shadow: 0 6px 14px -10px var(--accent-ink);
}
.btn-primary:hover {
  background: var(--accent-ink);
}
.btn-soft {
  background: var(--accent-soft);
  border-color: transparent;
  color: var(--accent-ink);
}
.btn-soft:hover {
  background: var(--surface-3);
}
.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--text-2);
}
.btn-ghost:hover {
  background: var(--surface-2);
  color: var(--text);
}
.btn-danger {
  background: var(--danger-soft);
  border-color: transparent;
  color: #a95562;
}
.btn-danger:hover {
  background: #f6dee3;
}
.btn-sm {
  height: 26px;
  padding: 0 9px;
  font-size: var(--fs-xs);
  border-radius: var(--radius-xs);
}
.btn-lg {
  height: 36px;
  padding: 0 16px;
  font-size: var(--fs);
}
.btn-block {
  width: 100%;
}
.btn-icon {
  width: 28px;
  height: 28px;
  padding: 0;
  border-radius: var(--radius-xs);
  border-color: transparent;
  background: transparent;
  color: var(--text-2);
}
.btn-icon:hover {
  background: var(--surface-2);
  color: var(--text);
}
.btn-icon.btn-sm {
  width: 24px;
  height: 24px;
}

/* ---------- chips / segmented ---------- */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 24px;
  padding: 0 9px;
  border-radius: 99px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text-2);
  font-size: var(--fs-xs);
  font-weight: 550;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}
.chip:hover {
  border-color: var(--accent-2);
  color: var(--accent-ink);
}
.chip.is-active {
  background: var(--accent-soft);
  border-color: transparent;
  color: var(--accent-ink);
}
.chip-static {
  cursor: default;
}
.chip-static:hover {
  border-color: var(--line);
  color: var(--text-2);
}
.tag {
  display: inline-flex;
  align-items: center;
  height: 18px;
  padding: 0 7px;
  border-radius: 99px;
  font-size: 10.5px;
  font-weight: 600;
  background: var(--surface-2);
  color: var(--text-2);
  white-space: nowrap;
}
.tag.accent {
  background: var(--accent-soft);
  color: var(--accent-ink);
}
.tag.pink {
  background: var(--pink-soft);
  color: #a8617e;
}
.tag.beige {
  background: var(--beige-soft);
  color: #8a7145;
}
.tag.mint {
  background: var(--mint-soft);
  color: #4e8270;
}
.tag.warn {
  background: var(--warn-soft);
  color: #96683a;
}
.tag.danger {
  background: var(--danger-soft);
  color: #a95562;
}
.tag.info {
  background: var(--info-soft);
  color: #5c659c;
}

.seg {
  display: inline-flex;
  padding: 2px;
  gap: 2px;
  background: var(--surface-2);
  border-radius: var(--radius-xs);
}
.seg > button {
  height: 24px;
  padding: 0 10px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--text-2);
  font-size: var(--fs-xs);
  font-weight: 550;
  cursor: pointer;
  transition: all 0.15s ease;
}
.seg > button:hover {
  color: var(--text);
}
.seg > button.is-active {
  background: var(--surface);
  color: var(--accent-ink);
  box-shadow: 0 1px 2px rgba(58, 48, 82, 0.08);
}

/* ---------- inputs ---------- */
.inp,
.sel,
.ta {
  width: 100%;
  height: 30px;
  padding: 0 9px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-size: var(--fs-sm);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  min-width: 0;
}
.ta {
  height: auto;
  padding: 7px 9px;
  resize: vertical;
  min-height: 60px;
  line-height: 1.5;
}
.inp::placeholder,
.ta::placeholder {
  color: var(--text-3);
}
.inp:focus,
.sel:focus,
.ta:focus {
  outline: none;
  border-color: var(--accent-2);
  box-shadow: 0 0 0 3px var(--accent-ring);
}
.sel {
  appearance: none;
  padding-right: 24px;
  background-image: linear-gradient(45deg, transparent 50%, var(--text-3) 50%),
    linear-gradient(135deg, var(--text-3) 50%, transparent 50%);
  background-position: calc(100% - 13px) 13px, calc(100% - 9px) 13px;
  background-size: 4px 4px, 4px 4px;
  background-repeat: no-repeat;
  cursor: pointer;
}
.field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 0;
}
.field > label {
  font-size: var(--fs-xs);
  font-weight: 600;
  color: var(--text-2);
}
.inp-ghost {
  border-color: transparent;
  background: var(--surface-2);
}
.check {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  min-width: 0;
}
.check input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}
.check .box {
  width: 17px;
  height: 17px;
  border-radius: 6px;
  border: 1.5px solid #d7cfe4;
  background: var(--surface);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  transition: all 0.15s ease;
  color: transparent;
}
.check input:checked + .box {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.check input:focus-visible + .box {
  box-shadow: 0 0 0 3px var(--accent-ring);
}
.check .box svg {
  width: 11px;
  height: 11px;
  stroke-width: 3;
}
.check:hover .box {
  border-color: var(--accent-2);
}

.switch {
  position: relative;
  width: 34px;
  height: 20px;
  border-radius: 99px;
  border: 0;
  background: #ddd6e6;
  cursor: pointer;
  transition: background 0.18s ease;
  flex: 0 0 auto;
  padding: 0;
}
.switch::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(58, 48, 82, 0.24);
  transition: transform 0.18s ease;
}
.switch.is-on {
  background: var(--accent);
}
.switch.is-on::after {
  transform: translateX(14px);
}

.dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex: 0 0 auto;
  background: var(--accent);
}
.dot-lg {
  width: 8px;
  height: 8px;
}
.dot.low {
  background: var(--mint);
}
.dot.mid {
  background: var(--warn);
}
.dot.high {
  background: var(--danger);
}

/* ---------- progress / bars ---------- */
.bar {
  height: 6px;
  border-radius: 99px;
  background: var(--surface-3);
  overflow: hidden;
  width: 100%;
}
.bar > i {
  display: block;
  height: 100%;
  border-radius: 99px;
  background: var(--accent);
  transition: width 0.3s ease;
}
.bar.thin {
  height: 4px;
}
.bar.thick {
  height: 8px;
}
.bar > i.ok {
  background: var(--ok);
}
.bar > i.warn {
  background: var(--warn);
}
.bar > i.pink {
  background: var(--pink);
}
.bar > i.mint {
  background: var(--mint);
}

.spark {
  display: flex;
  align-items: flex-end;
  gap: 3px;
  height: 34px;
}
.spark > span {
  flex: 1 1 0;
  min-width: 3px;
  border-radius: 3px 3px 2px 2px;
  background: var(--surface-3);
  position: relative;
}
.spark > span > i {
  position: absolute;
  inset: auto 0 0 0;
  display: block;
  border-radius: 3px 3px 2px 2px;
  background: var(--accent-2);
  min-height: 2px;
}
.spark > span.is-today > i {
  background: var(--accent);
}
.spark > span.is-empty > i {
  background: var(--surface-3);
}

/* ---------- list rows ---------- */
.lrow {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: var(--radius-xs);
  min-width: 0;
  transition: background 0.14s ease;
}
.lrow:hover {
  background: var(--surface-2);
}
.lrow.clickable {
  cursor: pointer;
}
.lrow.is-done .lrow-title {
  color: var(--text-3);
  text-decoration: line-through;
}
.lrow-title {
  font-size: var(--fs-sm);
  min-width: 0;
}
.list {
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.divider {
  height: 1px;
  background: var(--line-2);
  margin: 6px 0;
}
.empty {
  padding: 14px 8px;
  text-align: center;
  color: var(--text-3);
  font-size: var(--fs-sm);
}
.empty-soft {
  padding: 10px;
  border: 1px dashed var(--line);
  border-radius: var(--radius-sm);
  text-align: center;
  color: var(--text-3);
  font-size: var(--fs-sm);
}
.kv {
  display: flex;
  align-items: baseline;
  gap: 6px;
}
.stat-num {
  font-size: 1.24rem;
  font-weight: 660;
  line-height: 1.1;
}
.stat-num.sm {
  font-size: 1.02rem;
}
.stat-label {
  font-size: var(--fs-xs);
  color: var(--text-3);
  font-weight: 550;
}
.pos {
  color: var(--ok);
}
.neg {
  color: var(--danger);
}
