:root {
  color-scheme: dark;
  --bg: #0e1116; --card: #171b22; --line: #262c36; --text: #e8ecf2; --muted: #8b95a5;
  --accent: #3ec7a6; --accent2: #4b8dff; --bad: #ff6b6b; --warn: #ffc857;
  --r: 14px;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text);
  font-family: -apple-system, "Pretendard", "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
  font-size: 17px; line-height: 1.5; -webkit-tap-highlight-color: transparent; }
button, input, select { font: inherit; color: inherit; }

.top { position: sticky; top: 0; z-index: 5; background: rgba(14,17,22,.95); backdrop-filter: blur(8px);
  display: flex; align-items: center; gap: 16px; padding: 10px 20px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 10px; }
.brand b { font-size: 20px; }
.brand small { color: var(--muted); }
.logo { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; font-weight: 900;
  background: linear-gradient(135deg, var(--accent), var(--accent2)); color: #06121a; }
.tabs { display: flex; gap: 6px; margin-left: auto; overflow-x: auto; }
.tabs button { background: none; border: 1px solid var(--line); border-radius: 999px; padding: 10px 18px;
  min-height: 48px; white-space: nowrap; cursor: pointer; }
.tabs button.on { background: var(--text); color: var(--bg); border-color: var(--text); font-weight: 700; }
.safe { margin: 0; padding: 6px 20px; font-size: 14px; color: var(--warn); background: #1d1a10; }

main { max-width: 1400px; margin: 0 auto; padding: 20px; }
.panel { display: none; } .panel.on { display: block; }
h2 { font-size: 21px; margin: 0 0 8px; }
.mt { margin-top: 28px; }
.muted { color: var(--muted); margin: 6px 0; } .small { font-size: 14px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; margin: 10px 0; }
.btn { background: var(--accent); color: #06121a; border: 0; border-radius: 10px; padding: 12px 20px;
  min-height: 48px; font-weight: 700; cursor: pointer; display: inline-flex; align-items: center; }
.btn.ghost { background: transparent; color: var(--text); border: 1px solid var(--line); }
.btn.danger { background: transparent; color: var(--bad); border: 1px solid var(--bad); }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 20px; min-width: 0; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.cols { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.badge { font-size: 13px; background: var(--line); color: var(--muted); padding: 2px 10px; border-radius: 999px; vertical-align: middle; }

.progress { height: 10px; background: var(--line); border-radius: 99px; overflow: hidden; margin: 8px 0; }
.progress span { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--accent), var(--accent2)); transition: width .3s; }

.group { margin-top: 18px; }
.group h3 { font-size: 16px; color: var(--muted); margin: 0 0 8px; }
.items { display: grid; grid-template-columns: repeat(auto-fill, minmax(400px, 1fr)); gap: 8px; }
.item { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; }
.item .line { display: flex; align-items: center; gap: 10px; }
.item .t { flex: 1; }
.item .no { color: var(--muted); font-size: 13px; min-width: 26px; }
.seg { display: flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; flex-shrink: 0; }
.seg button { background: none; border: 0; padding: 8px 12px; min-height: 44px; cursor: pointer; color: var(--muted); }
.seg button.ok.on { background: var(--accent); color: #06121a; font-weight: 700; }
.seg button.bad.on { background: var(--bad); color: #fff; font-weight: 700; }
.item.isbad { border-color: var(--bad); }
.item input.memo { width: 100%; margin-top: 8px; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; }

.todo h3 { font-size: 16px; margin: 0 0 8px; color: var(--accent); }
.todo label { display: flex; gap: 10px; align-items: flex-start; padding: 8px 0; border-bottom: 1px dashed var(--line); cursor: pointer; }
.todo input { width: 22px; height: 22px; margin-top: 2px; accent-color: var(--accent); flex-shrink: 0; }
.todo label.done span { color: var(--muted); text-decoration: line-through; }

.form { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; align-items: end; margin: 12px 0; }
.form label { display: flex; flex-direction: column; gap: 4px; font-size: 14px; color: var(--muted); }
.form input, .form select { background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 10px; min-height: 48px; color: var(--text); width: 100%; }
.chart svg { width: 100%; height: auto; display: block; }
.big { font-size: 20px; font-weight: 700; margin: 8px 0; }
.tip { background: #10241f; border-left: 3px solid var(--accent); padding: 10px 12px; border-radius: 8px; margin: 8px 0 0; font-size: 15px; }
.tip:empty { display: none; }
.sum { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 12px 0; }
.sum div { background: var(--bg); border-radius: 10px; padding: 12px; }
.sum b { display: block; font-size: 20px; }
.sum small { color: var(--muted); }
.list .r { display: flex; gap: 10px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 15px; }
.list .r span:first-child { color: var(--muted); min-width: 92px; }
.list .r .x { margin-left: auto; background: none; border: 0; color: var(--muted); font-size: 20px; min-width: 44px; min-height: 44px; cursor: pointer; }
.feat { margin: 8px 0 0; padding-left: 20px; } .feat li { margin: 6px 0; }

.appcat { margin: 18px 0 8px; font-size: 18px; }
.apps { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.app { display: block; text-decoration: none; color: var(--text); background: var(--card); border: 1px solid var(--line);
  border-radius: var(--r); padding: 20px; min-height: 100px; transition: border-color .2s; }
.app:hover, .app:focus { border-color: var(--accent); }
.app b { font-size: 19px; display: block; }
.app span { color: var(--muted); font-size: 15px; }

footer { text-align: center; color: var(--muted); font-size: 13px; padding: 30px 20px; }
#toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--text); color: var(--bg);
  padding: 12px 20px; border-radius: 999px; font-weight: 700; opacity: 0; pointer-events: none; transition: opacity .25s; }
#toast.on { opacity: 1; }

@media (max-width: 900px) {
  .grid2 { grid-template-columns: 1fr; }
  .cols { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 560px) {
  body { font-size: 16px; }
  .top { padding: 8px 12px; } main { padding: 12px; }
  .brand small { display: none; }
  .tabs { margin-left: 0; width: 100%; display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; }
  .tabs button { padding: 6px 2px; font-size: 14px; white-space: nowrap; line-height: 1.25; }
  .tabs button i { display: none; }
  .cols { grid-template-columns: 1fr; }
  .items { grid-template-columns: 1fr; }
  .sum { grid-template-columns: 1fr 1fr; }
}

.tesla { margin-bottom: 20px; border-color: #2c4a52; }
.tesla .tline { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; justify-content: space-between; }
.tesla .row { margin: 0; }
.tesla a { color: var(--accent); }
.badge.on { background: #10302a; color: var(--accent); }
.src { font-size: 12px; color: var(--accent); border: 1px solid #2c4a52; border-radius: 6px; padding: 0 6px; }
select.car { background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 10px; min-height: 48px; color: var(--text); }

.hero { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin: 12px 0; }
.hero div { background: var(--bg); border-radius: 12px; padding: 14px 16px; }
.hero small { color: var(--muted); display: block; }
.hero b { font-size: 30px; display: block; line-height: 1.2; }
.hero div:first-child b { color: var(--accent); }
.hero span { color: var(--muted); font-size: 13px; }
.fold summary { cursor: pointer; min-height: 44px; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; font-weight: 700; list-style: none; }
.fold summary::-webkit-details-marker { display: none; }
.fold summary::before { content: '▸'; color: var(--muted); }
.fold[open] summary::before { content: '▾'; }
details.card.fold summary { font-size: 19px; }
@media (max-width: 900px) { .hero { grid-template-columns: 1fr 1fr; } .hero b { font-size: 24px; } }
@media (max-width: 560px) { details.card.fold summary .muted { flex-basis: 100%; padding-left: 18px; } }
.tesla a.btn { color: #06121a; text-decoration: none; }
/* iOS 사파리 날짜 칸이 고유 최소폭으로 옆 칸을 침범하지 않게 */
.form label { min-width: 0; }
.form input, .form select { min-width: 0; max-width: 100%; }
.form input[type=date] { -webkit-appearance: none; appearance: none; display: block; text-align: left; }
@media (max-width: 560px) {
  .form { grid-template-columns: 1fr 1fr; }
  .form label:has(input[type=date]) { grid-column: 1 / -1; }
}
.tabs button i { font-style: normal; margin-right: 6px; }
/* 기록 수정·삭제 */
.list .r .ic { background: none; border: 0; min-width: 44px; min-height: 44px; font-size: 18px; cursor: pointer; padding: 0; }
.list .r .acts { margin-left: auto; display: flex; align-items: center; gap: 2px; flex-shrink: 0; }
.list .r.edit { display: grid; grid-template-columns: 1.4fr 1fr 1fr auto auto; gap: 6px; }
.list .r.edit input { background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 8px; min-height: 44px; min-width: 0; width: 100%; color: var(--text); }
.btn.sm { padding: 8px 14px; min-height: 44px; }
#batRec { margin-top: 10px; }
@media (max-width: 560px) {
  .list .r.edit { grid-template-columns: 1fr 1fr; }
  .list .r.edit input[type=date] { grid-column: 1 / -1; }
}
.list .r .src { white-space: nowrap; }
@media (max-width: 560px) {
  .list .r:not(.edit) { flex-wrap: wrap; row-gap: 0; }
  .list .r:not(.edit) span:first-child { flex-basis: 100%; min-width: 0; font-size: 13px; }
}
.list .r .acts .src { color: var(--accent); min-width: 0; }
/* 넥시스 로그인 */
.acct { margin-bottom: 20px; }
.acct .tline { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; justify-content: space-between; }
.acct .row { margin: 0; }
.btn.kakao { background: #FEE500; color: #191600; }
.btn.google { background: #fff; color: #1f1f1f; }
.aform { max-width: 460px; display: grid; gap: 10px; margin-top: 10px; }
.aform[hidden] { display: none; }
.aform [hidden] { display: none !important; }
.aform label { display: flex; flex-direction: column; gap: 4px; font-size: 14px; color: var(--muted); }
.aform input { background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 10px; min-height: 48px; color: var(--text); }
.aform .row { align-items: center; margin: 0; }
.aform a { min-height: 44px; display: inline-flex; align-items: center; }
.atabs { display: flex; gap: 6px; }
.atab { background: none; border: 1px solid var(--line); border-radius: 999px; padding: 8px 18px; min-height: 44px; cursor: pointer; }
.atab.on { background: var(--text); color: var(--bg); font-weight: 700; }
.aerr { margin: 0; color: var(--bad); font-size: 14px; min-height: 1em; }
.aerr.ok { color: var(--accent); }
.list .r.edit select { background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 8px; min-height: 44px; min-width: 0; width: 100%; color: var(--text); }
.list .r.edit.chg { grid-template-columns: 1.3fr 1.6fr 0.8fr 1fr auto auto; }
@media (max-width: 560px) {
  .list .r.edit.chg { grid-template-columns: 1fr 1fr; }
  .list .r.edit.chg select { grid-column: 1 / -1; }
}
