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

/* ===== Login Screen ===== */
#login-screen {
  position: fixed;
  inset: 0;
  background: #080808;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  background-image:
    repeating-linear-gradient(0deg, transparent, transparent 39px, rgba(255,255,255,0.015) 39px, rgba(255,255,255,0.015) 40px),
    repeating-linear-gradient(90deg, transparent, transparent 39px, rgba(255,255,255,0.015) 39px, rgba(255,255,255,0.015) 40px);
}

#login-screen.hidden { display: none; }

/* ===== Identity Screen ===== */
#identity-screen {
  position: fixed;
  inset: 0;
  background: #080808;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9998;
  background-image:
    repeating-linear-gradient(0deg, transparent, transparent 39px, rgba(255,255,255,0.015) 39px, rgba(255,255,255,0.015) 40px),
    repeating-linear-gradient(90deg, transparent, transparent 39px, rgba(255,255,255,0.015) 39px, rgba(255,255,255,0.015) 40px);
}

#identity-screen.hidden { display: none; }

.identity-box {
  width: 460px;
  background: #111;
  border: 1px solid #222;
  border-top: 2px solid #3b82f6;
  border-radius: 6px;
  padding: 44px 40px 40px;
  box-shadow: 0 32px 80px rgba(0,0,0,0.9);
}

.identity-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 8px;
}

.identity-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 20px 14px;
  background: #181818;
  border: 1px solid #2a2a2a;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.15s;
  font-family: 'Courier New', monospace;
  color: #aaa;
  text-align: center;
}

.identity-btn:hover {
  border-color: #3b82f6;
  background: rgba(59,130,246,0.08);
  color: #fff;
  box-shadow: 0 0 0 1px rgba(59,130,246,0.2);
}

.id-avatar {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid #2a2a2a;
  display: block;
}

.id-avatar-placeholder {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: #222;
  border: 2px dashed #333;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
}

.id-name {
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

/* ===== History ===== */
.history-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.history-item {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-left: 3px solid #2a2a2a;
  border-radius: 4px;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  transition: background 0.12s;
}

.history-item:hover { background: #1f1f1f; }

.history-meta {
  display: flex;
  align-items: center;
  gap: 10px;
}

.history-action {
  font-size: 0.62rem;
  font-weight: 800;
  font-family: var(--mono);
  letter-spacing: 0.15em;
  text-transform: uppercase;
}

.history-type {
  font-size: 0.62rem;
  font-family: var(--mono);
  color: var(--text-muted);
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.history-detail {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1.4;
}

.history-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 4px;
}

.history-user {
  font-size: 0.7rem;
  font-family: var(--mono);
  color: var(--accent);
}

.history-date {
  font-size: 0.65rem;
  font-family: var(--mono);
  color: #333;
}

.login-box {
  width: 360px;
  background: #111;
  border: 1px solid #222;
  border-top: 2px solid #3b82f6;
  border-radius: 6px;
  padding: 44px 40px 40px;
  box-shadow: 0 32px 80px rgba(0,0,0,0.9);
}

.login-logo {
  font-size: 2.2rem;
  text-align: center;
  margin-bottom: 16px;
  filter: drop-shadow(0 0 12px #3b82f6);
}

.login-title {
  text-align: center;
  font-size: 0.85rem;
  font-weight: 900;
  letter-spacing: 0.2em;
  font-family: 'Courier New', monospace;
  color: #fff;
  margin-bottom: 4px;
}

.login-sub {
  text-align: center;
  font-size: 0.6rem;
  letter-spacing: 0.15em;
  font-family: 'Courier New', monospace;
  color: #333;
  margin-bottom: 36px;
}

.login-field {
  margin-bottom: 18px;
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.login-field label {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.15em;
  font-family: 'Courier New', monospace;
  color: #555;
  text-transform: uppercase;
}

.login-field input {
  background: #181818;
  border: 1px solid #262626;
  border-radius: 3px;
  padding: 11px 14px;
  font-size: 0.92rem;
  color: #e0e0e0;
  font-family: inherit;
  transition: border-color 0.15s, box-shadow 0.15s;
  letter-spacing: 0.04em;
}

.login-field input:focus {
  outline: none;
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59,130,246,0.12);
}

.login-field input::placeholder { color: #2a2a2a; }

.login-error {
  font-size: 0.75rem;
  color: #ef4444;
  font-family: 'Courier New', monospace;
  text-align: center;
  margin-bottom: 14px;
  padding: 8px;
  background: rgba(239,68,68,0.08);
  border: 1px solid rgba(239,68,68,0.2);
  border-radius: 3px;
  letter-spacing: 0.05em;
}

.login-btn {
  width: 100%;
  padding: 12px;
  background: #3b82f6;
  color: #fff;
  border: none;
  border-radius: 3px;
  font-size: 0.8rem;
  font-weight: 900;
  letter-spacing: 0.2em;
  font-family: 'Courier New', monospace;
  cursor: pointer;
  transition: background 0.15s, box-shadow 0.15s;
  margin-top: 6px;
}

.login-btn:hover {
  background: #60a5fa;
  box-shadow: 0 0 20px rgba(59,130,246,0.4);
}

:root {
  --bg: #0d0d0d;
  --bg2: #151515;
  --bg3: #1c1c1c;
  --sidebar-bg: #0a0a0a;
  --card-bg: #1a1a1a;
  --border: #242424;
  --accent: #3b82f6;
  --accent-dim: #1d4ed8;
  --danger: #ef4444;
  --success: #22c55e;
  --warning: #f59e0b;
  --text: #e0e0e0;
  --text-muted: #555;
  --text-dim: #888;
  --mono: 'Courier New', Consolas, monospace;
  --shadow: 0 4px 20px rgba(0,0,0,0.6);
  --brightness: 1;
}

html {
  filter: brightness(var(--brightness));
}

body.light {
  --bg: #f4f4f4;
  --bg2: #ebebeb;
  --bg3: #e0e0e0;
  --sidebar-bg: #fafafa;
  --card-bg: #ffffff;
  --border: #d8d8d8;
  --text: #1a1a1a;
  --text-muted: #777;
  --text-dim: #444;
  --shadow: 0 4px 20px rgba(0,0,0,0.12);
}

/* ===== Light mode overrides ===== */
body.light #sidebar                          { border-right-color: #d8d8d8; }
body.light .sidebar-logo                     { border-bottom-color: #d8d8d8; }
body.light .nav-divider                      { background: #d8d8d8; }
body.light .nav-btn:hover                    { border-color: #ccc; }
body.light .sidebar-footer                   { border-top-color: #d8d8d8; color: #888; }
body.light #main                             { scrollbar-color: #ccc transparent; }
body.light #main::-webkit-scrollbar-thumb    { background: #ccc; }
body.light .view-header                      { border-bottom-color: #d8d8d8; }

body.light .form-group input,
body.light .form-group select,
body.light .form-group textarea              { border-color: #ccc; background: #fff; }
body.light .form-group select option        { background: #fff; color: #1a1a1a; }
body.light .form-group input::placeholder,
body.light .form-group textarea::placeholder { color: #bbb; }
body.light .form-actions                     { border-top-color: #d8d8d8; }
body.light .check-item                       { border-color: #ccc; }
body.light .check-item:has(input:checked)    { color: #1a1a1a; }

body.light .btn-secondary                    { border-color: #ccc; color: #444; }
body.light .btn-secondary:hover              { border-color: #999; color: #1a1a1a; }
body.light .btn-icon:hover                   { border-color: #ccc; background: #ebebeb; color: #1a1a1a; }

body.light .parts-table th,
body.light .summary-table th                 { background: #ebebeb; color: #666; }
body.light .parts-table td                   { border-bottom-color: #ebebeb; }
body.light .parts-table tr:hover td,
body.light .summary-table tr:hover td        { background: #f5f5f5; }
body.light .summary-table td                 { border-bottom-color: #ebebeb; }
body.light .split-tag                        { background: #e8e8e8; border-color: #ccc; color: #444; }

body.light .race-schedule thead tr           { background: #ebebeb; }
body.light .race-schedule th                 { border-right-color: #d8d8d8; }
body.light .race-schedule tbody tr           { border-bottom-color: #d8d8d8; }
body.light .series-name-cell                 { border-right-color: #d8d8d8; }
body.light .race-cell                        { border-right-color: #d8d8d8; }
body.light .race-entry                       { background: #ebebeb; border-color: #ccc; }
body.light .race-entry:hover                 { background: #e0e0e0; border-color: #bbb; }
body.light .schedule-empty-row td            { color: #bbb; }
body.light .empty-msg                        { color: #bbb; }

body.light .event-date-badge                 { border-color: #ccc; }
body.light .avatar                           { border-color: #ccc; }
body.light .avatar-placeholder               { border-color: #ccc; }

body.light .modal                            { border-color: #ccc; box-shadow: 0 16px 48px rgba(0,0,0,0.15); }

body.light .car-gallery-slot                 { background: #ebebeb; }
body.light .car-gallery-slot.empty           { border-color: #ccc; }
body.light .car-gallery-slot.empty .plus-icon { color: #bbb; }

body.light .year-tab                         { border-color: #ccc; }
body.light .year-tab:hover                   { border-color: #999; }

body.light .note-filter-btn                  { border-color: #ccc; }
body.light .note-filter-btn:hover            { border-color: #999; }
body.light .note-card:hover                  { background: #f5f5f5; border-color: #ccc; }
body.light .note-card-content               { color: #555; }

body.light .pdf-drop-zone                    { border-color: #ccc; background: #fafafa; }
body.light .pdf-card                         { background: #fafafa; }

body.light .settings-card                    { background: #ffffff; }
body.light .theme-btn                        { background: #fafafa; border-color: #ccc; }

body.light #receipt-viewer-overlay .modal    { background: #ffffff; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Hiragino Sans', 'Yu Gothic UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  height: 100vh;
  overflow: hidden;
  background-image:
    repeating-linear-gradient(0deg, transparent, transparent 39px, rgba(255,255,255,0.012) 39px, rgba(255,255,255,0.012) 40px),
    repeating-linear-gradient(90deg, transparent, transparent 39px, rgba(255,255,255,0.012) 39px, rgba(255,255,255,0.012) 40px);
}

#app { display: flex; height: 100vh; }

/* ===== サイドバー ===== */
#sidebar {
  width: 220px;
  background: var(--sidebar-bg);
  border-right: 1px solid #1a1a1a;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: relative;
}

#sidebar::after {
  content: '';
  position: absolute;
  right: 0; top: 0; bottom: 0;
  width: 2px;
  background: linear-gradient(to bottom, transparent, var(--accent), transparent);
  opacity: 0.3;
}

.sidebar-logo {
  padding: 24px 20px 20px;
  border-bottom: 1px solid #1a1a1a;
}

.sidebar-logo .logo-icon { font-size: 1.6rem; display: block; margin-bottom: 8px; }

.sidebar-logo h1 {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--accent);
  font-family: var(--mono);
  line-height: 1.7;
}

.sidebar-logo .version {
  font-size: 0.6rem;
  color: var(--text-muted);
  font-family: var(--mono);
  margin-top: 4px;
  letter-spacing: 0.08em;
}

#sidebar nav {
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 0 10px;
}

.nav-divider {
  height: 1px;
  background: #1e1e1e;
  margin: 8px 4px;
}

.nav-btn {
  background: none;
  border: 1px solid transparent;
  color: var(--text-muted);
  text-align: left;
  padding: 10px 13px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-family: var(--mono);
  transition: all 0.15s;
  display: flex;
  align-items: center;
  gap: 9px;
}

.nav-btn:hover { background: rgba(59,130,246,0.07); color: var(--text); border-color: #2a2a2a; }
.nav-btn.active { background: rgba(59,130,246,0.12); color: var(--accent); border-color: var(--accent-dim); border-left: 3px solid var(--accent); }

.sidebar-footer {
  margin-top: auto;
  padding: 14px 20px;
  border-top: 1px solid #181818;
  font-size: 0.6rem;
  color: #2a2a2a;
  font-family: var(--mono);
  letter-spacing: 0.1em;
}

/* ===== メイン ===== */
#main {
  flex: 1;
  overflow-y: auto;
  padding: 28px 32px;
  scrollbar-width: thin;
  scrollbar-color: #2a2a2a transparent;
}

#main::-webkit-scrollbar { width: 5px; }
#main::-webkit-scrollbar-thumb { background: #2a2a2a; border-radius: 3px; }

.view { display: none; }
.view.active { display: block; }

/* ===== ヘッダー ===== */
.view-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 1px solid #1e1e1e;
  position: relative;
}

.view-header::after {
  content: '';
  position: absolute;
  bottom: -1px; left: 0;
  width: 60px; height: 2px;
  background: var(--accent);
}

.view-header h2 {
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-family: var(--mono);
}

.section-label {
  font-size: 0.62rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  font-family: var(--mono);
  color: var(--accent);
  margin-bottom: 12px;
  display: block;
}

/* ===== カード ===== */
.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 22px 24px;
  margin-bottom: 16px;
  position: relative;
  overflow: hidden;
}

.card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--accent), transparent);
}

/* ===== フォーム ===== */
.form-row { display: flex; gap: 14px; margin-bottom: 14px; }
.form-group { flex: 1; display: flex; flex-direction: column; gap: 6px; }
.form-group.full { margin-bottom: 14px; }

.form-group label {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  font-family: var(--mono);
  color: var(--text-muted);
}

.required { color: var(--accent); }

.form-group input,
.form-group select,
.form-group textarea {
  padding: 9px 12px;
  border: 1px solid #2a2a2a;
  border-radius: 3px;
  font-size: 0.88rem;
  color: var(--text);
  background: var(--bg3);
  font-family: inherit;
  transition: border-color 0.15s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(59,130,246,0.1);
}

.form-group select option { background: #1c1c1c; }
.form-group textarea { resize: vertical; }
.form-group input::placeholder,
.form-group textarea::placeholder { color: #383838; }

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid #222;
}

/* チェックグリッド */
.check-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 4px;
}

.check-item {
  display: flex;
  align-items: center;
  gap: 7px;
  background: var(--bg3);
  border: 1px solid #2a2a2a;
  border-radius: 3px;
  padding: 7px 12px;
  cursor: pointer;
  transition: all 0.12s;
  font-size: 0.85rem;
  user-select: none;
}

.check-item input[type="checkbox"] { accent-color: var(--accent); width: 14px; height: 14px; }
.check-item:has(input:checked) { border-color: var(--accent); background: rgba(59,130,246,0.1); color: #fff; }

/* ===== ボタン ===== */
.btn-primary {
  padding: 9px 22px;
  border: none;
  background: var(--accent);
  color: #fff;
  border-radius: 3px;
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  font-family: var(--mono);
  cursor: pointer;
  transition: background 0.15s, box-shadow 0.15s;
}

.btn-primary:hover { background: #60a5fa; box-shadow: 0 0 14px rgba(59,130,246,0.35); }

.btn-secondary {
  padding: 9px 18px;
  border: 1px solid #303030;
  background: transparent;
  color: var(--text-dim);
  border-radius: 3px;
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-family: var(--mono);
  cursor: pointer;
  transition: all 0.15s;
}

.btn-secondary:hover { border-color: #505050; color: var(--text); }

.btn-danger {
  padding: 9px 18px;
  border: 1px solid var(--danger);
  background: transparent;
  color: var(--danger);
  border-radius: 3px;
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-family: var(--mono);
  cursor: pointer;
  transition: all 0.15s;
}

.btn-danger:hover { background: var(--danger); color: #fff; }

.btn-icon {
  background: none;
  border: 1px solid transparent;
  color: var(--text-muted);
  padding: 5px 8px;
  border-radius: 3px;
  font-size: 0.82rem;
  cursor: pointer;
  transition: all 0.12s;
}

.btn-icon:hover { border-color: #333; color: var(--text); background: #222; }

/* ===== 費用統計バー ===== */
.stats-bar {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 20px;
}

.stat-cell {
  background: var(--card-bg);
  padding: 16px 20px;
  text-align: center;
}

.stat-cell .val {
  font-size: 1.5rem;
  font-weight: 900;
  font-family: var(--mono);
  color: var(--accent);
  line-height: 1;
}

.stat-cell .lbl {
  font-size: 0.62rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-family: var(--mono);
  color: var(--text-muted);
  margin-top: 5px;
}

/* ===== パーツリスト ===== */
.parts-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  overflow: hidden;
  font-size: 0.85rem;
  margin-bottom: 20px;
}

.parts-table th {
  background: #111;
  font-size: 0.62rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-family: var(--mono);
  color: var(--text-muted);
  padding: 9px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
}

.parts-table td {
  padding: 11px 14px;
  border-bottom: 1px solid #1e1e1e;
  vertical-align: middle;
}

.parts-table tr:last-child td { border-bottom: none; }
.parts-table tr:hover td { background: #1f1f1f; }

.parts-table .amount-cell {
  font-family: var(--mono);
  font-weight: 700;
  color: var(--warning);
}

.parts-table .paid-badge {
  font-size: 0.7rem;
  font-family: var(--mono);
  background: rgba(59,130,246,0.12);
  color: var(--accent);
  border: 1px solid rgba(59,130,246,0.25);
  padding: 2px 8px;
  border-radius: 2px;
}

.parts-table .split-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.split-tag {
  font-size: 0.65rem;
  font-family: var(--mono);
  background: #202020;
  color: var(--text-dim);
  border: 1px solid #2a2a2a;
  padding: 1px 6px;
  border-radius: 2px;
}

/* ===== 精算テーブル ===== */
.summary-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 20px;
}

.summary-table th {
  background: #111;
  font-size: 0.62rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-family: var(--mono);
  color: var(--text-muted);
  padding: 9px 16px;
  text-align: right;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
}

.summary-table th:first-child { text-align: left; }

.summary-table td {
  padding: 12px 16px;
  text-align: right;
  border-bottom: 1px solid #1e1e1e;
  font-family: var(--mono);
}

.summary-table td:first-child { text-align: left; font-family: inherit; font-weight: 700; }
.summary-table tr:last-child td { border-bottom: none; }
.summary-table tr:hover td { background: #1f1f1f; }

.balance-pos { color: var(--success); font-weight: 700; }
.balance-neg { color: var(--danger); font-weight: 700; }
.balance-zero { color: var(--text-muted); }

/* ===== 精算指示 ===== */
.settlement-list { display: flex; flex-direction: column; gap: 8px; }

.settlement-item {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: 3px;
  padding: 12px 16px;
  font-size: 0.88rem;
}

.settlement-item .arrow { color: var(--accent); font-weight: 700; font-family: var(--mono); }
.settlement-item .s-amount { font-family: var(--mono); font-weight: 800; color: var(--warning); margin-left: auto; }

/* ===== カレンダー ===== */
.cal-nav { display: flex; align-items: center; gap: 10px; }

.cal-month-label {
  font-family: var(--mono);
  font-size: 1.1rem;
  font-weight: 900;
  letter-spacing: 0.15em;
  min-width: 80px;
  text-align: center;
  color: var(--text);
}

/* ===== Race Schedule Table ===== */
.schedule-wrap {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--card-bg);
}

.race-schedule {
  width: 100%;
  border-collapse: collapse;
  min-width: 900px;
}

.race-schedule thead tr {
  background: #0d0d0d;
  border-bottom: 2px solid var(--accent);
}

.race-schedule th {
  padding: 10px 8px;
  font-size: 0.65rem;
  font-family: var(--mono);
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted);
  text-align: center;
  border-right: 1px solid #1a1a1a;
  white-space: nowrap;
}

.race-schedule th.series-col { text-align: left; padding-left: 18px; min-width: 160px; color: var(--accent); }
.race-schedule th.this-month { color: var(--accent); background: rgba(59,130,246,0.06); }

.race-schedule tbody tr {
  border-bottom: 1px solid #1a1a1a;
  transition: background 0.12s;
}

.race-schedule tbody tr:last-child { border-bottom: none; }
.race-schedule tbody tr:hover { background: rgba(255,255,255,0.02); }

.series-name-cell {
  padding: 12px 18px;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text);
  border-right: 1px solid #222;
  white-space: nowrap;
  position: relative;
}

.series-name-cell::before {
  content: '';
  position: absolute;
  left: 0; top: 20%; bottom: 20%;
  width: 3px;
  background: var(--accent);
  border-radius: 2px;
}

.race-cell {
  padding: 6px 5px;
  vertical-align: top;
  text-align: center;
  border-right: 1px solid #1a1a1a;
  min-width: 72px;
  min-height: 52px;
}

.race-cell.this-month { background: rgba(59,130,246,0.04); }

.race-entry {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  background: #222;
  border: 1px solid #2e2e2e;
  border-radius: 4px;
  padding: 5px 8px;
  margin: 2px;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s;
  min-width: 58px;
  gap: 2px;
}

.race-entry:hover { background: #2a2a2a; border-color: #3a3a3a; }

.race-entry.car-roadster { border-left: 3px solid #2563eb; }
.race-entry.car-alto     { border-left: 3px solid #7c3aed; }
.race-entry.car-both     { border-left: 3px solid #0f766e; }
.race-entry.car-         { border-left: 3px solid #444; }

.race-round {
  font-size: 0.72rem;
  font-weight: 700;
  font-family: var(--mono);
  color: var(--text);
  white-space: nowrap;
}

.race-date {
  font-size: 0.65rem;
  font-family: var(--mono);
  color: var(--accent);
  white-space: nowrap;
}

.schedule-empty-row td {
  text-align: center;
  padding: 40px;
  color: #2a2a2a;
  font-family: var(--mono);
  font-size: 0.75rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

/* イベントリスト */
.event-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: 3px;
  padding: 13px 16px;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 14px;
}

.event-card.car-roadster { border-left-color: #2563eb; }
.event-card.car-alto { border-left-color: #7c3aed; }
.event-card.car-both { border-left-color: #0f766e; }

.event-date-badge {
  text-align: center;
  background: var(--bg3);
  border: 1px solid #2a2a2a;
  border-radius: 3px;
  padding: 6px 10px;
  min-width: 52px;
  font-family: var(--mono);
}

.event-date-badge .eday { font-size: 1.3rem; font-weight: 900; line-height: 1; color: var(--accent); }
.event-date-badge .emon { font-size: 0.6rem; color: var(--text-muted); }

.event-info { flex: 1; }
.event-info h4 { font-size: 0.92rem; font-weight: 700; }
.event-info p { font-size: 0.75rem; color: var(--text-muted); margin-top: 3px; font-family: var(--mono); }

.car-badge {
  font-size: 0.62rem;
  font-weight: 700;
  font-family: var(--mono);
  padding: 2px 8px;
  border-radius: 2px;
  letter-spacing: 0.06em;
}

.car-badge.car-roadster { background: rgba(37,99,235,0.15); color: #60a5fa; border: 1px solid rgba(37,99,235,0.3); }
.car-badge.car-alto { background: rgba(124,58,237,0.15); color: #a78bfa; border: 1px solid rgba(124,58,237,0.3); }
.car-badge.car-both { background: rgba(15,118,110,0.15); color: #34d399; border: 1px solid rgba(15,118,110,0.3); }

/* ===== メンバーリスト ===== */
.member-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 14px 18px;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 16px;
  justify-content: space-between;
}

.member-card .member-name { font-weight: 700; font-size: 0.95rem; }
.member-card .member-meta { font-size: 0.72rem; color: var(--text-muted); font-family: var(--mono); margin-top: 2px; }

/* アバター */
.avatar-wrap {
  position: relative;
  flex-shrink: 0;
  cursor: pointer;
}

.avatar {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid #2a2a2a;
  display: block;
  background: var(--bg3);
  transition: border-color 0.15s;
}

.avatar-wrap:hover .avatar { border-color: var(--accent); }

.avatar-placeholder {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--bg3);
  border: 2px dashed #333;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  transition: border-color 0.15s, background 0.15s;
}

.avatar-wrap:hover .avatar-placeholder {
  border-color: var(--accent);
  background: rgba(59,130,246,0.08);
}

.avatar-edit-btn {
  position: absolute;
  bottom: -2px;
  right: -2px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid var(--bg2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.6rem;
  color: #fff;
  cursor: pointer;
  transition: background 0.15s;
}

.avatar-wrap:hover .avatar-edit-btn { background: #60a5fa; }

.avatar-input { display: none; }

/* ===== モーダル ===== */
#modal-overlay, #event-modal-overlay, #note-modal-overlay, #confirm-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.78);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  backdrop-filter: blur(2px);
}

.modal {
  background: var(--bg2);
  border: 1px solid #2a2a2a;
  border-top: 2px solid var(--accent);
  border-radius: 5px;
  padding: 28px 30px;
  box-shadow: 0 24px 64px rgba(0,0,0,0.8);
  width: 520px;
  max-width: calc(100vw - 40px);
  max-height: calc(100vh - 60px);
  overflow-y: auto;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.empty-msg {
  text-align: center;
  color: #2a2a2a;
  padding: 40px;
  font-size: 0.78rem;
  font-family: var(--mono);
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.add-btn-wrap {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 16px;
}

/* ===== Calendar Photo ===== */
.cal-photo-wrap {
  margin-top: 32px;
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
}

.cal-photo {
  width: 100%;
  display: block;
  object-fit: cover;
}

/* ===== Car Gallery ===== */
.car-main-wrap {
  position: relative;
  width: 100%;
  height: 200px;
  border-radius: 6px;
  overflow: hidden;
  cursor: pointer;
  margin-bottom: 10px;
  background: #111;
  border: 1px solid var(--border);
}
.car-main-wrap img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center;
  display: block;
}
.car-main-edit {
  position: absolute;
  bottom: 8px;
  right: 8px;
  background: rgba(0,0,0,0.65);
  border: 1px solid #444;
  border-radius: 4px;
  padding: 4px 10px;
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  color: #ccc;
  opacity: 0;
  transition: opacity 0.15s;
  pointer-events: none;
}
.car-main-wrap:hover .car-main-edit { opacity: 1; }

.car-gallery {
  display: flex;
  gap: 10px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.car-gallery-slot {
  width: 110px;
  height: 110px;
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: #111;
  flex-shrink: 0;
  position: relative;
  cursor: pointer;
}

.car-gallery-slot img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center;
  display: block;
}

.car-gallery-slot.empty {
  border: 2px dashed #2a2a2a;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.15s, background 0.15s;
}

.car-gallery-slot.empty:hover {
  border-color: var(--accent);
  background: rgba(59,130,246,0.06);
}

.car-gallery-slot.empty .plus-icon {
  font-size: 1.6rem;
  color: #2a2a2a;
  transition: color 0.15s;
  line-height: 1;
}

.car-gallery-slot.empty:hover .plus-icon { color: var(--accent); }

.car-gallery-slot .slot-delete {
  position: absolute;
  top: 4px; right: 4px;
  width: 20px; height: 20px;
  border-radius: 50%;
  background: rgba(0,0,0,0.7);
  border: 1px solid #444;
  color: #aaa;
  font-size: 0.6rem;
  display: none;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.12s;
}

.car-gallery-slot:hover .slot-delete { display: flex; }
.car-gallery-slot .slot-delete:hover { background: var(--danger); color: #fff; border-color: var(--danger); }

/* ===== Year Tab Bar ===== */
.year-tab-bar {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

.year-tab {
  background: none;
  border: 1px solid #2a2a2a;
  color: var(--text-muted);
  padding: 6px 16px;
  border-radius: 3px;
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  font-family: var(--mono);
  cursor: pointer;
  transition: all 0.15s;
  text-transform: uppercase;
}

.year-tab:hover { border-color: #444; color: var(--text-dim); }

.year-tab.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  box-shadow: 0 0 10px rgba(59,130,246,0.3);
}

/* ===== Notes ===== */
.notes-filter-bar {
  display: flex;
  gap: 6px;
  margin-bottom: 20px;
}

.note-filter-btn {
  background: none;
  border: 1px solid #2a2a2a;
  color: var(--text-muted);
  padding: 5px 14px;
  border-radius: 20px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-family: var(--mono);
  cursor: pointer;
  transition: all 0.15s;
}

.note-filter-btn:hover { border-color: #444; color: var(--text-dim); }
.note-filter-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }

.notes-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
}

.note-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 18px 18px 14px;
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: border-color 0.15s, background 0.15s;
}

.note-card:hover { background: #1f1f1f; border-color: #2e2e2e; }

.note-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
}

.note-card.tag-roadster::before { background: #2563eb; }
.note-card.tag-alto::before     { background: #7c3aed; }
.note-card.tag-general::before  { background: var(--accent); }

.note-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.note-card-title {
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.3;
  flex: 1;
}

.note-card-title.untitled { color: var(--text-muted); font-style: italic; font-weight: 400; }

.note-tag-badge {
  font-size: 0.6rem;
  font-weight: 700;
  font-family: var(--mono);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 2px 7px;
  border-radius: 2px;
  flex-shrink: 0;
}

.note-tag-badge.tag-roadster { background: rgba(37,99,235,0.15); color: #60a5fa; border: 1px solid rgba(37,99,235,0.25); }
.note-tag-badge.tag-alto     { background: rgba(124,58,237,0.15); color: #a78bfa; border: 1px solid rgba(124,58,237,0.25); }
.note-tag-badge.tag-general  { background: rgba(59,130,246,0.1); color: var(--accent); border: 1px solid rgba(59,130,246,0.2); }

.note-card-content {
  font-size: 0.84rem;
  color: #aaa;
  line-height: 1.65;
  white-space: pre-wrap;
  word-break: break-word;
}

.note-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: auto;
  padding-top: 10px;
  border-top: 1px solid #1e1e1e;
}

.note-card-date {
  font-size: 0.65rem;
  color: #333;
  font-family: var(--mono);
  letter-spacing: 0.06em;
}

.note-card-actions { display: flex; gap: 2px; }

/* ===== PDF Viewer ===== */
.pdf-drop-zone {
  border: 2px dashed #2a2a2a;
  border-radius: 6px;
  padding: 60px 32px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
  background: var(--bg2);
}

.pdf-drop-zone:hover,
.pdf-drop-zone.drag-over {
  border-color: var(--accent);
  background: rgba(59,130,246,0.05);
}

.pdf-drop-icon {
  font-size: 3rem;
  display: block;
  margin-bottom: 16px;
  opacity: 0.5;
}

.pdf-drop-title {
  font-size: 0.88rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  font-family: var(--mono);
  color: var(--text-dim);
  margin-bottom: 8px;
}

.pdf-drop-sub {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-family: var(--mono);
  letter-spacing: 0.06em;
}

.pdf-file-input { display: none; }

.pdf-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.pdf-count {
  flex: 1;
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  text-transform: uppercase;
}

.pdf-card-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.pdf-card-list.drag-over {
  outline: 2px dashed var(--accent);
  outline-offset: 4px;
  border-radius: 6px;
}

.pdf-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
  transition: border-color 0.15s;
}

.pdf-card:hover {
  border-color: #3a3a3a;
}

.pdf-card-header {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 16px;
}

.pdf-card-icon { font-size: 1.4rem; flex-shrink: 0; }

.pdf-card-info { flex: 1; min-width: 0; }
.pdf-card-name {
  font-weight: 700;
  font-size: 0.88rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.pdf-card-meta {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-family: var(--mono);
  margin-top: 2px;
}

.pdf-card-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

.pdf-card-viewer {
  border-top: 1px solid var(--border);
}

.pdf-card-viewer.hidden { display: none; }

.pdf-viewer {
  width: 100%;
  height: calc(100vh - 280px);
  min-height: 500px;
  border: none;
  display: block;
  background: #1a1a1a;
}

/* ===== Mobile Header ===== */
#mobile-header {
  display: none;
}

#sidebar-overlay {
  display: none;
}

/* ===== Responsive (Mobile) ===== */
@media (max-width: 768px) {
  body { overflow: auto; height: auto; }

  #app { flex-direction: column; height: auto; min-height: 100vh; }

  /* Mobile top bar */
  #mobile-header {
    display: flex;
    position: fixed;
    top: 0; left: 0; right: 0;
    height: 52px;
    background: var(--sidebar-bg);
    border-bottom: 1px solid #1a1a1a;
    z-index: 700;
    align-items: center;
    padding: 0 16px;
    gap: 14px;
  }

  #hamburger {
    background: none;
    border: 1px solid #2a2a2a;
    color: var(--text);
    width: 36px;
    height: 36px;
    border-radius: 4px;
    font-size: 1.2rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: border-color 0.15s;
  }

  #hamburger:hover { border-color: var(--accent); color: var(--accent); }

  .mobile-title {
    font-family: var(--mono);
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.18em;
    color: var(--accent);
    text-transform: uppercase;
  }

  /* Sidebar becomes fixed overlay */
  #sidebar {
    position: fixed;
    left: -240px;
    top: 0; bottom: 0;
    z-index: 800;
    width: 220px;
    transition: left 0.25s ease;
    box-shadow: 4px 0 24px rgba(0,0,0,0.7);
  }

  #sidebar.open { left: 0; }

  /* Dim overlay behind sidebar */
  #sidebar-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    z-index: 750;
    backdrop-filter: blur(2px);
  }

  #sidebar-overlay.visible { display: block; }

  /* Main content */
  #main {
    padding: 68px 14px 32px;
    height: auto;
    min-height: 100vh;
  }

  /* View header wrap */
  .view-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }

  /* Stats bar: single column */
  .stats-bar {
    grid-template-columns: 1fr;
  }

  /* Form rows stack vertically */
  .form-row { flex-direction: column; }

  /* Tables scroll horizontally */
  .parts-table, .summary-table {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* Car gallery smaller */
  .car-gallery-slot { width: 80px; height: 80px; }
  .car-main-wrap { height: 150px; }

  /* Modals full width */
  .modal {
    width: calc(100vw - 20px);
    padding: 20px 16px;
    max-height: calc(100vh - 40px);
  }

  /* Notes single column */
  .notes-grid { grid-template-columns: 1fr; }

  /* Settlement wrap */
  .settlement-item { flex-wrap: wrap; gap: 8px; }

  /* Cal nav wrap */
  .cal-nav { flex-wrap: wrap; gap: 8px; }

  /* Calendar: hide table, show list only */
  .schedule-wrap { display: none; }

  #event-list-section { margin-top: 0; }

  .event-card {
    flex-wrap: wrap;
    gap: 10px;
  }

  .event-info h4 { font-size: 0.88rem; }
  .event-info p { font-size: 0.7rem; }

  /* Identity grid single column on small phones */
  .identity-grid { grid-template-columns: 1fr 1fr; }
  .identity-box { width: calc(100vw - 40px); padding: 32px 20px; }

  /* Login box */
  .login-box { width: calc(100vw - 40px); padding: 32px 20px; }
}

/* ===== Receipts ===== */
.receipt-upload-btn {
  margin-top: 10px;
}

.receipt-thumbs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 4px;
}

.receipt-thumb-wrap {
  position: relative;
  width: 72px;
  height: 72px;
}

.receipt-thumb {
  width: 72px;
  height: 72px;
  object-fit: cover;
  border-radius: 4px;
  border: 1px solid var(--border);
  cursor: pointer;
  transition: opacity 0.15s;
}

.receipt-thumb:hover { opacity: 0.8; }

.receipt-thumb-del {
  position: absolute;
  top: -6px;
  right: -6px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #ef4444;
  color: #fff;
  border: none;
  font-size: 0.6rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.receipt-notice {
  margin-top: 8px;
  font-size: 0.7rem;
  font-family: var(--mono);
  color: var(--text-muted);
  letter-spacing: 0.03em;
}

.receipt-badge {
  display: inline-block;
  margin-top: 4px;
  font-size: 0.72rem;
  font-family: var(--mono);
  color: var(--accent);
  cursor: pointer;
  letter-spacing: 0.04em;
}

.receipt-badge:hover { text-decoration: underline; }

.receipt-modal {
  width: 640px;
  max-width: 92vw;
  max-height: 80vh;
  overflow-y: auto;
}

.receipt-viewer-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 14px;
  padding: 4px 0 8px;
}

.receipt-viewer-item {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.receipt-viewer-img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: 4px;
  border: 1px solid var(--border);
  cursor: pointer;
  transition: opacity 0.15s;
}

.receipt-viewer-img:hover { opacity: 0.8; }

.receipt-viewer-name {
  font-size: 0.7rem;
  font-family: var(--mono);
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#receipt-lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.92);
  z-index: 9999;
  display: none;
  align-items: center;
  justify-content: center;
  cursor: zoom-out;
}

#receipt-lightbox-img {
  max-width: 92vw;
  max-height: 90vh;
  object-fit: contain;
  border-radius: 4px;
}

/* ===== Settings ===== */
.settings-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 24px;
  margin-bottom: 16px;
  max-width: 480px;
}

.settings-label {
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.12em;
  color: var(--text-muted);
  text-transform: uppercase;
  margin-bottom: 16px;
}

.settings-theme-btns {
  display: flex;
  gap: 12px;
}

.theme-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 20px;
  border: 2px solid var(--border);
  border-radius: 6px;
  background: var(--bg2);
  color: var(--text-dim);
  font-family: var(--mono);
  font-size: 0.78rem;
  letter-spacing: 0.1em;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
  flex: 1;
  justify-content: center;
}

.theme-btn:hover {
  border-color: var(--accent);
  color: var(--text);
}

.theme-btn.active {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(59,130,246,0.08);
}

.theme-btn-swatch {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 1px solid var(--border);
  flex-shrink: 0;
}

.dark-swatch { background: #0d0d0d; border-color: #444; }
.light-swatch { background: #ffffff; border-color: #ccc; }

.settings-brightness-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brightness-icon { font-size: 1.1rem; flex-shrink: 0; }

#brightness-slider {
  flex: 1;
  accent-color: var(--accent);
  height: 4px;
  cursor: pointer;
}

.brightness-val {
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--text-dim);
  min-width: 40px;
  text-align: right;
}
