/* ============================================================
   TEAM FALCON — TERMINAL OPS  (Design A: Mission Control)
   Theme system: all app-chrome colors come from CSS variables.
   Dark is the default; body.theme-light remaps every variable,
   so the whole UI adapts automatically when the theme flips.
   Sheet / print ("paper") styles below stay fixed on purpose.
   ============================================================ */
:root {
  --bg: #07090d;
  --panel: #000000;
  --panel-2: #0a0a0a;
  --panel-3: #111111;
  --border: #272c38;
  --border-strong: #3d4454;
  --border-dashed: #262626;
  --text: #F1F5F9;
  --text-2: #E2E8F0;
  --muted: #8B9BB4;
  --faint: #5c6678;
  --accent: #0D9488;
  --accent-text: #2DD4BF;
  --accent-soft: rgba(13,148,136,0.15);
  --blue: #3B82F6;
  --blue-hover: #2563EB;
  --blue-soft: rgba(59,130,246,0.12);
  --gold: #D4AF37;
  --amber: #f5a623;
  --amber-soft: rgba(245,166,35,0.08);
  --red-text: #FCA5A5;
  --red-soft: rgba(220,38,38,0.15);
  --red-border: rgba(248,113,113,0.3);
  --chip-red-bg: rgba(180,50,20,0.18);
  --chip-red-border: rgba(180,50,20,0.45);
  --tab-active: #2DD4BF;
  --shadow-paper: 0 10px 30px rgba(0,0,0,0.9);
  --shadow-modal: 0 0 50px rgba(0,0,0,0.9);
  --input-focus: rgba(59,130,246,0.3);
}
body.theme-light {
  --bg: #f2f4f8;
  --panel: #ffffff;
  --panel-2: #f7f9fc;
  --panel-3: #eef1f5;
  --border: #e3e8ef;
  --border-strong: #cdd5df;
  --border-dashed: #cdd5df;
  --text: #161c26;
  --text-2: #2a3342;
  --muted: #66707f;
  --faint: #9aa4b2;
  --accent: #0d9488;
  --accent-text: #0d9488;
  --accent-soft: #e6f7f4;
  --blue: #2563eb;
  --blue-hover: #1d4fd7;
  --blue-soft: #eef4ff;
  --gold: #b8912e;
  --amber: #b45309;
  --amber-soft: #fdf3e3;
  --red-text: #dc4444;
  --red-soft: #fdeaea;
  --red-border: #f3c2c2;
  --chip-red-bg: #fdeaea;
  --chip-red-border: #f3c2c2;
  --tab-active: #2563eb;
  --shadow-paper: 0 10px 30px rgba(16,24,40,0.18);
  --shadow-modal: 0 20px 60px rgba(16,24,40,0.25);
  --input-focus: rgba(37,99,235,0.25);
}

/* designation dropdown in admin user list */
.desig-select { padding: 4px 6px; font-size: 11px; border-radius: 6px; background: var(--panel); color: var(--gold); border: 1px solid var(--gold); outline: none; cursor: pointer; font-family: inherit; max-width: 160px; }

/* ----- reset & base ----- */
* { box-sizing: border-box; }
body {
  margin: 0; font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg); color: var(--text);
  transition: background-color .25s ease, color .25s ease;
}
/* smooth theme flip on the main chrome */
#sidebar, .workflow-panel, .td-panel, .modal-card, .login-card, .card-chrome,
.dropzone, .gate-drop, .cs-eml-tile, input, textarea, select, .admin-user-item {
  transition: background-color .25s ease, border-color .25s ease, color .25s ease;
}

/* ---------- login overlay ---------- */
#loginOverlay {
  position: fixed; inset: 0; background: var(--bg);
  display: flex; align-items: center; justify-content: center; z-index: 9999;
}
.login-card {
  background: var(--panel); border: 1px solid var(--border); padding: 44px; border-radius: 18px;
  width: 100%; max-width: 400px; box-shadow: var(--shadow-modal);
  text-align: center; animation: slideUp 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes slideUp { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }
.login-logo {
  width: 60px; height: 60px; background: var(--accent-soft); border: 1px solid rgba(45,212,191,.55);
  color: var(--accent-text); font-size: 22px; font-weight: 900; display: flex; align-items: center; justify-content: center;
  border-radius: 14px; margin: 0 auto 16px;
}
.login-card h2 { margin: 0 0 8px; font-size: 24px; font-weight: 800; }
.login-card p { margin: 0 0 28px; color: var(--muted); font-size: 14px; }
.login-form { display: flex; flex-direction: column; gap: 18px; text-align: left; }
.login-form label { font-size: 11px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 0.5px; }

.login-form input, #appMCS .field input, #adminUserManagement input, #adminUserManagement select,
.modal-card .field input, .modal-card .field select {
  width: 100%; padding: 12px 14px; font-size: 14px; background: var(--panel); color: var(--text);
  border: 1.5px solid var(--border); border-radius: 10px; transition: border-color .2s, box-shadow .2s;
  font-family: inherit;
}
.login-form input:focus, #appMCS .field input:focus, #adminUserManagement input:focus, #adminUserManagement select:focus,
.modal-card .field input:focus, .modal-card .field select:focus {
  outline: none; border-color: var(--blue); box-shadow: 0 0 0 2px var(--input-focus);
}
.modal-card .field label { font-size: 11px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; }
.modal-card .field input::placeholder { color: var(--faint); }

.pw-wrap { position: relative; display: flex; align-items: center; width: 100%; }
.pw-wrap input { padding-right: 40px !important; }
.pw-toggle { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); display: flex; align-items: center; justify-content: center; width: 26px; height: 26px; background: transparent; border: none; border-radius: 6px; color: var(--muted); cursor: pointer; padding: 0; transition: color .2s, background .2s; outline: none; }
.pw-toggle:hover { color: var(--text); background: var(--border); }

.login-btn { background: var(--blue); color: #FFF; border: none; padding: 14px; font-weight: 700; border-radius: 8px; cursor: pointer; transition: 0.2s; margin-top: 6px; }
.login-btn:hover { background: var(--blue-hover); }
#loginError { color: var(--red-text); background: var(--red-soft); border: 1px solid var(--red-border); padding: 12px; border-radius: 8px; font-size: 13px; font-weight: 600; display: none; margin-bottom: 18px; }

/* ---------- SIDEBAR ---------- */
#sidebar {
  position: fixed; top: 0; left: 0; bottom: 0; width: 248px; z-index: 9000;
  background: var(--panel); border-right: 1px solid var(--border);
  display: none; flex-direction: column; padding: 20px 14px;
}
.sb-brand { display: flex; align-items: center; gap: 12px; padding: 4px 10px 20px; border-bottom: 1px solid var(--border); margin-bottom: 8px; }
.sb-brand-mark {
  width: 40px; height: 40px; border-radius: 11px; flex-shrink: 0;
  background: var(--accent-soft); border: 1px solid rgba(45,212,191,.55);
  color: var(--accent-text); font-weight: 800; font-size: 14px; letter-spacing: .5px;
  display: flex; align-items: center; justify-content: center;
}
.sb-brand-name { font-weight: 700; font-size: 15px; letter-spacing: -.2px; }
.sb-brand-sub { font-size: 11px; color: var(--faint); font-weight: 500; letter-spacing: .4px; text-transform: uppercase; }
.sb-nav { flex: 1; overflow-y: auto; }
.sb-label { font-size: 10.5px; font-weight: 700; letter-spacing: 1.2px; color: var(--faint); text-transform: uppercase; padding: 14px 12px 8px; }
.sb-item + .sb-label { border-top: 1px solid var(--border-strong); margin: 10px 4px 0; padding-top: 16px; }
.sb-item {
  display: flex; align-items: center; gap: 11px; padding: 9px 12px; margin-bottom: 6px;
  border-radius: 10px; color: var(--muted); font-weight: 500; font-size: 13.5px;
  cursor: pointer; border: 1px solid var(--border); background: var(--bg); transition: all .15s; user-select: none;
}
.sb-item:hover { background: var(--panel-2); color: var(--text); }
.sb-item.active { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-text); }
.sb-item .ico { width: 18px; text-align: center; font-size: 14px; }
.sb-lock { margin-left: auto; font-size: 9px; font-weight: 800; letter-spacing: .5px; padding: 2px 7px; border-radius: 99px; background: rgba(212,175,55,.1); color: var(--gold); border: 1px solid rgba(212,175,55,.3); }
.sb-foot { padding-top: 14px; border-top: 1px solid var(--border); }
.sb-theme {
  width: 100%; display: flex; align-items: center; justify-content: center; gap: 8px;
  padding: 9px 12px; margin-bottom: 12px; border-radius: 10px; cursor: pointer;
  background: var(--panel-2); border: 1px solid var(--border); color: var(--muted);
  font-family: inherit; font-size: 12.5px; font-weight: 600; transition: all .15s;
}
.sb-theme:hover { color: var(--text); border-color: var(--border-strong); }
.sb-user { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 10px; cursor: pointer; transition: background .15s; }
.sb-user:hover { background: var(--panel-2); }
.sb-avatar {
  width: 34px; height: 34px; border-radius: 9px; flex-shrink: 0;
  background: linear-gradient(145deg, #3B82F6, #1E40AF);
  color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 14px;
}
.sb-user-info { min-width: 0; }
.sb-user-name { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sb-user-desig { font-size: 11px; color: var(--faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ov-del-btn { background: none; border: 1px solid transparent; color: var(--faint); font-size: 11px; cursor: pointer; padding: 2px 6px; border-radius: 5px; line-height: 1; }
.ov-del-btn:hover { color: var(--red-text, #FCA5A5); border-color: rgba(239, 68, 68, 0.4); background: rgba(239, 68, 68, 0.08); }

.sb-user-timer { font-size: 10.5px; font-weight: 700; color: var(--amber); margin-top: 2px; white-space: nowrap; letter-spacing: .01em; }
.sb-user-timer:empty { display: none; }
.sb-user-timer.urgent { color: var(--red-text); }


/* ---------- toast ---------- */
.toast {
  position: fixed; bottom: 24px; right: 24px; background: var(--panel); border: 1px solid var(--amber);
  color: var(--amber); padding: 12px 24px; border-radius: 6px; font-size: 10.5pt; font-weight: 700;
  opacity: 0; transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1); pointer-events: none; z-index: 11000;
  transform: translateY(10px); box-shadow: var(--shadow-modal);
  display: flex; align-items: center; gap: 12px;
}
.toast.show { opacity: 1; transform: translateY(0); pointer-events: auto; }
.toast-undo { background: var(--amber); color: #000; border: none; padding: 4px 10px; border-radius: 4px; font-weight: 800; cursor: pointer; font-size: 11px; }
.toast-undo:hover { background: #fff; }

/* ========== MCS GENERATOR ========== */
#appMCS { display: none; padding: 28px 36px 60px; margin-left: 248px; }
#appMCS .app-container { max-width: 1100px; margin: 0 auto 40px; }

/* module tab bar — underline tabs on a clear divider */
#appMCS .switcher-wrapper {
  display: none; /* modules switch via sidebar only — one module visible at a time */
}
#appMCS .switch-btn {
  appearance: none; background: transparent; border: none; border-bottom: 2.5px solid transparent;
  margin-bottom: -2px; padding: 11px 4px; border-radius: 0;
  font-weight: 600; font-size: 14px; color: var(--muted); cursor: pointer; transition: 0.2s; font-family: inherit;
}
#appMCS .switch-btn:hover { color: var(--text); }
#appMCS .switch-btn.active { background: none; color: var(--tab-active); border-bottom-color: var(--tab-active); box-shadow: none; }

#appMCS .workflow-panel { display: none; background: var(--panel); border-radius: 14px; border: 1px solid var(--border); padding: 32px; animation: fadeIn 0.3s ease-out; }
#appMCS .workflow-panel.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }
#appMCS .panel-intro { margin-bottom: 24px; padding-bottom: 18px; border-bottom: 1px solid var(--border); }
#appMCS .panel-intro h2 { font-size: 19px; margin: 0; font-weight: 800; }
#appMCS .panel-intro p { margin: 6px 0 0; color: var(--muted); font-size: 14px; }
#appMCS .form-row { display: flex; gap: 16px; align-items: flex-end; margin-bottom: 22px; flex-wrap: wrap; }
#appMCS .form-group { display: flex; flex-direction: column; gap: 8px; flex: 1; min-width: 240px; }
#appMCS label { font-size: 11px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 0.5px; }
#appMCS select, #appMCS textarea { font: inherit; font-size: 14px; padding: 13px 16px; border: 1.5px solid var(--border); border-radius: 10px; background: var(--panel); color: var(--text); transition: 0.2s; width: 100%; }
#appMCS select:focus, #appMCS textarea:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 2px var(--input-focus); }
#appMCS textarea { min-height: 150px; font-family: ui-monospace, monospace; font-size: 13px; resize: vertical; }
#appMCS .dropzone { border: 2px dashed var(--border-dashed); border-radius: 14px; background: var(--panel); padding: 48px 20px; text-align: center; cursor: pointer; transition: 0.2s; }
#appMCS .dropzone:hover { background: var(--panel-2); border-color: var(--accent); }
#appMCS .dropzone-icon { font-size: 38px; display: block; margin-bottom: 14px; }
#appMCS .dropzone h3 { font-size: 16px; margin: 0 0 6px; font-weight: 700; }
#appMCS .dropzone p { font-size: 13px; color: var(--muted); margin: 0; }
#appMCS .dropzone-slim { padding: 16px 18px; }
#appMCS .dropzone-slim h3 { font-size: 14px; display: inline; }
#appMCS .dropzone-slim p { margin-top: 4px; }
#appMCS .dropzone-slim .file-badge { margin-top: 10px; }
#appMCS .excl-bar { display: flex; gap: 10px; align-items: center; margin-top: 10px; }
#appMCS .excl-bar input { flex: 0 0 220px; background: var(--panel); border: 1px solid var(--border); color: var(--text-2); border-radius: 8px; padding: 9px 12px; font-size: 13px; text-transform: uppercase; }
#appMCS .excl-bar input:focus { outline: none; border-color: var(--accent); }
#appMCS .excl-btn { background: var(--panel-3); border: 1px solid var(--border); color: var(--text-2); border-radius: 8px; padding: 9px 16px; font-size: 13px; font-weight: 700; cursor: pointer; }
#appMCS .excl-btn:hover { background: var(--accent); border-color: var(--accent); color: #fff; }
#appMCS .excl-chips { display: flex; flex-wrap: wrap; gap: 8px; }
#appMCS .excl-chip { background: var(--chip-red-bg); border: 1px solid var(--chip-red-border); color: var(--red-text); border-radius: 999px; padding: 4px 12px; font-size: 12px; font-weight: 700; cursor: pointer; }
#appMCS .excl-chip:hover { filter: brightness(1.15); }
#appMCS .file-badge { display: none; margin-top: 18px; background: var(--accent-soft); color: var(--accent-text); border: 1px solid var(--accent); padding: 10px 16px; border-radius: 8px; font-weight: 700; font-size: 13px; text-align: center; }
#appMCS .btn-primary { background: var(--blue); color: #FFF; border: none; padding: 14px 26px; border-radius: 10px; font-weight: 700; font-size: 14px; cursor: pointer; transition: 0.2s; display: inline-flex; align-items: center; gap: 8px; justify-content: center; }
#appMCS .btn-primary:hover { background: var(--blue-hover); transform: translateY(-1px); }
#appMCS .btn-secondary { background: var(--panel); border: 1.5px solid var(--border); color: var(--text); padding: 11px 20px; border-radius: 8px; font-weight: 600; font-size: 13px; cursor: pointer; transition: 0.2s; }
#appMCS .btn-secondary:hover { background: var(--panel-3); border-color: var(--border-strong); }
#appMCS .toolbar-actions { display: flex; justify-content: space-between; align-items: center; margin-top: 24px; padding-top: 22px; border-top: 1px solid var(--border); flex-wrap: wrap; gap: 10px; }
#appMCS #sheetWrap { display: none; margin: 40px auto; flex-direction: column; align-items: center; gap: 30px; }
#appMCS .empty-state { color: var(--muted); text-align: center; padding: 48px; border: 2px dashed var(--border-dashed); border-radius: 14px; font-weight: 600; background: var(--panel); width: 100%; max-width: 800px; margin: 0 auto; }

/* ===== Manual Handover entry (Airside) ===== */
#appMCS .handover-toggle { width: 100%; padding: 12px 16px; background: var(--amber-soft); border: 1px dashed var(--amber); color: var(--amber); border-radius: 10px; font-weight: 800; font-size: 13px; letter-spacing: 0.5px; cursor: pointer; transition: 0.2s; text-align: center; }
#appMCS .handover-toggle:hover { filter: brightness(1.1); }
#appMCS #handoverPanel { margin-top: 12px; background: var(--panel); border: 1px solid var(--border); border-left: 3px solid var(--amber); border-radius: 12px; padding: 16px 18px; }
#appMCS .ho-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
#appMCS .ho-head h3 { margin: 0; color: var(--amber); font-size: 15px; letter-spacing: 2px; }
#appMCS .ho-head p { font-size: 12px; color: var(--muted); margin: 4px 0 0 0; }
#appMCS .ho-clear-btn { padding: 8px 14px; font-size: 12px; font-weight: 700; background: var(--red-soft); color: var(--red-text); border: 1px solid var(--red-border); border-radius: 8px; cursor: pointer; }
#appMCS .ho-clear-btn:hover { filter: brightness(1.1); }
#appMCS .ho-grid { display: grid; grid-template-columns: 1.2fr 1fr 0.8fr 0.8fr 34px; gap: 8px; align-items: center; }
#appMCS .ho-grid-head { margin-bottom: 6px; }
#appMCS .ho-grid-head span { font-size: 10px; font-weight: 800; letter-spacing: 1px; color: var(--muted); text-transform: uppercase; }
#appMCS .ho-grid-row { margin-bottom: 8px; }
#appMCS .ho-grid-row input { width: 100%; padding: 9px 10px; font-size: 13px; font-weight: 700; text-transform: uppercase; background: var(--panel-2); border: 1px solid var(--border-dashed); color: var(--text); border-radius: 8px; outline: none; text-align: center; box-sizing: border-box; }
#appMCS .ho-grid-row input:focus { border-color: var(--amber); }
#appMCS .ho-del-btn { width: 34px; height: 34px; background: var(--red-soft); color: var(--red-text); border: 1px solid var(--red-border); border-radius: 8px; cursor: pointer; font-size: 12px; }
#appMCS .ho-del-btn:hover { filter: brightness(1.1); }
#appMCS .ho-add-btn { margin-top: 4px; padding: 9px 18px; font-size: 12px; font-weight: 800; background: var(--amber-soft); color: var(--amber); border: 1px solid var(--amber); border-radius: 8px; cursor: pointer; }
#appMCS .ho-add-btn:hover { filter: brightness(1.1); }

/* ========== TRANSFER DESK ========== */
#appTD { display: none; background: var(--bg); color: var(--text); padding: 28px 36px 60px; margin-left: 248px; min-height: 100vh; }
#appTD .td-container { max-width: 1100px; margin: 0 auto 40px; }

/* module tab bar — underline tabs on a clear divider */
#appTD .td-switcher {
  display: none; /* modules switch via sidebar only — one module visible at a time */
}
#appTD .td-switch-btn {
  appearance: none; background: transparent; border: none; border-bottom: 2.5px solid transparent;
  margin-bottom: -2px; padding: 11px 4px; border-radius: 0;
  font-weight: 600; font-size: 13.5px; color: var(--muted); cursor: pointer; transition: 0.2s;
  font-family: inherit; text-align: center; white-space: nowrap;
}
#appTD .td-switch-btn:hover { color: var(--text); }
#appTD .td-switch-btn.active { background: none; color: var(--tab-active); border-bottom-color: var(--tab-active); box-shadow: none; }

#appTD .td-panel {
  display: none; background: var(--panel); border-radius: 14px; border: 1px solid var(--border);
  padding: 32px; animation: fadeIn 0.3s ease-out;
}
#appTD .td-panel.active { display: block; }
#appTD .td-panel-intro { margin-bottom: 24px; padding-bottom: 18px; border-bottom: 1px solid var(--border); }
#appTD .td-panel-intro h2 { font-size: 19px; margin: 0; font-weight: 800; }
#appTD .td-panel-intro p { margin: 6px 0 0; color: var(--muted); font-size: 14px; }

#appTD .td-form-row { display: flex; gap: 16px; align-items: flex-end; margin-bottom: 22px; flex-wrap: wrap; }
#appTD .td-form-group { display: flex; flex-direction: column; gap: 8px; flex: 1; min-width: 240px; }
#appTD .td-form-group label { font-size: 11px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 0.5px; }
#appTD .td-form-group textarea, #appTD .td-form-group input {
  font: inherit; font-size: 14px; padding: 13px 16px; border: 1.5px solid var(--border); border-radius: 10px;
  background: var(--panel); color: var(--text); transition: 0.2s; width: 100%;
}
#appTD .td-form-group textarea:focus, #appTD .td-form-group input:focus {
  outline: none; border-color: var(--blue); box-shadow: 0 0 0 2px var(--input-focus);
}
#appTD .td-form-group textarea { min-height: 150px; font-family: ui-monospace, monospace; font-size: 13px; resize: vertical; }

#appTD .cs-eml-tile { background: var(--panel); border: 2px dashed var(--border-dashed); border-radius: 14px; padding: 16px 18px; cursor: pointer; transition: 0.2s; }
#appTD .cs-eml-tile:hover { border-color: var(--accent); background: var(--panel-2); }
#appTD .cs-eml-tile b { font-size: 13px; color: var(--text-2); }
#appTD .cs-eml-sub { display: block; font-size: 11px; color: var(--muted); margin-top: 4px; }
#appTD .cs-eml-badge { display: none; margin-top: 8px; font-size: 12px; font-weight: 700; color: var(--accent-text); }
#appTD .cs-eml-alt { font-size: 11px; color: var(--muted); margin-top: 6px; }
#appTD .cs-eml-alt a { color: var(--accent-text); text-decoration: none; }
#appTD .td-btn-primary {
  background: var(--blue); color: #FFF; border: none; padding: 14px 26px; border-radius: 10px;
  font-weight: 700; font-size: 14px; cursor: pointer; transition: 0.2s; display: inline-flex; align-items: center; gap: 8px;
}
#appTD .td-btn-primary:hover { background: var(--blue-hover); transform: translateY(-1px); }
#appTD .td-btn-secondary {
  background: var(--panel); border: 1.5px solid var(--border); color: var(--text); padding: 11px 20px;
  border-radius: 8px; font-weight: 600; font-size: 13px; cursor: pointer; transition: 0.2s;
}
#appTD .td-btn-secondary:hover { background: var(--panel-3); border-color: var(--border-strong); }

#appTD .td-toolbar { display: flex; justify-content: flex-end; gap: 12px; margin-top: 24px; padding-top: 22px; border-top: 1px solid var(--border-strong); flex-wrap: wrap; }

/* table section chrome (the table wrap below it is the printable white paper) */
#appTD .td-table-section {
  background: var(--panel-2); border-radius: 14px; border: 1px solid var(--border); overflow: hidden;
  display: none; padding-bottom: 24px; margin-top: 24px;
}
#appTD .td-table-header {
  padding: 14px 20px; display: flex; justify-content: space-between; align-items: center;
  border-bottom: 1px solid var(--border); background: var(--panel); flex-wrap: wrap; gap: 12px;
}
#appTD .td-counter { font-weight: 700; font-size: 11pt; color: var(--amber); letter-spacing: 0.5px; }
#appTD .td-table-wrap {
  overflow: auto; max-height: 80vh; width: 210mm; max-width: 95%;
  margin: 24px auto 0; padding: 12mm 8mm; background: #fff; color: #262626;
  border-radius: 3px; box-shadow: var(--shadow-paper);
}
#appTD table { width: 100%; border-collapse: collapse; font-size: 10.5pt; color: #262626; }
#appTD th, #appTD td { padding: 5px 6px; text-align: center; border: 1px solid #7f7f7f; white-space: nowrap; }
#appTD th { background-color: #000000; color: #fff; font-weight: 700; position: sticky; top: 0; border: 1px solid #222; z-index: 10; }
#appTD tr:nth-child(even) { background-color: #f9fbfd; }
#appTD tr:hover { background-color: #eef4fa; }
#appTD .cs-spacer td { height: 7px; padding: 0 !important; border-left: none; border-right: none; border-top: none; background: #fff; }
#appTD .cs-red td { color: #c0392b; }
#appTD .cs-bold td { font-weight: 700; }
#appTD .cs-grow td:first-child { border-left: 3px solid #333; }
#appTD .cs-grow td:last-child { border-right: 3px solid #333; }
#appTD .cs-gtop td { border-top: 3px solid #333; }
#appTD .cs-gbot td { border-bottom: 3px solid #333; }
#appTD .cs-subtotal td { background: #eef3f9; padding: 4px 10px !important; text-align: left; white-space: normal; border-left: 3px solid #333; border-right: 3px solid #333; }
#appTD .ft-section td { background-color: #e7edf5 !important; text-align: left !important; font-weight: 800; color: #000; text-transform: uppercase; letter-spacing: 0.4px; border-left: none; border-right: none; }
#appTD .ft-tight { background-color: #fff4d6 !important; }
#appTD .ft-tight:hover { background-color: #ffedbf !important; }
#appTD .cs-summary { display: flex; gap: 8px; flex-wrap: wrap; margin: 0 0 10px; }
#appTD .cs-stat { flex: 1; min-width: 90px; border: 1px solid #a6a6a6; border-radius: 6px; padding: 5px 10px; text-align: center; background: #f8fafc; }
#appTD .cs-stat .n { font-size: 13pt; font-weight: 800; line-height: 1; }
#appTD .cs-stat .l { font-size: 7pt; color: #666; margin-top: 3px; text-transform: uppercase; letter-spacing: 0.5px; font-weight: 700; }
#appTD .cs-stat.mis .n { color: #c0392b; }
#appTD .cs-stat.fast .n { color: #333333; }
#appTD .cs-stat.gate .n { color: #333333; }
#appTD .cs-stat.total .n { color: #000; }
#appTD .cs-chip { display: inline-block; font-weight: 700; margin-right: 16px; }
#appTD .cs-chip.mis { color: #c0392b; }
#appTD .cs-chip.fast { color: #333333; }
#appTD .cs-chip.gate { color: #333333; }
#appTD .ft-report-title { text-align: center; font-weight: 800; color: #000; font-size: 13pt; padding: 2px 0 7px; letter-spacing: 0.3px; }
#appTD .cs-table th, #appTD .cs-table td { padding: 3px 4px; }
#appTD .cs-table th { padding-top: 3px; padding-bottom: 3px; line-height: 1.1; color: #ffffff; }
#appTD .cs-table td.cs-wrap { white-space: normal; }
#appTD .cs-table .cs-narrow { white-space: normal; }
#appTD .cs-table td.cs-cnx-low { color: #c0392b; font-weight: 800; }
#appTD .cs-table td.cs-dcode { color: #c0392b; font-weight: 700; }
#appTD .cs-table .cs-x { color: #c0392b; font-weight: 800; }
#appTD .ft-table td.tot, #appTD .ft-table th.tot { font-weight: 800; }

/* Duplicate Resolution UI - Cards */
#csDupOptions { background: var(--panel); border: 1px dashed var(--amber); border-radius: 14px; padding: 20px; }
.dup-card { background: var(--panel-2); border: 1px solid var(--border); border-radius: 10px; overflow: hidden; display: flex; flex-direction: column; }
.dup-header { background: var(--panel-3); padding: 12px 16px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; }
.dup-route { font-weight: 800; font-size: 13px; color: var(--text); letter-spacing: 0.5px; }
.dup-guests { font-size: 11px; color: var(--muted); font-weight: 600; text-transform: uppercase; }
.dup-options-wrap { padding: 12px; display: flex; flex-direction: column; gap: 8px; }
.dup-option {
  position: relative; display: flex; align-items: center; padding: 12px 14px;
  background: var(--panel); border: 1.5px solid var(--border); border-radius: 8px; cursor: pointer; transition: 0.2s;
}
.dup-option:hover { border-color: var(--border-strong); background: var(--panel-2); }
.dup-option input[type="radio"] { display: none; }
.dup-option:has(input:checked) { border-color: var(--blue); background: var(--blue-soft); }
.dup-option:has(input:checked)::after { content: '✓'; position: absolute; right: 14px; color: var(--blue); font-size: 16px; font-weight: 900; }
.dup-details { font-size: 12px; color: var(--text-2); font-weight: 600; display: flex; align-items: center; gap: 10px; width: 100%; }
.dup-row-badge { font-size: 10px; background: var(--panel-3); padding: 3px 6px; border-radius: 4px; color: var(--muted); font-weight: 700; text-transform: uppercase; }

/* gate OCR & PDF compact row */
.gate-compact-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: stretch; }
.gate-compact-row .gate-drop {
  flex: 1 1 0; min-width: 120px; padding: 12px 8px; font-size: 11px;
  border-radius: 14px; background: var(--panel); border: 2px dashed var(--border-dashed);
  text-align: center; cursor: pointer; transition: 0.2s;
}
.gate-compact-row .gate-drop:hover { border-color: var(--accent); background: var(--panel-2); }
.gate-compact-row .gate-drop .gd-title { font-weight: 700; font-size: 11px; color: var(--text); }
.gate-compact-row .gate-drop .gd-sub { font-size: 9px; color: var(--muted); }
.gate-compact-row .gate-drop .gd-status { font-size: 8.5px; color: var(--muted); margin-top: 4px; min-height: 16px; }
.gate-compact-row .gate-drop .gate-progress { height: 3px; background: var(--border-strong); border-radius: 2px; margin-top: 4px; overflow: hidden; display: none; }
.gate-compact-row .gate-drop .gate-progress i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .2s; }

/* gate preview chips */
.gate-preview { margin-top: 14px; background: var(--panel-2); border: 1px solid var(--border-strong); border-radius: 8px; padding: 12px 14px; display: none; }
.gate-preview h4 { font-size: 9.5pt; color: var(--text); margin-bottom: 8px; font-weight: 800; }
.gate-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.gate-chip { display: inline-flex; align-items: center; gap: 6px; background: var(--panel-3); border: 1px solid var(--border-strong); border-radius: 6px; padding: 3px 6px 3px 8px; font-size: 9pt; }
.gate-chip b { color: var(--text); font-weight: 700; }
.gate-chip input { width: 46px; padding: 2px 4px; font-size: 9pt; text-align: center; text-transform: uppercase; background: var(--panel); border: 1px solid var(--border-strong); border-radius: 4px; color: var(--amber); font-weight: 800; }

.gate-manual { margin-top: 12px; display: none; }
.gate-manual textarea { min-height: 60px; font-family: monospace; font-size: 9pt; width: 100%; padding: 8px; background: var(--panel); color: var(--text); border: 1px solid var(--border-strong); border-radius: 4px; }
.gate-hint { font-size: 8.5pt; color: var(--muted); background: var(--blue-soft); border-left: 3px solid var(--blue); padding: 8px 10px; border-radius: 4px; margin-top: 10px; line-height: 1.4; }
.help-text { font-size: 8.5pt; color: var(--muted); margin-top: 6px; line-height: 1.3; }

/* ---------- profile / bug modals ---------- */
.modal-overlay { display: none; position: fixed; inset: 0; z-index: 10000; background: rgba(0,0,0,0.7); backdrop-filter: blur(4px); align-items: center; justify-content: center; padding: 20px; }
.modal-overlay.open { display: flex; }
.modal-card { background: var(--panel); border: 1px solid var(--border); border-radius: 18px; width: 100%; max-width: 520px; max-height: 88vh; overflow-y: auto; box-shadow: var(--shadow-modal); animation: slideUp 0.35s cubic-bezier(0.16,1,0.3,1); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 22px 26px; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--panel); z-index: 2; }
.modal-head h2 { margin: 0; font-size: 18px; font-weight: 800; }
.modal-close { background: transparent; border: none; color: var(--muted); font-size: 24px; cursor: pointer; padding: 4px 8px; border-radius: 8px; transition: 0.2s; }
.modal-close:hover { color: var(--text); background: var(--panel-3); }
.modal-body { padding: 24px 26px; }
.profile-hero { display: flex; align-items: center; gap: 16px; margin-bottom: 26px; }
.profile-hero .user-avatar { width: 54px; height: 54px; font-size: 22px; border-radius: 50%; background: linear-gradient(145deg, #3B82F6, #1E40AF); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 800; flex: none; }
.profile-hero-info strong { display: block; font-size: 18px; font-weight: 800; }
.profile-hero-info .pm-desig { display: block; font-size: 12.5px; color: var(--gold); font-weight: 600; margin: 1px 0; }
.profile-hero-info span { font-size: 13px; color: var(--muted); }
.modal-section { margin-bottom: 20px; }

/* --- account settings polish --- */
.pf-hero { display: flex; align-items: center; gap: 16px; padding: 18px; margin-bottom: 20px; background: linear-gradient(135deg, var(--panel-2), var(--panel)); border: 1px solid var(--border); border-radius: 14px; }
.pf-hero .pf-avatar { width: 56px; height: 56px; font-size: 23px; border-radius: 14px; background: linear-gradient(145deg, #3B82F6, #1E40AF); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 800; flex: none; box-shadow: 0 4px 14px rgba(59,130,246,.3); }
.pf-hero-info strong { display: block; font-size: 18px; font-weight: 800; }
.pf-hero-info .pm-desig { display: inline-block; font-size: 11px; color: var(--gold); font-weight: 700; margin: 4px 0 2px; padding: 2px 9px; border: 1px solid rgba(212,175,55,.35); background: rgba(212,175,55,.08); border-radius: 999px; }
.pf-hero-info > span:last-child { display: block; font-size: 12.5px; color: var(--muted); margin-top: 3px; }
.pf-card { background: var(--panel-2); border: 1px solid var(--border); border-radius: 14px; padding: 18px; }
.pf-card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.pf-card-head h3 { margin: 0; font-size: 12px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); font-weight: 800; }
.pf-badge { font-size: 11px; font-weight: 700; padding: 4px 10px; border-radius: 999px; background: rgba(13,148,136,.15); color: #2DD4BF; border: 1px solid rgba(13,148,136,.3); }
.pf-quota-num { font-size: 22px; font-weight: 800; color: var(--blue); }
.pf-quota-sub { font-size: 11px; color: var(--muted); margin: 3px 0 10px; }
.pf-quota-track { height: 6px; border-radius: 999px; background: var(--border); overflow: hidden; }
.pf-quota-fill { height: 100%; border-radius: 999px; background: linear-gradient(90deg, #3B82F6, #2DD4BF); transition: width .4s ease; }
.pf-mini-btn { padding: 5px 12px; font-size: 11px; }
.modal-section > h3 { font-size: 12px; text-transform: uppercase; letter-spacing: 0.6px; color: var(--muted); margin: 0 0 14px; font-weight: 800; padding-bottom: 8px; border-bottom: 1px solid var(--border); }
.field-grid { display: grid; gap: 14px; }
.field-grid.two { grid-template-columns: 1fr 1fr; }
.field { display: flex; flex-direction: column; gap: 6px; }

.form-msg { display: none; padding: 10px 13px; border-radius: 8px; font-size: 13px; font-weight: 600; margin-top: 4px; }
.form-msg.ok { display: block; color: var(--accent-text); background: var(--accent-soft); border: 1px solid var(--accent); }
.form-msg.err { display: block; color: var(--red-text); background: var(--red-soft); border: 1px solid var(--red-border); }

.btn-primary { background: var(--blue); color: #FFF; border: none; padding: 14px 26px; border-radius: 10px; font-weight: 700; font-size: 14px; cursor: pointer; transition: 0.2s; display: inline-flex; align-items: center; gap: 8px; justify-content: center; }
.btn-primary:hover { background: var(--blue-hover); transform: translateY(-1px); }
.btn-secondary { background: var(--panel); border: 1.5px solid var(--border); color: var(--text); padding: 11px 20px; border-radius: 8px; font-weight: 600; font-size: 13px; cursor: pointer; transition: 0.2s; }
.btn-secondary:hover { background: var(--panel-3); border-color: var(--border-strong); }

/* Admin user list items */
.admin-user-item { display:flex; justify-content:space-between; align-items:center; background:var(--panel); padding:10px 14px; border:1px solid var(--border); border-radius:8px; margin-bottom: 8px; }

#adminLogsList::-webkit-scrollbar { width: 6px; }
#adminLogsList::-webkit-scrollbar-track { background: var(--panel); }
#adminLogsList::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 4px; }
#adminLogsList::-webkit-scrollbar-thumb:hover { background: var(--faint); }

/* ========== OVERVIEW (admin only) ========== */
#appOV { display: none; padding: 28px 36px 60px; margin-left: 248px; min-height: 100vh; }
#appOV .ov-container { max-width: 1100px; margin: 0 auto; }
#appOV .ov-head { margin-bottom: 20px; }
#appOV .ov-head h1 { font-size: 22px; font-weight: 800; letter-spacing: -.3px; margin: 0; }
#appOV .ov-head p { font-size: 13px; color: var(--muted); margin: 3px 0 0; }
#appOV .ov-banner {
  display: flex; align-items: center; gap: 8px; padding: 11px 16px; border-radius: 11px; margin-bottom: 22px;
  background: rgba(212,175,55,.07); border: 1px solid rgba(212,175,55,.25); font-size: 12.5px; color: var(--gold); font-weight: 500;
}
#appOV .ov-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-bottom: 18px; }
#appOV .ov-stat { background: var(--panel); border: 1px solid var(--border); border-radius: 14px; padding: 18px 20px; }
#appOV .ov-stat-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
#appOV .ov-label { font-size: 12px; font-weight: 600; color: var(--muted); letter-spacing: .3px; }
#appOV .ov-ico { width: 32px; height: 32px; border-radius: 9px; display: flex; align-items: center; justify-content: center; font-size: 14px; background: var(--accent-soft); }
#appOV .ov-val { font-size: 27px; font-weight: 800; letter-spacing: -.8px; font-family: 'JetBrains Mono', ui-monospace, monospace; }
#appOV .ov-val-text { font-size: 19px; letter-spacing: -.3px; font-family: inherit; line-height: 1.25; }
#appOV .ov-sub { font-size: 11.5px; color: var(--faint); margin-top: 4px; }
#appOV .ov-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 18px; }
#appOV .ov-card { background: var(--panel); border: 1px solid var(--border); border-radius: 14px; padding: 20px 22px; margin-bottom: 18px; }
#appOV .ov-grid .ov-card { margin-bottom: 0; }
#appOV .ov-card h3 { font-size: 13px; font-weight: 700; margin: 0 0 16px; }
#appOV .ov-empty { color: var(--faint); font-size: 12.5px; text-align: center; padding: 16px; }
#appOV .ov-bar-row { margin-bottom: 14px; }
#appOV .ov-bar-row:last-child { margin-bottom: 0; }
#appOV .ov-bar-head { display: flex; justify-content: space-between; font-size: 12.5px; margin-bottom: 5px; }
#appOV .ov-bar-head .n { font-weight: 600; }
#appOV .ov-bar-head .c { color: var(--muted); font-family: ui-monospace, monospace; font-size: 12px; }
#appOV .ov-bar-track { height: 7px; border-radius: 99px; background: var(--panel-3); overflow: hidden; }
#appOV .ov-bar-fill { height: 100%; border-radius: 99px; background: var(--accent); transition: width .4s ease; }
#appOV .ov-user-row { display: flex; align-items: center; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--border); }
#appOV .ov-user-row:last-child { border-bottom: none; }
#appOV .ov-user-ava { width: 30px; height: 30px; border-radius: 8px; flex-shrink: 0; background: linear-gradient(145deg, #3B82F6, #1E40AF); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 12px; }
#appOV .ov-user-name { font-size: 13px; font-weight: 600; }
#appOV .ov-user-desig { font-size: 11px; color: var(--faint); }
#appOV .ov-user-cnt { margin-left: auto; font-family: ui-monospace, monospace; font-size: 13px; font-weight: 700; color: var(--accent-text); }
#appOV .ov-table { width: 100%; border-collapse: collapse; }
#appOV .ov-table th { text-align: left; font-size: 10.5px; font-weight: 700; letter-spacing: 1px; text-transform: uppercase; color: var(--faint); padding: 8px 10px; border-bottom: 1px solid var(--border); }
#appOV .ov-table td { padding: 9px 10px; font-size: 12.5px; border-bottom: 1px solid var(--border); color: var(--text-2); }
#appOV .ov-table tr:last-child td { border-bottom: none; }
#appOV .ov-table td.t { font-family: ui-monospace, monospace; font-size: 11.5px; color: var(--muted); }
#appOV .ov-action-pill { display: inline-block; padding: 2px 9px; border-radius: 99px; font-size: 10.5px; font-weight: 700; background: var(--blue-soft); color: var(--blue); }

/* ===== MCS sheet paper (screen preview of the printable sheet) ===== */
#appMCS .sheet { background: #fff; box-shadow: var(--shadow-paper); width: 210mm; min-height: 297mm; display: flex; flex-direction: column; border: 1px solid #CCC; font-family: 'Arial Narrow', 'Segoe UI Condensed', Tahoma, Arial, sans-serif; padding: 5mm; }
#appMCS .top-bar { display: flex; align-items: center; justify-content: space-between; background: #000000; color: #fff; border-bottom: 2px solid #D4AF37; min-height: 8mm; padding: 2mm 4mm; flex: none; }
#appMCS .top-bar .breakdown { font-weight: 800; font-size: 13.5px; letter-spacing: 0.5px; white-space: nowrap; }
#appMCS .top-bar .meta { background: #111111; padding: 2px 6px; border-radius: 4px; font-size: 11px; font-weight: 700; letter-spacing: 0.5px; border: 1px solid rgba(255,255,255,0.15); white-space: nowrap; display: inline-block; line-height: 1.2;}
#appMCS .cols { display: grid; grid-template-columns: 1fr 3px 1fr; flex: 1 1 100%; align-content: stretch; margin-top: 1.5mm; width: 100%; height: 100%; }
#appMCS .cols > div { display: flex; flex-direction: column; height: 100%; }
#appMCS .gap { background: #000; width: 2px; margin: 0 auto; opacity: 0.4; }
#appMCS table { width: 100%; height: 100%; border-collapse: collapse; table-layout: fixed; }
#appMCS td { line-height: 0.95 !important; overflow: hidden; padding: 0 3px !important; text-align: center; vertical-align: middle; word-wrap: break-word; }
#appMCS tr { page-break-inside: avoid !important; break-inside: avoid !important; }
#appMCS .ghead td { color: #fff; font-weight: 800; font-size: var(--fGroup, 12px); text-align: center; border: 1px solid #000; border-bottom: none; letter-spacing: 1px; height: var(--rowH); }
#appMCS tr.gsub { height: var(--rowH); }
#appMCS tr.gsub td { color: #fff; font-weight: 800; font-size: var(--fHead, 10px); border: 1px solid #000; }
#appMCS tr.gsub td.ntl { text-align: center; }
#appMCS tr.d { height: var(--rowH); }
#appMCS tbody td { border: 1px solid #000; font-size: var(--fData, 11px); font-weight: 700; color: #111; }
#appMCS tbody td span.cell-text { display: inline-block; transform: scaleY(0.95); letter-spacing: 0.3px; }
#appMCS td.nt { background: #fff; }
#appMCS td.nt span.cell-text { transform: none; letter-spacing: normal; }
#appMCS tr.d.alt td:not(.nt) { background: #F6F8FC; }
#appMCS tr.d.hl td:not(.nt) { color: #C53030; }
#appMCS .sp { height: calc(var(--rowH) * 0.5); width: 100%; background: #fff; border: none; flex: none; }

/* OAL sheet */
#appMCS .sheet.oal-sheet { font-family: 'Arial', sans-serif; height: auto !important; }
#appMCS .oal-title-bar { background: #1E3A2F; color: #FFFFFF; padding: 10px 14px; display: flex; justify-content: space-between; align-items: center; border: 2px solid #000000; border-bottom: none; }
#appMCS .oal-title-bar .oal-badges { display: flex; gap: 12px; align-items: center; }
#appMCS .oal-badge-date { font-size: 13px; color: #E8F0EB; font-weight: bold; }
#appMCS .oal-badge-shift { font-size: 12px; font-weight: 900; padding: 5px 12px; border-radius: 4px; color: #fff; letter-spacing: 0.5px; }
#appMCS .oal-badge-shift.night { background: #1E3060; border: 1px solid #4B6396; }
#appMCS .oal-badge-shift.day { background: #8B3A3A; border: 1px solid #B65858; }
#appMCS .oal-stats-bar { background: #F7F5F1; color: #111111; font-weight: 800; font-size: 13px; text-align: center; padding: 8px; border: 2px solid #000000; }
#appMCS table.oal-table { width: 100%; height: auto !important; border-collapse: collapse; border: 2px solid #000000; margin-top: 6px; }
#appMCS table.oal-table th { background: #243B30; color: #FFFFFF; font-size: 12px; font-weight: 800; padding: 5px 6px !important; line-height: 1.15 !important; border: 1px solid #000000; }
#appMCS table.oal-table td { font-size: 12px; padding: 3px 6px !important; line-height: 1.15 !important; border: 1px solid #000000; color: #000000; height: 19px !important; }
#appMCS tr.oal-row-3l.odd td { background: #FFF0F0; }
#appMCS tr.oal-row-3l.even td { background: #FFE5E5; }
#appMCS tr.oal-row-3l td.flt { color: #D31117; font-weight: 900; font-size: 13px; }
#appMCS tr.oal-row-6e.odd td { background: #F0F5FF; }
#appMCS tr.oal-row-6e.even td { background: #E2ECFF; }
#appMCS tr.oal-row-6e td.flt { color: #0044CC; font-weight: 900; font-size: 13px; }
#appMCS tr.oal-row-oal.odd td { background: #FFFFFF; }
#appMCS tr.oal-row-oal.even td { background: #F3F4F6; }
#appMCS tr.oal-row-oal td.flt { color: #0F172A; font-weight: 800; }
#appMCS tr.oal-row-empty td { background: #FAFAFA; color: #999; border: 1px solid #000000; }

/* EY sheet */
#appMCS .sheet.ey-sheet { font-family: 'Arial', sans-serif; height: auto !important; }
#appMCS .ey-title-bar { background: #8b641e; color: #FFFFFF; padding: 8px 14px; display: flex; justify-content: space-between; align-items: center; border: 2px solid #000000; border-bottom: none; }
#appMCS .ey-title-bar h1 { margin: 0; font-size: 16px; font-weight: 800; letter-spacing: 0.5px; }
#appMCS .ey-title-bar .ey-meta { background: rgba(0,0,0,0.35); padding: 3px 10px; border-radius: 4px; font-size: 11px; font-weight: 800; letter-spacing: 0.5px; border: 1px solid rgba(255,255,255,0.25); white-space: nowrap; }
#appMCS .ey-sub-bar { background: #b98c32; color: #FFFFFF; font-weight: 800; font-style: italic; font-size: 13px; text-align: center; padding: 5px; border: 2px solid #000000; }
#appMCS table.ey-table { width: 100%; height: auto !important; border-collapse: collapse; border: 2px solid #000000; margin-top: 5px; }
#appMCS table.ey-table th { background: #8b641e; color: #FFFFFF; font-size: 11px; font-weight: 800; padding: 5px 3px !important; line-height: 1.1 !important; border: 1px solid #000000 !important; }
#appMCS table.ey-table td { font-size: var(--eyFSize, 10px); padding: 1px 3px !important; line-height: 1.1 !important; border: 1px solid #000000 !important; color: #000000; height: var(--eyRowH, 4.3mm) !important; }
#appMCS tr.ey-row.odd td { background: #FFFFFF; }
#appMCS tr.ey-row.even td { background: #FAFAFA; }
#appMCS tr.ey-row td.neg-avail { color: #B40000 !important; font-weight: bold !important; }
#appMCS tr.ey-row td.muted-cell { color: #444444; }

/* Handover marking on the Gates/OTP sheet (screen + print) */
#appMCS tr.d.ho td:not(.nt) { background: #FFF3CD; }
#appMCS tr.d.ho.alt td:not(.nt) { background: #FFECB5; }
#appMCS td.nt .ho-tag { color: #8A6D00; font-weight: 900; font-size: 0.85em; letter-spacing: 0.5px; float: right; margin-right: 4px; }

/* ---------- print overrides ---------- */
@media print {
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }

  /* Setting page margin to 0 signals the browser to hide headers/footers by default */
  @page { size: A4 portrait; margin: 0 !important; }

  html, body { background: #fff !important; margin: 0 !important; padding: 0 !important; width: 100%; height: 100%; }
  #appMCS { padding: 0 !important; margin: 0 !important; }
  #loginOverlay, #sidebar, #appOV, .toast, #profileModal, #bugModal, .dashboard-header, .switcher-wrapper, .workflow-panel { display: none !important; }

  body.mode-mcs #appTD { display: none !important; }
  body.mode-mcs #appMCS .app-container { display: none !important; }
  body.mode-mcs #appMCS #missingGatesPanel { display: none !important; }
  body.mode-mcs #appMCS #sheetWrap { margin: 0 !important; padding: 0 !important; gap: 0 !important; width: 100% !important; display: block !important; overflow: visible !important; }

  /* The sheet itself acts as the A4 page. Minimal padding so data sits as close to the edge as possible without clipping. */
  body.mode-mcs #appMCS .sheet {
    box-shadow: none !important; border: none !important;
    page-break-after: always !important; page-break-inside: avoid !important;
    width: 210mm !important; height: 297mm !important; max-height: 297mm !important;
    margin: 0 auto !important;
    padding: 4mm 3mm !important; /* minimal safe margins */
    box-sizing: border-box !important; overflow: hidden !important; display: flex !important;
  }

  body.mode-mcs #appMCS .sheet:last-child { page-break-after: auto !important; }

  body.mode-mcs #appMCS .sheet.oal-sheet,
  body.mode-mcs #appMCS .sheet.ey-sheet {
    width: 100% !important; min-height: 0 !important;
    padding: 4mm 3mm !important;
    margin: 0 !important; box-sizing: border-box !important; page-break-inside: auto !important; page-break-after: auto !important; display: block !important;
  }

  body.mode-td #appMCS { display: none !important; }
  body.mode-td #appTD { background: white !important; color: #000 !important; padding: 0; margin: 0 !important; }
  body.mode-td #appTD .td-header, body.mode-td #appTD .td-switcher, body.mode-td #appTD .td-panel-intro,
  body.mode-td #appTD .td-form-row, body.mode-td #appTD .td-form-group, body.mode-td #appTD .td-toolbar,
  body.mode-td #appTD .td-table-header, body.mode-td #appTD .gate-ocr-card, body.mode-td #appTD .ft-sub-switch,
  body.mode-td #appTD .gate-drop, body.mode-td #appTD .gate-preview, body.mode-td #appTD .gate-manual,
  body.mode-td #appTD .gate-hint, body.mode-td #appTD .help-text { display: none !important; }

  body.mode-td #appTD .td-container { max-width: none !important; margin: 0 !important; padding: 0 !important; }
  body.mode-td #appTD .td-panel { background: white !important; border: none !important; border-radius: 0 !important; padding: 0 !important; margin: 0 !important; box-shadow: none !important; }
  body.mode-td #appTD .td-table-section { border: none !important; box-shadow: none !important; background: white !important; display: block !important; margin: 0 !important; padding: 0 !important; }

  body.mode-td #appTD .td-table-wrap {
    max-height: none !important; overflow: hidden !important; width: 210mm !important;
    padding: 4mm 3mm !important; /* minimal safe margins */
    margin: 0 auto !important; box-shadow: none !important; border: none !important; box-sizing: border-box !important;
  }

  body.mode-td #appTD table { width: 100% !important; font-size: 10pt !important; color: #000 !important; }
  body.mode-td #appTD td { padding: 4px 5px !important; border: 1px solid #555 !important; color: #000 !important; }
  body.mode-td #appTD th { padding: 4px 5px !important; border: 1px solid #555 !important; color: #fff !important; }
  body.mode-td #appTD .cs-table { table-layout: fixed !important; width: 100% !important; margin: 0 auto !important; box-sizing: border-box !important; border-collapse: collapse !important; }
  body.mode-td #appTD .cs-table th:nth-child(1) { width: 5.4% !important; }
  body.mode-td #appTD .cs-table th:nth-child(2) { width: 5.2% !important; }
  body.mode-td #appTD .cs-table th:nth-child(3) { width: 4.7% !important; }
  body.mode-td #appTD .cs-table th:nth-child(4) { width: 6.2% !important; }
  body.mode-td #appTD .cs-table th:nth-child(5) { width: 3.9% !important; }
  body.mode-td #appTD .cs-table th:nth-child(6) { width: 3.4% !important; }
  body.mode-td #appTD .cs-table th:nth-child(7) { width: 3.9% !important; }
  body.mode-td #appTD .cs-table th:nth-child(8) { width: 5.4% !important; }
  body.mode-td #appTD .cs-table th:nth-child(9) { width: 4.7% !important; }
  body.mode-td #appTD .cs-table th:nth-child(10) { width: 4.7% !important; }
  body.mode-td #appTD .cs-table th:nth-child(11) { width: 8.3% !important; }
  body.mode-td #appTD .cs-table th:nth-child(12) { width: 13.2% !important; }
  body.mode-td #appTD .cs-table th:nth-child(13) { width: 3.9% !important; }
  body.mode-td #appTD .cs-table th:nth-child(14) { width: 27.1% !important; }
  body.mode-td #appTD .cs-table th, body.mode-td #appTD .cs-table td { white-space: nowrap !important; word-break: normal !important; overflow-wrap: normal !important; font-size: 7.5pt !important; padding: 2px 2px !important; overflow: hidden !important; }
  body.mode-td #appTD .cs-table th.cs-narrow { white-space: normal !important; }
  body.mode-td #appTD .cs-table .cs-subtotal td { white-space: normal !important; }
  body.mode-td #appTD .cs-table td.cs-cnx-low, body.mode-td #appTD .cs-table td.cs-dcode { color: #c0392b !important; font-weight: 800 !important; }
  body.mode-td #appTD .cs-table .cs-x { color: #c0392b !important; font-weight: 800 !important; }
}

/* ---------- responsive: collapse sidebar on narrow screens ---------- */
@media (max-width: 900px) {
  #sidebar { width: 72px; padding: 16px 8px; }
  #sidebar .sb-brand-name, #sidebar .sb-brand-sub, #sidebar .sb-label,
  #sidebar .sb-item .sb-txt, #sidebar .sb-lock, #sidebar .sb-user-info, #sidebar .sb-theme .th-txt { display: none; }
  #sidebar .sb-brand { justify-content: center; padding-bottom: 14px; }
  #sidebar .sb-item { justify-content: center; padding: 10px; }
  #sidebar .sb-item .ico { width: auto; font-size: 17px; }
  #appMCS, #appTD, #appOV { margin-left: 72px; padding: 20px 16px 60px; }
  #appOV .ov-stats, #appOV .ov-grid { grid-template-columns: 1fr; }
}

/* Toggle tiles (Exclusions / Manual Paste) — open state indicator */
#appMCS .btn-secondary.tile-open { border-color: var(--accent); color: var(--accent-text); background: var(--accent-soft); }


/* Fast Track sub-switch (Arrival / Departure) */
#appTD .ft-sub-switch { display: flex; gap: 10px; margin-bottom: 20px; }
#appTD .ft-sub-btn { padding: 11px 20px; border-radius: 10px; border: 1px solid var(--border); background: var(--panel-2); color: var(--muted); font-weight: 700; font-size: 13px; cursor: pointer; font-family: inherit; transition: 0.2s; }
#appTD .ft-sub-btn:hover { border-color: var(--border-strong); color: var(--text); }
#appTD .ft-sub-btn.active { border-color: var(--blue); color: var(--blue); background: var(--blue-soft); }

/* Overview expandable stat tiles */
#appOV .ov-stat.ov-click { cursor: pointer; transition: border-color .15s; }
#appOV .ov-stat.ov-click:hover { border-color: var(--border-strong); }
#appOV .ov-stat.ov-click.open { border-color: var(--accent); }
#appOV .ov-detail { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--border); }
#appOV .ov-det-title { font-size: 10.5px; font-weight: 700; letter-spacing: 1px; color: var(--faint); text-transform: uppercase; margin-bottom: 6px; }
#appOV .ov-det-row { display: flex; justify-content: space-between; gap: 10px; padding: 4px 0; font-size: 12.5px; color: var(--text-2); }
#appOV .ov-det-dim { color: var(--faint); font-weight: 400; }

/* ---------- MCS simplified main tiles + More Options menu ---------- */
#appMCS .mcs-main-tiles { align-items: stretch; }
#appMCS .mcs-main-tiles .form-group { flex: 1 1 0; min-width: 200px; }
#appMCS .mcs-main-tiles .dropzone { height: 100%; box-sizing: border-box; display: flex; flex-direction: column; justify-content: center; }
#appMCS .ho-tile { border-color: rgba(245,166,35,.45); }
#appMCS .ho-tile:hover { border-color: var(--amber); }
#appMCS .ho-tile h3 { color: var(--amber); }
#appMCS .ho-tile .ho-chev { font-size: 12px; margin-left: 4px; }
#appMCS .more-wrap { position: relative; }
#appMCS .more-menu { position: absolute; bottom: calc(100% + 8px); right: 0; min-width: 220px; background: var(--panel-2); border: 1px solid var(--border-strong); border-radius: 12px; padding: 6px; box-shadow: var(--shadow-modal); z-index: 60; }
#appMCS .more-menu button { display: block; width: 100%; text-align: left; background: none; border: none; color: var(--text-2); padding: 10px 12px; font-size: 13px; font-weight: 600; border-radius: 8px; cursor: pointer; font-family: inherit; }
#appMCS .more-menu button:hover { background: var(--accent-soft); color: var(--accent-text); }
#appMCS .more-menu button.tile-open { color: var(--accent-text); }
#appMCS .more-menu button.more-danger { color: var(--red-text); }
#appMCS .more-menu button.more-danger:hover { background: var(--red-soft); color: var(--red-text); }
#appMCS .more-menu .menu-sep { height: 1px; background: var(--border); margin: 4px 8px; }
