:root {
  --delta-navy:   #002244;
  --delta-sky:    #0066B2;
  --delta-red:    #C8102E;
  --delta-red-lt: #E0455A;
  --delta-accent: #FFC72C;
  --border:       #E2E6EB;
  --text-dark:    #1A1F29;
  --text-mid:     #5B6472;
  --text-light:   #9AA3AF;
  --shadow-sm:    0 1px 3px rgba(0,0,0,.08);
  --shadow-md:    0 4px 16px rgba(0,0,0,.12);
  --header-h:     56px;
  --sidebar-w:    220px;
  --sidebar-w-collapsed: 64px;
}

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

body {
  font-family: 'Barlow', 'Inter', -apple-system, sans-serif;
  background: #F4F6F9;
  color: var(--text-dark);
  font-size: 14px;
  overflow: hidden;
}

.hidden { display: none !important; }

/* ── LOGIN ───────────────────────────────────────────────── */
#loginScreen {
  position: fixed; inset: 0;
  background: linear-gradient(135deg, var(--delta-navy) 0%, #003366 100%);
  display: flex; align-items: center; justify-content: center;
  z-index: 9000;
}
.login-box {
  background: #fff; border-radius: 8px; padding: 40px 36px;
  width: 380px; max-width: 92vw; box-shadow: var(--shadow-md);
}
.login-logo {
  font-family: 'Barlow Condensed', sans-serif; font-size: 26px; font-weight: 800;
  color: var(--delta-navy); letter-spacing: .04em; text-align: center; margin-bottom: 4px;
}
.login-logo span { color: var(--delta-red); }
.login-sub {
  text-align: center; font-size: 12px; color: var(--text-mid);
  text-transform: uppercase; letter-spacing: .08em; margin-bottom: 28px;
}
.login-field { margin-bottom: 16px; }
.login-field label {
  display: block; font-size: 11px; font-weight: 700; text-transform: uppercase;
  color: var(--text-mid); letter-spacing: .05em; margin-bottom: 6px;
}
.login-field input {
  width: 100%; height: 42px; border: 1px solid var(--border); border-radius: 5px;
  padding: 0 12px; font-size: 14px; outline: none; transition: border-color .15s;
}
.login-field input:focus { border-color: var(--delta-sky); }
.login-btn {
  width: 100%; height: 44px; background: var(--delta-red); color: #fff; border: none;
  border-radius: 5px; font-family: 'Barlow Condensed', sans-serif; font-size: 16px;
  font-weight: 700; letter-spacing: .06em; text-transform: uppercase; cursor: pointer;
  margin-top: 8px; transition: background .15s;
}
.login-btn:hover { background: var(--delta-red-lt); }
.login-btn:disabled { opacity: .6; cursor: not-allowed; }
.login-msg {
  margin-top: 14px; font-size: 13px; text-align: center; min-height: 18px;
}
.login-msg.error   { color: var(--delta-red); }
.login-msg.success { color: #2ECC71; }
.login-msg.info    { color: var(--text-mid); }

/* ── APP SHELL ───────────────────────────────────────────── */
#appShell { display: none; height: 100vh; flex-direction: column; }
#appShell.active { display: flex; }

.app-header {
  height: var(--header-h); background: var(--delta-navy); display: flex;
  align-items: center; padding: 0 18px; flex-shrink: 0; z-index: 100;
  box-shadow: 0 2px 6px rgba(0,0,0,.15);
}
.app-header-toggle {
  background: none; border: none; color: #fff; cursor: pointer; padding: 6px;
  margin-right: 12px; opacity: .85;
}
.app-logo {
  font-family: 'Barlow Condensed', sans-serif; font-size: 19px; font-weight: 800;
  color: #fff; letter-spacing: .04em;
}
.app-logo span { color: var(--delta-accent); }
.app-header-right {
  margin-left: auto; display: flex; align-items: center; gap: 16px;
}
.app-header-user {
  font-size: 12px; color: rgba(255,255,255,.85); text-align: right; line-height: 1.3;
}
.app-header-user b { display: block; color: #fff; font-size: 13px; }
.app-header-logout {
  background: rgba(255,255,255,.12); border: none; color: #fff; cursor: pointer;
  padding: 6px 12px; border-radius: 4px; font-size: 12px; font-weight: 600;
}
.app-header-logout:hover { background: rgba(255,255,255,.22); }

.app-body { display: flex; flex: 1; min-height: 0; }

/* ── SIDEBAR (auto-hide: colapsada por defecto, expande al pasar el mouse) ── */
.sidebar {
  width: var(--sidebar-w-collapsed); background: var(--delta-navy); border-right: 1px solid rgba(255,255,255,.08);
  flex-shrink: 0; overflow-y: auto; overflow-x: hidden; transition: width .22s cubic-bezier(.4,0,.2,1);
  position: relative; z-index: 50; box-shadow: 2px 0 8px rgba(0,0,0,.15);
}
.sidebar:hover { width: var(--sidebar-w); }
/* .pinned permite fijarla expandida manualmente (botón del header) */
.sidebar.pinned { width: var(--sidebar-w); }
.sidebar .menu-label, .sidebar .menu-group-arrow { opacity: 0; transition: opacity .15s; }
.sidebar:hover .menu-label, .sidebar:hover .menu-group-arrow,
.sidebar.pinned .menu-label, .sidebar.pinned .menu-group-arrow { opacity: 1; }
.sidebar:not(:hover):not(.pinned) .menu-group-children { max-height: 0 !important; }

.menu-item, .menu-group-header {
  display: flex; align-items: center; gap: 11px; padding: 11px 16px;
  cursor: pointer; color: rgba(255,255,255,.65); font-size: 13px; font-weight: 600;
  transition: background .12s, color .12s; user-select: none; white-space: nowrap;
}
.menu-item:hover, .menu-group-header:hover { background: rgba(255,255,255,.08); color: #fff; }
.menu-item.active { background: rgba(255,255,255,.12); color: var(--delta-accent); border-right: 3px solid var(--delta-accent); }
.menu-item svg, .menu-group-header svg { flex-shrink: 0; width: 16px; height: 16px; }
.menu-group-arrow { margin-left: auto; transition: transform .15s, opacity .15s; }
.menu-group.open .menu-group-arrow { transform: rotate(90deg); }
.menu-group-children { max-height: 0; overflow: hidden; transition: max-height .2s ease; }
.menu-group.open .menu-group-children { max-height: 300px; }
.menu-group-children .menu-item { padding-left: 40px; }
.menu-group.has-active .menu-group-header { color: #fff; font-weight: 700; }

/* ── MAIN CONTENT ────────────────────────────────────────── */
.main-content {
  flex: 1; overflow-y: auto; padding: 18px 22px; min-width: 0;
}

/* Utility classes reused across modules */
.card {
  background: #fff; border: 1px solid var(--border); border-radius: 8px;
  box-shadow: var(--shadow-sm);
}
.btn-primary {
  height: 36px; padding: 0 18px; background: var(--delta-red); color: #fff;
  border: none; border-radius: 4px; font-family: 'Barlow Condensed', sans-serif;
  font-size: 14px; font-weight: 700; letter-spacing: .04em; cursor: pointer;
  display: inline-flex; align-items: center; gap: 7px; text-transform: uppercase;
}
.btn-primary:hover { background: var(--delta-red-lt); }
.btn-primary:disabled { opacity: .5; cursor: not-allowed; }
.btn-secondary {
  height: 36px; padding: 0 16px; background: #fff; color: var(--text-mid);
  border: 1px solid var(--border); border-radius: 4px; font-size: 13px;
  font-weight: 600; cursor: pointer; display: inline-flex; align-items: center; gap: 6px;
}
.btn-secondary:hover { border-color: var(--delta-sky); color: var(--delta-sky); }

.data-table { width: 100%; border-collapse: collapse; font-size: 13px; text-transform: uppercase; }
.data-table thead th {
  background: #F4F7FB; color: var(--text-mid); font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .05em; padding: 10px 12px; text-align: left;
  border-bottom: 2px solid var(--border); white-space: nowrap;
}
.data-table tbody tr { border-bottom: 1px solid #EEF1F5; }
.data-table tbody tr:hover { background: #EDEFF3; }
.data-table tbody td { padding: 10px 12px; font-weight: 600; }

.status-badge {
  display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px;
  border-radius: 10px; font-size: 10px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .03em; white-space: nowrap;
}
.status-badge.st-clickable { cursor: pointer; border: 1px solid transparent; transition: filter .1s, border-color .1s; }
.status-badge.st-clickable:hover { filter: brightness(0.94); border-color: currentColor; }
.status-dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

/* Popover de cambio rápido de estado (click en el badge) */
.st-popover {
  position: fixed; z-index: 3000; background: #fff; border: 1px solid var(--border);
  border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,.16); min-width: 200px;
  font-size: 13px; overflow: hidden;
}
.st-popover-hdr {
  padding: 8px 12px; font-size: 10px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .05em; color: var(--text-mid); background: #F4F6F9; border-bottom: 1px solid var(--border);
}
.st-popover-opt {
  padding: 9px 12px; cursor: pointer; font-weight: 600; color: var(--delta-navy);
}
.st-popover-opt:hover { background: #EFF6FF; }
.st-popover-empty { padding: 10px 12px; font-size: 12px; color: var(--text-light); }
.st-popover-confirm { padding: 12px; }
.st-popover-confirm-msg { font-size: 13px; color: var(--delta-navy); margin-bottom: 8px; line-height: 1.4; }
.st-popover-confirm-msg strong { color: var(--delta-red); }
.st-popover-confirm textarea {
  width: 100%; height: 50px; border: 1px solid var(--border); border-radius: 4px;
  padding: 6px 8px; font-size: 12px; outline: none; resize: vertical; margin-bottom: 8px; box-sizing: border-box;
}
.st-popover-confirm-actions { display: flex; gap: 6px; justify-content: flex-end; }
.st-popover-confirm-actions button {
  padding: 5px 12px; font-size: 12px; font-weight: 700; border-radius: 5px; cursor: pointer; border: 1px solid var(--border);
}
.st-popover-confirm-actions .st-btn-confirm { background: var(--delta-navy); color: #fff; border-color: var(--delta-navy); }
.st-popover-confirm-actions .st-btn-cancel  { background: #fff; color: var(--text-mid); }
.st-popover-warn { padding: 8px 12px; font-size: 11px; color: var(--delta-red); font-weight: 600; border-top: 1px solid var(--border); background:#FFF5F5; }

/* Status colors — operational */
.st-RECEIVED  { background: #FFF3CD; color: #946C00; }
.st-CONFIRMED { background: #D4EDDA; color: #1E7E34; }
.st-LOADED    { background: #D1ECF1; color: #0C5460; }
.st-OFFLOADED { background: #FCE4E4; color: #A12622; }
.st-CANCELLED { background: #E2E3E5; color: #6C757D; }
/* Status colors — quality */
.qs-NOT_READY      { background: #E2E3E5; color: #6C757D; }
.qs-PENDING_REVIEW { background: #FFE8CC; color: #B25E00; }
.qs-VALIDATED      { background: #D4EDDA; color: #1E7E34; }

.empty-state {
  padding: 50px 20px; text-align: center; color: var(--text-light); font-size: 14px;
}

/* ── Flight Summary — dashboard ejecutivo (Rediseño Flight Summary) ── */
.fs-panel {
  background: #fff; border: 1px solid var(--border); border-radius: 8px; overflow: hidden;
}
.fs-panel-header {
  background: var(--delta-navy); color: #fff; padding: 8px 12px; font-size: 11px;
  font-weight: 800; text-transform: uppercase; letter-spacing: .05em;
  display: flex; align-items: center; gap: 7px;
}
.fs-summary-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.fs-summary-table thead th {
  background: #F4F6F9; color: var(--text-mid); font-size: 9.5px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .04em; padding: 6px 12px; text-align: left;
  border-bottom: 1px solid var(--border);
}
.fs-summary-table tbody td { padding: 8px 12px; border-bottom: 1px solid #F0F2F5; vertical-align: middle; }
.fs-summary-table tbody tr:last-child td { border-bottom: none; }
.fs-summary-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 22px; height: 22px; border-radius: 5px; flex-shrink: 0;
}
.fs-summary-label { font-weight: 700; color: #1A1F29; }
.fs-summary-detail { font-size: 13.5px; font-weight: 700; }
.fs-summary-detail-empty { font-size: 13px; color: var(--text-light); }
.fs-col-lbl {
  font-size: 9.5px; font-weight: 700; text-transform: uppercase; color: var(--text-mid); text-align: center;
}
.fs-row-lbl { font-size: 11px; font-weight: 800; color: #1A1F29; }
.fs-panel-input { height: 30px; font-size: 12px; width: 100%; text-align: center; }
.fs-pct-bar { display: flex; align-items: center; gap: 8px; }
.fs-pct-num { font-size: 12px; font-weight: 800; color: #1A1F29; width: 34px; text-align: right; flex-shrink: 0; }
.fs-bar-track { background: #E5E7EB; border-radius: 5px; height: 10px; overflow: hidden; flex: 1; }
.fs-bar-fill { height: 10px; border-radius: 5px; width: 0%; transition: width .5s; }

::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-thumb { background: #C7CDD6; border-radius: 5px; }
::-webkit-scrollbar-track { background: transparent; }
