:root {
  --bg: #0b0f19;
  --surface: #111827;
  --surface-2: #1e293b;
  --border: #334155;
  --text: #f8fafc;
  --muted: #94a3b8;
  --primary: #dc2626;
  --primary-hover: #b91c1c;
  --secondary: #2563eb;
  --success: #16a34a;
  --warning: #d97706;
  --danger: #ef4444;
  --radius: 12px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: "Inter", system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

.hidden {
  display: none !important;
}

/* Login */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 28px 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

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

.login-brand h1 {
  font-size: 20px;
  font-weight: 800;
}

.login-brand p {
  font-size: 12.5px;
  color: var(--muted);
}

.brand-badge {
  background: var(--primary);
  color: #fff;
  font-weight: 800;
  font-size: 14px;
  padding: 10px 12px;
  border-radius: 10px;
  letter-spacing: 0.5px;
}

.brand-badge.sm {
  padding: 6px 9px;
  font-size: 12px;
}

/* Header & Navigation */
.app-shell {
  max-width: 1320px;
  margin: 0 auto;
  padding: 12px 16px 48px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
}

.topbar-left,
.topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.topbar-title {
  font-weight: 800;
  font-size: 16px;
}

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

.clock-pill,
.pool-pill {
  background: var(--surface-2);
  border: 1px solid var(--border);
  padding: 6px 10px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
}

.nav-tabs {
  display: flex;
  gap: 8px;
  margin: 14px 0;
  overflow-x: auto;
  padding-bottom: 4px;
}

.nav-tab {
  background: var(--surface);
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 9px 14px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

.nav-tab.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

/* Cards & Grids */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 14px;
}

.card h3 {
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 6px;
}

.toolbar-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.filters-row {
  margin-top: 12px;
}

.date-nav {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

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

.kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
}

.kpi-card.success {
  border-left: 4px solid var(--success);
}

.kpi-card.warning {
  border-left: 4px solid var(--warning);
}

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

.kpi-value {
  font-size: 22px;
  font-weight: 800;
  margin-top: 2px;
}

.batch-title {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--muted);
  margin-bottom: 8px;
}

.batch-controls {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.batch-controls select,
.batch-controls input {
  flex: 1;
  min-width: 160px;
}

.two-col-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
}

.recap-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
}

.full-span {
  grid-column: 1 / -1;
}

/* Inputs & Buttons */
input,
select {
  width: 100%;
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 11px;
  font-size: 13.5px;
  font-family: inherit;
}

input:focus,
select:focus {
  outline: none;
  border-color: #60a5fa;
}

.input-date,
.select-compact,
.select-filter {
  width: auto;
}

.search-input {
  flex: 1;
  min-width: 220px;
}

.prefix-input-group {
  display: flex;
  align-items: stretch;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  background: var(--surface-2);
}

.prefix-badge {
  display: flex;
  align-items: center;
  padding: 0 10px;
  background: #0f172a;
  color: #facc15;
  font-weight: 700;
  font-size: 13px;
  border-right: 1px solid var(--border);
  white-space: nowrap;
  user-select: none;
}

.prefix-input-group input {
  border: none;
  border-radius: 0;
  flex: 1;
}

.btn {
  border: none;
  border-radius: 8px;
  padding: 9px 14px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  font-family: inherit;
}

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

.btn-block {
  width: 100%;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
}

.btn-primary:hover {
  background: var(--primary-hover);
}

.btn-secondary {
  background: var(--secondary);
  color: #fff;
}

.btn-ghost {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-danger {
  background: var(--danger);
  color: #fff;
}

.btn-icon {
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 18px;
  cursor: pointer;
}

.link-btn {
  background: none;
  border: none;
  color: #60a5fa;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  padding: 0;
}

/* Forms */
.stack-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.inline-form {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.inline-form input,
.inline-form select {
  flex: 1;
  min-width: 140px;
}

.form-grid-2 {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.form-group.full {
  grid-column: 1 / -1;
}

.label-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

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

.checkbox-inline {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text);
  cursor: pointer;
}

.checkbox-inline input {
  width: auto;
}

/* Tables & Badges */
.table-responsive {
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.data-table th,
.data-table td {
  text-align: left;
  padding: 10px 10px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.data-table th {
  color: var(--muted);
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.badge {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 700;
  background: var(--surface-2);
  border: 1px solid var(--border);
}

.badge-boarded {
  background: rgba(22, 163, 74, 0.2);
  color: #4ade80;
  border-color: rgba(74, 222, 128, 0.35);
}

.badge-checked {
  background: rgba(37, 99, 235, 0.2);
  color: #60a5fa;
  border-color: rgba(96, 165, 250, 0.35);
}

.badge-booked {
  background: rgba(217, 119, 6, 0.2);
  color: #fbbf24;
  border-color: rgba(251, 191, 36, 0.35);
}

.badge-noshow,
.badge-cancelled {
  background: rgba(239, 68, 68, 0.2);
  color: #f87171;
  border-color: rgba(248, 113, 113, 0.35);
}

/* Mobile Manifest Cards */
.mobile-only {
  display: none;
}

.mobile-cards-list {
  flex-direction: column;
  gap: 10px;
}

.m-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 13px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.m-card-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.m-card-name {
  font-size: 15px;
  font-weight: 800;
}

.m-card-meta {
  font-size: 12px;
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.m-card-actions {
  display: flex;
  gap: 8px;
  margin-top: 4px;
}

.m-card-actions .btn {
  flex: 1;
}

/* Modals, Boxes & Toast */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(2, 6, 23, 0.78);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 14px;
  z-index: 50;
}

.modal-card {
  width: 100%;
  max-width: 620px;
  max-height: 92vh;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 18px;
}

.modal-sm {
  max-width: 400px;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 12px;
}

.hint-text {
  font-size: 12.5px;
  color: var(--muted);
}

.error-box {
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.4);
  color: #fca5a5;
  padding: 9px 12px;
  border-radius: 8px;
  font-size: 12.5px;
}

.empty-box {
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  padding: 28px 16px;
  text-align: center;
  color: var(--muted);
  font-size: 13.5px;
}

.log-box {
  background: #020617;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px;
  font-family: monospace;
  font-size: 12px;
  max-height: 180px;
  overflow-y: auto;
  white-space: pre-wrap;
}

.toast-bar {
  position: fixed;
  bottom: 18px;
  left: 50%;
  transform: translateX(-50%);
  background: #1e293b;
  color: #f8fafc;
  border: 1px solid #475569;
  padding: 10px 16px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 600;
  z-index: 90;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.45);
}

@media (max-width: 768px) {
  .desktop-only {
    display: none !important;
  }
  .mobile-only {
    display: flex !important;
  }
  .kpi-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .two-col-grid,
  .recap-grid,
  .form-grid-2 {
    grid-template-columns: 1fr;
  }
}

/* Real Eka Logo */
.brand-logo {
  height: 44px;
  width: auto;
  object-fit: contain;
  display: block;
}

.brand-logo.sm {
  height: 32px;
}

/* Clickable Status Cycle Pill */
.status-cycle-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 10px;
  border-radius: 7px;
  font-size: 11px;
  font-weight: 800;
  font-family: inherit;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  cursor: pointer;
  transition: transform 0.08s ease, filter 0.15s ease;
}

.status-cycle-btn:hover {
  filter: brightness(1.15);
}

.status-cycle-btn:active {
  transform: scale(0.96);
}

.status-cycle-btn.st-boarded {
  background: rgba(22, 163, 74, 0.22);
  color: #4ade80;
  border-color: rgba(74, 222, 128, 0.45);
}

.status-cycle-btn.st-checked {
  background: rgba(37, 99, 235, 0.22);
  color: #60a5fa;
  border-color: rgba(96, 165, 250, 0.45);
}

.status-cycle-btn.st-booked {
  background: rgba(217, 119, 6, 0.22);
  color: #fbbf24;
  border-color: rgba(251, 191, 36, 0.45);
}

.status-cycle-btn.st-noshow {
  background: rgba(239, 68, 68, 0.22);
  color: #f87171;
  border-color: rgba(248, 113, 113, 0.45);
}

/* Inline Notes Input */
.inline-notes-input {
  padding: 6px 8px;
  font-size: 12.5px;
  min-width: 140px;
  background: #0f172a;
}

/* Group / Multi-Invoice Highlight */
tr.group-highlight-row {
  background: rgba(250, 204, 21, 0.06);
}

tr.group-highlight-row td:first-child {
  border-left: 3px solid #facc15;
}

.m-card.group-highlight-card {
  border-left: 4px solid #facc15;
  background: linear-gradient(90deg, rgba(250, 204, 21, 0.07) 0%, var(--surface) 45%);
}

.badge-group {
  display: inline-block;
  margin-top: 4px;
  background: rgba(250, 204, 21, 0.16);
  color: #fde047;
  border-color: rgba(250, 204, 21, 0.4);
}

/* Crew Summary Pills */
.crew-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}

.crew-pill {
  background: #0f172a;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 5px 10px;
  font-size: 12px;
  color: var(--text);
  cursor: pointer;
}

.crew-pill:hover {
  border-color: #60a5fa;
}
