:root {
  --bg: #ffffff;
  --text: #111827;
  --muted: #6b7280;
  --grid: #d1d5db;
  --grid-dark: #9ca3af;
  --bar: #0b6ea8;
  --today: #dc2626;
  --panel: #f9fafb;
  --shadow: 0 1px 2px rgba(0,0,0,0.06);
  --radius: 10px;
  --font: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, "Apple Color Emoji", "Segoe UI Emoji";
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
}

.container {
  max-width: 1240px;
  margin: 0 auto;
  padding: 18px 16px 28px;
}

.topbar {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.title {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.2px;
}

.version {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
}

.nav {
  display: flex;
  gap: 10px;
  align-items: center;
}

.nav a {
  font-size: 13px;
  text-decoration: none;
  color: var(--text);
  padding: 6px 10px;
  border: 1px solid var(--grid);
  border-radius: 8px;
  background: #fff;
}

.nav a.active {
  border-color: var(--grid-dark);
  background: var(--panel);
}

.card {
  border: 1px solid var(--grid);
  border-radius: var(--radius);
  background: #fff;
  box-shadow: var(--shadow);
}

.card-header {
  padding: 10px 12px;
  border-bottom: 1px solid var(--grid);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.card-header .hint {
  font-size: 12px;
  color: var(--muted);
}

.timeline-wrap {
  overflow: auto;
}

.timeline {
  position: relative;
  min-width: 1060px;
}

.grid {
  display: grid;
  grid-template-columns: 240px 1fr;
}

.axis {
  display: grid;
  grid-template-columns: 240px 1fr;
  border-bottom: 1px solid var(--grid-dark);
}

.axis-left {
  padding: 6px 10px;
  font-size: 12px;
  color: var(--muted);
  position: sticky;
  left: 0;
  z-index: 5;
  background: #fff;
  border-right: 1px solid var(--grid-dark);
}

.axis-left-title {
  font-weight: 700;
  color: var(--text);
  line-height: 1.1;
}

.axis-left-sub {
  margin-top: 2px;
  font-size: 11px;
  color: var(--muted);
  line-height: 1.1;
}

.axis-right {
  position: relative;
}

.axis-row {
  display: grid;
  grid-auto-flow: column;
  border-left: 1px solid var(--grid-dark);
}

.axis-cell {
  border-right: 1px solid var(--grid);
  text-align: center;
  padding: 4px 0;
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
}

.axis-cell.strong {
  color: var(--text);
  font-weight: 600;
  border-right: 1px solid var(--grid-dark);
}

.row {
  display: grid;
  grid-template-columns: 240px 1fr;
  border-bottom: 1px solid var(--grid);
  align-items: stretch;
}

.row-left {
  padding: 7px 10px;
  font-size: 12px;
  border-right: 1px solid var(--grid-dark);
  display: flex;
  flex-direction: column;
  gap: 2px;
  justify-content: center;
  position: sticky;
  left: 0;
  z-index: 4;
  background: #fff;
}

.row-left-title {
  font-weight: 600;
  line-height: 1.1;
}

.row-left-sub {
  font-size: 11px;
  color: var(--muted);
  line-height: 1.1;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--muted);
}

.row-right {
  position: relative;
  min-height: 44px;
}

.row-right .month-grid {
  position: absolute;
  inset: 0;
  display: grid;
  grid-auto-flow: column;
  border-left: 1px solid var(--grid-dark);
}

.row-right .month-cell {
  border-right: 1px solid var(--grid);
}

.bar {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  height: 18px;
  background: var(--bar);
  border-radius: 2px;
}

.bar-label {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  font-size: 11px;
  white-space: nowrap;
  color: var(--text);
}

.bar-sub-label {
  position: absolute;
  top: calc(50% + 14px);
  transform: translate(-50%, -50%);
  font-size: 10px;
  white-space: nowrap;
  color: var(--muted);
}

.today-line {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--today);
  opacity: 0.9;
  pointer-events: none;
}

.overview-top-tables {
  margin-top: 12px;
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  align-items: start;
}

.overview-top-tables .card {
  overflow-x: auto;
}

#tableVessels th:nth-child(3),
#tableVessels th:nth-child(4),
#tableVessels th:nth-child(5),
#tableVessels th:nth-child(6),
#tableVessels th:nth-child(7),
#tableVessels td:nth-child(3),
#tableVessels td:nth-child(4),
#tableVessels td:nth-child(5),
#tableVessels td:nth-child(6),
#tableVessels td:nth-child(7) {
  text-align: center;
}

.util-wrap {
  overflow: auto;
}

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

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(17, 24, 39, 0.35);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 18px;
  z-index: 100;
}

.modal-backdrop.open {
  display: flex;
}

.modal {
  width: min(980px, 100%);
  max-height: 90vh;
  overflow: auto;
  background: #fff;
  border: 1px solid var(--grid);
  border-radius: var(--radius);
  box-shadow: 0 10px 30px rgba(0,0,0,0.18);
}

.modal-header {
  padding: 10px 12px;
  border-bottom: 1px solid var(--grid);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.modal-title {
  font-size: 14px;
  font-weight: 700;
}

.modal-body {
  padding: 12px;
}

.budget-row {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  align-items: end;
}

.budget-row input {
  height: 30px;
  padding: 6px 10px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  grid-column: 2;
  justify-self: end;
  padding: 12px 0 0;
}

.modal-footer-line {
  grid-column: 1 / -1;
  margin: 2px -12px 0;
  border-top: 1px solid var(--grid);
  height: 0;
}

.color-swatch {
  height: 34px;
  width: 54px;
  padding: 0;
  border-radius: 8px;
  border: 1px solid var(--grid);
  background: #64748b;
}

.color-popover {
  display: none;
  position: absolute;
  margin-top: 6px;
  padding: 8px;
  background: #fff;
  border: 1px solid var(--grid);
  border-radius: 10px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.18);
  z-index: 200;
  grid-template-columns: repeat(7, 22px);
  gap: 8px;
}

.color-popover.open {
  display: grid;
}

.color-chip {
  width: 22px;
  height: 22px;
  border-radius: 6px;
  border: 1px solid rgba(0,0,0,0.12);
  padding: 0;
}

.table {
  width: 100%;
  border-collapse: collapse;
}

.table th, .table td {
  border: 1px solid var(--grid);
  padding: 4px 6px;
  font-size: 11px;
}

.table th {
  background: var(--panel);
  font-weight: 600;
}

.small {
  font-size: 12px;
  color: var(--muted);
}

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

.field {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

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

.field input, .field select, .field textarea {
  font-size: 13px;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--grid);
}

.field textarea {
  resize: vertical;
  min-height: 76px;
}

.actions {
  grid-column: 1 / -1;
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: flex-end;
}

button {
  border: 1px solid var(--grid);
  background: #fff;
  padding: 8px 10px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
}

button.primary {
  background: #111827;
  color: #fff;
  border-color: #111827;
}

button.danger {
  background: #fff;
  border-color: #ef4444;
  color: #b91c1c;
}

@media (max-width: 980px) {
  .overview-top-tables {
    grid-template-columns: 1fr;
  }
  .form {
    grid-template-columns: 1fr;
  }
}
