@font-face{
  font-family: "Soyuz Grotesk";
  src:
    url("fonts/SoyuzGrotesk.woff2") format("woff2"),
    url("fonts/SoyuzGrotesk.woff") format("woff");
  font-weight: 300 900;
  font-style: normal;
  font-display: swap;
}

:root{
  --bg:#F2F2F7;
  --card:#FFFFFF;
  --text:#0B0B0F;
  --sub:#6B7280;
  --line:rgba(17,17,17,.08);

  --accent:#007AFF;
  --pos:#34C759;
  --neg:#FF3B30;

  --shadow: 0 10px 30px rgba(0,0,0,.08);
  --radius: 18px;

  --safeTop: env(safe-area-inset-top);
  --safeBottom: env(safe-area-inset-bottom);
}

@media (prefers-color-scheme: dark){
  :root{
    --bg:#0B0B0F;
    --card:#15151C;
    --text:#F3F4F6;
    --sub:#A1A1AA;
    --line:rgba(255,255,255,.10);
    --shadow: 0 14px 40px rgba(0,0,0,.35);
  }
}

*{ box-sizing:border-box; -webkit-tap-highlight-color: transparent; }
html,body{ height:100%; }
body{
  margin:0;
  font-family: "Soyuz Grotesk", -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "Segoe UI", Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}

.app{
  min-height:100%;
  padding-top: calc(10px + var(--safeTop));
  padding-bottom: calc(78px + var(--safeBottom));
}

.topbar{
  position: sticky;
  top: 0;
  z-index: 5;
  background: color-mix(in srgb, var(--bg) 84%, transparent);
  backdrop-filter: blur(16px);
  padding: 10px 16px 12px;
  border-bottom: 1px solid var(--line);
  display:flex;
  align-items:center;
  justify-content:space-between;
}

.appname{
  font-size: 20px;
  font-weight: 900;
  letter-spacing: -0.4px;
}
.subtitle{
  font-size: 12px;
  color: var(--sub);
  margin-top: 2px;
  font-weight: 700;
}

.topbar__actions{ display:flex; gap:10px; }
.iconbtn{
  width: 40px;
  height: 40px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: color-mix(in srgb, var(--card) 86%, transparent);
  box-shadow: 0 6px 18px rgba(0,0,0,.06);
  color: var(--text);
  font-size: 16px;
  cursor:pointer;
  font-weight: 900;
}

.content{ padding: 12px 14px 0; }
.screen{ display:none; }
.screen.active{ display:block; }

.cards{
  display:grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 12px;
}

.card{
  background: var(--card);
  border-radius: var(--radius);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  padding: 14px;
}

.card__title{
  font-size: 12px;
  color: var(--sub);
  font-weight: 800;
}
.card__big{
  font-size: 28px;
  font-weight: 900;
  margin-top: 8px;
  letter-spacing: -0.6px;
}
.card__hint{
  font-size: 12px;
  color: var(--sub);
  margin-top: 4px;
  font-weight: 700;
}

.section{ margin-top: 14px; }
.section__head{
  display:flex;
  align-items:flex-end;
  justify-content:space-between;
  gap: 10px;
  margin-bottom: 10px;
}
.section__title{
  font-size: 15px;
  font-weight: 900;
  letter-spacing:-0.2px;
}
.microhint{
  font-size: 12px;
  color: var(--sub);
  font-weight: 800;
}

.list{ display:flex; flex-direction:column; gap: 10px; }

.quick{ display:flex; gap: 10px; flex-wrap: wrap; }

.pill{
  appearance:none;
  border: none;
  border-radius: 999px;
  padding: 10px 14px;
  font-weight: 900;
  background: var(--accent);
  color:#fff;
  cursor:pointer;
  box-shadow: 0 10px 24px rgba(0,122,255,.25);
}
.pill--small{ padding: 8px 12px; font-size: 13px; }
.pill--danger{ background: var(--neg); box-shadow: 0 10px 24px rgba(255,59,48,.22); }
.pill--green{ background: var(--pos); box-shadow: 0 10px 24px rgba(52,199,89,.22); }
.pill--red{ background: var(--neg); box-shadow: 0 10px 24px rgba(255,59,48,.22); }

.ghost{
  appearance:none;
  border: none;
  background: transparent;
  color: var(--accent);
  font-weight: 900;
  cursor:pointer;
  padding: 8px 10px;
  border-radius: 12px;
}
.ghost:active{ background: color-mix(in srgb, var(--accent) 12%, transparent); }
.row-actions{ display:flex; gap: 8px; }

.segmented{
  display:flex;
  background: color-mix(in srgb, var(--card) 86%, transparent);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 4px;
  gap: 4px;
  box-shadow: 0 10px 24px rgba(0,0,0,.05);
}
.seg{
  flex:1;
  border:none;
  border-radius: 12px;
  padding: 10px 10px;
  font-weight: 900;
  background: transparent;
  color: var(--sub);
  cursor:pointer;
}
.seg.active{
  background: var(--card);
  color: var(--text);
  box-shadow: 0 10px 24px rgba(0,0,0,.08);
}

.tabbar{
  position: fixed;
  left: 0; right: 0; bottom: 0;
  padding-bottom: var(--safeBottom);
  background: color-mix(in srgb, var(--bg) 78%, transparent);
  backdrop-filter: blur(18px);
  border-top: 1px solid var(--line);
  display:flex;
  gap: 6px;
  padding: 10px 10px calc(10px + var(--safeBottom));
  z-index: 6;
}
.tab{
  flex:1;
  border: none;
  background: transparent;
  border-radius: 16px;
  padding: 10px 8px;
  cursor:pointer;
  color: var(--sub);
  font-weight: 900;
}
.tab.active{ background: color-mix(in srgb, var(--accent) 14%, transparent); color: var(--accent); }
.tab__icon{ font-size: 18px; line-height: 1; }
.tab__label{ font-size: 11px; font-weight: 900; margin-top: 5px; }

.chartcard canvas{ width: 100%; display:block; }
.chartlegend{
  display:flex; gap: 14px; margin-top: 8px;
  font-size: 12px; color: var(--sub); font-weight: 800;
}
.dot{ width: 10px; height: 10px; border-radius: 999px; display:inline-block; margin-right: 6px; vertical-align: middle; }
.dot--pos{ background: var(--pos); }
.dot--neg{ background: var(--neg); }

/* iOS-like bottom sheet */
.sheetbackdrop{ position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 9; }
.sheet{
  position: fixed; left: 0; right: 0; bottom: 0;
  z-index: 10; background: var(--card);
  border-top-left-radius: 22px; border-top-right-radius: 22px;
  border: 1px solid var(--line);
  box-shadow: 0 -20px 60px rgba(0,0,0,.25);
  padding: 10px 14px calc(16px + var(--safeBottom));
  max-height: 86vh; overflow:auto;
}
.sheet__grab{
  width: 44px; height: 5px; border-radius: 999px;
  background: color-mix(in srgb, var(--sub) 35%, transparent);
  margin: 6px auto 10px;
}
.sheet__head{ display:flex; align-items:center; justify-content:space-between; gap: 10px; padding: 6px 2px 10px; }
.sheet__title{ font-size: 16px; font-weight: 900; }
.sheet__actions{ display:flex; gap: 8px; align-items:center; }

.field{ display:flex; flex-direction:column; gap: 6px; margin-top: 12px; }
.label{ font-size: 12px; color: var(--sub); font-weight: 900; }
.input, .select, .textarea{
  width: 100%;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: color-mix(in srgb, var(--card) 88%, transparent);
  padding: 12px 12px;
  font-size: 15px;
  color: var(--text);
  outline: none;
  font-family: inherit;
  font-weight: 800;
}
.textarea{ min-height: 92px; resize: vertical; }
.input:focus, .select:focus, .textarea:focus{
  border-color: color-mix(in srgb, var(--accent) 55%, var(--line));
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 14%, transparent);
}

.divider{ height: 1px; background: var(--line); margin: 12px 0; }

.settingrow{ display:flex; justify-content:space-between; align-items:center; gap: 10px; }
.settingrow__title{ font-weight: 900; }
.settingrow__hint{ font-size: 12px; color: var(--sub); margin-top: 2px; font-weight: 700; }
.danger{ color: var(--neg); }

.footerhint{
  margin-top: 14px;
  font-size: 12px;
  color: var(--sub);
  text-align:center;
  font-weight: 800;
}

.search{
  position: fixed; left: 0; right: 0;
  top: calc(8px + var(--safeTop));
  z-index: 11;
  margin: 0 12px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: var(--card);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.search__row{ display:flex; align-items:center; gap: 10px; padding: 10px; border-bottom: 1px solid var(--line); }
.search__input{
  flex:1;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px 12px;
  background: color-mix(in srgb, var(--card) 88%, transparent);
  color: var(--text);
  outline:none;
  font-size: 15px;
  font-family: inherit;
  font-weight: 800;
}

.toast{
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(90px + var(--safeBottom));
  z-index: 20;
  background: color-mix(in srgb, var(--text) 90%, transparent);
  color: var(--bg);
  padding: 10px 12px;
  border-radius: 999px;
  font-weight: 900;
  font-size: 13px;
  box-shadow: 0 12px 40px rgba(0,0,0,.25);
}

.hidden{ display:none !important; }

/* ===== Swipe rows ===== */
.swipe{
  position: relative;
  overflow: hidden;
  border-radius: 16px;
}
.swipe__under{
  position:absolute; inset:0;
  display:flex; justify-content:flex-end; gap: 8px;
  padding: 10px;
}
.swipe__under .swbtn{
  border:none; border-radius: 14px;
  padding: 10px 12px;
  font-weight: 900;
  cursor:pointer;
  color:#fff;
}
.swbtn--ok{ background: var(--pos); }
.swbtn--edit{ background: var(--accent); }
.swbtn--del{ background: var(--neg); }
.swipe__top{
  position: relative;
  transform: translateX(0);
  transition: transform .18s ease;
}
.swipe.open .swipe__top{
  transform: translateX(var(--swipeX, -140px));
}

/* Item */
.item{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap: 10px;
  padding: 12px 12px;
  background: var(--card);
  border: 1px solid var(--line);
  box-shadow: 0 10px 24px rgba(0,0,0,.06);
}
.item__left{ display:flex; align-items:flex-start; gap: 10px; min-width: 0; }
.item__main{ min-width:0; }
.item__title{
  font-weight: 900; font-size: 15px; line-height: 1.2;
  white-space: nowrap; overflow:hidden; text-overflow: ellipsis;
}
.item__meta{
  margin-top: 4px;
  font-size: 12px;
  color: var(--sub);
  display:flex;
  flex-wrap:wrap;
  gap: 6px 10px;
  font-weight: 700;
}

.badge{
  display:inline-flex;
  align-items:center;
  gap: 6px;
  padding: 4px 8px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: color-mix(in srgb, var(--card) 86%, transparent);
  font-weight: 800;
}

.item.done .item__title{ text-decoration: line-through; opacity: .65; }
.item.done{ opacity: .95; }

.check{
  width: 28px; height: 28px;
  border-radius: 999px;
  border: 2px solid color-mix(in srgb, var(--accent) 70%, var(--line));
  display:flex; align-items:center; justify-content:center;
  color: #fff; background: transparent;
  cursor:pointer; flex: 0 0 auto;
  font-weight: 900;
}
.check.done{ background: var(--accent); border-color: var(--accent); }

/* Chips */
.chips{ display:flex; gap: 8px; flex-wrap:wrap; }
.chip{
  border: 1px solid var(--line);
  background: color-mix(in srgb, var(--card) 86%, transparent);
  border-radius: 999px;
  padding: 8px 12px;
  font-weight: 900;
  cursor:pointer;
}
.chip:active{ transform: scale(.98); }