:root {
  --bg: #0d1117;
  --card: #161b22;
  --card-2: #1c2129;
  --line: #2a313c;
  --text: #e6edf3;
  --muted: #8b949e;
  --accent: #4f9cf9;
  --up: #f85149;
  --down: #3fb950;
  --warn: #d29922;
  --radius: 14px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  overflow-x: hidden;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 15px;
  padding-bottom: 40px;
}

header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(13, 17, 23, 0.92);
  backdrop-filter: blur(12px);
  padding: 14px 16px 10px;
  border-bottom: 1px solid var(--line);
}

header h1 { margin: 0; font-size: 18px; font-weight: 600; }
header .sub { color: var(--muted); font-size: 12px; margin-top: 2px; }

main { padding: 12px; max-width: 760px; margin: 0 auto; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 12px;
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.card-head h2 { margin: 0; font-size: 15px; font-weight: 600; }

label { display: block; color: var(--muted); font-size: 12px; margin-bottom: 6px; }

input, select, button {
  font-family: inherit;
  font-size: 15px;
  color: var(--text);
  background: var(--card-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  min-height: 44px;
  outline: none;
  width: 100%;
}

input:focus, select:focus { border-color: var(--accent); }

button { cursor: pointer; width: auto; }

button.mini {
  padding: 6px 12px;
  min-height: 34px;
  font-size: 13px;
  background: transparent;
  border-color: var(--accent);
  color: var(--accent);
}

button.primary {
  width: 100%;
  padding: 15px;
  background: var(--accent);
  border: none;
  color: #06121f;
  font-weight: 600;
  font-size: 16px;
  border-radius: var(--radius);
  margin: 6px 0 14px;
}

button.primary:active { opacity: 0.85; }

.row {
  display: grid;
  gap: 6px;
  margin-bottom: 8px;
  align-items: center;
}

/* grid 子项默认 min-width:auto，会被输入框内容撑破，必须归零 */
.row > * { min-width: 0; }

.row.fut { grid-template-columns: 1.3fr 0.7fr 0.7fr 1fr 32px; }
.row.opt { grid-template-columns: 1.2fr 0.9fr 0.7fr 0.9fr 0.8fr 0.9fr 0.8fr 32px; }

.row .del {
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 20px;
  padding: 0;
  min-height: 44px;
}

.row .del:active { color: var(--up); }

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }

details summary {
  cursor: pointer;
  color: var(--muted);
  font-size: 14px;
  padding: 4px 0;
  list-style: none;
}
details summary::-webkit-details-marker { display: none; }
details[open] summary { margin-bottom: 10px; }

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.kpi {
  background: var(--card-2);
  border-radius: 10px;
  padding: 10px 12px;
}

.kpi .k { color: var(--muted); font-size: 11px; }
.kpi .v { font-size: 17px; font-weight: 600; margin-top: 3px; font-variant-numeric: tabular-nums; }

.num { font-variant-numeric: tabular-nums; }
.up { color: var(--up); }
.down { color: var(--down); }
.warn { color: var(--warn); }

.bar {
  height: 8px;
  background: var(--card-2);
  border-radius: 4px;
  overflow: hidden;
  margin: 10px 0 6px;
}
.bar > i {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--up));
  border-radius: 4px;
  transition: width 0.3s;
}

table { width: 100%; border-collapse: collapse; font-size: 13px; table-layout: fixed; }
th, td {
  padding: 7px 4px;
  text-align: right;
  border-bottom: 1px solid var(--line);
  min-width: 0;
}
th { color: var(--muted); font-weight: 500; font-size: 11px; }
th:first-child, td:first-child { text-align: left; width: 30%; }
td:first-child { overflow-wrap: anywhere; }
th:not(:first-child), td:not(:first-child) { font-size: 12px; }
tr:last-child td { border-bottom: none; }

.tips { list-style: none; padding: 0; margin: 8px 0 0; }
.tips li {
  font-size: 13px;
  color: var(--warn);
  padding: 7px 10px;
  background: rgba(210, 153, 34, 0.1);
  border-left: 3px solid var(--warn);
  border-radius: 4px;
  margin-bottom: 6px;
}

.plan-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 9px 10px;
  background: var(--card-2);
  border-radius: 8px;
  margin-bottom: 6px;
  font-size: 13px;
}

.badge {
  display: inline-block;
  font-size: 11px;
  padding: 2px 7px;
  border-radius: 5px;
  background: rgba(79, 156, 249, 0.15);
  color: var(--accent);
  margin-left: 6px;
}

.section-title {
  font-size: 14px;
  font-weight: 600;
  margin: 16px 0 8px;
  padding-left: 8px;
  border-left: 3px solid var(--accent);
}

.empty { color: var(--muted); font-size: 13px; text-align: center; padding: 14px 0; }

.entry {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  margin-bottom: 12px;
  background: rgba(79, 156, 249, 0.12);
  border: 1px solid rgba(79, 156, 249, 0.35);
  border-radius: var(--radius);
  color: var(--accent);
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
}
.entry:active { opacity: 0.8; }

@media (max-width: 480px) {
  main { padding: 10px; }
  .card { padding: 12px; }
  .row.fut { grid-template-columns: 1.2fr 0.8fr 0.8fr; }
  .row.opt { grid-template-columns: 1fr 1fr; }
  .row .del { justify-self: end; }
  .grid3 { grid-template-columns: 1fr 1fr; }
  table { font-size: 12px; }
  th, td { padding: 6px 3px; }
  th:not(:first-child), td:not(:first-child) { font-size: 11px; }
}
