:root {
  --ink: #172129;
  --muted: #65747b;
  --paper: #eef2f1;
  --surface: #ffffff;
  --line: #d8e0de;
  --navy: #102e35;
  --teal: #19766f;
  --teal-soft: #e2f1ee;
  --orange: #b96635;
  --red: #b54543;
}

* { 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; }

.admin-header { min-height: 68px; padding: 0 max(24px, calc((100vw - 1500px) / 2)); display: flex; align-items: center; justify-content: space-between; color: white; background: var(--navy); }
.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; }
.header-actions { display: flex; align-items: center; gap: 22px; }
.environment { display: flex; align-items: center; gap: 7px; color: #b8c7c9; font-size: 10px; letter-spacing: .06em; }
.environment i { width: 7px; height: 7px; border-radius: 50%; background: #6ed09f; box-shadow: 0 0 0 4px rgba(110,208,159,.12); }
.back-link { color: white; font-size: 11px; text-decoration: none; border-bottom: 1px solid #6f8589; }

main { width: min(1500px, calc(100% - 48px)); margin: 0 auto 60px; }
.intro { padding: 36px 2px 24px; display: flex; align-items: end; justify-content: space-between; gap: 20px; }
.eyebrow { margin: 0 0 7px; color: var(--teal); font-size: 10px; font-weight: 700; letter-spacing: .16em; }
.intro h1 { margin: 0; font-size: 30px; letter-spacing: -.04em; }
.intro p:not(.eyebrow) { margin: 8px 0 0; color: var(--muted); font-size: 12px; }
.intro-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.primary-button, .secondary-button, .danger-button { padding: 10px 14px; border-radius: 8px; font-weight: 600; font-size: 11px; cursor: pointer; }
.primary-button { color: white; background: var(--teal); border: 1px solid var(--teal); }
.secondary-button { background: white; border: 1px solid var(--line); }
.danger-button { color: white; background: var(--red); border: 1px solid var(--red); }
button:disabled { opacity: .45; cursor: wait; }

.test-notice { margin-bottom: 14px; padding: 11px 15px; display: flex; gap: 12px; align-items: center; border: 1px solid #e5c8b2; border-radius: 9px; background: #fff8ef; color: #72513c; font-size: 11px; }
.test-notice strong { color: var(--orange); }

.summary-grid { display: grid; grid-template-columns: repeat(4, minmax(130px, 1fr)) minmax(220px, 1.4fr); gap: 9px; margin-bottom: 14px; }
.summary-grid article { min-height: 91px; padding: 17px 18px; background: white; border: 1px solid var(--line); border-radius: 10px; }
.summary-grid article > span { display: block; color: var(--muted); font-size: 10px; }
.summary-grid strong { display: inline-block; margin-top: 7px; font-size: 25px; line-height: 1; }
.summary-grid small { margin-left: 5px; color: #93a0a4; font-size: 8px; text-transform: uppercase; }
.summary-grid .last-update { background: #173b43; color: white; border-color: #173b43; }
.summary-grid .last-update span { color: #b8cbcd; }
.summary-grid .last-update strong { display: block; margin-top: 12px; font-size: 14px; font-variant-numeric: tabular-nums; }

.database-panel { overflow: hidden; background: white; border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 14px 35px rgba(20,50,53,.07); }
.panel-heading { padding: 21px 22px 14px; display: flex; justify-content: space-between; align-items: end; }
.panel-heading h2 { margin: 0; font-size: 18px; }
.panel-heading > span { color: var(--muted); font-size: 10px; }
.toolbar { padding: 0 22px 17px; display: grid; grid-template-columns: minmax(220px, 1.4fr) repeat(4, minmax(115px, .55fr)) auto; gap: 8px; align-items: end; }
.toolbar label > span { display: block; margin-bottom: 5px; color: var(--muted); font-size: 9px; }
.toolbar input, .toolbar select { width: 100%; height: 38px; padding: 0 9px; border: 1px solid var(--line); border-radius: 7px; background: #f8faf9; color: var(--ink); outline: none; font-size: 11px; }
.toolbar input:focus, .toolbar select:focus { border-color: var(--teal); box-shadow: 0 0 0 3px rgba(25,118,111,.09); background: white; }
.text-button { height: 38px; padding: 0 5px; border: 0; background: transparent; color: var(--muted); text-decoration: underline; font-size: 10px; cursor: pointer; }
.message { min-height: 24px; padding: 0 22px 8px; color: var(--teal); font-size: 10px; }
.message.error { color: var(--red); }

.table-wrap { max-height: 62vh; overflow: auto; border-top: 1px solid var(--line); }
table { width: 100%; min-width: 1900px; border-collapse: separate; border-spacing: 0; }
th { position: sticky; top: 0; z-index: 2; padding: 9px 10px; color: #6d7b81; background: #f4f7f6; border-bottom: 1px solid var(--line); text-align: left; font-size: 9px; letter-spacing: .04em; white-space: nowrap; }
th small { color: var(--teal); font-size: 7px; }
td { padding: 10px; border-bottom: 1px solid #edf1f0; vertical-align: middle; font-size: 10px; white-space: nowrap; }
tbody tr:hover td { background: #f9fbfa; }
tbody tr.cancelled td { color: #8c9699; background: #fdf9f9; }
.id-cell strong { color: var(--teal); font-size: 12px; }
.name-cell { font-weight: 600; }
.route-badge, .status-badge { display: inline-block; padding: 4px 6px; border-radius: 5px; font-weight: 600; }
.route-badge { color: #176c67; background: var(--teal-soft); }
.status-badge { color: var(--teal); background: #e5f3ef; }
.status-badge.cancelled { color: var(--red); background: #f7e5e3; }
.note-cell { max-width: 180px; overflow: hidden; text-overflow: ellipsis; }
.timestamp { color: var(--muted); font-variant-numeric: tabular-nums; }
.timestamp.modified { color: var(--orange); font-weight: 600; }
.actions-cell { position: sticky; right: 0; z-index: 1; background: white; box-shadow: -5px 0 8px rgba(25,45,48,.04); }
.cancelled .actions-cell { background: #fdf9f9; }
.actions-cell button { padding: 5px 7px; border: 0; border-radius: 5px; color: var(--teal); background: var(--teal-soft); font-size: 9px; cursor: pointer; }
.actions-cell button.delete { color: var(--red); background: #f8e9e7; }
.empty-state { padding: 55px; color: var(--muted); text-align: center; font-size: 12px; }
.pagination { padding: 13px 22px; display: flex; justify-content: flex-end; align-items: center; gap: 14px; color: var(--muted); font-size: 10px; }
.pagination button { padding: 7px 10px; border: 1px solid var(--line); border-radius: 6px; background: white; font-size: 10px; cursor: pointer; }

dialog { color: var(--ink); background: white; border: 1px solid var(--line); border-radius: 13px; box-shadow: 0 25px 70px rgba(11,35,39,.24); }
dialog::backdrop { background: rgba(10,31,35,.5); backdrop-filter: blur(3px); }
.edit-dialog { width: min(720px, calc(100% - 30px)); padding: 0; }
.edit-dialog form { padding: 26px 28px; }
.dialog-header { display: flex; justify-content: space-between; margin-bottom: 20px; }
.dialog-header h2 { margin: 0; font-size: 20px; }
.close-button { width: 32px; height: 32px; border: 1px solid var(--line); border-radius: 50%; background: white; color: var(--muted); font-size: 18px; cursor: pointer; }
.form-grid { display: grid; gap: 12px; margin-top: 14px; }
.form-grid.two { grid-template-columns: 1fr 1fr; }
.form-grid.three { grid-template-columns: .65fr 1fr 1fr; }
.edit-dialog label { color: #48585e; font-size: 10px; font-weight: 600; }
.edit-dialog label em { float: right; color: var(--orange); font-size: 8px; font-style: normal; }
.edit-dialog input, .edit-dialog select { width: 100%; height: 39px; margin-top: 6px; padding: 0 9px; border: 1px solid var(--line); border-radius: 7px; background: #fafbfa; outline: none; font-size: 11px; }
fieldset { margin: 15px 0 0; padding: 11px 13px 14px; border: 1px solid var(--line); border-radius: 9px; }
legend { padding: 0 6px; color: var(--teal); font-size: 9px; font-weight: 700; }
.dialog-actions { margin-top: 21px; display: flex; justify-content: flex-end; gap: 8px; }
.delete-dialog { width: min(420px, calc(100% - 30px)); padding: 28px; text-align: center; }
.delete-dialog h2 { margin: 0; font-size: 18px; }
.delete-dialog p { color: var(--muted); font-size: 11px; }
.delete-dialog .delete-warning { color: var(--red); }
.delete-dialog .dialog-actions { justify-content: center; }
.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; }

@media (max-width: 1050px) {
  .summary-grid { grid-template-columns: repeat(4, 1fr); }
  .summary-grid .last-update { grid-column: 1 / -1; min-height: 70px; }
  .toolbar { grid-template-columns: repeat(3, 1fr); }
  .search-field { grid-column: 1 / -1; }
}

@media (max-width: 680px) {
  .admin-header, .intro { align-items: flex-start; }
  .admin-header { padding: 16px; }
  .environment { display: none; }
  main { width: calc(100% - 24px); }
  .intro { padding-top: 26px; flex-direction: column; }
  .intro-actions { justify-content: flex-start; }
  .test-notice { align-items: flex-start; flex-direction: column; gap: 3px; }
  .summary-grid { grid-template-columns: 1fr 1fr; }
  .summary-grid .last-update { grid-column: 1 / -1; }
  .toolbar { grid-template-columns: 1fr 1fr; padding-inline: 15px; }
  .search-field { grid-column: 1 / -1; }
  .panel-heading, .message, .pagination { padding-inline: 15px; }
  .form-grid.two, .form-grid.three { grid-template-columns: 1fr; }
  .edit-dialog { max-height: calc(100vh - 20px); overflow-y: auto; }
}
