:root {
  --ink: #172129;
  --muted: #69767f;
  --paper: #f3f5f4;
  --surface: #ffffff;
  --line: #dce3e1;
  --navy: #183d45;
  --navy-dark: #102e35;
  --teal: #1a7a74;
  --mint: #d9eeea;
  --orange: #df7a3e;
  --red: #b64d4b;
  --shadow: 0 14px 40px rgba(21, 48, 52, .08);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-width: 320px; min-height: 100vh; color: var(--ink); background: var(--paper); font-family: "DM Sans", "Noto Sans JP", sans-serif; }
button, input, select { font: inherit; }
button { color: inherit; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.app-header { background: var(--navy-dark); color: white; }
.header-inner { width: min(1240px, calc(100% - 48px)); height: 68px; margin: 0 auto; display: flex; align-items: center; justify-content: space-between; }
.brand { display: flex; align-items: center; gap: 11px; color: white; text-decoration: none; font-size: 19px; letter-spacing: -.035em; }
.brand strong { color: #75c9bb; }
.brand-mark { width: 34px; height: 34px; display: block; position: relative; border-radius: 10px; background: var(--teal); overflow: hidden; }
.brand-mark i { position: absolute; width: 20px; height: 4px; left: -1px; top: 10px; border-radius: 4px; background: #bce6d6; transform: rotate(-36deg); }
.brand-mark i + i { left: 14px; top: 21px; transform: rotate(-36deg); }
.header-meta { display: flex; align-items: center; gap: 24px; color: #b8c7c9; font-size: 11px; letter-spacing: .06em; }
.db-status { display: flex; align-items: center; gap: 7px; }
.db-status i { width: 7px; height: 7px; display: block; border-radius: 50%; background: #6ed09f; box-shadow: 0 0 0 4px rgba(110,208,159,.12); }
.admin-link { padding: 6px 9px; color: white; border: 1px solid #456268; border-radius: 6px; text-decoration: none; font-size: 10px; }
.admin-link:hover { border-color: #75c9bb; color: #75c9bb; }

.page-shell { width: min(1240px, calc(100% - 48px)); margin: 0 auto; }
.page-intro { display: flex; align-items: end; justify-content: space-between; padding: 42px 2px 28px; }
.eyebrow { margin: 0 0 8px; color: var(--teal); font-size: 10px; font-weight: 700; letter-spacing: .18em; }
.page-intro h1 { margin: 0; font-family: "Noto Sans JP", sans-serif; font-size: 32px; letter-spacing: -.04em; }
.page-intro p:not(.eyebrow) { margin: 9px 0 0; color: var(--muted); font-size: 13px; }

.primary-button, .secondary-button, .danger-button { border-radius: 9px; padding: 11px 17px; font-weight: 600; cursor: pointer; transition: .18s ease; }
.primary-button { border: 1px solid var(--teal); background: var(--teal); color: white; box-shadow: 0 6px 15px rgba(26,122,116,.16); }
.primary-button:hover { background: #146b66; transform: translateY(-1px); }
.primary-button:disabled { opacity: .55; cursor: wait; transform: none; }
.secondary-button { border: 1px solid var(--line); background: white; }
.secondary-button:hover { border-color: #aab7b3; background: #f7f9f8; }
.danger-button { border: 1px solid var(--red); background: var(--red); color: white; }

.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 18px; }
.stat-card { min-height: 105px; padding: 21px 22px; display: flex; justify-content: space-between; align-items: center; background: var(--surface); border: 1px solid var(--line); border-radius: 13px; box-shadow: 0 4px 14px rgba(24,61,69,.035); }
.stat-card.stat-main { background: var(--navy); color: white; border-color: var(--navy); justify-content: flex-start; gap: 17px; }
.stat-icon { width: 44px; height: 44px; display: grid; place-items: center; border-radius: 12px; background: rgba(255,255,255,.1); color: #8ed3c6; font-size: 15px; }
.stat-card div > span { display: block; margin-bottom: 4px; color: var(--muted); font-size: 11px; }
.stat-main div > span { color: #bed0d1; }
.stat-card strong { font-size: 29px; line-height: 1; letter-spacing: -.04em; }
.stat-card small { margin-left: 6px; color: #98a3a6; font-size: 9px; text-transform: uppercase; letter-spacing: .09em; }
.trend { padding: 5px 8px; border-radius: 99px; font-size: 9px; }
.trend.positive { color: var(--teal); background: #e4f3f0; }
.trend.warning { color: var(--red); background: #f8e9e6; }
.route-glyph { width: 36px; height: 36px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 50%; color: var(--teal); font-size: 18px; }

.data-panel { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); overflow: hidden; }
.panel-top { display: flex; align-items: end; justify-content: space-between; padding: 25px 27px 18px; }
.panel-top h2 { margin: 0; font-size: 19px; letter-spacing: -.035em; }
.result-count { color: var(--muted); font-size: 11px; }
.result-count strong { color: var(--teal); font-size: 16px; }
.toolbar { display: grid; grid-template-columns: minmax(220px, 1.6fr) repeat(3, minmax(130px, .55fr)) auto; gap: 8px; padding: 0 27px 18px; }
.toolbar input, .toolbar select { width: 100%; height: 41px; border: 1px solid var(--line); border-radius: 8px; background: #f8faf9; color: var(--ink); padding: 0 11px; outline: none; font-size: 12px; }
.toolbar input:focus, .toolbar select:focus { border-color: var(--teal); box-shadow: 0 0 0 3px rgba(26,122,116,.09); background: white; }
.search-field { position: relative; }
.search-field > span:not(.visually-hidden) { position: absolute; top: 8px; left: 12px; color: var(--muted); font-size: 18px; }
.search-field input { padding-left: 37px; }
.reset-button { border: 0; background: transparent; color: var(--muted); font-size: 11px; text-decoration: underline; cursor: pointer; }
.message { min-height: 22px; padding: 0 27px 7px; color: var(--teal); font-size: 11px; }
.message.error { color: var(--red); }

.table-wrap { overflow-x: auto; border-top: 1px solid var(--line); }
table { width: 100%; border-collapse: collapse; min-width: 980px; }
th { padding: 11px 14px; color: #758188; background: #f6f8f7; text-align: left; font-size: 9px; text-transform: uppercase; letter-spacing: .1em; font-weight: 600; }
th:first-child, td:first-child { padding-left: 27px; }
th:last-child, td:last-child { padding-right: 27px; }
td { padding: 13px 14px; border-top: 1px solid #edf0ef; vertical-align: middle; font-size: 12px; }
tbody tr { transition: background .15s; }
tbody tr:hover { background: #fbfcfb; }
tbody tr.cancelled td { color: #90999d; background: #fdfafa; }
.time-cell strong { font-size: 15px; font-variant-numeric: tabular-nums; }
.passenger strong { display: block; font-size: 13px; }
.passenger small, .date-cell small { color: #9aa4a8; font-size: 9px; }
.route-badge { display: inline-block; padding: 5px 8px; border-radius: 6px; background: #e4f0ee; color: #176c67; font-size: 11px; font-weight: 700; }
.journey { min-width: 230px; display: grid; grid-template-columns: 1fr 28px 1fr; align-items: center; }
.journey span { display: block; }
.journey small { display: block; margin-top: 2px; color: var(--muted); font-size: 9px; }
.journey i { height: 1px; position: relative; background: #aab7b3; }
.journey i::after { content: ""; position: absolute; right: 0; top: -3px; width: 6px; height: 6px; border-top: 1px solid #aab7b3; border-right: 1px solid #aab7b3; transform: rotate(45deg); }
.date-cell span { display: block; white-space: nowrap; }
.status-badge { display: inline-block; padding: 4px 7px; border-radius: 99px; background: #e6f3ef; color: var(--teal); font-size: 9px; font-weight: 600; }
.status-badge.cancelled { background: #f6e5e3; color: var(--red); }
.note-text { display: block; max-width: 140px; margin-top: 4px; color: var(--orange); font-size: 9px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-actions { display: flex; justify-content: flex-end; gap: 4px; }
.icon-button { border: 0; border-radius: 6px; padding: 6px 7px; background: transparent; color: var(--muted); font-size: 10px; white-space: nowrap; cursor: pointer; }
.icon-button:hover { color: var(--teal); background: #e9f2f0; }
.icon-button.delete:hover { color: var(--red); background: #f8e9e7; }
.empty-state { padding: 65px 20px; text-align: center; color: var(--muted); }
.empty-state > div { width: 42px; height: 42px; margin: 0 auto 12px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 50%; font-size: 20px; }
.empty-state h3 { margin: 0 0 6px; color: var(--ink); font-size: 14px; }
.empty-state p { margin: 0; font-size: 11px; }
.pagination { padding: 15px 27px; display: flex; align-items: center; justify-content: space-between; border-top: 1px solid var(--line); color: var(--muted); font-size: 10px; }
.pagination div { display: flex; gap: 5px; }
.pagination button { width: 31px; height: 31px; border: 1px solid var(--line); border-radius: 7px; background: white; cursor: pointer; }
.pagination button:disabled { opacity: .35; cursor: default; }

footer { width: min(1240px, calc(100% - 48px)); min-height: 76px; margin: 0 auto; display: flex; align-items: center; justify-content: space-between; color: #8a969a; font-size: 9px; letter-spacing: .08em; text-transform: uppercase; }

dialog { color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: 15px; box-shadow: 0 25px 70px rgba(11,35,39,.24); }
dialog::backdrop { background: rgba(10,31,35,.5); backdrop-filter: blur(3px); }
.form-dialog { width: min(720px, calc(100% - 30px)); padding: 0; }
.form-dialog form { padding: 28px 30px 26px; }
.dialog-header { display: flex; justify-content: space-between; margin-bottom: 22px; }
.dialog-header h2 { margin: 0; font-size: 21px; }
.close-button { width: 34px; height: 34px; border: 1px solid var(--line); border-radius: 50%; background: white; color: var(--muted); font-size: 20px; cursor: pointer; }
.form-grid { display: grid; gap: 13px; }
.form-grid.two { grid-template-columns: 1fr 1fr; }
.form-grid.three { grid-template-columns: .65fr 1fr 1fr; }
.form-dialog label { color: #4a5960; font-size: 11px; font-weight: 600; }
.form-dialog label em { float: right; color: var(--orange); font-size: 9px; font-style: normal; }
.form-dialog input, .form-dialog select { width: 100%; height: 40px; margin-top: 7px; border: 1px solid var(--line); border-radius: 8px; padding: 0 10px; outline: none; background: #fafbfa; font-size: 12px; }
.form-dialog input:focus, .form-dialog select:focus { border-color: var(--teal); box-shadow: 0 0 0 3px rgba(26,122,116,.09); background: white; }
fieldset { margin: 17px 0 0; padding: 13px 14px 15px; border: 1px solid var(--line); border-radius: 10px; }
legend { padding: 0 7px; color: var(--teal); font-size: 10px; font-weight: 700; letter-spacing: .08em; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 23px; }
.delete-dialog { width: min(410px, calc(100% - 30px)); padding: 30px; text-align: center; }
.delete-dialog h2 { margin: 0; font-size: 18px; }
.delete-dialog p { color: var(--muted); font-size: 12px; }
.alert-icon { width: 42px; height: 42px; margin: 0 auto 14px; display: grid; place-items: center; border-radius: 50%; color: var(--red); background: #f7e5e2; font-weight: 700; }
.delete-dialog .dialog-actions { justify-content: center; }

@media (max-width: 960px) {
  .stats { grid-template-columns: 1fr 1fr; }
  .toolbar { grid-template-columns: 1fr 1fr 1fr; }
  .search-field { grid-column: 1 / -1; }
}

@media (max-width: 680px) {
  .header-inner, .page-shell, footer { width: min(100% - 28px, 540px); }
  .header-meta #today { display: none; }
  .db-status { display: none; }
  .page-intro { align-items: center; padding-top: 30px; }
  .page-intro h1 { font-size: 27px; }
  .page-intro p:not(.eyebrow) { display: none; }
  .page-intro .primary-button { padding: 10px 13px; font-size: 12px; }
  .stats { grid-template-columns: 1fr 1fr; gap: 8px; }
  .stat-card { min-height: 90px; padding: 16px; }
  .stat-card strong { font-size: 25px; }
  .stat-icon, .trend, .route-glyph { display: none; }
  .panel-top { padding-inline: 18px; }
  .toolbar { grid-template-columns: 1fr 1fr; padding-inline: 18px; }
  .search-field { grid-column: 1 / -1; }
  .reset-button { grid-column: 1 / -1; }
  .message { padding-inline: 18px; }
  .table-wrap { border-top: 1px solid var(--line); overflow: visible; }
  table, thead, tbody, tr, td { display: block; }
  table { min-width: 0; }
  thead { display: none; }
  tbody tr { padding: 16px 18px; border-top: 1px solid var(--line); position: relative; }
  tbody tr:first-child { border-top: 0; }
  td { padding: 0; border: 0; }
  td.time-cell { position: absolute; top: 18px; right: 18px; }
  td.passenger { padding-right: 70px; }
  td.route-cell { margin-top: 10px; display: inline-block; }
  td.journey-cell { margin-top: 12px; }
  .journey { min-width: 0; }
  td.date-cell { margin-top: 11px; display: inline-block; }
  td.status-cell { margin: 11px 0 0 10px; display: inline-block; }
  td.actions-cell { position: absolute; right: 13px; bottom: 12px; }
  .row-actions { background: rgba(255,255,255,.8); }
  .pagination { padding-inline: 18px; }
  .form-dialog form { padding: 24px 20px; }
  .form-grid.two, .form-grid.three { grid-template-columns: 1fr; }
  .form-dialog { max-height: calc(100vh - 24px); overflow-y: auto; }
  footer { min-height: 60px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}
