:root {
  --bg-1: #eef2fb;
  --bg-2: #f6f1fb;
  --panel: #ffffff;
  --border: #dde3ee;
  --border-strong: #c7cee0;
  --text: #1e2837;
  --muted: #6b7585;
  --brand: #5e8c3e;
  --brand-2: #7a9b4a;
  --brand-dark: #466a2c;
  --tint: #eef3e2;
  --danger: #e11d48;
  --ok: #4d7c2e;
  --sel: #5e8c3e;
  --shadow-sm: 0 1px 2px rgba(30,40,60,.06);
  --shadow-md: 0 6px 16px rgba(30,40,60,.09);
  --shadow-lg: 0 20px 44px rgba(50,60,30,.16);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Hiragino Sans",
    "Hiragino Kaku Gothic ProN", Meiryo, sans-serif;
  background:
    radial-gradient(1200px 600px at 12% -8%, #e6eed3 0%, transparent 55%),
    radial-gradient(1000px 560px at 100% 0%, #eaf0d8 0%, transparent 50%),
    linear-gradient(180deg, #e8eed9, #eef2e1);
  background-attachment: fixed;
  color: var(--text);
  font-size: 14px;
  line-height: 1.65;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
body::after {
  content: ""; position: fixed; inset: 0; pointer-events: none; z-index: 0;
  background: url("assets/car-bg.jpg") center center / cover no-repeat fixed;
  filter: grayscale(1);
  opacity: .12;
}
header, .toolbar, main, .modal-back { position: relative; z-index: 1; }

/* ===== Header ===== */
header.app-header {
  background: rgba(255,255,255,.92);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
  padding: 13px 22px;
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  position: sticky; top: 0; z-index: 40;
}
.brand { display: inline-flex; align-items: center; }
.brand-logo { height: 30px; display: block; }
.privacy-badge {
  font-size: 12px; color: #4d7c2e; background: #eef5df; border: 1px solid #cfe0a8;
  padding: 4px 11px; white-space: nowrap; font-weight: 600;
}
.app-header .spacer { flex: 1; }
.app-header .counter {
  font-size: 13px; color: var(--brand-dark); font-weight: 700;
  background: var(--tint); border: 1px solid #cdddae; padding: 4px 11px; white-space: nowrap;
}

/* ===== Toolbar ===== */
.toolbar {
  position: sticky; top: 57px; z-index: 30;
  background: rgba(255,255,255,.92); backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  padding: 11px 22px; display: flex; gap: 10px; flex-wrap: wrap; align-items: center;
}
.toolbar .group {
  display: flex; gap: 7px; align-items: center;
  padding: 4px 13px 4px 8px; border-right: 1px solid var(--border);
}
.toolbar .group:last-child { border-right: none; }
.toolbar .group.grow { flex: 1 1 220px; }
.toolbar .group-label { font-size: 11px; color: var(--muted); margin-right: 2px; font-weight: 700; }
.chk { font-size: 13px; display: inline-flex; align-items: center; gap: 6px; cursor: pointer; white-space: nowrap; }
.chk input { width: 16px; height: 16px; accent-color: var(--brand); }
.search {
  width: 100%; font: inherit; font-size: 13px; padding: 8px 12px;
  border: 1px solid var(--border-strong); background: #fff; color: var(--text);
}
.search:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 2px rgba(94,140,62,.18); }

/* ===== Buttons ===== */
button.btn {
  font: inherit; font-size: 13px; font-weight: 600;
  border: 1px solid var(--border-strong); background: #fff; color: var(--text);
  padding: 8px 13px; cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px;
  transition: background .12s, border-color .12s, color .12s, box-shadow .12s, transform .06s;
  white-space: nowrap;
}
button.btn:hover:not(:disabled) { background: var(--tint); border-color: var(--brand); color: var(--brand-dark); }
button.btn:active:not(:disabled) { transform: translateY(1px); }
button.btn:disabled { opacity: .45; cursor: not-allowed; }
button.btn.primary {
  background: var(--brand); border-color: var(--brand); color: #fff;
  box-shadow: 0 1px 3px rgba(94,140,62,.25);
}
button.btn.primary:hover:not(:disabled) { background: var(--brand-dark); border-color: var(--brand-dark); color: #fff; }
button.btn.ghost { border-color: transparent; background: transparent; color: var(--brand-dark); text-decoration: underline; }
button.btn.ghost:hover:not(:disabled) { background: transparent; color: var(--brand); }
button.btn.big {
  padding: 17px 40px; font-size: 16px; font-weight: 700; letter-spacing: .3px;
  transition: transform .22s cubic-bezier(.2,.7,.2,1), box-shadow .22s ease, background .18s ease;
}
button.btn.big.primary { box-shadow: 0 8px 24px rgba(94,140,62,.4); }
button.btn.big.primary:hover:not(:disabled) {
  transform: translateY(-3px); box-shadow: 0 16px 34px rgba(94,140,62,.5); background: var(--brand);
}
button.btn.danger { color: var(--danger); border-color: #f0c4ce; }
button.btn.danger:hover:not(:disabled) { background: #fff1f3; border-color: var(--danger); color: var(--danger); }

/* ===== Main ===== */
main { padding: 30px 22px 44px; flex: 1 1 auto; }

/* ===== Hero (empty state) ===== */
.hero { max-width: 920px; margin: 26px auto 0; display: flex; flex-direction: column; align-items: center; gap: 22px; }
.hero-card {
  width: 100%; background: transparent; border: 2px dashed rgba(94,140,62,.5);
  padding: 56px 28px 50px; text-align: center; transition: border-color .18s, background .18s;
}
.hero.drag .hero-card { border-color: var(--brand); background: rgba(94,140,62,.06); }
.hero-icon {
  width: 80px; height: 80px; margin: 0 auto 22px;
  display: flex; align-items: center; justify-content: center; color: var(--brand); background: var(--tint);
}
.hero h2 { font-size: 28px; margin: 0 0 12px; font-weight: 800; letter-spacing: .4px; color: var(--text); }
.hero-sub { color: #3f4654; margin: 0 0 26px; font-size: 15px; line-height: 1.7; }
.hero-sub strong { color: var(--brand); font-weight: 700; }
.picker-btn { margin-bottom: 6px; }
.newbtn { margin-left: 6px; }
.hero-privacy { color: var(--ok); font-size: 12.5px; margin: 20px 0 0; font-weight: 600; }

.steps { display: flex; align-items: stretch; gap: 10px; flex-wrap: wrap; justify-content: center; width: 100%; }
.step { flex: 1; min-width: 190px; background: #fff; border: 1px solid var(--border); padding: 18px 20px; display: flex; align-items: center; gap: 15px; }
.step .num { flex: none; width: 30px; height: 30px; background: var(--brand); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 14px; }
.step div { display: flex; flex-direction: column; line-height: 1.45; }
.step b { font-size: 14px; }
.step div span { color: var(--muted); font-size: 12px; }
.step-arrow { display: flex; align-items: center; color: #c0c5d8; font-size: 18px; font-weight: 700; }

.features { width: 100%; display: grid; grid-template-columns: repeat(auto-fit, minmax(205px, 1fr)); gap: 1px; background: var(--border); border: 1px solid var(--border); }
.feat { background: #fff; padding: 18px 20px; display: flex; align-items: center; gap: 15px; transition: background .12s; }
.feat:hover { background: #f7f8fc; }
.feat .ico { flex: none; width: 40px; height: 40px; background: var(--tint); color: var(--brand); display: flex; align-items: center; justify-content: center; font-size: 19px; }
.feat .txt { display: flex; flex-direction: column; gap: 2px; line-height: 1.4; }
.feat .txt b { font-size: 14px; font-weight: 700; }
.feat .txt small { color: var(--muted); font-size: 11.5px; }

/* ===== Grid / Sheet ===== */
.grid-wrap { max-width: 100%; margin: 0 auto; }
.filebar {
  display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap;
  padding: 4px 2px 12px;
}
.file-name { font-weight: 700; font-size: 15px; color: var(--text); }
.file-meta { font-size: 12px; color: var(--muted); }
.file-meta .tag { background: var(--tint); color: var(--brand-dark); padding: 2px 8px; font-weight: 600; margin-right: 6px; }

.table-scroll {
  overflow: auto; max-height: calc(100vh - 200px);
  border: 1px solid var(--border-strong); background: #fff; box-shadow: var(--shadow-md);
}
table.sheet { border-collapse: separate; border-spacing: 0; font-size: 13px; table-layout: fixed; }
table.sheet th, table.sheet td {
  border-right: 1px solid var(--border); border-bottom: 1px solid var(--border);
  padding: 0; vertical-align: top; position: relative;
}
/* corner + headers */
table.sheet thead th {
  position: sticky; top: 0; z-index: 6;
  background: #f0f3e6; color: var(--brand-dark); font-weight: 700;
  text-align: center; user-select: none; cursor: pointer;
  border-bottom: 2px solid var(--border-strong);
  white-space: nowrap;
}
table.sheet thead th .colhead {
  padding: 7px 10px; display: block; overflow: hidden; text-overflow: ellipsis;
}
table.sheet thead th.corner {
  left: 0; z-index: 8; width: 46px; min-width: 46px; max-width: 46px;
  cursor: default; background: #e6edd2;
}
table.sheet thead th.col-sel { background: var(--brand); color: #fff; }
/* row number cell */
table.sheet td.rownum, table.sheet th.rownum {
  position: sticky; left: 0; z-index: 5;
  width: 46px; min-width: 46px; max-width: 46px;
  background: #f0f3e6; color: var(--muted); text-align: center; font-size: 11px;
  user-select: none; cursor: pointer; padding: 4px 0; font-weight: 600;
}
table.sheet tr.row-sel td.rownum { background: var(--brand); color: #fff; }
table.sheet td.cell {
  min-width: 90px;
}
table.sheet td.cell .ed {
  padding: 6px 9px; min-height: 31px; outline: none; white-space: pre-wrap; word-break: break-word;
  cursor: text;
}
table.sheet td.cell .ed:focus { box-shadow: inset 0 0 0 2px var(--brand); background: #fbfbff; }
table.sheet td.cell.in-selcol { background: #f3f6e8; }
table.sheet tr.in-selrow td.cell { background: #f3f6e8; }
table.sheet td.cell.hit .ed { background: #fff4c2; }
table.sheet td.cell.hit-active .ed { background: #ffd84d; }
table.sheet tbody tr:nth-child(even) td.cell { background: #fafbfe; }
table.sheet tbody tr:nth-child(even) td.cell.in-selcol { background: #ebf1da; }
table.sheet thead th:hover:not(.corner) { background: #e9efd6; }

/* col resize handle */
.col-resize {
  position: absolute; top: 0; right: -3px; width: 7px; height: 100%;
  cursor: col-resize; z-index: 9;
}

/* ===== Modal ===== */
.modal-back {
  position: fixed; inset: 0; background: rgba(25,28,45,.5); backdrop-filter: blur(2px);
  display: flex; align-items: center; justify-content: center; z-index: 80; padding: 20px;
}
.modal {
  background: #fff; border: 1px solid var(--border); box-shadow: var(--shadow-lg);
  width: 100%; max-width: 560px; padding: 26px 28px 22px;
}
.modal h3 { margin: 0 0 18px; font-size: 19px; font-weight: 800; }
.field { margin-bottom: 20px; }
.field-label { display: block; font-size: 12px; font-weight: 700; color: var(--muted); margin-bottom: 9px; }
.radio-row { display: flex; flex-direction: column; gap: 8px; }
.radio { display: flex; align-items: flex-start; gap: 10px; cursor: pointer; padding: 10px 12px; border: 1px solid var(--border); transition: border-color .12s, background .12s; }
.radio:hover { border-color: var(--brand); background: var(--tint); }
.radio input { margin-top: 3px; width: 16px; height: 16px; accent-color: var(--brand); flex: none; }
.radio span { display: flex; flex-direction: column; line-height: 1.45; }
.radio b { font-size: 13.5px; }
.radio small { color: var(--muted); font-size: 11.5px; }
.radio.compact { flex: 1; align-items: center; }
.radio.compact span { flex-direction: row; }
.radio-row:has(.compact) { flex-direction: row; }

.zero-opt { display: flex; align-items: flex-start; gap: 10px; cursor: pointer; padding: 12px 14px; border: 1px solid #f0d48a; background: #fffbef; }
.zero-opt input { margin-top: 3px; width: 17px; height: 17px; accent-color: #d9920a; flex: none; }
.zero-opt span { display: flex; flex-direction: column; line-height: 1.5; }
.zero-opt b { font-size: 13.5px; }
.zero-opt small { color: #7a6a3a; font-size: 11.5px; }
.zero-opt code { background: #fff; border: 1px solid #e3d9b8; padding: 0 4px; font-size: 11px; }

.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 8px; }

/* ===== Toast ===== */
.toast {
  position: fixed; bottom: 26px; left: 50%; transform: translateX(-50%);
  background: #1e2837; color: #fff; padding: 12px 22px; font-size: 13px; font-weight: 600;
  box-shadow: var(--shadow-lg); z-index: 90; max-width: 90vw;
}
.toast.warn { background: #b45309; }

.hidden { display: none !important; }

@media (max-width: 640px) {
  .hero h2 { font-size: 22px; }
  .radio-row:has(.compact) { flex-direction: column; }
}
