:root {
  --ink: #111820;
  --muted: #69747d;
  --line: #d9e0e5;
  --surface: #ffffff;
  --canvas: #f3f6f8;
  --brand-black: #020407;
  --brand-cream: #ffedd3;
  --accent: #3494d1;
  --accent-dark: #1f6592;
  --amber: #b96d11;
  --red: #b6423b;
  --green: #167a59;
  --blue: #3494d1;
  font-family: "Noto Sans JP", Inter, sans-serif;
  color: var(--ink);
  background: var(--canvas);
  line-height: 1.5;
  letter-spacing: 0;
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; background: var(--canvas); }
a { color: var(--accent-dark); text-decoration: none; }
a:hover { text-decoration: underline; }

.app-header { height: 76px; display: flex; align-items: center; gap: 52px; padding: 0 36px; color: #fff; background: var(--brand-black); border-bottom: 2px solid var(--accent); }
.brand { display: flex; align-items: center; gap: 16px; color: #fff; min-width: 268px; }
.brand:hover { text-decoration: none; }
.brand img { width: 42px; height: 51px; object-fit: contain; }
.product-name strong, .product-name small { display: block; }
.product-name strong { color: var(--brand-cream); font-family: "Zalando Sans Expanded", sans-serif; font-size: 17px; font-weight: 400; }
.product-name small { margin-top: 2px; color: #8f9ba5; font-family: Inter, sans-serif; font-size: 9px; font-weight: 600; text-transform: uppercase; }
.app-header nav { display: flex; align-self: stretch; gap: 34px; overflow-y: hidden; scrollbar-width: none; }
.app-header nav::-webkit-scrollbar { display: none; }
.app-header nav a { display: flex; align-items: center; color: #aeb8c0; font-family: Inter, sans-serif; font-size: 12px; font-weight: 600; border-bottom: 2px solid transparent; margin-bottom: -2px; }
.app-header nav a:hover, .app-header nav a[aria-current="page"] { color: var(--brand-cream); text-decoration: none; border-bottom-color: var(--accent); }
.admin-link { margin-left: auto; color: #d7dde1; font-family: Inter, sans-serif; font-size: 12px; }
.admin-link span { margin-right: 7px; color: #6f7b85; font-size: 9px; text-transform: uppercase; }
.auth-actions { margin-left: auto; min-width: 0; display: flex; align-items: center; gap: 18px; color: #d7dde1; font-size: 12px; }
.auth-actions > span { max-width: 190px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.auth-actions .admin-link { margin-left: 0; }
.auth-actions form { margin: 0; }
.auth-logout { padding: 4px 0; border: 0; color: #d7dde1; background: transparent; cursor: pointer; font: inherit; }
.auth-logout:hover { color: #fff; }
.auth-shell h1 { margin-bottom: 18px; }
.auth-shell .data-form p { margin: 0 0 14px; }
.auth-shell .data-form label { display: block; margin-bottom: 5px; }
.auth-shell .data-form input { width: 100%; }

@media (max-width: 600px) {
  .auth-actions { width: 100%; margin-left: 0; justify-content: flex-end; gap: 12px; }
  .auth-actions > span { max-width: min(55vw, 190px); }
}

.page-shell { width: min(1440px, 100%); margin: 0 auto; padding: 36px 40px 64px; }
.page-heading { margin-bottom: 28px; }
.page-heading.compact { margin-bottom: 22px; }
.page-heading h1 { margin: 4px 0 7px; font-family: "Zalando Sans Expanded", "Noto Sans JP", sans-serif; font-size: clamp(27px, 3vw, 40px); line-height: 1.14; font-weight: 400; }
.page-heading p:not(.eyebrow) { margin: 0; color: var(--muted); }
.heading-actions { display: flex; justify-content: space-between; align-items: end; gap: 20px; }
.eyebrow { margin: 0; color: var(--accent-dark); font-family: "Zalando Sans Expanded", Inter, sans-serif; font-size: 10px; font-weight: 600; letter-spacing: 1.2px; }
.muted { color: var(--muted); font-size: 12px; }

.button { display: inline-flex; min-height: 40px; align-items: center; justify-content: center; padding: 8px 16px; border: 1px solid transparent; border-radius: 2px; font: inherit; font-size: 12px; font-weight: 600; cursor: pointer; white-space: nowrap; }
.button:hover { text-decoration: none; }
.button.primary { color: #fff; background: var(--accent-dark); border-color: var(--accent-dark); }
.button.primary:hover { background: var(--accent-dark); }
.button.secondary { color: var(--ink); background: #fff; border-color: #cbd2d0; }
.button.ghost { color: var(--muted); background: transparent; }
.action-group { display: flex; flex-wrap: wrap; gap: 8px; }

.messages { position: fixed; z-index: 1000; top: 76px; right: 20px; display: grid; gap: 8px; max-width: 420px; }
.message { padding: 12px 16px; background: #fff; border-left: 4px solid var(--accent); box-shadow: 0 8px 30px #13201d2b; font-size: 13px; }
.message.warning { border-color: var(--amber); }

.metric-strip { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); border: 1px solid var(--line); border-top: 2px solid var(--brand-black); background: var(--surface); margin-bottom: 24px; }
.metric-strip > div { display: flex; align-items: baseline; justify-content: space-between; padding: 16px 20px; border-right: 1px solid var(--line); }
.metric-strip > div:last-child { border-right: 0; }
.metric-strip span { color: var(--muted); font-size: 12px; }
.metric-strip strong { font-size: 25px; font-weight: 650; }
.status-green { color: var(--green); }
.status-amber { color: var(--amber); }

.split-layout { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(320px, .7fr); gap: 24px; }
.dashboard-main { min-height: 410px; }
.map-panel, .vehicle-panel { min-width: 0; background: var(--surface); border: 1px solid var(--line); border-top: 2px solid var(--brand-black); }
.section-heading { display: flex; align-items: end; justify-content: space-between; gap: 16px; margin-bottom: 15px; }
.map-panel .section-heading, .vehicle-panel .section-heading { padding: 18px 20px 0; }
.section-heading h2 { margin: 3px 0 0; font-family: "Zalando Sans Expanded", "Noto Sans JP", sans-serif; font-size: 17px; font-weight: 500; }
.section-heading > a { font-size: 12px; font-weight: 600; }
#fleet-map { height: 342px; background: #dfe7e4; }
.vehicle-stack { border-top: 1px solid var(--line); }
.vehicle-row { display: grid; grid-template-columns: 10px 1fr auto; gap: 12px; align-items: center; min-height: 70px; padding: 10px 18px; color: var(--ink); border-bottom: 1px solid var(--line); }
.vehicle-row:hover { text-decoration: none; background: #f8faf9; }
.vehicle-name strong, .vehicle-name small, .vehicle-meta strong, .vehicle-meta small { display: block; }
.vehicle-name strong, .vehicle-meta strong { font-size: 12px; }
.vehicle-name small, .vehicle-meta small { margin-top: 3px; color: var(--muted); font-size: 10px; }
.vehicle-meta { text-align: right; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: #9ca5a3; }
.status-in_operation, .status-ready, .status-completed { background: var(--green); }
.status-maintenance, .status-planned { background: var(--amber); }
.status-grounded, .status-cancelled { background: var(--red); }
.status-in_progress { background: var(--blue); }

.content-section { margin-top: 28px; padding: 22px; background: var(--surface); border: 1px solid var(--line); border-top: 2px solid var(--brand-black); }
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-top: 2px solid var(--brand-black); }
.content-section .table-wrap { border: 0; margin: 0 -22px -22px; }
table { width: 100%; border-collapse: collapse; font-size: 12px; }
th { padding: 10px 14px; text-align: left; color: #56636d; background: #eef3f6; border-bottom: 1px solid var(--line); font-family: Inter, sans-serif; font-size: 9px; font-weight: 700; text-transform: uppercase; }
td { padding: 13px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #fafcfb; }
.empty-cell, .empty-state { color: var(--muted); text-align: center; padding: 30px; }
.empty-state.prominent { border: 1px dashed #bac5c2; background: #f8faf9; }
.cell-note { display: block; margin-top: 2px; color: var(--muted); }
.status-label { display: inline-flex; align-items: center; min-height: 24px; padding: 3px 8px; border-radius: 3px; color: #495351; background: #edf0ef; font-size: 10px; font-weight: 700; }
.status-label.status-ready, .status-label.status-completed, .status-label.status-in_operation { color: #0d6549; background: #dcefe8; }
.status-label.status-maintenance, .status-label.status-planned { color: #8f5107; background: #f8ead6; }
.status-label.status-grounded, .status-label.status-cancelled { color: #92342f; background: #f8dfdd; }
.status-label.status-in_progress { color: #1f578e; background: #ddeaf6; }

.filter-bar { display: grid; grid-template-columns: minmax(240px, 1fr) 220px auto; gap: 12px; align-items: end; margin-bottom: 18px; padding: 14px; background: #e9edeb; border: 1px solid #d7ddda; }
.filter-bar label span { display: block; margin-bottom: 4px; color: var(--muted); font-size: 10px; font-weight: 700; text-transform: uppercase; }
input, select, textarea { width: 100%; min-height: 40px; padding: 8px 10px; color: var(--ink); background: #fff; border: 1px solid #bfc8c5; border-radius: 3px; font: inherit; font-size: 13px; }
textarea { min-height: 96px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid #7dcabd; outline-offset: 1px; border-color: var(--accent); }

.breadcrumbs { display: flex; gap: 8px; margin-bottom: 20px; color: var(--muted); font-size: 11px; }
.detail-band { display: grid; grid-template-columns: repeat(4, 1fr); background: var(--brand-black); color: #fff; border-top: 2px solid var(--accent); }
.detail-band > div { padding: 16px 20px; border-right: 1px solid #303941; }
.detail-band > div:last-child { border-right: 0; }
.detail-band span:first-child { display: block; margin-bottom: 5px; color: #aeb8b6; font-size: 10px; text-transform: uppercase; }
.detail-band strong { color: var(--brand-cream); font-size: 13px; }
.trace-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0; border: 1px solid var(--line); }
.trace-grid article { min-width: 0; padding: 18px; border-right: 1px solid var(--line); }
.trace-grid article:last-child { border-right: 0; }
.trace-grid h3 { margin: 0 0 15px; font-size: 13px; }
dl { margin: 0; }
dl > div { display: grid; grid-template-columns: 86px 1fr; gap: 10px; margin-bottom: 8px; font-size: 11px; }
dt { color: var(--muted); }
dd { margin: 0; overflow-wrap: anywhere; }
.component-list { list-style: none; margin: 0; padding: 0; }
.component-list li { padding: 9px 0; border-top: 1px solid var(--line); }
.component-list li:first-child { border-top: 0; padding-top: 0; }
.component-list strong, .component-list span { display: block; font-size: 11px; overflow-wrap: anywhere; }
.component-list span { margin-top: 2px; color: var(--muted); }
.mono { font-family: Consolas, monospace; }
.hash { max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.configuration-reason { margin: 14px 0 0; font-size: 12px; }
.configuration-reason span { margin-right: 12px; color: var(--muted); }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { display: grid; grid-template-columns: 150px 18px 1fr; gap: 10px; padding-bottom: 20px; position: relative; }
.timeline li::before { content: ""; grid-column: 2; grid-row: 1; width: 9px; height: 9px; margin: 5px auto 0; border-radius: 50%; background: var(--accent); z-index: 1; }
.timeline li::after { content: ""; position: absolute; left: 168px; top: 14px; bottom: -5px; width: 1px; background: var(--line); }
.timeline li:last-child::after { display: none; }
.timeline time { color: var(--muted); font-size: 11px; text-align: right; }
.timeline strong, .timeline p, .timeline small { display: block; margin: 0; font-size: 11px; }
.timeline p { margin-top: 3px; }
.timeline small { margin-top: 3px; color: var(--muted); }

.form-shell { width: min(720px, 100%); margin: 0 auto; }
.configuration-form-shell { width: min(900px, 100%); }
.data-form { padding: 24px; background: #fff; border: 1px solid var(--line); border-top: 2px solid var(--brand-black); }
.field { margin-bottom: 18px; }
.field > label { display: flex; justify-content: space-between; margin-bottom: 6px; font-size: 12px; font-weight: 600; }
.field > small { display: block; margin-top: 5px; color: var(--muted); font-size: 10px; }
.required { color: var(--red); font-size: 9px; font-weight: 600; }
.field-error, .errorlist { color: var(--red); font-size: 11px; }
.errorlist { margin: 5px 0; padding-left: 18px; }
.form-errors { margin-bottom: 18px; padding: 12px; background: #f8dfdd; border-left: 3px solid var(--red); }
.field ul { list-style: none; margin: 0; padding: 5px 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 5px; }
.field ul label { display: flex; align-items: start; gap: 8px; padding: 7px 9px; border: 1px solid var(--line); font-size: 11px; }
.field ul input { width: 15px; min-height: 15px; margin: 1px 0 0; }
.assignment-fieldset { margin: 4px 0 24px; padding: 18px; border: 1px solid var(--line); }
.assignment-fieldset legend { padding: 0 8px; font-size: 13px; font-weight: 600; }
.assignment-help { margin: 0 0 14px; color: var(--muted); font-size: 11px; }
.assignment-rows { display: grid; gap: 10px; margin-bottom: 12px; }
.assignment-row { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr) auto; gap: 12px; align-items: end; padding: 14px; background: #f8faf9; border: 1px solid var(--line); }
.assignment-row > input[type="checkbox"] { display: none; }
.assignment-row.is-deleted { display: none; }
.assignment-row .field { margin-bottom: 0; }
.assignment-arrow { padding-bottom: 10px; color: var(--muted); }
.assignment-remove { min-height: 40px; padding: 8px 4px; color: var(--red); background: transparent; border: 0; font: inherit; font-size: 11px; cursor: pointer; }
.form-actions { display: flex; justify-content: flex-end; gap: 8px; padding-top: 18px; border-top: 1px solid var(--line); }

.registry-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); border: 1px solid var(--line); border-top: 2px solid var(--brand-black); background: #fff; }
.registry-grid section { padding: 24px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.registry-grid section:nth-child(2n) { border-right: 0; }
.registry-grid section:nth-last-child(-n + 2) { border-bottom: 0; }
.registry-grid h2 { margin: 2px 0 20px; font-size: 20px; }
.registry-counts { display: flex; gap: 24px; margin-bottom: 20px; }
.registry-counts span { color: var(--muted); font-size: 11px; }
.registry-counts strong { display: block; margin-top: 2px; color: var(--ink); font-size: 24px; }
.admin-callout { padding: 14px 18px; background: #e6edeb; font-size: 12px; }

@media (max-width: 900px) {
  .app-header { padding: 0 18px; gap: 20px; }
  .brand { min-width: 0; }
  .product-name { display: none; }
  .app-header nav { gap: 16px; overflow-x: auto; }
  .page-shell { padding: 24px 18px 48px; }
  .split-layout { grid-template-columns: 1fr; }
  .metric-strip { grid-template-columns: repeat(2, 1fr); }
  .metric-strip > div:nth-child(2) { border-right: 0; }
  .metric-strip > div:nth-child(-n + 2) { border-bottom: 1px solid var(--line); }
  .trace-grid { grid-template-columns: 1fr; }
  .trace-grid article { border-right: 0; border-bottom: 1px solid var(--line); }
  .trace-grid article:last-child { border-bottom: 0; }
}

@media (max-width: 620px) {
  .app-header { height: auto; min-height: 72px; flex-wrap: wrap; padding: 8px 18px 0; }
  .app-header nav { order: 3; width: 100%; height: 42px; }
  .admin-link { margin-left: auto; }
  .heading-actions { align-items: stretch; flex-direction: column; }
  .action-group { width: 100%; }
  .action-group .button { flex: 1; }
  .metric-strip, .detail-band, .registry-grid { grid-template-columns: 1fr; }
  .metric-strip > div, .detail-band > div, .registry-grid section { border-right: 0; border-bottom: 1px solid var(--line); }
  .metric-strip > div:last-child, .detail-band > div:last-child, .registry-grid section:last-child { border-bottom: 0; }
  .filter-bar { grid-template-columns: 1fr; }
  .field ul { grid-template-columns: 1fr; }
  .assignment-row { grid-template-columns: 1fr auto; }
  .assignment-row .field { grid-column: 1 / -1; }
  .assignment-arrow { display: none; }
  .timeline li { grid-template-columns: 92px 14px 1fr; }
  .timeline li::after { left: 103px; }
}
