:root {
  color-scheme: light;
  --bg: #f4f7fa;
  --text: #0b2848;
  --muted: #64748b;
  --line: #dce4ee;
  --panel: #ffffff;
  --surface: #eef3f8;
  --surface-strong: #e5edf5;
  --navy: #0b2848;
  --navy-soft: #12365d;
  --navy-muted: #234766;
  --accent: #ef6c00;
  --accent-strong: #cf5d00;
  --accent-soft: #fff1e6;
  --green: #16a34a;
  --blue: #2563eb;
  --warn: #a16207;
  --danger: #b42318;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: linear-gradient(180deg, #eef3f8 0, var(--bg) 240px);
  color: var(--text);
  font-family: Arial, Helvetica, sans-serif;
  font-size: 14px;
}

.login-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: var(--navy);
}

.login-panel {
  position: relative;
  width: min(420px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 28px;
  box-shadow: 0 24px 80px rgb(0 0 0 / 28%);
}

.login-panel::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 6px;
  border-radius: 8px 0 0 8px;
  background: var(--accent);
}

.login-panel-small {
  width: min(460px, 100%);
}

.login-header {
  margin-bottom: 22px;
}

.brand-logo {
  display: block;
  height: auto;
}

.brand-logo-login {
  width: 210px;
  margin-bottom: 18px;
}

.login-header h1 {
  font-size: 28px;
}

.login-header p:last-child {
  margin: 8px 0 0;
  color: var(--muted);
}

.login-form {
  display: grid;
  gap: 14px;
}

.login-submit {
  width: 100%;
  min-height: 42px;
  margin-top: 4px;
}

.login-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 18px;
}

.login-actions-stacked {
  grid-template-columns: 1fr;
}

.login-actions .button-ghost {
  grid-column: 1 / -1;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 24px 32px;
  background: var(--navy);
  border-bottom: 4px solid var(--accent);
  color: #ffffff;
  box-shadow: 0 14px 36px rgb(11 40 72 / 18%);
}

.brand {
  margin: 0 0 4px;
  color: var(--accent);
  font-weight: 700;
}

.brand-logo-topbar {
  width: 156px;
  margin-bottom: 6px;
}

h1 {
  margin: 0;
  font-size: 24px;
  line-height: 1.2;
  letter-spacing: 0;
}

.topbar h1 {
  color: #f7fafc;
  font-size: 22px;
  font-weight: 700;
}

.env {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
  color: #dbe5f0;
}

.env span {
  border: 1px solid rgb(255 255 255 / 20%);
  padding: 7px 10px;
  border-radius: 6px;
  background: rgb(255 255 255 / 8%);
}

.topbar-link {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  border: 1px solid rgb(255 255 255 / 22%);
  border-radius: 6px;
  padding: 7px 10px;
  color: #f7fafc;
  font-weight: 700;
  text-decoration: none;
  background: rgb(255 255 255 / 8%);
}

.topbar-link:hover {
  border-color: var(--accent);
  background: rgb(239 108 0 / 22%);
}

.shell {
  width: min(1380px, calc(100vw - 32px));
  margin: 26px auto 44px;
}

.flash {
  padding: 12px 14px;
  background: var(--accent-soft);
  border: 1px solid #ffd0a8;
  border-radius: 6px;
  margin-bottom: 14px;
  color: var(--navy);
  font-weight: 700;
}

.flash-error {
  background: #fff1f0;
  border-color: #fecaca;
  color: var(--danger);
}

.summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(120px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.summary div {
  position: relative;
  background: var(--panel);
  border: 1px solid var(--line);
  border-left: 6px solid var(--accent);
  border-radius: 6px;
  padding: 14px 16px;
  box-shadow: 0 10px 28px rgb(11 40 72 / 8%);
}

.summary span {
  display: block;
  font-size: 26px;
  font-weight: 700;
  color: var(--navy);
}

.summary p {
  margin: 4px 0 0;
  color: var(--muted);
}

.entry {
  background: var(--panel);
  border: 1px solid var(--line);
  border-left: 6px solid var(--accent);
  border-radius: 6px;
  padding: 16px;
  margin-bottom: 18px;
  box-shadow: 0 10px 28px rgb(11 40 72 / 8%);
}

.ship-section {
  background: var(--panel);
  border: 1px solid var(--line);
  border-top: 4px solid var(--accent);
  border-radius: 6px;
  margin-bottom: 18px;
  overflow: hidden;
  box-shadow: 0 12px 32px rgb(11 40 72 / 9%);
}

.ship-title,
.cell-with-signal {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.signal {
  display: inline-block;
  flex: 0 0 auto;
  width: 12px;
  height: 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #e5e7eb;
}

.signal-green {
  border-color: #15803d;
  background: var(--green);
  box-shadow: 0 0 0 3px rgb(22 163 74 / 16%);
}

.signal-red {
  border-color: #991b1b;
  background: var(--danger);
  box-shadow: 0 0 0 3px rgb(180 35 24 / 16%);
}

.signal-blue {
  border-color: #1d4ed8;
  background: var(--blue);
  box-shadow: 0 0 0 3px rgb(37 99 235 / 16%);
}

.signal-off {
  background: #e5e7eb;
}

.row-window td {
  background: #f0fdf4;
}

.container-actions {
  display: inline-flex;
}

.ship-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.modal {
  width: min(920px, calc(100vw - 28px));
  max-height: none;
  overflow: visible;
  border: 1px solid var(--line);
  border-top: 6px solid var(--accent);
  border-radius: 8px;
  padding: 16px;
  color: var(--text);
  background: var(--panel);
  box-shadow: 0 24px 80px rgb(15 23 42 / 25%);
}

.modal-ship {
  width: min(640px, calc(100vw - 28px));
}

.modal-transfer {
  width: min(520px, calc(100vw - 28px));
}

.modal-confirm {
  width: min(560px, calc(100vw - 28px));
}

.modal::backdrop {
  background: rgb(11 40 72 / 62%);
}

.modal-title {
  grid-column: 1 / -1;
}

.modal-title h3 {
  margin: 0;
  font-size: 18px;
  color: var(--navy);
  letter-spacing: 0;
}

.modal-title p {
  margin: 4px 0 0;
  color: var(--muted);
}

.modal-close {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 8px;
}

.modal-close button {
  min-height: 32px;
  background: #eef2f7;
  color: var(--navy);
}

.modal-actions {
  grid-column: 1 / -1;
  display: flex;
  justify-content: flex-end;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(130px, 1fr));
  gap: 10px;
  align-items: end;
}

.form-grid.ship-edit {
  width: 100%;
  max-width: 100%;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.modal-ship .ship-edit {
  grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
}

.modal-ship .wide,
.modal-ship .modal-actions,
.modal-ship .modal-title {
  grid-column: 1 / -1;
}

.modal-ship .modal-actions {
  justify-content: flex-end;
}

.form-grid.container-entry {
  grid-template-columns: repeat(3, minmax(160px, 1fr));
}

.form-grid.transfer-entry {
  width: 100%;
  grid-template-columns: 1fr;
}

.confirm-entry {
  display: grid;
  gap: 14px;
}

.form-grid-compact {
  grid-template-columns: repeat(5, minmax(130px, 1fr));
}

.form-grid.user-entry {
  grid-template-columns: repeat(5, minmax(150px, 1fr));
}

.profile-entry {
  display: grid;
  gap: 16px;
}

.profile-entry h2 {
  margin: 0;
  color: var(--navy);
}

.profile-entry p {
  margin: 4px 0 0;
  color: var(--muted);
}

.form-grid.profile-password-form {
  grid-template-columns: repeat(3, minmax(160px, 1fr));
}

label {
  display: grid;
  gap: 6px;
  color: var(--navy-muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

input,
select {
  width: 100%;
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #ffffff;
  color: var(--text);
  padding: 7px 9px;
  font: inherit;
}

input:focus,
select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgb(239 108 0 / 14%);
  outline: none;
}

.wide {
  grid-column: span 2;
}

button {
  min-height: 34px;
  border: 0;
  border-radius: 6px;
  background: var(--accent);
  color: #ffffff;
  font-weight: 700;
  cursor: pointer;
  padding: 7px 12px;
}

button:hover {
  background: var(--accent-strong);
}

button:disabled {
  background: #cbd5e1;
  color: #64748b;
  cursor: not-allowed;
}

.button-link {
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  background: var(--accent);
  color: #ffffff;
  font-weight: 700;
  padding: 8px 12px;
  text-decoration: none;
}

.button-link:hover {
  background: var(--accent-strong);
}

.button-secondary {
  border: 1px solid var(--line);
  background: #ffffff;
  color: var(--navy);
}

.button-secondary:hover {
  border-color: #b8c2d2;
  background: #f8fafc;
}

.button-ghost {
  border: 1px solid transparent;
  background: transparent;
  color: var(--navy);
}

.button-ghost:hover {
  border-color: #ffd1ad;
  background: #fff4ec;
}

.button-danger {
  background: var(--danger);
}

.button-danger:hover {
  background: #901b12;
}

.button-subtle {
  min-height: 32px;
  padding: 6px 10px;
  font-size: 12px;
}

.text-link {
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 700;
  text-decoration: none;
  text-transform: uppercase;
}

.text-link:hover {
  text-decoration: underline;
}

.ship-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
}

.ship-card {
  display: grid;
  gap: 0;
  overflow: hidden;
  background: var(--panel);
  border: 1px solid var(--line);
  border-top: 4px solid var(--accent);
  border-radius: 8px;
  box-shadow: 0 14px 34px rgb(11 40 72 / 10%);
}

.ship-card-archived {
  border-top-color: var(--blue);
}

.ship-card-main {
  display: grid;
  gap: 10px;
  min-height: 210px;
  padding: 18px;
  color: inherit;
  text-decoration: none;
}

a.ship-card-main:hover {
  background: #fbfdff;
}

.ship-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.ship-card-kicker {
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.ship-card-archived .ship-card-kicker {
  color: var(--blue);
}

.ship-card h2 {
  margin: 0;
  color: var(--navy);
  font-size: 24px;
  line-height: 1.15;
}

.ship-card p {
  margin: 0;
  color: var(--muted);
}

.ship-card small {
  display: block;
  min-height: 18px;
}

.ship-card-metrics {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: auto;
}

.ship-card-metrics span {
  display: grid;
  gap: 2px;
  min-height: 54px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--muted);
  font-size: 12px;
}

.ship-card-metrics strong {
  color: var(--navy);
  font-size: 18px;
}

.ship-card-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border-top: 1px solid var(--line);
  background: #fbfdff;
}

.ship-detail-hero {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
  padding: 18px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-left: 6px solid var(--accent);
  border-radius: 8px;
  box-shadow: 0 12px 32px rgb(11 40 72 / 9%);
}

.ship-detail-archived {
  border-left-color: var(--blue);
}

.ship-detail-hero h2 {
  margin: 8px 0 4px;
  color: var(--navy);
  font-size: 26px;
  line-height: 1.15;
}

.ship-detail-hero p,
.registry-intro p {
  margin: 0;
  color: var(--muted);
}

.registry-intro h2 {
  margin: 0 0 6px;
  color: var(--navy);
}

.warning-box {
  border: 1px solid #fed7aa;
  border-radius: 6px;
  background: #fff7ed;
  color: var(--navy);
  padding: 12px;
  line-height: 1.45;
}

.table-wrap {
  overflow-x: auto;
  background: var(--panel);
  border: 0;
  border-radius: 0;
}

.table-wrap::-webkit-scrollbar {
  height: 10px;
}

.table-wrap::-webkit-scrollbar-track {
  background: var(--surface);
}

.table-wrap::-webkit-scrollbar-thumb {
  background: var(--navy-muted);
  border-radius: 999px;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 1540px;
}

.users-table {
  min-width: 980px;
}

.audit-table {
  min-width: 980px;
}

th,
td {
  padding: 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

th {
  color: #f7fafc;
  background: var(--navy);
  font-size: 12px;
  text-transform: uppercase;
}

tbody tr {
  background: #ffffff;
}

tbody tr:nth-child(even) {
  background: #fbfdff;
}

tbody tr:hover td {
  background: #fff7f0;
}

tr:last-child td {
  border-bottom: 0;
}

.status {
  display: inline-block;
  min-width: 94px;
  padding: 5px 8px;
  border-radius: 6px;
  text-align: center;
  font-size: 12px;
  font-weight: 700;
}

.status-monitorar {
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.status-agendado {
  background: #e8f1fb;
  color: var(--navy);
}

.status-pausado {
  background: #fef3c7;
  color: var(--warn);
}

.status-cancelado,
.status-arquivado {
  background: #fee2e2;
  color: var(--danger);
}

.inline-form {
  display: grid;
  grid-template-columns: minmax(170px, 1fr) minmax(128px, 150px) auto;
  gap: 8px;
  align-items: start;
}

td .inline-form {
  grid-template-columns: 154px 120px auto;
  gap: 6px;
  align-items: center;
}

td .status-form-compact {
  grid-template-columns: 120px auto;
}

td input,
td select {
  min-height: 30px;
  border-radius: 5px;
  padding: 5px 8px;
  font-size: 13px;
}

td button {
  min-height: 30px;
  border-radius: 5px;
  padding: 5px 9px;
  font-size: 12px;
  line-height: 1.1;
  white-space: nowrap;
}

td button:not(.button-danger) {
  border: 1px solid #ffd0a8;
  background: var(--accent-soft);
  color: var(--accent-strong);
}

td button:not(.button-danger):hover {
  border-color: var(--accent);
  background: #ffe4cc;
}

td .button-danger {
  border: 1px solid #fecaca;
  background: #fff1f0;
  color: var(--danger);
}

td .button-danger:hover {
  background: #fee2e2;
}

.user-password-form {
  grid-template-columns: minmax(180px, 1fr) auto;
}

small {
  color: var(--muted);
}

.empty {
  color: var(--muted);
  text-align: center;
  padding: 34px;
}

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

  .env {
    justify-content: flex-start;
  }

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

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

  .form-grid-compact,
  .ship-edit {
    grid-template-columns: 1fr;
  }

  .ship-summary {
    align-items: stretch;
    flex-direction: column;
  }

  .ship-detail-hero {
    align-items: stretch;
    flex-direction: column;
  }

  .ship-card-grid {
    grid-template-columns: 1fr;
  }

  .wide {
    grid-column: auto;
  }
}

@media (max-width: 520px) {
  .login-body {
    padding: 16px;
  }

  .login-panel {
    padding: 22px;
  }

  .login-actions {
    grid-template-columns: 1fr;
  }

  .login-actions .button-ghost {
    grid-column: auto;
  }
}
