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

:root {
  --bg: #0f0f12; --bg-card: #1a1a20; --bg-input: #141418;
  --text: #e8e8ed; --text2: #8e8e96; --dim: #5e5e66;
  --border: #2a2a32; --accent: #5e5eff;
  --green: #34c759; --red: #ff453a; --orange: #ff9f0a;
  --radius: 12px; --radius-sm: 8px;
}
[data-theme="light"] {
  --bg: #f2f2f7; --bg-card: #ffffff; --bg-input: #e8e8ed;
  --text: #111114; --text2: #6c6c74; --dim: #a0a0a8; --border: #dcdce2;
}

html, body { background: var(--bg); color: var(--text); font: 15px/1.4 -apple-system, "Segoe UI", Roboto, sans-serif; }
#app { min-height: 100vh; padding-bottom: 80px; }

#topBar { position: sticky; top: 0; z-index: 5; display: flex; justify-content: space-between; align-items: center;
  padding: 12px 16px; background: var(--bg); border-bottom: 1px solid var(--border); }
#topBar .title { font-weight: 600; font-size: 17px; }
#topBar .sub { font-size: 12px; color: var(--text2); }
#topBar .theme-btn { background: none; border: 1px solid var(--border); color: var(--text); border-radius: 8px; padding: 4px 10px; }

#content { padding: 12px 12px 0; }

#tabBar { position: fixed; bottom: 0; left: 0; right: 0; display: flex; background: var(--bg);
  border-top: 1px solid var(--border); padding-bottom: env(safe-area-inset-bottom); z-index: 5; }
.tab-btn { flex: 1; background: none; border: 0; color: var(--dim); padding: 8px 0 10px; font-size: 11px; display: flex; flex-direction: column; align-items: center; gap: 2px; }
.tab-btn .ico { font-size: 20px; line-height: 1; }
.tab-btn.active { color: var(--text); }

.section-title { font-size: 13px; text-transform: uppercase; color: var(--text2); margin: 16px 4px 8px; letter-spacing: .04em; }
.section-title:first-child { margin-top: 4px; }

.card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; margin-bottom: 10px; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.card-title { font-weight: 600; }
.card-sub { color: var(--text2); font-size: 13px; margin-top: 2px; }
.card-actions { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.card.click { cursor: pointer; }

.row { display: flex; justify-content: space-between; align-items: center; padding: 6px 0; gap: 8px; }
.row + .row { border-top: 1px solid var(--border); }
.row .lbl { color: var(--text2); font-size: 14px; }

.btn { border: 0; border-radius: var(--radius-sm); padding: 9px 14px; font-size: 14px; font-weight: 500; background: var(--bg-input); color: var(--text); cursor: pointer; }
.btn:active { opacity: .7; }
.btn:disabled { opacity: .4; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-danger { background: transparent; color: var(--red); border: 1px solid var(--red); }
.btn-outline { background: transparent; border: 1px solid var(--border); }
.btn-block { width: 100%; }
.btn-sm { padding: 5px 10px; font-size: 13px; }

.form-group { margin-bottom: 12px; }
.form-group > label { display: block; font-size: 13px; color: var(--text2); margin-bottom: 4px; }
.form-input, .form-select { width: 100%; background: var(--bg-input); color: var(--text); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 9px 10px; font-size: 15px; outline: none; font-family: inherit; }
.form-input:focus, .form-select:focus { border-color: var(--accent); }
.form-input::placeholder { color: var(--dim); }
.hint { font-size: 12px; color: var(--dim); margin-top: 4px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.seg { display: flex; background: var(--bg-input); border-radius: var(--radius-sm); padding: 2px; }
.seg button { flex: 1; border: 0; background: none; color: var(--text2); padding: 7px 4px; border-radius: 6px; font-size: 14px; }
.seg button.on { background: var(--accent); color: #fff; }

.toggle { position: relative; display: inline-block; width: 44px; height: 26px; flex-shrink: 0; }
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle span { position: absolute; inset: 0; background: var(--border); border-radius: 26px; transition: .2s; }
.toggle span::before { content: ""; position: absolute; width: 20px; height: 20px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .2s; }
.toggle input:checked + span { background: var(--green); }
.toggle input:checked + span::before { transform: translateX(18px); }

.badge { display: inline-block; font-size: 11px; padding: 2px 7px; border-radius: 10px; font-weight: 600; }
.badge-green { background: rgba(52,199,89,.15); color: var(--green); }
.badge-red { background: rgba(255,69,58,.15); color: var(--red); }
.badge-orange { background: rgba(255,159,10,.15); color: var(--orange); }
.badge-gray { background: var(--bg-input); color: var(--text2); }

.ladder { width: 100%; border-collapse: collapse; font-size: 14px; }
.ladder th { text-align: left; color: var(--text2); font-weight: 400; font-size: 12px; padding: 4px; }
.ladder td { padding: 3px 4px; }
.ladder .del { background: none; border: 0; color: var(--red); font-size: 18px; }
.sum { font-size: 12px; margin-top: 4px; }
.sum.bad { color: var(--red); } .sum.ok { color: var(--green); }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { border: 1px solid var(--border); border-radius: 14px; padding: 5px 11px; font-size: 13px; background: none; color: var(--text2); }
.chip.on { border-color: var(--accent); color: var(--text); background: rgba(94,94,255,.15); }

.empty { text-align: center; color: var(--text2); padding: 30px 10px; }
.error-text { color: var(--red); font-size: 13px; margin-top: 6px; white-space: pre-wrap; }
.ok-text { color: var(--green); font-size: 13px; margin-top: 6px; }

#loading { display: flex; flex-direction: column; align-items: center; justify-content: center; height: 80vh; color: var(--text2); gap: 12px; }
.spinner { width: 32px; height: 32px; border: 3px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.6); z-index: 20; display: flex; align-items: flex-end; }
.modal { background: var(--bg); width: 100%; max-height: 92vh; overflow-y: auto; border-radius: 16px 16px 0 0; padding: 16px 14px 24px; }
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.modal-header h2 { font-size: 18px; }
.modal-close { background: none; border: 0; color: var(--text2); font-size: 24px; }
.modal-footer { display: flex; gap: 8px; margin-top: 14px; }
.modal-footer .btn { flex: 1; }

#toast { position: fixed; left: 50%; bottom: 90px; transform: translateX(-50%); background: var(--bg-card); border: 1px solid var(--border);
  padding: 9px 16px; border-radius: 20px; font-size: 14px; z-index: 30; display: none; max-width: 90vw; }
