:root {
  --bg: #f4f6f3;
  --card: #ffffff;
  --text: #1c2420;
  --muted: #6b7670;
  --line: #e2e7e3;
  --accent: #1f6f4a;
  --accent-soft: #e3f1e9;
  --danger: #b4392f;
  --warn-bg: #fff4d6;
  --err-bg: #fde6e3;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121614;
    --card: #1b211e;
    --text: #e6ece8;
    --muted: #93a099;
    --line: #2c3530;
    --accent: #4cc38a;
    --accent-soft: #1f3a2c;
    --danger: #e66a5f;
    --warn-bg: #3b3218;
    --err-bg: #3d1f1c;
  }
}
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
}
a { color: var(--accent); text-decoration: none; }
main { max-width: 900px; margin: 0 auto; padding: 16px; }
h1 { font-size: 22px; margin: 8px 0 6px; }
h2 { font-size: 16px; margin: 0 0 12px; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.desc { padding-left: 2.6em; }
main > p { word-break: keep-all; }
h1 .basis { font-size: 13px; font-weight: 400; color: var(--muted); }
.whs table { margin: 4px 0; }
.whs td, .whs th { text-align: center; }
.whs .formula { font-size: 15px; font-weight: 600; background: var(--accent-soft); padding: 10px 12px; border-radius: 8px; }
.whs ul { padding-left: 18px; margin: 6px 0; }
.whs li { margin: 4px 0; }
.desc span { margin-left: -2.6em; display: inline-block; width: 2.6em; }
.nowrap { white-space: nowrap; }

.top {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; background: var(--accent); color: #fff;
}
.top a { color: #fff; }
.brand { font-weight: 700; font-size: 17px; }
.top nav a { margin-left: 14px; opacity: .9; font-size: 14px; }

.card {
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  padding: 16px; margin: 14px 0;
}
.empty { text-align: center; color: var(--muted); }
.flash { padding: 10px 14px; border-radius: 8px; margin: 8px 0; background: var(--accent-soft); }
.flash.error { background: var(--err-bg); }
.flash.warn { background: var(--warn-bg); }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 9px 8px; text-align: right; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { font-size: 12.5px; color: var(--muted); font-weight: 600; }
.l { text-align: left; }
.br-sm { display: none; }
tbody tr:last-child td { border-bottom: 0; }
table.log td { white-space: normal; font-size: 13.5px; }
.sum .name { font-weight: 600; font-size: 15.5px; }
table.sum th, table.sum td { text-align: center; }
table.sum th:first-child, table.sum td:first-child { text-align: left; }
.sum .hcp b { font-size: 18px; color: var(--accent); }
.sum td.two b { display: block; font-weight: 500; }
.sum td.two.pick b { font-weight: 700; }
.sum td.two small { display: block; font-size: 11.5px; color: var(--muted); }
.sum .hcp small, .stat small { display: block; font-size: 11.5px; color: var(--muted); }
td.pick { background: var(--accent-soft); font-weight: 700; color: var(--accent); }
tr.off td { opacity: .55; }
tr.used td { background: var(--accent-soft); }
tr.used td:first-child { box-shadow: inset 3px 0 0 var(--accent); }
tr.editing td { background: var(--accent-soft); }

.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 12px 0; }
.stat {
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  padding: 10px; text-align: center;
}
.stat span { display: block; font-size: 12px; color: var(--muted); }
.stat b { font-size: 20px; }
.stat.main b { color: var(--accent); font-size: 26px; }
.stat.pick { border-color: var(--accent); background: var(--accent-soft); }

.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-end; }
.row.tight { flex-wrap: nowrap; }
.row label { display: flex; flex-direction: column; font-size: 12.5px; color: var(--muted); gap: 4px; flex: 1 1 140px; }
input, select, button, .btn {
  font: inherit; padding: 9px 12px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--bg); color: var(--text); min-height: 40px;
}
input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.row.tight input { min-width: 0; width: 120px; }
.w-s { width: 90px; }
button, .btn {
  background: var(--accent); color: #fff; border-color: var(--accent);
  cursor: pointer; font-weight: 600; display: inline-flex; align-items: center; justify-content: center;
}
.btn.ghost { background: transparent; color: var(--accent); }
.btn.danger { background: transparent; color: var(--danger); border-color: var(--danger); }
.btn.sm { padding: 4px 10px; min-height: 30px; font-size: 13px; }
.acts { display: flex; gap: 6px; justify-content: flex-end; }
.acts form { margin: 0; }
.acts.order { justify-content: flex-start; gap: 4px; }
button:disabled { opacity: .3; cursor: default; }
.entry { border: 2px solid var(--accent); }
.entry button { flex: 0 0 auto; }
.back { display: inline-block; margin-top: 4px; font-size: 14px; }
.tag { font-size: 12px; padding: 2px 8px; border-radius: 99px; background: var(--accent-soft); color: var(--accent); white-space: nowrap; }
.tag.t-삭제, .tag.t-수정 { background: var(--err-bg); color: var(--danger); }
.login { max-width: 360px; margin: 40px auto; display: flex; flex-direction: column; gap: 10px; }

@media (max-width: 600px) {
  .hide-sm { display: none; }
  .yr { display: none; }
  table.hist .acts { gap: 4px; }
  table.hist .btn.sm { padding: 3px 7px; font-size: 12.5px; }
  .br-sm { display: inline; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  th, td { padding: 8px 4px; }
  main { padding: 12px 10px; }
  .card { padding: 12px 10px; }
  table.sum { font-size: 13.5px; table-layout: fixed; }
  .card.table-wrap { padding: 6px 6px; }
  /* 이름 칸은 한글 3글자 폭으로 고정, 나머지 칸이 남은 폭을 나눠 씀 */
  table.sum th.cnt, table.sum td.cnt { width: 48px; padding-left: 2px; padding-right: 2px; }
  table.sum th.cnt { white-space: nowrap; font-size: 12px; }
  table.sum th:first-child, table.sum td:first-child { width: 62px; white-space: nowrap; padding-left: 6px; padding-right: 2px; overflow: hidden; text-overflow: clip; }
  table.sum th { font-size: 11.5px; white-space: normal; line-height: 1.25; word-break: keep-all; }
  .sum .name { font-size: 14px; }
  .sum .hcp b { font-size: 16px; }
  .top { flex-wrap: wrap; gap: 4px 0; }
  .top nav a { margin-left: 12px; }
  .entry .row label { flex: 1 1 100%; }
  .entry button { width: 100%; }
}
