:root {
  color-scheme: light;
  --ink: #17212b;
  --muted: #637181;
  --line: #d5dce3;
  --line-strong: #aab5c0;
  --surface: #ffffff;
  --subtle: #f5f7f9;
  --navy: #173b57;
  --navy-dark: #0d2a40;
  --blue-light: #eaf2f8;
  --green: #176b45;
  --green-light: #e7f4ed;
  --amber: #8b5a00;
  --amber-light: #fff3d7;
  --red: #9e2f2f;
  --red-light: #fbeaea;
  --shadow: 0 12px 34px rgba(21, 39, 55, .09);
  font-family: "Yu Gothic UI", "Yu Gothic", "Noto Sans JP", system-ui, sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; color: var(--ink); background: var(--subtle); }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
a { color: var(--navy); }

.login-page { display: grid; place-items: center; padding: 24px; background: #eef2f5; }
.login-shell { width: min(920px, 100%); min-height: 520px; display: grid; grid-template-columns: 1.25fr .75fr; background: var(--surface); box-shadow: var(--shadow); border: 1px solid var(--line); }
.login-panel { padding: 64px 72px; }
.login-aside { padding: 64px 44px; background: var(--navy-dark); color: #fff; }
.login-brand { display: flex; align-items: center; gap: 12px; margin: 0 0 18px; }
.login-logo { width: 42px; height: 42px; object-fit: contain; flex: 0 0 auto; }
.eyebrow { margin: 0; color: var(--navy); font-weight: 700; letter-spacing: .05em; }
.login-panel h1 { margin: 0; max-width: 520px; font-size: clamp(28px, 4vw, 42px); line-height: 1.25; letter-spacing: -.02em; }
.login-copy { margin: 20px 0 32px; color: var(--muted); line-height: 1.8; }
.login-aside h2 { margin: 0 0 28px; font-size: 18px; }
.role-list { margin: 0; }
.role-list div { padding: 20px 0; border-top: 1px solid rgba(255,255,255,.2); }
.role-list dt { margin-bottom: 5px; font-weight: 700; }
.role-list dd { margin: 0; color: #c9d7e2; font-size: 14px; }
.fine-print { margin: 24px 0 0; color: var(--muted); font-size: 12px; }

.form-stack { display: grid; gap: 18px; }
label { display: grid; gap: 7px; font-size: 13px; font-weight: 700; color: #344250; }
input, select, textarea { width: 100%; min-height: 44px; padding: 9px 11px; border: 1px solid var(--line-strong); border-radius: 3px; background: #fff; color: var(--ink); }
textarea { min-height: 84px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 3px solid rgba(43, 112, 157, .18); border-color: #2b709d; }
.form-error { min-height: 18px; margin: -4px 0; color: var(--red); font-size: 13px; }

.button { display: inline-flex; align-items: center; justify-content: center; min-height: 42px; padding: 8px 16px; border: 1px solid var(--navy); border-radius: 3px; background: #fff; color: var(--navy); font-weight: 700; text-decoration: none; }
.button.primary { background: var(--navy); color: #fff; }
.button.primary:hover { background: var(--navy-dark); }
.button.secondary { border-color: var(--line-strong); color: var(--ink); }
.button.danger { border-color: var(--red); color: var(--red); }
.button.ghost { border-color: transparent; background: transparent; }
.button.small { min-height: 34px; padding: 5px 10px; font-size: 13px; }
.button:disabled { cursor: not-allowed; opacity: .5; }

.app-header { position: sticky; top: 0; z-index: 10; height: 68px; display: flex; align-items: center; justify-content: space-between; padding: 0 28px; background: var(--surface); border-bottom: 1px solid var(--line); }
.app-identity { display: flex; align-items: center; gap: 11px; min-width: 0; }
.app-logo { width: 36px; height: 36px; object-fit: contain; flex: 0 0 auto; }
.app-name { margin: 0; font-weight: 800; letter-spacing: .02em; }
.user-label { margin: 3px 0 0; color: var(--muted); font-size: 12px; }
.header-actions { display: flex; align-items: center; gap: 4px; }
.app-layout { min-height: calc(100vh - 68px); display: grid; grid-template-columns: 210px 1fr; }
.navigation { padding: 22px 14px; background: #f9fafb; border-right: 1px solid var(--line); }
.navigation button { width: 100%; padding: 11px 12px; border: 0; border-left: 3px solid transparent; background: transparent; color: #40505f; text-align: left; font-weight: 700; }
.navigation button:hover, .navigation button.active { border-left-color: var(--navy); background: var(--blue-light); color: var(--navy); }
.main-content { width: min(1220px, 100%); padding: 34px 42px 64px; }
.page-header { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 22px; }
.page-header h1 { margin: 0; font-size: 25px; }
.page-header p { margin: 6px 0 0; color: var(--muted); }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }
.section { margin-top: 26px; padding-top: 22px; border-top: 1px solid var(--line); }
.section h2 { margin: 0 0 14px; font-size: 17px; }
.section-note { margin: -6px 0 16px; color: var(--muted); font-size: 13px; }
.summary-strip { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); border: 1px solid var(--line); background: var(--surface); }
.summary-item { padding: 15px 18px; border-right: 1px solid var(--line); }
.summary-item:last-child { border-right: 0; }
.summary-item span { display: block; color: var(--muted); font-size: 12px; }
.summary-item strong { display: block; margin-top: 4px; font-size: 20px; }

.table-wrap { overflow-x: auto; border: 1px solid var(--line); background: #fff; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { padding: 11px 12px; border-bottom: 1px solid var(--line-strong); background: #eef2f5; color: #31404e; text-align: left; white-space: nowrap; }
td { padding: 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #fafcfd; }
.numeric { text-align: right; }
.nowrap { white-space: nowrap; }
.empty { padding: 34px; color: var(--muted); text-align: center; }

.status { display: inline-flex; align-items: center; min-height: 25px; padding: 2px 9px; border-radius: 999px; background: #edf1f4; color: #40505f; font-size: 12px; font-weight: 700; white-space: nowrap; }
.status-VESSEL_WAITING { background: var(--amber-light); color: var(--amber); }
.status-VESSEL_INPUT { background: var(--blue-light); color: #1b5f8e; }
.status-VESSEL_SUBMITTED, .status-ADMIN_CONFIRMED { background: var(--green-light); color: var(--green); }
.status-FINALIZED { background: #e8ebee; color: #273540; }

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px 22px; }
.form-grid .wide { grid-column: 1 / -1; }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 22px; }
.stops-editor { display: grid; gap: 10px; }
.stop-row { display: grid; grid-template-columns: 54px 1fr 1fr auto; gap: 10px; align-items: end; padding: 12px; border: 1px solid var(--line); background: var(--subtle); }
.stop-number { align-self: center; color: var(--muted); font-weight: 700; text-align: center; }

.voyage-lead { padding: 18px 20px; border-left: 4px solid var(--navy); background: #fff; }
.voyage-lead h1 { margin: 0 0 6px; font-size: 24px; }
.voyage-lead p { margin: 0; color: var(--muted); }
.input-blocks { display: grid; gap: 14px; }
.input-block { padding: 18px; border: 1px solid var(--line); background: #fff; }
.input-block-header { display: flex; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.input-block-header h3 { margin: 0; font-size: 16px; }
.input-block-header span { color: var(--muted); font-size: 12px; }
.event-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.datetime-control { display: grid; grid-template-columns: 76px auto minmax(76px, 1fr) auto minmax(92px, 1fr); align-items: center; gap: 4px; margin-top: 5px; }
.datetime-control input { min-width: 0; padding: 9px 7px; }
.datetime-control span { color: var(--muted); font-size: 12px; white-space: nowrap; }
.fuel-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.help { margin: 6px 0 0; color: var(--muted); font-size: 12px; font-weight: 400; }
.audit-list { margin: 0; padding: 0; list-style: none; }
.audit-list li { padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 13px; }
.audit-list time { color: var(--muted); }
.warning { padding: 12px 14px; border-left: 3px solid var(--amber); background: var(--amber-light); color: #654400; font-size: 13px; }
.loading { color: var(--muted); }
.toast { position: fixed; right: 22px; bottom: 22px; z-index: 20; max-width: 360px; padding: 12px 16px; border-radius: 3px; background: var(--navy-dark); color: #fff; box-shadow: var(--shadow); transform: translateY(120px); opacity: 0; transition: .2s ease; }
.toast.show { transform: translateY(0); opacity: 1; }

@media (max-width: 820px) {
  .login-page { padding: 0; }
  .login-shell { min-height: 100vh; grid-template-columns: 1fr; }
  .login-panel { padding: 44px 24px; }
  .login-aside { padding: 34px 24px; }
  .app-header { height: 62px; padding: 0 16px; }
  .header-actions { gap: 0; }
  .header-actions .button { padding-inline: 7px; }
  .app-layout { display: block; min-height: calc(100vh - 62px); }
  .navigation { position: sticky; top: 62px; z-index: 9; display: flex; gap: 2px; overflow-x: auto; padding: 7px 8px; border-right: 0; border-bottom: 1px solid var(--line); }
  .navigation button { flex: 0 0 auto; width: auto; padding: 9px 12px; border-left: 0; border-bottom: 3px solid transparent; white-space: nowrap; }
  .navigation button.active { border-left-color: transparent; border-bottom-color: var(--navy); }
  .main-content { padding: 24px 16px 90px; }
  .page-header { align-items: flex-start; flex-direction: column; }
  .summary-strip { grid-template-columns: repeat(2, 1fr); }
  .summary-item:nth-child(2) { border-right: 0; }
  .summary-item:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
  .form-grid, .event-grid, .fuel-grid { grid-template-columns: 1fr; }
  .datetime-control { grid-template-columns: 68px auto minmax(68px, 1fr) auto minmax(86px, 1fr); }
  .stop-row { grid-template-columns: 40px 1fr; }
  .stop-row label { grid-column: 2; }
  .stop-row .button { grid-column: 2; justify-self: start; }
  .form-actions { position: sticky; bottom: 0; z-index: 5; margin: 22px -16px -24px; padding: 12px 16px; background: rgba(255,255,255,.96); border-top: 1px solid var(--line); }
  .form-actions .button { flex: 1; }
  .desktop-only { display: none; }
  .voyage-table, .voyage-table tbody, .voyage-table tr, .voyage-table td { display: block; width: 100%; }
  .voyage-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .voyage-table tbody { padding: 0 14px; }
  .voyage-table tr { margin: 14px 0; padding: 12px 0; border: 1px solid var(--line); background: #fff; }
  .voyage-table td { display: grid; grid-template-columns: 86px 1fr; gap: 10px; padding: 7px 12px; border: 0; }
  .voyage-table td::before { content: attr(data-label); color: var(--muted); font-size: 12px; font-weight: 700; }
  .voyage-table .row-action { display: block; padding-top: 12px; }
  .voyage-table .row-action::before { display: none; }
  .voyage-table .row-action .button { width: 100%; }
}
