:root {
  color-scheme: dark;
  --bg: #07111f;
  --panel: #0d1a2c;
  --panel-2: #12233a;
  --line: rgba(255,255,255,.09);
  --text: #f5f7fb;
  --muted: #9aacbf;
  --accent: #42d6b5;
  --accent-2: #6ea8ff;
  --danger: #ff7d88;
  --warning: #f4c96b;
  --success: #60ddb5;
  --shadow: 0 18px 50px rgba(0,0,0,.28);
  --radius-lg: 24px;
  --radius-md: 18px;
  --radius-sm: 14px;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", Tahoma, Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: radial-gradient(circle at top right, #13284a 0, #07111f 42%, #050c16 100%); color: var(--text); }
body { min-height: 100dvh; }
button, input, select, textarea { font: inherit; }
button { color: inherit; }

.app-shell {
  width: min(100%, 720px);
  min-height: 100dvh;
  margin: 0 auto;
  position: relative;
  padding-bottom: calc(154px + env(safe-area-inset-bottom));
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: calc(18px + env(safe-area-inset-top)) 20px 14px;
  background: linear-gradient(to bottom, rgba(7,17,31,.96), rgba(7,17,31,.82), transparent);
  backdrop-filter: blur(18px);
}

.eyebrow { color: var(--muted); font-size: 12px; letter-spacing: .02em; }
h1, h2, h3, p { margin: 0; }
h1 { margin-top: 4px; font-size: 28px; line-height: 1.15; }
h2 { margin-top: 4px; font-size: 22px; }
h3 { font-size: 17px; }

.icon-button {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255,255,255,.05);
  cursor: pointer;
}
.icon-button svg { width: 21px; fill: currentColor; opacity: .9; }

.main-content { padding: 8px 18px 28px; }
.stack { display: grid; gap: 14px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 12px; }

.card {
  background: linear-gradient(180deg, rgba(18,35,58,.98), rgba(12,27,46,.98));
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 18px;
}
.card--flat { box-shadow: none; }
.card--hero {
  padding: 22px;
  background:
    linear-gradient(135deg, rgba(66,214,181,.18), rgba(110,168,255,.08)),
    linear-gradient(180deg, rgba(19,42,68,.98), rgba(10,25,43,.98));
}

.section-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 8px 2px 2px; }
.section-title { font-size: 17px; font-weight: 700; }
.section-link { color: var(--accent); font-size: 13px; background: none; border: 0; padding: 6px 0; cursor: pointer; }

.metric-label { color: var(--muted); font-size: 13px; }
.metric-value { margin-top: 7px; font-size: clamp(26px, 8vw, 40px); font-weight: 800; letter-spacing: -.02em; direction: ltr; text-align: right; }
.metric-sub { margin-top: 9px; color: var(--muted); font-size: 13px; line-height: 1.7; }

.stat-card { padding: 16px; border-radius: var(--radius-md); background: rgba(255,255,255,.045); border: 1px solid var(--line); }
.stat-card strong { display: block; margin-top: 7px; font-size: 20px; direction: ltr; text-align: right; }
.stat-card small { color: var(--muted); }

.empty-state { text-align: center; padding: 30px 18px; }
.empty-state-icon { width: 58px; height: 58px; margin: 0 auto 14px; border-radius: 18px; display: grid; place-items: center; background: rgba(66,214,181,.1); color: var(--accent); font-size: 28px; }
.empty-state p { color: var(--muted); line-height: 1.75; margin-top: 8px; }

.primary-button, .secondary-button, .danger-button {
  min-height: 48px;
  border-radius: 15px;
  border: 1px solid transparent;
  padding: 0 18px;
  font-weight: 750;
  cursor: pointer;
}
.primary-button { background: var(--accent); color: #03221b; }
.secondary-button { background: rgba(255,255,255,.06); border-color: var(--line); color: var(--text); }
.danger-button { background: rgba(255,125,136,.12); border-color: rgba(255,125,136,.24); color: #ffadb4; }
.button-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.entry-dock {
  position: fixed;
  z-index: 30;
  inset-inline: 0;
  bottom: calc(72px + env(safe-area-inset-bottom));
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 160px));
  justify-content: center;
  gap: 10px;
  pointer-events: none;
}
.entry-button {
  pointer-events: auto;
  border: 0;
  border-radius: 18px;
  min-height: 54px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  font-weight: 800;
  box-shadow: 0 14px 30px rgba(0,0,0,.35);
  cursor: pointer;
}
.entry-button--input { background: var(--accent); color: #03221b; }
.entry-button--output { background: #ff8b91; color: #321014; }
.entry-icon { font-size: 23px; line-height: 1; }

.bottom-nav {
  position: fixed;
  z-index: 25;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: min(100%, 720px);
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 2px;
  padding: 10px 8px calc(8px + env(safe-area-inset-bottom));
  background: rgba(8,18,32,.94);
  border-top: 1px solid var(--line);
  backdrop-filter: blur(22px);
}
.nav-item { background: none; border: 0; padding: 5px 2px; display: grid; place-items: center; gap: 3px; color: #7f92a7; font-size: 10px; cursor: pointer; }
.nav-item svg { width: 21px; fill: currentColor; }
.nav-item.is-active { color: var(--accent); }

.list { display: grid; gap: 10px; }
.list-item {
  width: 100%;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 12px;
  text-align: right;
  border: 1px solid var(--line);
  background: rgba(255,255,255,.035);
  border-radius: 16px;
  padding: 13px;
}
.list-item-button { cursor: pointer; color: inherit; }
.list-icon { width: 42px; height: 42px; border-radius: 14px; display: grid; place-items: center; background: rgba(110,168,255,.1); color: #a8c8ff; font-size: 20px; }
.list-main { min-width: 0; }
.list-title { font-weight: 720; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list-sub { margin-top: 4px; color: var(--muted); font-size: 12px; line-height: 1.45; }
.list-value { direction: ltr; text-align: left; font-weight: 800; white-space: nowrap; }
.list-value.positive { color: var(--success); }
.list-value.negative { color: var(--danger); }

.badge { display: inline-flex; align-items: center; min-height: 26px; padding: 0 9px; border-radius: 999px; font-size: 11px; background: rgba(255,255,255,.06); border: 1px solid var(--line); color: var(--muted); }
.badge--success { color: var(--success); background: rgba(96,221,181,.08); }
.badge--danger { color: var(--danger); background: rgba(255,125,136,.08); }
.badge--warning { color: var(--warning); background: rgba(244,201,107,.08); }

.sheet-backdrop { position: fixed; inset: 0; z-index: 80; background: rgba(0,0,0,.58); backdrop-filter: blur(4px); }
.sheet {
  position: fixed;
  z-index: 90;
  left: 50%;
  transform: translateX(-50%);
  bottom: 0;
  width: min(100%, 720px);
  max-height: min(92dvh, 900px);
  overflow: hidden;
  border-radius: 28px 28px 0 0;
  background: #0c192a;
  border: 1px solid var(--line);
  box-shadow: 0 -22px 70px rgba(0,0,0,.5);
}
.sheet-handle { width: 44px; height: 5px; border-radius: 999px; background: rgba(255,255,255,.2); margin: 10px auto 4px; }
.sheet-header { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 12px 18px 14px; border-bottom: 1px solid var(--line); }
.sheet-body { overflow-y: auto; max-height: calc(min(92dvh,900px) - 84px); padding: 18px 18px calc(24px + env(safe-area-inset-bottom)); }

.form { display: grid; gap: 15px; }
.field { display: grid; gap: 7px; }
.field-label { font-size: 13px; color: #dbe4ef; font-weight: 650; }
.field-hint { color: var(--muted); font-size: 11px; line-height: 1.55; }
.input, .select, .textarea {
  width: 100%;
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: rgba(255,255,255,.045);
  color: var(--text);
  padding: 0 14px;
  outline: none;
}
.textarea { min-height: 92px; padding-top: 12px; resize: vertical; }
.input:focus, .select:focus, .textarea:focus { border-color: rgba(66,214,181,.65); box-shadow: 0 0 0 3px rgba(66,214,181,.08); }
.select option { color: #111827; }
.inline-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.form-divider { height: 1px; background: var(--line); margin: 3px 0; }

.segmented { display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px; padding: 5px; border-radius: 16px; background: rgba(255,255,255,.035); border: 1px solid var(--line); }
.segmented button { min-height: 42px; border: 0; border-radius: 12px; background: none; color: var(--muted); cursor: pointer; }
.segmented button.is-active { background: rgba(255,255,255,.08); color: var(--text); font-weight: 750; }

.operation-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 10px; }
.operation-card { min-height: 96px; padding: 14px; border: 1px solid var(--line); border-radius: 17px; background: rgba(255,255,255,.04); color: var(--text); text-align: right; cursor: pointer; }
.operation-card strong { display: block; margin-top: 9px; }
.operation-card small { display: block; margin-top: 5px; color: var(--muted); line-height: 1.45; }
.operation-symbol { font-size: 24px; }

.notice { padding: 13px 14px; border: 1px solid rgba(110,168,255,.2); background: rgba(110,168,255,.07); border-radius: 14px; color: #c8dbff; font-size: 12px; line-height: 1.7; }
.notice--warning { border-color: rgba(244,201,107,.22); background: rgba(244,201,107,.07); color: #f8df9f; }
.notice--danger { border-color: rgba(255,125,136,.22); background: rgba(255,125,136,.07); color: #ffc2c7; }

.toast { position: fixed; z-index: 120; left: 50%; transform: translateX(-50%); bottom: calc(150px + env(safe-area-inset-bottom)); width: min(calc(100% - 36px), 520px); padding: 13px 16px; border-radius: 15px; background: #f5f7fb; color: #111827; box-shadow: 0 16px 38px rgba(0,0,0,.35); text-align: center; font-weight: 700; }

.filter-bar { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
.filter-bar::-webkit-scrollbar { display: none; }
.filter-button { flex: 0 0 auto; border: 1px solid var(--line); border-radius: 999px; background: rgba(255,255,255,.035); color: var(--muted); min-height: 34px; padding: 0 13px; cursor: pointer; }
.filter-button.is-active { color: var(--text); background: rgba(66,214,181,.12); border-color: rgba(66,214,181,.25); }

.progress { height: 8px; border-radius: 999px; background: rgba(255,255,255,.06); overflow: hidden; }
.progress > span { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent-2)); border-radius: inherit; }

.kv { display: grid; gap: 9px; }
.kv-row { display: flex; justify-content: space-between; gap: 14px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.kv-row:last-child { border-bottom: 0; }
.kv-key { color: var(--muted); }
.kv-value { font-weight: 700; direction: ltr; text-align: left; }

.storage-status { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 12px; }
.storage-dot { width: 8px; height: 8px; border-radius: 999px; background: var(--success); box-shadow: 0 0 0 4px rgba(96,221,181,.08); }

@media (max-width: 420px) {
  .main-content { padding-inline: 14px; }
  .app-header { padding-inline: 16px; }
  .grid-2, .inline-fields { grid-template-columns: 1fr; }
  .entry-dock { grid-template-columns: repeat(2, minmax(0, 142px)); }
  .operation-grid { grid-template-columns: 1fr 1fr; }
}
