:root {
  --bg: #0d1117;
  --surface: #161b22;
  --surface-alt: #1f2630;
  --border: #30363d;
  --text: #f0f6fc;
  --muted: #9aa4b2;
  --accent: #f7931a;
  --accent-dark: #c97209;
  --ok: #2ea043;
  --warn: #d29922;
  --danger: #f85149;
  --radius: 14px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  line-height: 1.45;
}

body {
  padding-bottom: calc(84px + env(safe-area-inset-bottom));
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 1.05rem;
  font-weight: 700;
}

h2 {
  font-size: 1rem;
  font-weight: 700;
}

code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.85em;
  background: var(--surface-alt);
  padding: 0.1rem 0.35rem;
  border-radius: 6px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  padding: max(0.85rem, env(safe-area-inset-top)) 1rem 0.85rem;
  background: rgba(13, 17, 23, 0.94);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.brand-badge {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: var(--accent);
  color: var(--bg);
  font-weight: 800;
  font-size: 1.25rem;
}

.subtitle {
  font-size: 0.75rem;
  color: var(--muted);
}

.price-pill {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.35rem 0.55rem;
}

.pill-label {
  display: block;
  font-size: 0.68rem;
  color: var(--muted);
}

.container {
  max-width: 520px;
  margin: 0 auto;
  padding: 1rem;
}

.panel {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.panel[hidden] {
  display: none;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
}

.stack-gap {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
}

.card-label {
  display: block;
  font-size: 0.75rem;
  color: var(--muted);
  margin-bottom: 0.25rem;
}

.card-value {
  display: block;
  font-size: 1.15rem;
  font-weight: 700;
  word-break: break-word;
}

.card-sub {
  display: block;
  font-size: 0.78rem;
  color: var(--muted);
  margin-top: 0.2rem;
}

.accent {
  color: var(--accent);
}

.positive {
  color: #3fb950;
}

.negative {
  color: var(--danger);
}

.muted {
  color: var(--muted);
  font-size: 0.875rem;
}

.small-text {
  font-size: 0.8rem;
}

.row-between {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
}

.row-actions {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.badge {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
}

.badge.ok {
  border-color: var(--ok);
  color: #3fb950;
}

.badge.warn {
  border-color: var(--warn);
  color: #e3b341;
}

.badge.danger {
  border-color: var(--danger);
  color: var(--danger);
}

.progress-track {
  width: 100%;
  height: 10px;
  background: var(--surface-alt);
  border-radius: 999px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--accent);
  transition: width 200ms ease;
}

.stack-form {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  margin-top: 0.75rem;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
}

.inline-form {
  display: flex;
  align-items: flex-end;
  gap: 0.65rem;
}

.inline-form .field {
  flex: 1;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text);
}

.hint {
  font-size: 0.78rem;
  color: var(--muted);
}

input[type="text"],
input[type="date"],
select {
  width: 100%;
  font: inherit;
  font-size: max(1rem, 1em);
  min-height: 48px;
  padding: 0.65rem 0.75rem;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
}

input:focus-visible,
select:focus-visible,
button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

input:user-invalid {
  border-color: var(--danger);
}

.radio-group {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.7rem 0.8rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.radio-group legend {
  font-size: 0.82rem;
  font-weight: 600;
  padding: 0 0.3rem;
}

.radio-option {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  min-height: 40px;
  font-weight: 400;
}

.radio-option input {
  width: 20px;
  height: 20px;
  accent-color: var(--accent);
}

button,
.file-btn {
  font: inherit;
  font-size: 0.92rem;
  font-weight: 600;
  min-height: 48px;
  padding: 0.65rem 1rem;
  border-radius: 10px;
  border: 1px solid transparent;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.btn-primary {
  background: var(--accent);
  color: #0d1117;
}

.btn-primary:active {
  background: var(--accent-dark);
}

.btn-secondary {
  background: var(--surface-alt);
  color: var(--text);
  border-color: var(--border);
}

.btn-ghost {
  background: transparent;
  color: var(--accent);
  border-color: var(--border);
  min-height: 40px;
  padding: 0.35rem 0.7rem;
}

.btn-danger-sm {
  background: transparent;
  color: var(--danger);
  border: 1px solid rgba(248, 81, 73, 0.4);
  min-height: 36px;
  padding: 0.25rem 0.6rem;
  font-size: 0.8rem;
}

.btn-ok-sm {
  background: rgba(46, 160, 67, 0.15);
  color: #3fb950;
  border: 1px solid rgba(46, 160, 67, 0.45);
  min-height: 36px;
  padding: 0.25rem 0.6rem;
  font-size: 0.8rem;
}

.planner-result {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.85rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
}

.planner-result strong {
  font-size: 1.15rem;
}

.item-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.list-item {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.guide-steps {
  margin: 0.65rem 0;
  padding-left: 1.2rem;
  color: var(--muted);
  font-size: 0.88rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.security-note {
  background: rgba(247, 147, 26, 0.1);
  border: 1px solid rgba(247, 147, 26, 0.35);
  color: #ffd089;
  padding: 0.65rem 0.75rem;
  border-radius: 10px;
  font-size: 0.82rem;
}

.status-banner {
  max-width: 520px;
  margin: 0.75rem auto 0;
  padding: 0.75rem 1rem;
  border-radius: 10px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  font-size: 0.88rem;
}

.status-banner.error {
  border-color: var(--danger);
  color: #ffb3ad;
}

.status-banner.ok {
  border-color: var(--ok);
  color: #9be9a8;
}

.bottom-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.25rem;
  padding: 0.45rem 0.75rem calc(0.45rem + env(safe-area-inset-bottom));
  background: rgba(13, 17, 23, 0.96);
  backdrop-filter: blur(8px);
  border-top: 1px solid var(--border);
}

.nav-btn {
  background: transparent;
  color: var(--muted);
  min-height: 48px;
  border-radius: 10px;
  font-size: 0.88rem;
}

.nav-btn.active {
  background: var(--surface-alt);
  color: var(--accent);
}

.visually-hidden {
  position: absolute;
  clip-path: inset(50%);
  overflow: hidden;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  border: 0;
  white-space: nowrap;
}

@media (max-width: 400px) {
  .form-grid {
    grid-template-columns: 1fr;
  }
}
