:root {
  color-scheme: light;
  --bg: #eef3f2;
  --panel: #ffffff;
  --ink: #16323a;
  --muted: #65747a;
  --line: #d6e0df;
  --teal: #0f766e;
  --teal-dark: #0b5750;
  --amber: #b7791f;
  --red: #d71920;
  --green: #4b7f35;
  --blue: #082eea;
  --shadow: 0 18px 44px rgba(22, 50, 58, 0.13);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family:
    "Microsoft JhengHei",
    "PingFang TC",
    "Noto Sans TC",
    system-ui,
    sans-serif;
}

button,
input {
  font: inherit;
}

.app-shell {
  min-height: 100vh;
  padding: 20px;
}

.topbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 20px;
  margin: 0 auto 14px;
  max-width: 1600px;
}

.eyebrow,
.panel-kicker {
  margin: 0 0 4px;
  color: var(--teal);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  line-height: 1.15;
}

h1 {
  font-size: 2.1rem;
}

h2 {
  font-size: 1.35rem;
}

.status-strip {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.status-strip span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 34px;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.78);
  color: var(--muted);
}

.status-strip strong {
  color: var(--ink);
  font-size: 1.1rem;
}

.berth-form input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  outline: none;
  transition:
    border-color 160ms ease,
    box-shadow 160ms ease;
}

.berth-form input {
  height: 44px;
  padding: 0 10px;
}

.berth-form input:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.14);
}

.workbench {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 16px;
  max-width: 1600px;
  margin: 0 auto;
  align-items: start;
}

.map-panel,
.editor-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.map-panel {
  overflow: hidden;
}

.map-scroll {
  overflow: auto;
  padding: 10px;
}

.map-wrap {
  position: relative;
  min-width: 1180px;
  width: 100%;
  margin: 0 auto;
  line-height: 0;
}

.map-wrap img {
  display: block;
  width: 100%;
  height: auto;
  filter: contrast(1.04) saturate(1.03);
  image-rendering: auto;
  user-select: none;
}

.berth-layer {
  position: absolute;
  inset: 0;
  z-index: 2;
}

.berth-button {
  position: absolute;
  width: 5.05%;
  height: 3.05%;
  transform: translate(-50%, -50%);
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--zone-color);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.45rem;
  font-weight: 900;
  letter-spacing: 0;
  line-height: 1;
  overflow: visible;
  padding: 0 5px;
  text-align: center;
  white-space: normal;
  box-shadow: none;
  transition:
    border-color 140ms ease,
    box-shadow 140ms ease,
    transform 140ms ease,
    opacity 140ms ease;
}

.berth-button.side-left.has-vessel {
  --vessel-x-offset: -50%;
  width: 5.5%;
  height: 3.36%;
  transform: translate(-50%, -43%);
}

.berth-button.side-right.has-vessel {
  --vessel-x-offset: -34%;
  width: 5.5%;
  height: 3.36%;
  transform: translate(-34%, -43%);
}

.berth-id {
  display: none;
}

.berth-name {
  display: block;
  width: 100%;
  color: var(--zone-color);
  line-height: 1.05;
  max-height: 2.15em;
  overflow: hidden;
  overflow-wrap: anywhere;
  text-wrap: balance;
}

.berth-button.has-vessel .berth-name {
  font-size: 0.78rem;
}

.berth-button.has-vessel .name-long {
  font-size: 0.68rem;
}

.berth-button.has-vessel .name-very-long {
  font-size: 0.6rem;
}

.berth-button.has-vessel {
  border: 1px solid rgba(255, 255, 255, 0.98);
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.berth-button:hover,
.berth-button:focus-visible {
  border-color: var(--teal);
  box-shadow: 0 0 0 2px rgba(15, 118, 110, 0.2);
  transform: translate(-50%, -50%);
  z-index: 3;
}

.berth-button.side-left.has-vessel:hover,
.berth-button.side-left.has-vessel:focus-visible {
  transform: translate(-50%, -43%);
}

.berth-button.side-right.has-vessel:hover,
.berth-button.side-right.has-vessel:focus-visible {
  transform: translate(-34%, -43%);
}

.berth-button.zone-b.has-vessel {
  transform: translate(var(--vessel-x-offset), -35%);
}

.berth-button.zone-b.has-vessel:hover,
.berth-button.zone-b.has-vessel:focus-visible {
  transform: translate(var(--vessel-x-offset), -35%);
}

.berth-button.zone-c.side-left.has-vessel {
  transform: translate(-50%, -43%);
}

.berth-button.zone-c.side-left.has-vessel:hover,
.berth-button.zone-c.side-left.has-vessel:focus-visible {
  transform: translate(-50%, -43%);
}

.berth-button.is-selected {
  border-color: #111827;
  box-shadow: 0 0 0 2px rgba(17, 24, 39, 0.2);
  z-index: 4;
}

.berth-button.is-due {
  background: transparent;
}

.berth-button.is-expired {
  background: transparent;
}

.berth-button.has-vessel.is-due {
  background: rgba(255, 248, 220, 0.96);
}

.berth-button.has-vessel.is-expired {
  background: rgba(255, 232, 232, 0.96);
}

.berth-button.is-filtered {
  opacity: 0.22;
}

.berth-button.zone-a {
  --zone-color: var(--red);
}

.berth-button.zone-b {
  --zone-color: #f1b600;
}

.berth-button.zone-c {
  --zone-color: var(--green);
}

.berth-button.zone-d {
  --zone-color: var(--blue);
}

.editor-panel {
  position: sticky;
  top: 16px;
  display: grid;
  gap: 18px;
  max-height: calc(100vh - 32px);
  padding: 20px;
  overflow-y: auto;
  scrollbar-gutter: stable;
}

.empty-state {
  display: grid;
  gap: 8px;
  min-height: 160px;
  align-content: start;
  padding: 6px 0;
}

.empty-state p:last-child {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
}

.berth-form {
  display: grid;
  gap: 16px;
}

.berth-detail,
.admin-login,
.admin-edit {
  display: grid;
  gap: 16px;
}

.admin-login,
.admin-edit,
.admin-status {
  margin-top: 0;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.application-info {
  display: grid;
  gap: 14px;
  padding: 20px 2px 4px;
  border-top: 1px solid var(--line);
}

.application-info-head {
  display: flex;
  align-items: center;
  gap: 12px;
}

.application-info-head h2 {
  font-size: 1.08rem;
}

.application-info-head .panel-kicker {
  margin-bottom: 3px;
}

.application-yacht {
  display: grid;
  flex: 0 0 76px;
  width: 76px;
  height: 58px;
  place-items: center;
  border-radius: 8px;
  background: #e7f4f2;
  color: var(--teal-dark);
}

.application-yacht svg {
  width: 66px;
  height: 48px;
}

.application-info-list {
  display: grid;
  gap: 12px;
  margin: 0;
  padding-left: 1.4rem;
  color: var(--ink);
  font-size: 0.92rem;
  line-height: 1.7;
}

.application-info-list li::marker {
  color: var(--teal);
  font-weight: 900;
}

.application-info-list a {
  color: var(--teal-dark);
  font-weight: 850;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

.detail-list {
  display: grid;
  gap: 10px;
  margin: 0;
}

.detail-list div {
  display: grid;
  gap: 4px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fbfb;
}

.detail-list dt {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.detail-list dd {
  margin: 0;
  color: var(--ink);
  font-size: 1rem;
  font-weight: 800;
  overflow-wrap: anywhere;
}

.admin-login label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 800;
}

.admin-login input {
  width: 100%;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 0 10px;
  outline: none;
}

.admin-login input:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.14);
}

.login-note {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
}

.admin-status {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: var(--teal-dark);
  font-weight: 800;
}

.form-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 4px;
}

.zone-pill {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 5px 10px;
  border-radius: 999px;
  background: #e7f4f2;
  color: var(--teal-dark);
  font-weight: 800;
}

.berth-form label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 800;
}

.date-field {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 800;
}

.field-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.date-range {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.date-range label {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.yacht-animation {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  overflow: hidden;
}

.moving-yacht {
  position: absolute;
  left: 5.2%;
  bottom: 3.8%;
  width: 9.2%;
  aspect-ratio: 1 / 1;
  animation: yachtShuttle 24s ease-in-out infinite;
  transform-origin: 50% 70%;
  opacity: 0.96;
}

.yacht-svg {
  display: block;
  width: 100%;
  height: 100%;
  filter: drop-shadow(0 7px 7px rgba(20, 55, 65, 0.2));
}

@keyframes yachtShuttle {
  0% {
    transform: translateX(0) scaleX(1);
  }

  47% {
    transform: translateX(900%) scaleX(1);
  }

  50% {
    transform: translateX(900%) scaleX(-1);
  }

  97% {
    transform: translateX(0) scaleX(-1);
  }

  100% {
    transform: translateX(0) scaleX(1);
  }
}

.form-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.primary-button,
.danger-button,
.ghost-button {
  min-height: 42px;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 850;
  transition:
    transform 120ms ease,
    box-shadow 120ms ease,
    background 120ms ease;
}

.primary-button {
  border: 1px solid var(--teal);
  background: var(--teal);
  color: #fff;
}

.danger-button {
  border: 1px solid #f0b4b4;
  background: #fff1f1;
  color: #a92323;
}

.ghost-button {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  padding: 0 12px;
}

.primary-button:hover,
.danger-button:hover,
.ghost-button:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 18px rgba(22, 50, 58, 0.12);
}

.save-message {
  min-height: 22px;
  margin: 0;
  color: var(--teal-dark);
  font-weight: 800;
}

.tooltip {
  position: fixed;
  z-index: 20;
  max-width: 260px;
  padding: 10px 12px;
  border: 1px solid rgba(17, 24, 39, 0.08);
  border-radius: 8px;
  background: rgba(17, 24, 39, 0.94);
  color: #fff;
  box-shadow: 0 14px 30px rgba(0, 0, 0, 0.25);
  font-size: 0.9rem;
  line-height: 1.5;
  pointer-events: none;
}

.tooltip strong {
  display: block;
  margin-bottom: 4px;
  font-size: 1rem;
}

.tooltip span {
  display: block;
  color: rgba(255, 255, 255, 0.78);
}

@media (max-width: 1100px) {
  .topbar {
    align-items: start;
    flex-direction: column;
  }

  .status-strip {
    justify-content: flex-start;
  }

  .workbench {
    grid-template-columns: 1fr;
  }

  .editor-panel {
    position: static;
    max-height: none;
    overflow: visible;
  }
}

@media (max-width: 680px) {
  .app-shell {
    padding: 12px;
  }

  h1 {
    font-size: 1.45rem;
  }

  .map-wrap {
    min-width: 760px;
  }

  .berth-button {
    font-size: 0.95rem;
  }

  .field-grid,
  .date-range,
  .form-actions {
    grid-template-columns: 1fr;
  }

  .application-info-head {
    align-items: flex-start;
  }
}
