:root {
  --bg: #0d1117;
  --bg-panel: #161b22;
  --bg-panel-alt: #0f141b;
  --border: #30363d;
  --text: #c9d1d9;
  --muted: #8b949e;
  --accent: #1f6feb;
  --ok: #2ea043;
  --warning: #d29922;
  --critical: #f85149;
  --radius: 12px;
  --shadow: 0 18px 40px rgba(0, 0, 0, 0.26);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

.login-body {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.portal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
  background: #0f141b;
}

.header-left,
.header-right {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand-copy {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-width: 0;
}

.brand-logo {
  width: 40px;
  height: 40px;
  object-fit: contain;
  flex: 0 0 auto;
}

.brand-wordmark {
  display: block;
  width: 190px;
  max-width: 100%;
  height: auto;
}

.brand-name {
  font-size: 28px;
  font-weight: 600;
}

.brand-sub {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

.header-chip {
  padding: 7px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-panel);
  font-size: 13px;
  font-weight: 600;
}

.header-chip-muted {
  color: var(--muted);
  font-weight: 500;
}

.header-action-btn {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: rgba(13, 17, 23, 0.92);
  color: var(--text);
  font: inherit;
  cursor: pointer;
  transition: border-color 120ms ease, background-color 120ms ease;
}

.header-action-btn:hover {
  border-color: var(--accent);
  background: rgba(31, 111, 235, 0.12);
}

.header-chip-error {
  color: var(--critical);
  border-color: rgba(248, 81, 73, 0.42);
  background: rgba(248, 81, 73, 0.12);
}

.header-parent-brand {
  width: 210px;
  max-width: 28vw;
  height: auto;
  opacity: 0.9;
}

.portal-shell {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr) 360px;
  gap: 16px;
  padding: 16px;
  min-height: calc(100vh - 79px);
  align-items: start;
}

.login-shell {
  width: min(100%, 440px);
}

.login-panel {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: linear-gradient(180deg, var(--bg-panel) 0%, var(--bg-panel-alt) 100%);
  box-shadow: var(--shadow);
  padding: 28px;
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.login-intro {
  margin-top: 16px;
  color: var(--muted);
  line-height: 1.5;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 18px;
}

.field-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
}

.field-input {
  width: 100%;
  padding: 11px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #0d1117;
  color: var(--text);
  font: inherit;
}

.field-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(31, 111, 235, 0.18);
}

.primary-btn {
  display: inline-block;
  padding: 10px 14px;
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  border: 0;
}

.primary-btn:hover {
  background: #388bfd;
}

.login-submit {
  margin-top: 8px;
  cursor: pointer;
}

.login-error {
  margin-top: 16px;
  padding: 12px 14px;
  border: 1px solid rgba(248, 81, 73, 0.42);
  border-radius: 12px;
  background: rgba(248, 81, 73, 0.12);
  color: #ffd7d5;
}

.portal-column {
  min-width: 0;
}

.portal-shell > * {
  min-width: 0;
}

.fleet-strip {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.fleet-card {
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: linear-gradient(180deg, var(--bg-panel) 0%, var(--bg-panel-alt) 100%);
  box-shadow: var(--shadow);
}

.fleet-label {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.fleet-value {
  display: block;
  margin-top: 4px;
  font-size: 24px;
  font-weight: 700;
  color: var(--text);
}

.hidden {
  display: none !important;
}

.portal-error {
  grid-column: 1 / -1;
  padding: 14px 16px;
  border: 1px solid rgba(248, 81, 73, 0.45);
  border-radius: 12px;
  background: rgba(248, 81, 73, 0.12);
  box-shadow: var(--shadow);
}

.portal-error-title {
  color: #ffd7d5;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.portal-error-message {
  margin-top: 6px;
  color: var(--text);
  font-size: 14px;
  line-height: 1.45;
}

.panel {
  display: flex;
  flex-direction: column;
  min-height: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: linear-gradient(180deg, var(--bg-panel) 0%, var(--bg-panel-alt) 100%);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.panel-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
}

.panel-header-title {
  display: flex;
  align-items: baseline;
  gap: 12px;
  min-width: 0;
}

.panel-header h2 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
}

.panel-sub {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.panel-action-link {
  display: inline-flex;
  align-items: center;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: rgba(13, 17, 23, 0.92);
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  transition: border-color 120ms ease, background-color 120ms ease;
}

.panel-action-link:hover {
  border-color: var(--accent);
  background: rgba(31, 111, 235, 0.12);
}

.panel-action-link[aria-disabled="true"] {
  color: var(--muted);
  pointer-events: none;
}

.panel-body {
  padding: 16px;
}

.ship-search-wrap {
  margin-bottom: 14px;
}

.ship-search {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #0d1117;
  color: var(--text);
}

.ship-list,
.alert-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.ship-card,
.alert-card {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: rgba(13, 17, 23, 0.92);
  padding: 12px 14px;
}

.ship-card {
  display: block;
  width: 100%;
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  transition: border-color 120ms ease, background-color 120ms ease, transform 120ms ease;
}

.alert-card {
  display: block;
  width: 100%;
  color: var(--text);
  font: inherit;
  text-align: left;
  appearance: none;
  -webkit-appearance: none;
}

.ship-card:hover {
  transform: translateY(-1px);
  border-color: #3b82f6;
}

.ship-card.is-selected,
.alert-card.is-selected {
  border-color: var(--accent);
  background: rgba(31, 111, 235, 0.12);
}

.alert-card[data-vessel-id] {
  cursor: pointer;
  transition: border-color 120ms ease, background-color 120ms ease, transform 120ms ease;
}

.alert-card[data-vessel-id]:hover {
  transform: translateY(-1px);
  border-color: #3b82f6;
}

.ship-card-top,
.alert-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.ship-name,
.alert-title {
  font-weight: 600;
}

.status-pill,
.severity-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  border: 1px solid var(--border);
}

.status-ok,
.severity-ok {
  color: var(--ok);
  border-color: rgba(46, 160, 67, 0.4);
  background: rgba(46, 160, 67, 0.12);
}

.status-warning,
.severity-warning {
  color: var(--warning);
  border-color: rgba(210, 153, 34, 0.42);
  background: rgba(210, 153, 34, 0.12);
}

.status-alert,
.severity-critical {
  color: var(--critical);
  border-color: rgba(248, 81, 73, 0.42);
  background: rgba(248, 81, 73, 0.12);
}

.ship-meta,
.alert-meta,
.alert-message {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.ship-meta {
  display: flex;
  align-items: baseline;
  gap: 6px;
  flex-wrap: wrap;
}

.ship-meta + .ship-meta {
  margin-top: 4px;
}

.ship-meta-label {
  color: #90a4b8;
}

.ship-meta-value {
  color: #d7e3f4;
}

.ship-meta-value-time {
  white-space: nowrap;
}

.ship-meta-value-position {
  color: #a9bfd8;
}

.ship-meta-separator {
  color: #546274;
}

.ship-meta-pair {
  display: inline-flex;
  align-items: baseline;
  gap: 4px;
  white-space: nowrap;
}

.ship-meta-update {
  white-space: nowrap;
}

.ship-meta-nav {
  row-gap: 2px;
}

.ship-meta-alerts .ship-meta-value {
  color: #ffffff;
  font-weight: 600;
}

.map-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.summary-item {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: rgba(13, 17, 23, 0.86);
}

.summary-label {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.summary-value {
  display: block;
  margin-top: 4px;
  font-size: 14px;
  font-weight: 600;
}

.summary-value-empty {
  color: var(--muted);
}

.map-stage {
  position: relative;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: #0b1016;
  overflow: hidden;
  min-height: 560px;
}

.map-canvas {
  display: block;
  width: 100%;
  height: 560px;
}

.map-empty {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(11, 16, 22, 0.72);
  color: var(--text);
  font-size: 15px;
  font-weight: 600;
  text-align: center;
  z-index: 500;
}

.leaflet-container {
  background: #0b1016;
  color: var(--text);
}

.leaflet-control-attribution {
  background: rgba(13, 17, 23, 0.88);
  color: var(--muted);
  border-top-left-radius: 8px;
}

.leaflet-control-attribution a {
  color: #8ab4ff;
}

.leaflet-popup-content-wrapper,
.leaflet-popup-tip {
  background: #161b22;
  color: var(--text);
  border: 1px solid var(--border);
}

.map-vessel-popup {
  font-size: 13px;
  line-height: 1.45;
}

@media (max-width: 1180px) {
  .portal-shell {
    grid-template-columns: 260px minmax(0, 1fr);
  }

  .portal-column-alerts {
    grid-column: 1 / -1;
  }
}

@media (max-width: 820px) {
  .portal-shell {
    grid-template-columns: 1fr;
  }

  .fleet-strip {
    grid-template-columns: 1fr 1fr;
  }

  .map-summary {
    grid-template-columns: 1fr 1fr;
  }

  .portal-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .header-right {
    flex-wrap: wrap;
  }

  .brand-wordmark {
    width: 160px;
  }

  .brand-logo {
    width: 34px;
    height: 34px;
  }

  .header-parent-brand {
    width: 180px;
    max-width: 100%;
  }
}
