:root {
  --bg: #070d13;
  --panel: rgba(15, 25, 36, 0.92);
  --panel-2: rgba(20, 32, 45, 0.86);
  --line: rgba(153, 174, 196, 0.13);
  --line-strong: rgba(153, 174, 196, 0.22);
  --text: #f2f7ff;
  --muted: #93a1b1;
  --muted-2: #6f7d8e;
  --cyan: #24e0de;
  --cyan-soft: rgba(36, 224, 222, 0.18);
  --cyan-line: rgba(36, 224, 222, 0.42);
  --violet: #a45cff;
  --violet-soft: rgba(164, 92, 255, 0.18);
  --violet-line: rgba(164, 92, 255, 0.50);
  --green: #24e0a7;
  --gray-tile: rgba(255, 255, 255, 0.05);
  --danger: #ff5d7a;
  --radius: 18px;
  --shadow: 0 20px 80px rgba(0, 0, 0, 0.45);
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body {
  margin: 0;
  color: var(--text);
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at 20% 8%, rgba(36, 224, 222, 0.16), transparent 34%),
    radial-gradient(circle at 84% 2%, rgba(164, 92, 255, 0.15), transparent 32%),
    linear-gradient(135deg, #111923 0%, #05070a 100%);
}

button, input { font: inherit; }
button { cursor: pointer; }

.phone-shell {
  width: 100%;
  max-width: 620px;
  min-height: 100vh;
  margin: 0 auto;
  padding: 18px 12px;
}

.app-card {
  min-height: calc(100vh - 36px);
  position: relative;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 34px;
  background:
    linear-gradient(180deg, rgba(9, 18, 27, 0.96), rgba(5, 11, 18, 0.98)),
    var(--bg);
  box-shadow: var(--shadow);
  padding: 20px;
}

.app-card::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(90deg, rgba(36,224,222,0.04), transparent 34%, rgba(164,92,255,0.04)),
    radial-gradient(circle at 16% 12%, rgba(36,224,222,0.12), transparent 22%);
}

.topbar, .tabs, .view, .bottom-status, .status-line { position: relative; z-index: 1; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.brand { display: flex; align-items: center; gap: 13px; }
.brand h1 { margin: 0; font-size: 20px; line-height: 1.1; letter-spacing: -0.02em; }
.brand p { margin: 5px 0 0; color: var(--muted); font-size: 15px; }

.bot-avatar {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle at 50% 34%, rgba(255,255,255,0.28), transparent 18%),
    linear-gradient(145deg, rgba(36,224,222,0.36), rgba(32,65,95,0.74));
  border: 1px solid rgba(36, 224, 222, 0.28);
  box-shadow: 0 0 26px rgba(36,224,222,0.2);
}
.bot-avatar span {
  width: 34px;
  height: 23px;
  border-radius: 12px;
  background: #071018;
  border: 2px solid var(--cyan);
  position: relative;
  box-shadow: inset 0 -5px 12px rgba(36, 224, 222, 0.18);
}
.bot-avatar span::before,
.bot-avatar span::after {
  content: "";
  position: absolute;
  top: 8px;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--cyan);
}
.bot-avatar span::before { left: 8px; }
.bot-avatar span::after { right: 8px; }

.icon-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid var(--line-strong);
  background: rgba(255,255,255,0.06);
  color: var(--text);
  display: grid;
  place-items: center;
  font-size: 20px;
}

.tabs {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  padding: 8px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 16px;
  margin-bottom: 20px;
}

.tab {
  height: 52px;
  border: 0;
  border-radius: 12px;
  color: #dfe8f2;
  background: transparent;
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 15px;
}

.tab.active[data-tab="accruals"] {
  background: linear-gradient(135deg, rgba(36,224,222,0.31), rgba(24,88,111,0.5));
  color: #79ffff;
}

.tab.active[data-tab="fill"] {
  background: linear-gradient(135deg, rgba(164,92,255,0.78), rgba(112,48,184,0.76));
  color: #fff;
}

.tab.active[data-tab="withdraw"] {
  background: linear-gradient(135deg, rgba(255,214,102,0.34), rgba(92,118,52,0.5));
  color: #fff0a6;
}

.tab-icon { font-size: 24px; line-height: 1; }

.hidden { display: none !important; }

.status-line {
  color: #ffc2cd;
  border: 1px solid rgba(255,93,122,0.35);
  background: rgba(255,93,122,0.08);
  border-radius: 12px;
  padding: 10px 12px;
  margin-bottom: 14px;
}

.section-title {
  margin: 0 0 13px;
  font-size: 22px;
  line-height: 1.2;
  letter-spacing: -0.02em;
}

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

.stat-card,
.group-card,
.history-card,
.period-card,
.fill-group-card {
  background: linear-gradient(180deg, rgba(23,37,52,0.92), rgba(13,23,34,0.88));
  border: 1px solid var(--line-strong);
  border-radius: 13px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.05);
}

.stat-card {
  min-height: 88px;
  padding: 13px;
  position: relative;
  overflow: hidden;
}
.stat-card p { margin: 0 0 8px; color: var(--muted); font-size: 14px; }
.stat-card b { font-size: 24px; letter-spacing: 0.01em; }
.stat-card svg {
  position: absolute;
  right: 10px;
  bottom: 11px;
  width: 90px;
  height: 36px;
  opacity: 0.95;
}

.group-list { display: grid; gap: 10px; margin-bottom: 16px; }
.group-card { padding: 13px; }
.group-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.group-title { display: flex; align-items: center; gap: 9px; min-width: 0; }
.group-title h3 { margin: 0; font-size: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.group-title small { display: block; color: var(--muted); margin-top: 2px; }
.group-icon {
  width: 28px;
  height: 28px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  color: var(--cyan);
  background: var(--cyan-soft);
  border: 1px solid var(--cyan-line);
}
.group-icon.violet { color: #d4b7ff; background: var(--violet-soft); border-color: var(--violet-line); }
.balance-badge {
  white-space: nowrap;
  border-radius: 999px;
  padding: 7px 10px;
  font-weight: 800;
  font-size: 14px;
  color: var(--cyan);
  background: rgba(36,224,222,0.10);
  border: 1px solid rgba(36,224,222,0.25);
}
.balance-badge.ready { color: #fff0a6; background: rgba(255,214,102,0.10); border-color: rgba(255,214,102,0.36); }
.progress-line {
  height: 8px;
  border-radius: 999px;
  background: rgba(255,255,255,0.08);
  overflow: hidden;
  margin-top: 11px;
}
.progress-fill {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--cyan), #44f5b6);
  width: 0%;
}
.withdraw-btn {
  margin-top: 11px;
  width: 100%;
  border: 1px solid rgba(255,214,102,0.36);
  background: rgba(255,214,102,0.12);
  color: #ffe99d;
  border-radius: 12px;
  padding: 11px;
  font-weight: 800;
}

.history-card { padding: 14px; margin-bottom: 74px; }
.history-head, .period-head, .fill-group-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}
.history-head h2, .period-head h2, .fill-group-head h2 { margin: 0; font-size: 17px; }
.history-head p, .period-head p, .fill-group-head p { margin: 0; color: var(--muted); font-size: 13px; }

.day-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
}

.day-tile {
  min-height: 66px;
  border-radius: 9px;
  border: 1px solid var(--line-strong);
  background: rgba(255,255,255,0.04);
  padding: 8px 5px;
  text-align: center;
  display: grid;
  align-content: center;
  gap: 4px;
  overflow: hidden;
}
.day-tile .date { font-size: 13px; font-weight: 750; color: #d9e2ee; }
.day-tile .amount {
  color: var(--cyan);
  font-size: 13px;
  font-weight: 850;
  letter-spacing: -0.02em;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
}

.period-card { padding: 14px; margin-bottom: 12px; }
.period-date { font-size: 16px; font-weight: 800; color: #f8fbff; }
.edit-pill {
  border: 1px solid rgba(164,92,255,0.55);
  background: rgba(164,92,255,0.11);
  color: #cfadff;
  padding: 10px 12px;
  border-radius: 10px;
  font-weight: 800;
}

.fill-groups { display: grid; gap: 12px; padding-bottom: 74px; }
.fill-group-card { padding: 12px; }
.fill-group-title { display: flex; align-items: center; gap: 8px; min-width: 0; }
.fill-group-title h2 { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fill-group-meta { text-align: right; display: grid; gap: 3px; }
.fill-group-meta strong { color: var(--cyan); }
.fill-group-meta span { color: var(--muted); font-size: 12px; }

.fill-day {
  min-height: 62px;
  border: 1px solid var(--line-strong);
  background: var(--gray-tile);
  color: var(--muted);
}
.fill-day.filled {
  border-color: rgba(36,224,222,0.42);
  background: rgba(36,224,222,0.15);
}
.fill-day.filled .amount { color: var(--cyan); }
.fill-day.selected {
  border-color: rgba(164,92,255,0.85);
  background: rgba(164,92,255,0.25);
}
.fill-day .amount.empty { color: var(--muted-2); }

.bottom-status {
  position: absolute;
  left: 20px;
  right: 20px;
  bottom: 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: rgba(17, 29, 41, 0.92);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 10px 11px;
  color: var(--muted);
  font-size: 13px;
  backdrop-filter: blur(14px);
}
.bottom-status b { color: var(--cyan); font-weight: 700; }
.sync-icon { margin-right: 5px; }
.small-btn {
  border: 1px solid rgba(36,224,222,0.28);
  color: var(--cyan);
  background: rgba(36,224,222,0.09);
  border-radius: 10px;
  padding: 8px 11px;
  font-weight: 800;
}

.modal {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: end center;
  z-index: 10;
}
.modal-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,0.62); backdrop-filter: blur(8px); }
.modal-box {
  position: relative;
  width: min(620px, calc(100% - 22px));
  border: 1px solid var(--line-strong);
  border-radius: 22px 22px 0 0;
  background: linear-gradient(180deg, rgba(18,31,44,0.98), rgba(8,15,24,0.98));
  padding: 18px;
  box-shadow: 0 -20px 70px rgba(0,0,0,0.55);
}
.settings-box { max-height: 86vh; overflow: auto; }
.modal-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 14px; margin-bottom: 16px; }
.modal-head h2 { margin: 0; font-size: 20px; }
.modal-head p { margin: 5px 0 0; color: var(--muted); font-size: 13px; }
.field-label { display: block; margin: 0 0 8px; color: var(--muted); font-size: 14px; }
.amount-input, .text-input {
  width: 100%;
  border: 1px solid var(--line-strong);
  background: rgba(255,255,255,0.06);
  color: var(--text);
  outline: none;
  border-radius: 13px;
  padding: 14px 13px;
}
.amount-input { font-size: 24px; font-weight: 850; letter-spacing: -0.02em; }
.amount-input:focus, .text-input:focus { border-color: rgba(36,224,222,0.55); }
.modal-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 14px; }
.primary-btn, .ghost-btn {
  border-radius: 12px;
  padding: 13px;
  border: 1px solid transparent;
  font-weight: 850;
}
.primary-btn { color: white; background: linear-gradient(135deg, rgba(164,92,255,0.94), rgba(98,49,189,0.94)); }
.ghost-btn { color: #c9d2dd; background: rgba(255,255,255,0.05); border-color: var(--line-strong); }
.compact { padding: 12px 14px; }

.settings-list { display: grid; gap: 10px; }
.settings-item {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 8px;
  align-items: center;
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.04);
  border-radius: 13px;
  padding: 9px;
}
.settings-item .text-input { padding: 11px; }
.delete-btn {
  border: 1px solid rgba(255,93,122,0.35);
  background: rgba(255,93,122,0.10);
  color: #ff97aa;
  border-radius: 10px;
  padding: 11px;
  font-weight: 800;
}
.add-group-row { display: grid; grid-template-columns: 1fr auto; gap: 8px; margin-top: 12px; }


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

.withdraw-summary {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 12px;
}
.withdraw-summary > div {
  background: linear-gradient(180deg, rgba(23,37,52,0.92), rgba(13,23,34,0.88));
  border: 1px solid var(--line-strong);
  border-radius: 13px;
  padding: 13px;
}
.withdraw-summary p { margin: 0 0 7px; color: var(--muted); font-size: 13px; }
.withdraw-summary b { font-size: 22px; }
.withdraw-list { padding-bottom: 74px; }
.ready-card { border-color: rgba(255,214,102,0.38); }
.balance-badge {
  cursor: pointer;
}
.balance-badge:active,
.balance-edit-btn:active {
  transform: scale(0.98);
}
.balance-edit-btn {
  white-space: nowrap;
  justify-self: end;
  border-radius: 999px;
  padding: 7px 10px;
  font-weight: 850;
  font-size: 14px;
  color: var(--cyan);
  background: rgba(36,224,222,0.10);
  border: 1px solid rgba(36,224,222,0.25);
}
.balance-edit-btn.ready {
  color: #fff0a6;
  background: rgba(255,214,102,0.10);
  border-color: rgba(255,214,102,0.36);
}
.empty-card { padding: 14px; color: var(--muted); }
.modal-actions.single { grid-template-columns: 1fr; }

@media (max-width: 420px) {
  .phone-shell { padding: 0; }
  .app-card { min-height: 100vh; border-radius: 0; border-left: 0; border-right: 0; padding: 16px 12px; }
  .brand h1 { font-size: 18px; }
  .brand p { font-size: 14px; }
  .bot-avatar { width: 52px; height: 52px; }
  .tabs { gap: 6px; padding: 6px; }
  .tab { font-size: 12px; gap: 4px; }
  .tab-icon { font-size: 18px; }
  .stats-grid { gap: 9px; }
  .day-grid { gap: 6px; }
  .day-tile { min-height: 58px; padding: 7px 3px; }
  .day-tile .date { font-size: 12px; }
  .day-tile .amount { font-size: 12px; }
  .balance-edit-btn, .balance-badge { font-size: 12px; padding: 6px 8px; }
  .bottom-status { left: 12px; right: 12px; bottom: 14px; }
}

.withdraw-btn:disabled {
  cursor: not-allowed;
  opacity: 0.72;
  color: #c8d0d8;
  background: rgba(255,255,255,0.06);
  border-color: var(--line-strong);
}
.balance-detail {
  margin-top: 8px;
  color: var(--muted);
  font-size: 12px;
}
.accrual-day.filled {
  border-color: rgba(36,224,222,0.34);
  background: rgba(36,224,222,0.10);
}
