/**
 * TheCharterBox — Laytime Calculator Stylesheet
 * Brand colors: Navy #1B2A4A, Teal #2CA6A4, Red #D64045, Green #4CAF50
 */

/* ── FIX 1: Full-width breakout from WordPress theme container ────── */

.tcb-laytime-calculator-wrapper {
  position: relative;
  z-index: 1;
  width: 100vw;
  max-width: 100vw;
  margin-left: calc(-50vw + 50%);
  padding: 0 40px;
  box-sizing: border-box;
  position: relative;
}

/* ── FIX 4: Hide WordPress page title — the navy header IS the title */

.tcb-laytime-calculator-wrapper ~ .page-title,
.tcb-laytime-calculator-wrapper ~ .entry-title,
.page .tcb-laytime-calculator-wrapper ~ h1,
body.page:has(.tcb-laytime-calculator-wrapper) .entry-title,
body.page:has(.tcb-laytime-calculator-wrapper) .page-title,
body.page:has(.tcb-laytime-calculator-wrapper) article > header .entry-title {
  display: none;
}

/* Full-width page template main area */
.tcb-fullwidth-main {
  width: 100%;
  max-width: 100%;
  margin: 0;
  padding: 0;
}

.tcb-fullwidth-main .tcb-laytime-calculator-wrapper {
  width: 100%;
  max-width: 100%;
  margin-left: 0;
  padding: 0 40px;
}

/* ── Reset & Base ──────────────────────────────────────────────────── */

.tcb-wrapper {
  --tcb-navy:    #1B2A4A;
  --tcb-teal:    #2CA6A4;
  --tcb-red:     #D64045;
  --tcb-green:   #4CAF50;
  --tcb-bg:      #F5F7FA;
  --tcb-text:    #333333;
  --tcb-border:  #D1D5DB;
  --tcb-white:   #FFFFFF;
  --tcb-muted:   #6B7280;
  --tcb-blue:    #3B82F6;

  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  color: var(--tcb-text);
  background: var(--tcb-bg);
  max-width: 1400px;
  margin: 0 auto;
  padding: 0;
  min-height: 600px;
}

.tcb-wrapper *,
.tcb-wrapper *::before,
.tcb-wrapper *::after {
  box-sizing: border-box;
}

/* ── Header ────────────────────────────────────────────────────────── */

.tcb-header {
  background: var(--tcb-navy);
  color: var(--tcb-white);
  padding: 16px 24px;
  border-radius: 8px 8px 0 0;
  margin-bottom: 0;
  position: sticky;
  top: 0;
  z-index: auto;
}

.tcb-header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.tcb-title {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: #ffffff;
}

.tcb-title span {
  font-weight: 400;
  opacity: 0.85;
}

.tcb-header-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

.tcb-btn-header {
  background: rgba(255,255,255,0.15);
  color: var(--tcb-white);
  border: 1px solid rgba(255,255,255,0.3);
  padding: 6px 14px;
  font-size: 13px;
  font-weight: 500;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.2s;
}

.tcb-btn-header:hover {
  background: rgba(255,255,255,0.25);
}

/* ── Main Layout: two-column 70% / 30% ────────────────────────────── */

.tcb-main {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 24px;
  align-items: start;
  min-height: 500px;
}

/* ── Content area (left column) ───────────────────────────────────── */

.tcb-content {
  min-width: 0; /* Prevents grid blowout */
}

/* ── Tabs ──────────────────────────────────────────────────────────── */

.tcb-tabs {
  display: flex;
  background: var(--tcb-white);
  border-bottom: 2px solid #E0E0E0;
  padding: 0 24px;
  margin-bottom: 0;
  gap: 0;
}

.tcb-tab {
  padding: 12px 24px;
  font-size: 14px;
  font-weight: 500;
  color: #666;
  background: none;
  border: none;
  border-bottom: 3px solid transparent;
  cursor: pointer;
  transition: all 0.2s;
  margin-bottom: -2px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.tcb-tab:hover {
  color: var(--tcb-navy);
}

.tcb-tab.active {
  color: var(--tcb-teal);
  border-bottom-color: var(--tcb-teal);
}

.tcb-step-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--tcb-border);
  color: var(--tcb-muted);
  font-size: 12px;
  font-weight: 700;
}

.tcb-tab.active .tcb-step-num {
  background: var(--tcb-teal);
  color: var(--tcb-white);
}

/* ── Panels ────────────────────────────────────────────────────────── */

.tcb-tab-panels {
  padding: 24px;
  overflow-y: auto;
}

.tcb-panel {
  animation: tcb-fadeIn 0.2s ease;
}

.tcb-hidden {
  display: none !important;
}

@keyframes tcb-fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Sidebar / Running Summary (right column) ─────────────────────── */

.tcb-sidebar {
  background: var(--tcb-bg);
  border: 1px solid #E0E0E0;
  border-radius: 8px;
  padding: 20px;
  position: sticky;
  top: 20px;
  height: fit-content;
  max-height: calc(100vh - 120px);
  overflow-y: auto;
  /* DO NOT use position: absolute or float */
}

.tcb-sidebar h4 {
  margin: 0 0 12px;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--tcb-muted);
}

.tcb-sidebar-summary {
  font-size: 13px;
}

/* Per-port block */
.tcb-sidebar-port {
  padding-bottom: 10px;
  margin-bottom: 10px;
  border-bottom: 1px solid var(--tcb-border);
}

.tcb-sidebar-port-name {
  font-size: 11px;
  font-weight: 600;
  color: var(--tcb-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin-bottom: 4px;
}

.tcb-sidebar-port-row {
  display: flex;
  gap: 12px;
  font-size: 12px;
  line-height: 1.6;
}

.tcb-sidebar-port-amt {
  font-size: 12px;
  font-weight: 600;
  margin-top: 2px;
}

.tcb-sidebar-standalone-label {
  font-weight: 400;
  font-style: italic;
  font-size: 11px;
  opacity: 0.8;
}

/* Combined reversible block */
.tcb-sidebar-combined {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 2px solid var(--tcb-navy);
}

.tcb-sidebar-combined-title {
  font-size: 11px;
  font-weight: 700;
  color: var(--tcb-navy);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 4px;
}

.tcb-sidebar-combined-amt {
  font-size: 14px;
  font-weight: 700;
  margin-top: 4px;
}

.tcb-muted {
  color: var(--tcb-muted);
  font-size: 13px;
}

/* ── Forms ─────────────────────────────────────────────────────────── */

.tcb-form {
  max-width: none;
}

.tcb-fieldset {
  border: 1px solid #E0E0E0;
  border-radius: 8px;
  padding: 24px;
  margin: 0 0 32px;
  background: var(--tcb-white);
}

.tcb-fieldset legend {
  font-size: 16px;
  font-weight: 600;
  color: var(--tcb-navy);
  padding: 0 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  border-bottom: 1px solid #E0E0E0;
  padding-bottom: 8px;
  margin-bottom: 16px;
  width: 100%;
}

.tcb-fieldset legend::after {
  content: '▾';
  font-size: 20px;
  color: var(--tcb-teal);
  transition: transform 0.2s;
  margin-left: auto;
  line-height: 1;
}

.tcb-fieldset.tcb-collapsed legend::after {
  transform: rotate(-90deg);
}

.tcb-fieldset.tcb-collapsed legend {
  margin-bottom: 0;
  border-bottom: none;
  padding-bottom: 0;
}

.tcb-fieldset-content {
  overflow: visible; /* must be visible so tooltips escape the container */
  transition: max-height 0.3s ease, opacity 0.2s ease;
}

.tcb-fieldset.tcb-collapsed .tcb-fieldset-content {
  overflow: hidden; /* only clip content when collapsed */
  max-height: 0 !important;
  opacity: 0;
  padding-top: 0;
  margin-top: 0;
}

/* Form grid for charter terms — auto-fit responsive columns */
.tcb-form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px 24px;
  margin-bottom: 16px;
}

.tcb-form-row > label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 13px;
  font-weight: 600;
  color: #555;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Push inputs/selects to the bottom of their label cell so they
   align horizontally across a grid row even when label texts differ
   in length (e.g. one has a tooltip icon, the other does not). */
.tcb-form-row > label > input,
.tcb-form-row > label > select {
  margin-top: auto;
}

/* ── Form inputs — consistent sizing ──────────────────────────────── */

.tcb-input {
  height: 40px;
  padding: 8px 12px;
  border: 1px solid #CCC;
  border-radius: 4px;
  font-size: 14px;
  font-family: inherit;
  color: var(--tcb-text);
  background: var(--tcb-white);
  transition: border-color 0.2s, box-shadow 0.2s;
  width: 100%;
  box-sizing: border-box;
}

.tcb-input:focus {
  outline: none;
  border-color: var(--tcb-teal);
  box-shadow: 0 0 0 3px rgba(44, 166, 164, 0.15);
}

select.tcb-input {
  position: relative;
  z-index: 1;
}

select.tcb-input:focus {
  z-index: 1000;
}

.tcb-form-divider {
  text-align: center;
  color: var(--tcb-muted);
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin: 4px 0;
  padding: 4px 0;
  grid-column: 1 / -1;
}

.tcb-checkbox-label {
  flex-direction: row !important;
  align-items: center;
  gap: 8px !important;
  cursor: pointer;
  text-transform: none !important;
  font-weight: 500 !important;
  letter-spacing: 0 !important;
}

.tcb-checkbox-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  margin-top: 4px;
}

.tcb-checkbox-group label {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 13px;
  font-weight: 400;
  cursor: pointer;
  text-transform: none;
  letter-spacing: 0;
}

/* ── Tooltips ─────────────────────────────────────────────────────── */

.tcb-tooltip-trigger {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: help;
}

.tcb-tooltip-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: rgba(44, 166, 164, 0.15);
  color: var(--tcb-teal);
  font-size: 11px;
  font-weight: 600;
  font-style: normal;
  line-height: 1;
  flex-shrink: 0;
}

.tcb-tooltip-text {
  display: none;
  position: fixed;    /* fixed so overflow:hidden on scroll containers can't clip it */
  background: var(--tcb-navy);
  color: var(--tcb-white);
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 12px;
  line-height: 1.5;
  font-weight: 400;
  font-style: normal;
  text-transform: none;
  letter-spacing: 0;
  white-space: normal;
  width: 300px;
  max-width: calc(100vw - 32px);
  z-index: 9999;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  pointer-events: none;
}

/* Arrow pointing down (tooltip above icon) */
.tcb-tooltip-text::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 5px solid transparent;
  border-top-color: var(--tcb-navy);
}

/* Arrow pointing up (tooltip below icon) */
.tcb-tooltip-text.tip-below::after {
  top: auto;
  bottom: 100%;
  border-top-color: transparent;
  border-bottom-color: var(--tcb-navy);
}

/* Show on hover (desktop) or tap (mobile) */
.tcb-tooltip-trigger:hover .tcb-tooltip-text,
.tcb-tooltip-trigger:focus-within .tcb-tooltip-text,
.tcb-tooltip-text.active {
  display: block;
}

/* Mobile: show as fixed bottom panel */
@media (max-width: 768px) {
  .tcb-tooltip-text {
    bottom: 16px;
    left: 16px !important;
    right: 16px;
    top: auto !important;
    transform: none !important;
    width: auto;
    max-width: none;
    z-index: 10001;
  }

  .tcb-tooltip-text::after {
    display: none;
  }
}

/* ── Buttons ───────────────────────────────────────────────────────── */

.tcb-btn {
  padding: 10px 20px;
  font-size: 14px;
  font-weight: 500;
  font-family: inherit;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
}

.tcb-btn:active {
  transform: scale(0.97);
}

.tcb-btn-accent {
  background: #2CA6A4;
  color: #fff;
  border: 1px solid #2CA6A4;
}

.tcb-btn-accent:hover {
  background: #238B89;
  border-color: #238B89;
}

.tcb-btn-remove {
  background: transparent;
  color: var(--tcb-red);
  font-size: 18px;
  padding: 4px 10px;
  line-height: 1;
}

.tcb-btn-remove:hover {
  background: rgba(214, 64, 69, 0.1);
}

/* ── FIX 3: SOF Table — full content, no cut-off EVENT column ────── */

.tcb-sof-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.tcb-sof-header h3 {
  margin: 0;
  font-size: 16px;
  color: var(--tcb-navy);
}

.tcb-sof-table-container {
  min-width: 0; /* Prevents grid blowout */
  width: 100%;
}

.tcb-sof-table {
  width: 100%;
  table-layout: auto; /* NOT fixed — let columns size to content */
  border-collapse: collapse;
  background: var(--tcb-white);
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--tcb-border);
}

.tcb-sof-table thead {
  background: var(--tcb-navy);
  color: var(--tcb-white);
}

.tcb-sof-table th,
.tcb-sof-table td {
  padding: 10px 12px;
  vertical-align: middle;
}

.tcb-sof-table th {
  white-space: nowrap; /* keep header labels on one line */
}

.tcb-sof-table th {
  text-align: left;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.tcb-sof-table td {
  border-bottom: 1px solid var(--tcb-bg);
}

.tcb-sof-table tr:hover {
  background: rgba(44, 166, 164, 0.04);
}

.tcb-sof-table tr.tcb-sof-row-error {
  background: #fff1f1;
}

.tcb-sof-table tr.tcb-sof-row-error .tcb-sof-date,
.tcb-sof-table tr.tcb-sof-row-error .tcb-sof-time {
  border-color: var(--tcb-red);
  color: var(--tcb-red);
}

.tcb-sof-table tr.tcb-sof-row-warn {
  background: #fff8e1;
}

.tcb-sof-table tr.tcb-sof-row-warn .tcb-sof-event select {
  border-color: #f9a825;
  color: #e65100;
}

.tcb-sof-order-warning {
  background: #fff1f1;
  border-left: 3px solid var(--tcb-red);
  border-radius: 0 6px 6px 0;
  color: var(--tcb-red);
  font-size: 13px;
  font-weight: 500;
  padding: 8px 12px;
  margin-bottom: 8px;
}

.tcb-sof-order-warning div {
  padding: 2px 0;
}

/* Column widths */
.tcb-sof-col-num {
  width: 40px;
  text-align: center;
  color: var(--tcb-muted);
  font-size: 12px;
}

.tcb-sof-col-date { width: 140px; white-space: nowrap; }
.tcb-sof-col-time { width: 100px; white-space: nowrap; }
.tcb-sof-col-event { width: 30%; } /* proportional, no forced min-width */
.tcb-sof-col-remarks { width: auto; } /* takes remaining space */
.tcb-sof-col-actions { width: 48px; text-align: center; white-space: nowrap; }

/* Event dropdown fills its cell */
.tcb-sof-table select.tcb-input {
  width: 100%;
  padding: 8px 12px;
  font-size: 14px;
  height: 36px;
}

.tcb-sof-table .tcb-input {
  padding: 6px 8px;
  font-size: 13px;
  height: 36px;
}

.tcb-hint {
  margin-top: 8px;
  font-size: 12px;
  color: var(--tcb-muted);
}

/* ── Results ───────────────────────────────────────────────────────── */

.tcb-results-summary {
  background: var(--tcb-bg);
  border: 2px solid var(--tcb-navy);
  border-radius: 8px;
  padding: 24px;
  margin-bottom: 24px;
}

.tcb-results-summary h3,
.tcb-breakdown h3 {
  font-size: 16px;
  color: var(--tcb-navy);
  margin: 0 0 16px;
}

.tcb-summary-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
}

.tcb-card {
  background: var(--tcb-white);
  border: 1px solid var(--tcb-border);
  border-radius: 8px;
  padding: 16px;
  text-align: center;
}

.tcb-card-label {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--tcb-muted);
  margin-bottom: 4px;
}

.tcb-card-value {
  font-size: 22px;
  font-weight: 700;
  color: var(--tcb-navy);
}

.tcb-card-sub {
  font-size: 12px;
  color: var(--tcb-muted);
  margin-top: 2px;
}

.tcb-card.tcb-demurrage {
  border-color: var(--tcb-red);
  background: rgba(214, 64, 69, 0.04);
}

.tcb-card.tcb-demurrage .tcb-card-value {
  color: var(--tcb-red);
  font-size: 24px;
}

.tcb-card.tcb-despatch {
  border-color: var(--tcb-green);
  background: rgba(76, 175, 80, 0.04);
}

.tcb-card.tcb-despatch .tcb-card-value {
  color: var(--tcb-green);
  font-size: 24px;
}

/* ── Breakdown Table ───────────────────────────────────────────────── */

.tcb-breakdown {
  margin-top: 24px;
}

.tcb-breakdown-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.tcb-breakdown-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--tcb-white);
  border: 1px solid var(--tcb-border);
  border-radius: 8px;
  overflow: hidden;
  font-size: 13px;
}

.tcb-breakdown-table thead {
  background: var(--tcb-navy);
  color: var(--tcb-white);
}

.tcb-breakdown-table th {
  padding: 10px 8px;
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.tcb-breakdown-table td {
  padding: 8px;
  border-bottom: 1px solid var(--tcb-bg);
}

/* Color coding per spec */
.tcb-row-counting       { background: #E8F5E9; }
.tcb-row-halftime       { background: #F3E5F5; }
.tcb-row-weekend        { background: #F5F5F5; }
.tcb-row-holiday        { background: #E3F2FD; }
.tcb-row-excluded       { background: #EEEEEE; }   /* outside working hours */
.tcb-row-weather        { background: #E1F5FE; }
.tcb-row-interrupted    { background: #FFF3E0; }
.tcb-row-demurrage      { background: #FFEBEE; }
.tcb-row-despatch       { background: rgba(200, 230, 201, 0.5); }
.tcb-row-before_laytime { background: rgba(107, 114, 128, 0.03); }

/* ── Laytime Expired divider ─────────────────────────────────────── */

.tcb-row-laytime-expired td {
  background: #D32F2F;
  color: #fff;
  text-align: center;
  font-weight: 700;
  padding: 8px 12px;
  font-size: 13px;
  letter-spacing: 1px;
}

/* ── Badges ────────────────────────────────────────────────────────── */

.tcb-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.tcb-badge-counting       { background: #4CAF50; color: #fff; }
.tcb-badge-halftime       { background: #9C27B0; color: #fff; }
.tcb-badge-weekend        { background: #9E9E9E; color: #fff; }
.tcb-badge-holiday        { background: #42A5F5; color: #fff; }
.tcb-badge-excluded       { background: #757575; color: #fff; }
.tcb-badge-weather        { background: #29B6F6; color: #fff; }
.tcb-badge-interrupted    { background: #FFA726; color: #fff; }
.tcb-badge-demurrage      { background: #EF5350; color: #fff; }
.tcb-badge-despatch       { background: #C8E6C9; color: #1B5E20; }
.tcb-badge-before_laytime { background: #D1D5DB; color: #6B7280; }

/* ── Breakdown Legend ───────────────────────────────────────────────── */

/* ── Breakdown controls ───────────────────────────────────────── */

.tcb-bd-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.tcb-bd-port-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.tcb-bd-port-tab {
  background: var(--tcb-bg, #F8F9FA);
  border: 1px solid var(--tcb-border, #DEE2E6);
  border-radius: 4px;
  padding: 4px 10px;
  font-size: 12px;
  cursor: pointer;
  color: var(--tcb-text-secondary, #6B7280);
  font-weight: 500;
}

.tcb-bd-port-tab.active {
  background: var(--tcb-navy, #1B2A4A);
  color: #fff;
  border-color: var(--tcb-navy, #1B2A4A);
}

.tcb-bd-view-toggle {
  display: flex;
  gap: 0;
  margin-left: auto;
  border: 1px solid var(--tcb-border, #DEE2E6);
  border-radius: 4px;
  overflow: hidden;
}

.tcb-bd-view-btn {
  background: var(--tcb-bg, #F8F9FA);
  border: none;
  border-right: 1px solid var(--tcb-border, #DEE2E6);
  padding: 4px 12px;
  font-size: 12px;
  cursor: pointer;
  color: var(--tcb-text-secondary, #6B7280);
  font-weight: 500;
}

.tcb-bd-view-btn:last-child {
  border-right: none;
}

.tcb-bd-view-btn.active {
  background: var(--tcb-teal, #2CA6A4);
  color: #fff;
}

/* Port section header row in breakdown table */
.tcb-row-port-header td {
  background: var(--tcb-navy, #1B2A4A);
  color: #fff;
  font-weight: 700;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 8px 10px;
  border: none;
}

.tcb-port-header-info {
  font-weight: 400;
  opacity: 0.8;
  text-transform: none;
  letter-spacing: 0;
}

/* Hide rows filtered out by port tab or summary view */
.tcb-bd-port-hidden {
  display: none !important;
}

.tcb-breakdown-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  margin-bottom: 12px;
  padding: 10px 12px;
  background: var(--tcb-bg);
  border-radius: 6px;
  border: 1px solid var(--tcb-border);
}

.tcb-legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--tcb-navy);
}

.tcb-legend-swatch {
  width: 14px;
  height: 14px;
  border-radius: 3px;
  flex-shrink: 0;
}

/* ── Timeline Bar ───────────────────────────────────────────────────── */

.tcb-timeline-wrap {
  margin: 16px 0 0;
}

.tcb-timeline-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--tcb-muted);
  margin-bottom: 4px;
}

.tcb-timeline-bar {
  position: relative;
  display: flex;
  height: 32px;
  border-radius: 4px;
  overflow: visible;
  border: 1px solid var(--tcb-border);
}

.tcb-timeline-inner {
  display: flex;
  width: 100%;
  height: 100%;
  border-radius: 4px;
  overflow: hidden;
}

.tcb-segment {
  height: 100%;
  cursor: pointer;
  transition: opacity 0.2s;
  min-width: 1px;
}

.tcb-segment:hover { opacity: 0.75; }
.tcb-segment.counting    { background: #4CAF50; }
.tcb-segment.halftime    { background: #CE93D8; }
.tcb-segment.weekend     { background: #E0E0E0; }
.tcb-segment.holiday     { background: #BBDEFB; }
.tcb-segment.excluded    { background: #BDBDBD; }
.tcb-segment.weather     { background: #90CAF9; }
.tcb-segment.interrupted { background: #FFB74D; }
.tcb-segment.demurrage   { background: #EF5350; }
.tcb-segment.before_laytime { background: #F3F4F6; }

.tcb-expired-marker {
  position: absolute;
  top: -20px;
  transform: translateX(-50%);
  color: #D32F2F;
  font-size: 14px;
  font-weight: bold;
  white-space: nowrap;
  pointer-events: none;
}

.tcb-expired-marker::after {
  content: '▼';
  display: block;
  text-align: center;
  font-size: 12px;
}

.tcb-timeline-dates {
  display: flex;
  justify-content: space-between;
  margin-top: 4px;
  font-size: 10px;
  color: var(--tcb-muted);
}

/* ── Demurrage / Despatch highlight in sidebar ─────────────────────── */

.tcb-demurrage { color: var(--tcb-red); }
.tcb-despatch  { color: var(--tcb-green); }

/* ── Empty results ─────────────────────────────────────────────────── */

.tcb-empty-results {
  text-align: center;
  padding: 48px 24px;
  color: var(--tcb-muted);
}

/* ── Footer ────────────────────────────────────────────────────────── */

.tcb-footer {
  background: var(--tcb-navy);
  color: rgba(255,255,255,0.6);
  text-align: center;
  padding: 12px 24px;
  font-size: 13px;
  border-radius: 0 0 8px 8px;
}

/* ── Export bar ────────────────────────────────────────────────────── */

.tcb-export-bar {
  display: flex;
  gap: 12px;
  margin-bottom: 24px;
  padding: 16px;
  background: var(--tcb-bg);
  border-radius: 8px;
}

.tcb-export-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  border: 1px solid var(--tcb-navy);
  border-radius: 4px;
  background: var(--tcb-white);
  color: var(--tcb-navy);
  cursor: pointer;
  font-size: 14px;
  font-family: inherit;
  transition: background 0.2s, color 0.2s;
}

.tcb-export-btn:hover {
  background: var(--tcb-navy);
  color: var(--tcb-white);
}

/* ── Share buttons ────────────────────────────────────────────────── */

.tcb-share-group {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.tcb-share-label {
  font-size: 12px;
  color: #888;
  font-weight: 500;
}

.tcb-share-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  min-width: 36px;
  min-height: 36px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  padding: 0;
  transition: transform 0.2s, opacity 0.2s;
}

.tcb-share-btn:hover {
  transform: scale(1.1);
  opacity: 0.85;
}

.tcb-share-linkedin { background: #0A66C2; color: white; }
.tcb-share-facebook { background: #1877F2; color: white; }
.tcb-share-x { background: #000000; color: white; }

/* ── Port Manager Bar ──────────────────────────────────────────────── */

.tcb-port-manager {
  background: var(--tcb-white);
  border-bottom: 2px solid var(--tcb-border);
  padding: 12px 24px 0;
}

.tcb-port-bar {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  flex-wrap: wrap;
}

.tcb-port-bar-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--tcb-muted);
  padding-bottom: 10px;
  margin-right: 4px;
}

/* Port card — tab-style chip */
.tcb-port-card {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  border: 1px solid var(--tcb-border);
  border-bottom: none;
  border-radius: 6px 6px 0 0;
  background: var(--tcb-bg);
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  color: var(--tcb-muted);
  transition: border-color 0.15s, color 0.15s, background 0.15s;
  margin-bottom: -2px;
  position: relative;
}

.tcb-port-card:hover {
  border-color: var(--tcb-teal);
  color: var(--tcb-navy);
}

.tcb-port-card.active {
  border-color: var(--tcb-navy);
  border-bottom: 2px solid var(--tcb-white);
  background: var(--tcb-white);
  color: var(--tcb-navy);
  z-index: 1;
}

.tcb-port-card-name {
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tcb-port-card-rename {
  background: none;
  border: none;
  color: var(--tcb-muted);
  cursor: pointer;
  padding: 0 2px;
  font-size: 13px;
  line-height: 1;
  opacity: 0.5;
  transition: color 0.15s, opacity 0.15s;
}

.tcb-port-card-rename:hover {
  color: var(--tcb-teal);
  opacity: 1;
}

.tcb-port-card-remove {
  background: none;
  border: none;
  color: var(--tcb-muted);
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  padding: 0 2px;
  opacity: 0.5;
}

.tcb-port-card-remove:hover {
  color: var(--tcb-red);
  opacity: 1;
}

/* Type badge inside port card */
.tcb-port-type-badge {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 2px 6px;
  border-radius: 3px;
  flex-shrink: 0;
  background: var(--tcb-navy);
  color: var(--tcb-white);
}

.tcb-port-type-badge.loading     { background: var(--tcb-teal); }
.tcb-port-type-badge.discharging { background: var(--tcb-navy); }

/* When the badge is a toggle button */
button.tcb-port-type-toggle {
  border: none;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.1s;
}

button.tcb-port-type-toggle:hover {
  opacity: 0.8;
  transform: scale(1.05);
}

button.tcb-port-type-toggle:active {
  transform: scale(0.97);
}

button.tcb-port-type-toggle::after {
  content: ' ⇄';
  font-size: 9px;
  opacity: 0.7;
}

/* "+ Add Port" button */
.tcb-btn-add-port {
  padding: 7px 14px;
  font-size: 13px;
  font-family: inherit;
  border: 1px dashed var(--tcb-border);
  border-bottom: none;
  border-radius: 6px 6px 0 0;
  background: transparent;
  color: var(--tcb-muted);
  cursor: pointer;
  margin-bottom: -2px;
}

.tcb-btn-add-port:hover {
  border-color: var(--tcb-teal);
  color: var(--tcb-teal);
}

/* ── Berth tabs (sub-row under active port card) ────────────────────── */

.tcb-berth-bar {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 8px 0 0;
}

.tcb-berth-tab {
  padding: 5px 14px;
  font-size: 12px;
  font-family: inherit;
  border: 1px solid var(--tcb-border);
  border-radius: 4px 4px 0 0;
  border-bottom: none;
  background: var(--tcb-bg);
  color: var(--tcb-muted);
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}

.tcb-berth-tab:hover {
  border-color: var(--tcb-teal);
  color: var(--tcb-teal);
}

.tcb-berth-tab.active {
  background: var(--tcb-white);
  border-color: var(--tcb-teal);
  color: var(--tcb-teal);
  font-weight: 600;
}

.tcb-berth-tab-rename {
  background: none;
  border: none;
  color: var(--tcb-muted);
  cursor: pointer;
  padding: 0 2px;
  font-size: 12px;
  line-height: 1;
  opacity: 0.4;
  margin-left: -2px; /* tuck it close to the berth tab */
  transition: color 0.15s, opacity 0.15s;
}

.tcb-berth-tab-rename:hover {
  color: var(--tcb-teal);
  opacity: 1;
}

.tcb-btn-add-berth {
  padding: 5px 10px;
  font-size: 12px;
  font-family: inherit;
  border: 1px dashed var(--tcb-border);
  border-radius: 4px;
  background: transparent;
  color: var(--tcb-muted);
  cursor: pointer;
}

.tcb-btn-add-berth:hover {
  border-color: var(--tcb-teal);
  color: var(--tcb-teal);
}

/* ── SOF panel inner padding (below port manager) ───────────────────── */

.tcb-tab-panels-inner {
  padding: 24px;
}

/* ── Multi-Port Results ─────────────────────────────────────────────── */

.tcb-port-results {
  margin-bottom: 24px;
}

.tcb-port-result {
  border: 1px solid var(--tcb-border);
  border-radius: 8px;
  margin-bottom: 12px;
  overflow: hidden;
}

.tcb-port-result-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  background: var(--tcb-bg);
  border-bottom: 1px solid var(--tcb-border);
  cursor: pointer;
  font-weight: 600;
  color: var(--tcb-navy);
  font-size: 14px;
}

.tcb-port-result-header:hover {
  background: rgba(44, 166, 164, 0.05);
}

.tcb-port-result-body {
  padding: 16px;
}

.tcb-combined-result {
  border: 2px solid var(--tcb-navy);
  border-radius: 8px;
  padding: 24px;
  margin-bottom: 24px;
  background: var(--tcb-bg);
}

.tcb-combined-result h3 {
  font-size: 16px;
  color: var(--tcb-navy);
  margin: 0 0 16px;
}

/* ── Non-Reversible Per-Port Summary ─────────────────────────────── */

.tcb-non-reversible-summary {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.tcb-non-reversible-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: white;
  border: 1px solid var(--tcb-border);
  border-radius: 6px;
}

.tcb-non-reversible-port-name {
  flex: 1;
  font-weight: 600;
}

.tcb-non-reversible-verdict {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.tcb-non-reversible-amount {
  font-size: 16px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  min-width: 130px;
  text-align: right;
}

/* ── Public Holiday Calendar ─────────────────────────────────────── */

#tcb-public-holidays-section {
  margin-top: 16px;
  margin-bottom: 8px;
}

.tcb-ph-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.tcb-ph-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--tcb-navy);
}

.tcb-ph-year-sel {
  width: auto;
  min-width: 80px;
  padding: 4px 8px;
  font-size: 13px;
}

.tcb-ph-warning {
  background: #fef3c7;
  border: 1px solid #f59e0b;
  border-radius: 4px;
  padding: 7px 12px;
  font-size: 12px;
  color: #92400e;
  margin-bottom: 8px;
}

.tcb-ph-list {
  max-height: 220px;
  overflow-y: auto;
  border: 1px solid var(--tcb-border);
  border-radius: 4px;
  padding: 4px 10px;
  margin-bottom: 8px;
  background: var(--tcb-white);
}

.tcb-holiday-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 0;
  font-size: 13px;
  cursor: pointer;
  border-bottom: 1px solid #f0f0f0;
}

.tcb-holiday-item:last-child {
  border-bottom: none;
}

.tcb-holiday-item:hover {
  background: var(--tcb-bg);
}

.tcb-holiday-date {
  color: var(--tcb-muted);
  font-size: 12px;
  min-width: 44px;
  flex-shrink: 0;
}

.tcb-ph-approx {
  color: #f59e0b;
  cursor: help;
  font-size: 12px;
}

.tcb-ph-actions {
  margin-top: 4px;
}

/* ── Charter Party Preset Info Box ──────────────────────────────── */

.tcb-preset-info {
  background: #eef7f7;
  border-left: 3px solid var(--tcb-teal);
  border-radius: 0 6px 6px 0;
  padding: 10px 14px;
  margin-top: 8px;
  font-size: 13px;
  line-height: 1.5;
}

.tcb-preset-desc {
  font-weight: 600;
  color: var(--tcb-navy);
  margin-bottom: 4px;
}

.tcb-preset-notes {
  color: var(--tcb-muted);
  font-size: 12px;
}

/* ── Laytime Commencement Info (Results) ─────────────────────────── */

.tcb-commence-info {
  font-size: 13px;
  color: var(--tcb-muted);
  margin-bottom: 12px;
  padding: 8px 12px;
  background: var(--tcb-bg);
  border-radius: 6px;
  border-left: 3px solid var(--tcb-teal);
}

.tcb-commence-label {
  font-weight: 600;
  color: var(--tcb-navy);
}

.tcb-commence-rule {
  color: var(--tcb-muted);
  font-size: 12px;
}

/* ── Weather Log ─────────────────────────────────────────────────── */

.tcb-weather-log {
  margin-top: 24px;
}

.tcb-weather-table-container {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.tcb-weather-table {
  width: 100%;
  min-width: 600px;
  border-collapse: collapse;
  table-layout: fixed;
  font-size: 14px;
}

.tcb-weather-table thead {
  background: var(--tcb-navy);
  color: var(--tcb-white);
}

.tcb-weather-table th {
  padding: 10px 12px;
  text-align: left;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  letter-spacing: 0.04em;
}

.tcb-weather-table td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--tcb-border);
  vertical-align: middle;
}

.tcb-weather-table .tcb-input {
  padding: 6px 8px;
  font-size: 13px;
}

/* Column widths */
.tcb-wl-num     { width: 40px; text-align: center; color: var(--tcb-muted); font-size: 12px; }
.tcb-wl-from,
.tcb-wl-to      { width: 150px; }
.tcb-wl-from .tcb-dt-wrap,
.tcb-wl-to   .tcb-dt-wrap { display: flex; flex-direction: column; gap: 4px; }
.tcb-wl-from .tcb-input,
.tcb-wl-to   .tcb-input { width: 100%; }
.tcb-wl-type    { width: 18%; }
.tcb-wl-remarks { width: auto; }
.tcb-wl-actions { width: 48px; text-align: center; }

.tcb-wl-empty {
  text-align: center;
  color: var(--tcb-muted);
  font-style: italic;
  padding: 16px;
}


/* ── Per-Port Allowances ─────────────────────────────────────────── */

/* Per-port allowance blocks */
.tcb-port-allowance-block {
  padding: 12px 0;
  border-bottom: 1px solid var(--tcb-border);
}

.tcb-port-allowance-block:last-of-type {
  border-bottom: none;
}

.tcb-port-allowance-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}

.tcb-port-allowance-label {
  font-weight: 600;
  font-size: 13px;
  color: var(--tcb-navy);
}

/* Method toggle radio pills */
.tcb-allowance-method-toggle {
  display: flex;
  gap: 0;
  border: 1px solid var(--tcb-border);
  border-radius: 6px;
  overflow: hidden;
}

.tcb-method-radio {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 5px 12px;
  font-size: 12px;
  font-weight: 500;
  color: var(--tcb-muted);
  cursor: pointer;
  background: var(--tcb-bg);
  transition: background 0.15s, color 0.15s;
  text-transform: none;
  letter-spacing: 0;
}

.tcb-method-radio + .tcb-method-radio {
  border-left: 1px solid var(--tcb-border);
}

.tcb-method-radio input[type="radio"] {
  display: none;
}

.tcb-method-radio.active,
.tcb-method-radio:has(input:checked) {
  background: var(--tcb-navy);
  color: #fff;
}

/* Calculated result display */
.tcb-allowance-calc-result {
  margin-top: 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--tcb-teal);
  padding: 6px 10px;
  background: rgba(44, 166, 164, 0.08);
  border-radius: 4px;
  border-left: 3px solid var(--tcb-teal);
}

/* Legacy row class kept for total row */
.tcb-port-allowances-fieldset .tcb-port-allowance-row {
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.tcb-port-allowance-row .tcb-input {
  width: 72px;
}

.tcb-port-allowance-total {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--tcb-border);
  font-size: 13px;
}

.tcb-port-allowance-total-label {
  font-weight: 700;
  color: var(--tcb-navy);
  min-width: 160px;
}

.tcb-port-allowance-total-value {
  font-weight: 700;
  color: var(--tcb-teal);
  font-size: 15px;
}

/* ── Responsive: Tablet (768px–1200px) ────────────────────────────── */

@media (max-width: 1200px) {
  .tcb-main {
    grid-template-columns: 1fr;
  }

  .tcb-sidebar {
    border: 1px solid #E0E0E0;
    border-radius: 8px;
    position: relative;
    top: 0;
    order: -1; /* Moves summary ABOVE the tab content */
  }

  .tcb-laytime-calculator-wrapper {
    padding: 0 24px;
  }
}

/* ── Responsive: Mobile (<768px) ──────────────────────────────────── */

@media (max-width: 768px) {
  .tcb-main {
    grid-template-columns: 1fr;
  }

  .tcb-sidebar {
    border-left: none;
    border-top: 1px solid var(--tcb-border);
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    top: auto;
    max-height: 120px;
    z-index: 100;
    box-shadow: 0 -2px 8px rgba(0,0,0,0.1);
    border-radius: 0;
    order: unset;
  }

  .tcb-tab-panels {
    padding: 16px;
    padding-bottom: 140px;
  }

  .tcb-sof-table-container {
    overflow-x: auto; /* allow scroll on small screens if table overflows */
    -webkit-overflow-scrolling: touch;
  }

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

  .tcb-header {
    border-radius: 0;
    padding: 12px 16px;
  }

  .tcb-header-top {
    flex-wrap: wrap;
  }

  .tcb-footer {
    border-radius: 0;
  }

  .tcb-laytime-calculator-wrapper {
    padding: 0 12px;
  }

  .tcb-fieldset {
    padding: 16px;
    margin: 0 0 24px;
  }
}

@media (max-width: 600px) {
  .tcb-tabs {
    padding: 0 8px;
  }

  .tcb-tab {
    padding: 10px 12px;
    font-size: 13px;
  }

  .tcb-tab-panels {
    padding: 12px;
    padding-bottom: 140px;
  }

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

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

  .tcb-header-actions {
    width: 100%;
  }

  .tcb-header-actions .tcb-btn-header {
    flex: 1;
    text-align: center;
  }

  .tcb-laytime-calculator-wrapper {
    padding: 0 8px;
  }
}

/* ============================================================
   Port Cards (Charter Terms Tab)
   ============================================================ */

.tcb-ports-section {
  margin-top: 24px;
}

.tcb-ports-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.tcb-ports-title {
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--tcb-text-secondary);
}

.tcb-port-card-term {
  border: 1px solid var(--tcb-border);
  border-radius: 8px;
  margin-bottom: 10px;
  background: var(--tcb-surface);
  overflow: hidden;
}

.tcb-port-card-term-header {
  display: flex;
  align-items: center;
  padding: 10px 14px;
  cursor: pointer;
  user-select: none;
  gap: 10px;
  background: var(--tcb-surface);
  transition: background 0.15s;
}

.tcb-port-card-term-header:hover {
  background: var(--tcb-surface-hover, rgba(0,0,0,0.03));
}

.tcb-port-card-term-toggle {
  font-size: 11px;
  color: var(--tcb-text-secondary);
  width: 16px;
  flex-shrink: 0;
  transition: transform 0.2s;
}

.tcb-port-card-term.open .tcb-port-card-term-toggle {
  transform: rotate(90deg);
}

.tcb-port-card-term-title {
  flex: 1;
  font-size: 13px;
  font-weight: 600;
  color: var(--tcb-text-primary);
}

.tcb-port-card-term-actions {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}

.tcb-port-card-rename,
.tcb-port-card-remove {
  background: none;
  border: none;
  padding: 4px 6px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 13px;
  line-height: 1;
  color: var(--tcb-text-secondary);
  transition: background 0.15s, color 0.15s;
}

.tcb-port-card-rename:hover {
  background: var(--tcb-surface-hover, rgba(0,0,0,0.06));
  color: var(--tcb-text-primary);
}

.tcb-port-card-remove:hover {
  background: #fee2e2;
  color: #dc2626;
}

.tcb-port-card-term-body {
  padding: 0 14px 16px;
  border-top: 1px solid var(--tcb-border);
  display: none;
}

.tcb-port-card-term.open .tcb-port-card-term-body {
  display: block;
}

/* Laytime allowance inside port card */

.tcb-allowance-section {
  margin-top: 14px;
}

.tcb-allowance-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.tcb-allowance-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--tcb-text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* (toggle/radio/calc-result styles defined earlier — see "Method toggle radio pills") */

/* Special Counting Rules */

.tcb-counting-rules-section {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px dashed var(--tcb-border);
}

.tcb-counting-rules-header {
  font-size: 12px;
  font-weight: 600;
  color: var(--tcb-text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 8px;
}

/* ── Working Hours UI ────────────────────────────────────────────── */

.tcb-wh-custom-section {
  margin-top: 4px;
  padding-left: 4px;
}

.tcb-wh-perday-row {
  margin-bottom: 6px;
}

.tcb-wh-period-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 4px;
}

.tcb-wh-period-row input[type="time"] {
  width: 110px;
}

.tcb-wh-to {
  font-size: 12px;
  color: var(--tcb-text-secondary);
}

.tcb-wh-period-remove {
  background: none;
  border: none;
  color: var(--tcb-danger, #D64045);
  font-size: 16px;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
}

.tcb-wh-period-remove:hover {
  opacity: 0.7;
}

.tcb-link-btn {
  background: none;
  border: none;
  color: var(--tcb-teal, #2CA6A4);
  font-size: 12px;
  cursor: pointer;
  padding: 2px 0;
  font-weight: 600;
}

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

.tcb-wh-perday-grid {
  margin-top: 6px;
}

.tcb-wh-grid-header {
  display: grid;
  grid-template-columns: 90px 1fr;
  gap: 6px;
  font-size: 11px;
  font-weight: 600;
  color: var(--tcb-text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--tcb-border);
  margin-bottom: 4px;
}

.tcb-wh-day-row {
  display: grid;
  grid-template-columns: 90px 1fr;
  gap: 6px;
  align-items: start;
  padding: 3px 0;
}

.tcb-wh-day-label {
  font-size: 13px;
  font-weight: 500;
  padding-top: 6px;
}

.tcb-wh-day-periods {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.tcb-wh-day-periods .tcb-wh-period-row input[type="time"] {
  width: 90px;
  font-size: 12px;
  padding: 3px 4px;
}

.tcb-wh-badge {
  font-size: 11px;
  font-weight: 500;
  color: var(--tcb-teal, #2CA6A4);
  margin-left: 6px;
}

.tcb-wh-overlap-warn {
  font-size: 11px;
  color: var(--tcb-danger, #D64045);
  margin: 2px 0 4px;
}

.tcb-wh-period-error {
  background: #FFF3F3;
  border-radius: 4px;
  padding: 2px 4px;
}

.tcb-wh-period-error input[type="time"] {
  border-color: var(--tcb-danger, #D64045);
}

.tcb-wh-row-error {
  font-size: 11px;
  color: var(--tcb-danger, #D64045);
  white-space: nowrap;
}

/* Reversible total */

.tcb-port-allowance-total {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--tcb-surface-alt, #f8fafc);
  border: 1px solid var(--tcb-border);
  border-radius: 8px;
  padding: 10px 14px;
  margin-top: 12px;
}

.tcb-port-allowance-total-label {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--tcb-text-secondary);
}

.tcb-port-allowance-total-value {
  font-size: 14px;
  font-weight: 700;
  color: var(--tcb-text-primary);
}

/* Add Port button */

.tcb-btn-add-port {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  font-size: 13px;
  font-weight: 500;
  border: 1px dashed var(--tcb-border);
  border-radius: 6px;
  background: none;
  color: var(--tcb-text-secondary);
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
  margin-top: 10px;
  width: 100%;
  justify-content: center;
}

.tcb-btn-add-port:hover {
  border-color: var(--tcb-primary, #2563eb);
  color: var(--tcb-primary, #2563eb);
  background: rgba(37,99,235,0.04);
}

/* Public holidays section inside port card */

.tcb-ph-section-port {
  margin-top: 10px;
}

/* NOR hours row (shown/hidden based on NOR valid setting) */

.tcb-nor-hours-row {
  display: none;
}

.tcb-nor-hours-row.visible {
  display: grid;
}

/* SOF port tab bar */

.tcb-sof-port-bar {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--tcb-border);
}

.tcb-sof-port-tab {
  padding: 6px 14px;
  font-size: 13px;
  font-weight: 500;
  border: 1px solid var(--tcb-border);
  border-radius: 6px;
  background: var(--tcb-surface);
  color: var(--tcb-text-secondary);
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  white-space: nowrap;
}

.tcb-sof-port-tab:hover {
  background: var(--tcb-surface-hover, rgba(0,0,0,0.04));
  color: var(--tcb-text-primary);
}

.tcb-sof-port-tab.active {
  background: var(--tcb-primary, #2563eb);
  color: #fff;
  border-color: var(--tcb-primary, #2563eb);
}

/* ============================================================
   Responsive additions — Mobile & Tablet (Phase C)
   ============================================================ */

/* ── Global: iOS date/time input fixes ────────────────────── */

input[type="date"],
input[type="time"] {
  -webkit-appearance: none;
  min-height: 44px;
}

/* iOS momentum scrolling for scrollable containers */
.tcb-breakdown-scroll {
  -webkit-overflow-scrolling: touch;
}

/* ── Tablet (≤ 1200px) additions ──────────────────────────── */

@media (max-width: 1200px) {
  /* SOF port tab bar wraps on narrower tablet */
  .tcb-sof-port-bar {
    flex-wrap: wrap;
  }
}

/* ── Phone (≤ 768px) additions ───────────────────────────── */

@media (max-width: 768px) {

  /* Inputs full width within form rows */
  .tcb-form-row input,
  .tcb-form-row select,
  .tcb-fieldset input,
  .tcb-fieldset select {
    max-width: 100%;
    width: 100%;
    box-sizing: border-box;
  }

  /* SOF table: minimum width so columns don't crush */
  .tcb-sof-table {
    min-width: 560px;
  }

  /* Breakdown table: scrollable */
  .tcb-breakdown-scroll {
    overflow-x: auto;
    margin: 0 -4px;
    padding: 0 4px;
  }

  .tcb-breakdown-table {
    min-width: 640px;
  }

  /* Export bar: stack buttons vertically */
  .tcb-export-bar {
    flex-direction: column;
    gap: 8px;
  }

  .tcb-export-btn {
    width: 100%;
    text-align: center;
  }

  /* Holiday checklist: single column */
  .tcb-ph-list {
    columns: 1 !important;
  }

  /* Preset info: smaller text */
  .tcb-preset-info {
    font-size: 12px;
  }

  /* Timeline bar: reduced height */
  .tcb-timeline-bar {
    height: 24px;
  }

  /* Results amount: larger on phone for readability */
  .tcb-card.tcb-demurrage .tcb-card-value,
  .tcb-card.tcb-despatch .tcb-card-value {
    font-size: 20px;
  }

  /* ── Touch targets (min 44 × 44px) ─────────────────────── */

  .tcb-btn {
    min-height: 44px;
    padding: 10px 18px;
  }

  .tcb-input {
    min-height: 44px;
    font-size: 16px; /* prevents iOS auto-zoom on focus */
  }

  /* SOF row delete button */
  .tcb-btn-remove {
    min-width: 44px;
    min-height: 44px;
  }

  /* Port card rename / remove buttons */
  .tcb-port-card-rename,
  .tcb-port-card-remove {
    min-width: 44px;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  /* Holiday list checkboxes */
  .tcb-ph-list input[type="checkbox"] {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
  }

  /* ── iOS: prevent zoom on input focus ──────────────────── */

  input[type="text"],
  input[type="number"],
  input[type="date"],
  input[type="time"],
  select,
  textarea {
    font-size: 16px !important;
  }
}

/* ═══════════════════════════════════════════════════════════════════════
   SAVE / LOAD MODALS & UI
   ═══════════════════════════════════════════════════════════════════════ */

/* ── Modal overlay ─────────────────────────────────────────────────── */

.tcb-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.tcb-modal {
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.25);
  width: 100%;
  max-width: 520px;
  max-height: 80vh;
  overflow-y: auto;
  padding: 24px;
  animation: tcb-fadeIn 0.2s ease;
}

.tcb-modal h3 {
  margin: 0 0 16px;
  font-size: 18px;
  color: var(--tcb-navy, #1a2740);
}

.tcb-modal p {
  margin: 0 0 16px;
  color: var(--tcb-muted, #666);
  font-size: 14px;
  line-height: 1.5;
}

.tcb-modal-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--tcb-navy, #1a2740);
  margin-bottom: 6px;
}

.tcb-modal-input {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--tcb-border, #ddd);
  border-radius: 4px;
  font-size: 14px;
  margin-bottom: 16px;
  box-sizing: border-box;
}

.tcb-modal-input:focus {
  outline: none;
  border-color: var(--tcb-teal, #00897b);
  box-shadow: 0 0 0 2px rgba(0, 137, 123, 0.15);
}

.tcb-modal-error {
  background: #fff1f1;
  color: var(--tcb-red, #D64045);
  font-size: 13px;
  padding: 8px 12px;
  border-radius: 4px;
  margin-bottom: 8px;
}

/* ── Save limit count ───────────────────────────────────────────── */
.tcb-save-count {
  font-size: 13px;
  color: var(--tcb-navy, #1B2A4A);
  padding: 6px 10px;
  background: #f0f4f8;
  border-radius: 4px;
  margin-bottom: 10px;
  font-weight: 500;
}
.tcb-save-count-orange, .tcb-save-count-orange span { color: #e67e22; background: #fef6e8; }
.tcb-save-count-red, .tcb-save-count-red span { color: var(--tcb-red, #D64045); background: #fff1f1; font-weight: 600; }

.tcb-modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 16px;
}

.tcb-btn-cancel {
  background: transparent;
  color: var(--tcb-muted, #666);
  border: 1px solid var(--tcb-border, #ddd);
}

.tcb-btn-cancel:hover {
  background: #2CA6A4 !important;
  color: #fff !important;
  border-color: #2CA6A4 !important;
}

.tcb-btn-outline,
a.tcb-btn-outline,
a.tcb-btn-outline:link,
a.tcb-btn-outline:visited {
  background: #fff;
  color: #1B2A4A;
  border: 1px solid #ddd;
  text-decoration: none;
  display: inline-block;
  text-align: center;
}

.tcb-btn-outline:hover,
a.tcb-btn-outline:hover {
  background: #2CA6A4 !important;
  color: #fff !important;
  border-color: #2CA6A4 !important;
}

.tcb-btn-sm {
  padding: 4px 10px;
  font-size: 12px;
}

.tcb-load-btn {
  background: #2CA6A4;
  color: #fff;
  padding: 8px 16px;
  border-radius: 4px;
  font-weight: 600;
  font-size: 13px;
  border: none;
  min-height: 44px;
  cursor: pointer;
  transition: background 0.15s;
}

.tcb-load-btn:hover {
  background: #238B89;
}

.tcb-delete-btn {
  background: transparent;
  color: #D64045;
  border: 1px solid #D64045;
  padding: 8px 12px;
  border-radius: 4px;
  font-size: 13px;
  min-height: 44px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.tcb-delete-btn:hover {
  background: #D64045;
  color: #fff;
}

/* ── Load list ─────────────────────────────────────────────────────── */

.tcb-load-list {
  max-height: 400px;
  overflow-y: auto;
  margin: 0 -8px;
  padding: 0 8px;
}

.tcb-load-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--tcb-border, #ddd);
  border-radius: 6px;
  margin-bottom: 8px;
  transition: background 0.15s;
}

.tcb-load-item:hover {
  background: #f8f9fa;
}

.tcb-load-item-info {
  flex: 1;
  min-width: 0;
}

.tcb-load-item-title {
  font-weight: 600;
  font-size: 14px;
  color: var(--tcb-navy, #1a2740);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tcb-load-item-meta {
  font-size: 12px;
  color: var(--tcb-muted, #666);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tcb-load-item-date {
  font-size: 11px;
  color: #999;
  margin-top: 2px;
}

.tcb-load-item-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

.tcb-load-count {
  text-align: center;
  font-size: 12px;
  color: var(--tcb-muted, #666);
  margin-top: 8px;
}

/* ── Auto-save indicator ───────────────────────────────────────────── */

.tcb-autosave-indicator {
  text-align: right;
  font-size: 11px;
  color: var(--tcb-muted, #888);
  padding: 6px 12px;
}

/* ── Toast notice ──────────────────────────────────────────────────── */

.tcb-notice {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--tcb-navy, #1a2740);
  color: #fff;
  padding: 10px 20px;
  border-radius: 6px;
  font-size: 13px;
  z-index: 10001;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.3s, transform 0.3s;
  pointer-events: none;
}

.tcb-notice-show {
  opacity: 1;
  transform: translateY(0);
}

/* ── User Guide button ─────────────────────────────────────────────── */
.tcb-btn-guide {
  background: transparent;
  border: 1px solid #2CA6A4;
  color: #2CA6A4;
  padding: 6px 14px;
  font-size: 13px;
  font-weight: 500;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}
.tcb-btn-guide:hover {
  background: #2CA6A4;
  color: #fff;
}

/* ── Report Issue button & form ─────────────────────────────────────── */
.tcb-btn-report {
  background: transparent;
  border: 1.5px solid #5b6b7d;
  color: #5b6b7d;
}
.tcb-btn-report:hover {
  background: #5b6b7d;
  color: #fff;
}
.tcb-email-from {
  background: #f5f7fa;
  border-radius: 6px;
  padding: 10px 14px;
  margin-bottom: 14px;
  font-size: 0.92em;
  color: #5b6b7d;
}
.tcb-email-options {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
}
.tcb-email-options label {
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
}
.tcb-report-profile {
  background: #f5f7fa;
  border-radius: 6px;
  padding: 10px 14px;
  margin-bottom: 14px;
  font-size: 0.92em;
  line-height: 1.6;
}
.tcb-report-profile strong {
  display: inline-block;
  min-width: 50px;
}
.tcb-issue-description {
  width: 100%;
  min-height: 150px;
  height: 150px;
  resize: vertical;
  font-family: inherit;
  font-size: 14px;
  padding: 10px;
  border: 1px solid #CCC;
  border-radius: 4px;
  box-sizing: border-box;
}

/* ── Mandatory field asterisk ───────────────────────────────────────── */
.tcb-required::after {
  content: ' *';
  color: #D64045;
  font-weight: 700;
}

/* ── Validation: disabled buttons ──────────────────────────────────── */
.tcb-btn-disabled,
.tcb-export-btn.tcb-btn-disabled {
  opacity: 0.45;
  cursor: not-allowed;
  pointer-events: auto; /* still clickable to show popup */
}
.tcb-btn-disabled:hover {
  opacity: 0.55;
}

/* ── Validation: port tab error/ok indicators ──────────────────────── */
.tcb-port-error-icon {
  color: #D64045;
  font-size: 0.85em;
  margin-left: 4px;
}
.tcb-port-ok-icon {
  color: #4CAF50;
  font-size: 0.85em;
  margin-left: 4px;
}
.tcb-sof-port-tab.tcb-port-has-error {
  border-color: #D64045;
}

/* ── Validation summary modal list ─────────────────────────────────── */
.tcb-validation-list {
  text-align: left;
  padding-left: 20px;
  margin: 12px 0;
  max-height: 300px;
  overflow-y: auto;
}
.tcb-validation-list li {
  margin-bottom: 6px;
  font-size: 0.92em;
  line-height: 1.4;
}
.tcb-validation-list li strong {
  color: #D64045;
}
