:root { --brand: #104205; --bg: #f4f6f8; --border: #dee2e6; }
* { box-sizing: border-box; }
html { overflow-x: hidden; max-width: 100%; }
body {
    font-family: 'Outfit', -apple-system, BlinkMacSystemFont, sans-serif;
    background-color: var(--bg);
    margin: 0;
    color: #1f2937;
    overflow-x: hidden;
    max-width: 100%;
}
a { color: inherit; }

/* ---------- Login ---------- */
.login-wrap { max-width: 420px; margin: 80px auto; width: 100%; padding: 0 10px; }
.login-panel { background: #fff; border: 1px solid var(--border); border-radius: 12px; padding: 30px; box-shadow: 0 10px 25px rgba(0,0,0,0.08); }
.form-group { margin-bottom: 20px; text-align: left; }
.form-group label { display: block; font-size: .88em; font-weight: 600; margin-bottom: 8px; color: #444; }
.alert-msg { background: #fff5f5; border-left: 4px solid #e53e3e; color: #c62828; padding: 10px 14px; border-radius: 6px; margin-bottom: 16px; font-size: .88em; }
.success-msg { background: #f4fbf7; border-left: 4px solid #2e7d32; color: #2e7d32; padding: 10px 14px; border-radius: 6px; margin-bottom: 16px; font-size: .88em; }
.btn-submit { background: var(--brand); color: #fff; border: none; padding: 12px; border-radius: 8px; font-weight: 600; font-size: 1em; cursor: pointer; font-family: inherit; }
.btn-submit:hover { opacity: .92; }

/* ---------- Shared form controls ---------- */
.form-control { width: 100%; padding: 9px 12px; border: 1px solid var(--border); border-radius: 6px; font-family: inherit; font-size: .95em; background: #fff; }
.form-control:focus { outline: none; border-color: var(--brand); }
label { font-size: .85em; font-weight: 600; color: #334155; display: block; margin-bottom: 4px; }
.form-grid { display: flex; gap: 15px; flex-wrap: wrap; margin-bottom: 15px; }
.form-grid > div { flex: 1; min-width: 180px; }

/* ---------- Buttons ---------- */
.btn { padding: 9px 16px; border-radius: 8px; border: none; font-weight: 600; font-family: inherit; font-size: .9em; cursor: pointer; }
.btn-success { background: var(--brand); color: #fff; }
.btn-success:hover { opacity: .92; }
.btn-primary { background: #334155; color: #fff; }
.btn-danger { background: #dc2626; color: #fff; }

/* ---------- Badges ---------- */
.badge { display: inline-block; padding: 3px 10px; border-radius: 20px; font-size: .78em; font-weight: 700; background: #f1f5f9; color: #475569; }
.badge-active { background: #dcfce7; color: #166534; }
.badge-paused { background: #fee2e2; color: #991b1b; }

/* ---------- Panels ---------- */
.panel { background: #fff; border: 1px solid #eef2f5; border-radius: 12px; padding: 22px; margin-bottom: 24px; box-shadow: 0 2px 8px rgba(0,0,0,.03); }
.panel h3 { margin-top: 0; color: var(--brand); }

/* ---------- Admin header + tabs ---------- */
.admin-container { max-width: 100%; margin: 0; padding: 20px 30px; }
.admin-header {
    background: var(--brand); color: #fff; padding: 18px 24px; border-radius: 10px; margin-bottom: 20px; display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 10px;
}
.tab-nav-bar { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 20px; }
.tab-btn { background: #fff; border: 1px solid var(--border); padding: 10px 16px; border-radius: 8px; cursor: pointer; font-weight: 600; font-family: inherit; font-size: .9em; color: #475569; }
.tab-btn.active-tab { background: var(--brand); color: #fff; border-color: var(--brand); }
.tab-window-content { display: none; }
.tab-window-content.active-window { display: block; }
.system-alert-banner-item { padding: 12px 18px; border-radius: 8px; margin-bottom: 16px; font-size: .9em; font-weight: 500; }

/* ---------- Tables ---------- */
.table-responsive-container { overflow-x: auto; max-width: 100%; -webkit-overflow-scrolling: touch; }
table { border-collapse: collapse; width: 100%; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid #eef2f5; font-size: .9em; white-space: nowrap; }
td small[title], .delay-badge[title] { cursor: help; border-bottom: 1px dotted #94a3b8; }
th { background: #f8fafc; color: #475569; font-weight: 700; text-transform: uppercase; font-size: .78em; letter-spacing: .3px; }
th.sortable-col { cursor: pointer; user-select: none; }
th.sortable-col:hover { background: #eef2f7; }
th.sortable-col .sort-icon { opacity: .4; margin-left: 3px; }
th.sortable-col.sort-active .sort-icon { opacity: 1; color: var(--brand); }
.delay-tracker-select { font-size: .7em; text-transform: none; font-weight: 600; margin-top: 4px; padding: 2px 4px; border-radius: 4px; border: 1px solid #cbd5e1; width: 100%; }

/* ---------- Modals ---------- */
.modal-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.55); z-index: 99999; justify-content: center; align-items: center; padding: 10px; }
.modal-overlay.active-modal { display: flex; }
.modal-content { background: #fff; width: 100%; max-width: 550px; padding: 30px; border-radius: 12px; box-shadow: 0 15px 35px rgba(0,0,0,.2); position: relative; max-height: 90vh; overflow-y: auto; }
.modal-content h3 { margin-top: 0; color: var(--brand); border-bottom: 1px solid #eef2f5; padding-bottom: 12px; }
.modal-close-x-btn { position: absolute; top: 14px; right: 14px; background: none; border: none; font-size: 1.6em; line-height: 1; cursor: pointer; color: #94a3b8; }
.modal-close-x-btn:hover { color: #334155; }

/* ---------- Dashboard ---------- */
.dashboard-container { max-width: 100%; margin: 0; padding: 12px 24px; }
.dashboard-header-bar { background: var(--brand); color: #fff; padding: 15px 25px; border-radius: 10px; display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 15px; box-shadow: 0 4px 6px rgba(0,0,0,.05); margin-bottom: 20px; }
.dashboard-company-name { font-size: 1.3em; font-weight: 700; display: block; }
.dashboard-active-trips-label { font-size: .85em; font-weight: 600; color: rgba(255,255,255,.8); margin-left: 4px; }
.dashboard-clock { font-size: .88em; color: rgba(255,255,255,.75); font-weight: 500; margin-top: 2px; }
.viewing-company-bar { background: #4c1d95; color: #fff; border-radius: 8px; padding: 14px 20px; margin-bottom: 15px; display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: .95em; }
.viewing-company-bar select { padding: 8px 14px; border-radius: 6px; border: none; font-family: inherit; font-weight: 600; min-width: 160px; }
.system-admin-bar { background: #fff3e0; border: 1px solid #ffcc80; border-radius: 8px; padding: 10px 16px; margin-bottom: 15px; display: flex; align-items: center; gap: 10px; font-size: .9em; }
.system-admin-bar select { padding: 6px 10px; border-radius: 6px; border: 1px solid var(--border); font-family: inherit; }

/* Delay tracker + status badges */
.delay-badge { display: inline-flex; align-items: center; gap: 4px; padding: 4px 10px; border-radius: 6px; font-weight: 700; font-size: .82em; color: #fff; white-space: nowrap; }
.delay-ok { background: #166534; }
.delay-warning { background: #b45309; }
.delay-critical { background: #b91c1c; animation: delay-critical-flash 1s infinite; }
@keyframes delay-critical-flash {
    0%, 100% { opacity: 1; }
    50% { opacity: .45; }
}
.status-state-badge { display: inline-block; padding: 4px 12px; border-radius: 20px; font-size: .8em; font-weight: 700; }
.status-dispatching { background: #f1f5f9; color: #475569; }
.status-accepted { background: #dbeafe; color: #1e40af; }
.status-arrived { background: #fef3c7; color: #92400e; }
.status-pob { background: #dcfce7; color: #166534; }
.status-completed { background: #e2e8f0; color: #334155; }
.status-cancelled { background: #fee2e2; color: #991b1b; }
.status-created { background: #f1f5f9; color: #64748b; }

/* Status summary cards */
.status-summary-grid { display: grid; grid-template-columns: repeat(8, 1fr); gap: 10px; margin-bottom: 20px; }
.status-summary-card { background: #fff; border: 1px solid #eef2f5; border-radius: 10px; padding: 14px 10px; text-align: center; box-shadow: 0 2px 6px rgba(0,0,0,.03); }
.status-summary-count { font-size: 1.7em; font-weight: 800; color: var(--brand); }
.status-summary-label { font-size: .72em; font-weight: 700; color: #64748b; text-transform: uppercase; margin-top: 2px; letter-spacing: .3px; }
@media (max-width: 900px) {
    .status-summary-grid { grid-template-columns: repeat(4, 1fr); }
}
@media (max-width: 560px) {
    .status-summary-grid { grid-template-columns: repeat(2, 1fr); }
}

/* Fullscreen mode - matches the main project's approach: hide chrome, expand the table */
.fullscreen-active-matrix { position: fixed; inset: 0; z-index: 99998; background: #fff; padding: 15px; overflow-y: auto; }
.fullscreen-active-matrix .dashboard-header-bar,
.fullscreen-active-matrix .viewing-company-bar,
.fullscreen-active-matrix .tab-nav-bar,
.fullscreen-active-matrix #fs-filter-box-2 { display: none !important; }
.fullscreen-active-matrix #fs-filter-box-1 { margin-bottom: 10px; }
.fullscreen-active-matrix #icabbi-data-container table thead th { position: sticky; top: 0; z-index: 2; }


/* ---------- Universal mobile safety ---------- */
@media (max-width: 768px) {
    * { max-width: 100%; }
    .admin-container { padding: 12px; }
    .dashboard-container { padding: 8px; }
    .panel { padding: 14px !important; }
    .modal-content { padding: 18px; max-width: 100% !important; width: calc(100% - 20px); }
    .admin-header h2 { font-size: 1.15em !important; }
    .admin-header p { display: none; }
    table { font-size: .85em; }
    .form-control, select, input[type="text"], input[type="email"], input[type="number"], input[type="password"], input[type="url"] { font-size: 16px; }
    .form-grid { flex-direction: column; }
    .form-grid > div { min-width: 100% !important; width: 100%; }
    .table-responsive-container, .table-responsive-container table { max-width: none; }
}
