/* ==========================================================================
   Equipment Tracker – shared styles
   ========================================================================== */
:root {
    --primary: #667eea;
    --primary-dark: #764ba2;
    --ink: #2d3748;
    --muted: #718096;
    --faint: #a0aec0;
    --line: #e2e8f0;
    --surface: #ffffff;
    --surface-alt: #f7fafc;
    --ok: #48bb78;
    --ok-dark: #38a169;
    --warn: #dd6b20;
    --grad: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.2);
}

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

body {
    font-family: 'Inter', sans-serif;
    background: var(--grad);
    background-attachment: fixed;
    min-height: 100vh;
    padding: 20px;
    position: relative;
    overflow-x: hidden;
}

/* ---------- animated background ---------- */
.bg-orbs { position: fixed; inset: 0; z-index: 0; pointer-events: none; overflow: hidden; }
.bg-orbs span {
    position: absolute; border-radius: 50%; filter: blur(70px); opacity: .35;
    background: rgba(255, 255, 255, .55); animation: drift 22s ease-in-out infinite;
}
.bg-orbs span:nth-child(1) { width: 380px; height: 380px; top: -120px; left: -80px; }
.bg-orbs span:nth-child(2) { width: 460px; height: 460px; bottom: -180px; right: -120px; animation-delay: -8s; background: rgba(118, 75, 162, .7); }
.bg-orbs span:nth-child(3) { width: 260px; height: 260px; top: 45%; left: 55%; animation-delay: -14s; opacity: .2; }
@keyframes drift {
    0%, 100% { transform: translate(0, 0) scale(1); }
    33% { transform: translate(40px, 30px) scale(1.08); }
    66% { transform: translate(-30px, 50px) scale(.95); }
}

.dashboard-container, .home-container { position: relative; z-index: 1; }
.dashboard-container { max-width: 1600px; margin: 0 auto; animation: fadeUp .5s ease both; }
.page-dashboard { zoom: .9; } /* 100% browser zoom looks like 90% */

@keyframes fadeUp { from { opacity: 0; transform: translateY(18px); } to { opacity: 1; transform: none; } }

.demo-pill {
    display: inline-flex; align-items: center; gap: 6px; padding: 5px 12px; border-radius: 20px;
    background: rgba(255, 255, 255, .2); color: #fff; font-size: .75em; font-weight: 600;
    border: 1px solid rgba(255, 255, 255, .4); backdrop-filter: blur(6px);
}
.demo-pill.small { background: #fefcbf; color: #744210; border-color: #f6e05e; margin-left: 10px; vertical-align: middle; }

/* ==========================================================================
   Landing page
   ========================================================================== */
.home-container {
    max-width: 1040px; margin: 0 auto; min-height: calc(100vh - 40px); /* 40px = body padding */
    display: flex; flex-direction: column; justify-content: center;
}

.page-home { background: linear-gradient(135deg, #12102f 0%, #231c63 55%, #47288a 100%) fixed; }
.page-home .bg-orbs { display: none; }
.route-canvas { /* dispatch network, drawn by home.js; fades behind the content */
    position: fixed; inset: 0; width: 100%; height: 100%; z-index: 0; pointer-events: none;
    -webkit-mask-image: radial-gradient(ellipse at center, rgba(0, 0, 0, .3) 0%, #000 70%);
    mask-image: radial-gradient(ellipse at center, rgba(0, 0, 0, .3) 0%, #000 70%);
}

.home-hero { text-align: center; color: #fff; margin: -8px 0 22px; animation: fadeUp .6s ease both; }
.home-logo { position: absolute; top: 17px; left: 16px; z-index: 1; display: block; height: 24px; width: auto; max-width: 100%; }
.hero-title { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 12px; margin-bottom: 12px; }
.hero-mark {
    width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center;
    background: rgba(255, 255, 255, .18); border: 1px solid rgba(255, 255, 255, .35);
    backdrop-filter: blur(8px); font-size: 15px; animation: float 4s ease-in-out infinite;
}
.home-hero h1 { font-size: 1.75em; font-weight: 800; letter-spacing: -.5px; }
.home-hero p { font-size: .95em; opacity: .88; max-width: 560px; margin: 0 auto 8px; line-height: 1.45; }
@keyframes float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-7px); } }

.portal-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 20px; width: 100%; max-width: 1040px; margin: auto; } /* auto: centred in the space under the title */

.portal-card {
    position: relative; display: flex; flex-direction: column; background: var(--surface); border-radius: 16px;
    padding: 20px; text-decoration: none; color: var(--ink); overflow: hidden;
    box-shadow: var(--shadow-lg); transition: transform .35s ease, box-shadow .35s ease;
    opacity: 0; animation: fadeUp .6s ease forwards; animation-delay: calc(.25s + var(--delay, 0s));
}
.portal-card::before { /* top accent bar */
    content: ''; position: absolute; top: 0; left: 0; right: 0; height: 5px; background: var(--grad);
    transform: scaleX(.25); transform-origin: left; transition: transform .45s ease;
}
.portal-card::after { /* sheen */
    content: ''; position: absolute; top: 0; left: -120%; width: 80%; height: 100%;
    background: linear-gradient(100deg, transparent, rgba(255, 255, 255, .55), transparent);
    transform: skewX(-18deg); transition: left .7s ease;
}
.portal-card:hover, .portal-card:focus-visible { transform: translateY(-8px); box-shadow: 0 22px 50px rgba(0, 0, 0, .3); outline: none; }
.portal-card:hover::before, .portal-card:focus-visible::before { transform: scaleX(1); }
.portal-card:hover::after { left: 140%; }

.portal-card-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.portal-icon {
    width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; font-size: 19px; color: #fff;
    background: var(--grad); box-shadow: 0 8px 20px rgba(102, 126, 234, .45); transition: transform .35s ease;
}
.portal-card:hover .portal-icon { transform: rotate(-6deg) scale(1.08); }
.portal-badge {
    font-size: .72em; font-weight: 700; text-transform: uppercase; letter-spacing: .6px; color: var(--primary);
    background: #edf2ff; padding: 6px 12px; border-radius: 20px;
}
.portal-card h2 { font-size: 1.15em; font-weight: 700; margin-bottom: 6px; }
.portal-desc { color: var(--muted); font-size: .85em; line-height: 1.5; margin-bottom: 14px; flex-grow: 1; }

.portal-stats {
    display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; padding: 10px 0;
    border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); margin-bottom: 12px;
}
.pstat { text-align: center; }
.pstat-val { display: block; font-size: 1.25em; font-weight: 700; color: var(--ink); line-height: 1.1; }
.pstat-lbl { font-size: .7em; text-transform: uppercase; letter-spacing: .5px; color: var(--faint); font-weight: 600; }
.pstat-val.loading { animation: pulseText 1.1s ease-in-out infinite; }
@keyframes pulseText { 50% { opacity: .35; } }

.portal-cta {
    display: flex; align-items: center; justify-content: space-between; font-size: .9em; font-weight: 600; color: var(--primary);
}
.portal-cta i { transition: transform .3s ease; }
.portal-card:hover .portal-cta i { transform: translateX(8px); }

.page-loader { /* shown on card click until the dashboard arrives */
    position: fixed; inset: 0; z-index: 10; display: none; flex-direction: column; align-items: center; justify-content: center; gap: 14px;
    color: #fff; font-weight: 600; background: rgba(18, 16, 47, .6); backdrop-filter: blur(4px);
}
.page-loader.show { display: flex; }
.page-loader-spinner {
    width: 42px; height: 42px; border-radius: 50%; border: 4px solid rgba(255, 255, 255, .25); border-top-color: #fff;
    animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.home-actions { position: absolute; top: 12px; right: 16px; z-index: 2; display: flex; align-items: center; gap: 8px; }
.home-actions a, .home-actions button {
    display: inline-flex; align-items: center; gap: 7px; padding: 7px 14px; border-radius: 20px; cursor: pointer; text-decoration: none;
    color: #fff; font: 600 13px 'Inter', sans-serif; background: rgba(255, 255, 255, .14); border: 1px solid rgba(255, 255, 255, .3);
    transition: background .2s ease;
}
.home-actions a:hover, .home-actions a:focus-visible, .home-actions button:hover, .home-actions button:focus-visible { background: rgba(255, 255, 255, .26); outline: none; }

.users-page {
    position: relative; z-index: 1; display: grid; grid-template-columns: 340px minmax(0, 1fr); gap: 20px; align-items: start;
    max-width: 1280px; margin: 0 auto; padding-top: 70px;
}
.login-card.users-form { max-width: none; }
.login-card.users-form h1, .users-form .login-subtitle { text-align: left; }
.users-form select {
    padding: 10px 12px; margin-bottom: 14px; border-radius: 8px; border: 1px solid var(--line);
    font: inherit; font-size: .92em; color: var(--ink); background: var(--surface-alt);
}
.users-form select:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(102, 126, 234, .2); background: var(--surface); }
.users-form select:disabled { color: var(--muted); cursor: not-allowed; }
.users-hint { margin: -8px 0 14px; font-size: .78em; color: var(--muted); }
.users-cancel { margin-top: 10px; text-align: center; font-size: .86em; font-weight: 600; color: var(--primary); text-decoration: none; }
.users-cancel:hover, .users-cancel:focus-visible { text-decoration: underline; }
.users-you { color: var(--muted); font-size: .85em; }
.pw-field { position: relative; display: flex; flex-direction: column; }
.pw-field input { padding-right: 42px; }
.login-card .pw-eye, .pw-eye {
    display: inline-flex; align-items: center; justify-content: center; width: 30px; height: 30px; margin: 0; padding: 0; border: 0; border-radius: 6px;
    cursor: pointer; color: var(--muted); background: none; font-size: .9em;
}
.login-card .pw-eye:hover, .login-card .pw-eye:focus-visible, .pw-eye:hover, .pw-eye:focus-visible { color: var(--primary); background: var(--surface-alt); opacity: 1; outline: none; }
.pw-field .pw-eye { position: absolute; top: 6px; right: 6px; }
.pw-cell { white-space: nowrap; }
.users-actions { display: flex; align-items: center; gap: 6px; }
.users-actions form { display: flex; }
.users-actions .status-radios { gap: 10px; margin-right: 4px; }
.status-radios label { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; color: var(--muted); cursor: pointer; white-space: nowrap; }
.status-radios input { margin: 0; cursor: pointer; }
.status-radios input:disabled, .status-radios input:disabled + span { cursor: not-allowed; }
.status-radios input:checked + span { font-weight: 600; }
.status-active input { accent-color: #2f855a; }
.status-active input:checked + span { color: #276749; }
.status-inactive input { accent-color: #c53030; }
.status-inactive input:checked + span { color: #9b2c2c; }
.users-icon {
    display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 28px; border: 0; border-radius: 6px;
    cursor: pointer; font-size: 13px; color: var(--muted); background: none; text-decoration: none;
}
.users-icon:hover, .users-icon:focus-visible { color: var(--primary); background: var(--surface-alt); outline: none; }
.users-delete:hover, .users-delete:focus-visible { color: #c53030; background: #fff5f5; }
.users-ok { padding: 9px 12px; margin-bottom: 14px; border-radius: 8px; font-size: .84em; color: #276749; background: #f0fff4; border: 1px solid #9ae6b4; }
.users-list { padding: 24px; border-radius: 16px; background: var(--surface); color: var(--ink); box-shadow: var(--shadow-lg); animation: fadeUp .6s ease both; }
.users-list h2 { font-size: 1.1em; font-weight: 800; margin-bottom: 14px; }
.users-list h2 span { color: var(--muted); font-weight: 600; font-size: .85em; margin-left: 4px; }
.users-scroll { overflow-x: auto; }
.users-table { width: 100%; min-width: 840px; border-collapse: collapse; font-size: .88em; }
.users-table th { text-align: left; font-size: .85em; font-weight: 600; color: var(--muted); padding: 8px 10px; border-bottom: 2px solid var(--line); white-space: nowrap; }
.users-table td { padding: 10px; border-bottom: 1px solid var(--line); overflow-wrap: anywhere; }
.users-table td:last-child { white-space: nowrap; }
.users-empty { text-align: center; color: var(--muted); }
.role-pill { display: inline-block; white-space: nowrap; padding: 2px 10px; border-radius: 12px; font-size: .85em; font-weight: 600; color: #4a5568; background: #edf2f7; }
.role-admin { color: #553c9a; background: #e9e3fb; }

.login-page { position: relative; z-index: 1; min-height: calc(100vh - 40px); display: flex; align-items: center; justify-content: center; }
.login-card {
    display: flex; flex-direction: column; width: 100%; max-width: 380px; padding: 28px; border-radius: 16px;
    background: var(--surface); color: var(--ink); box-shadow: var(--shadow-lg); animation: fadeUp .6s ease both;
}
.login-icon { margin: 0 auto 12px; }
.login-card h1 { font-size: 1.4em; font-weight: 800; letter-spacing: -.3px; text-align: center; }
.login-subtitle { color: var(--muted); font-size: .88em; text-align: center; margin: 4px 0 18px; }
.login-error { padding: 9px 12px; margin-bottom: 14px; border-radius: 8px; font-size: .84em; color: #9b2c2c; background: #fff5f5; border: 1px solid #feb2b2; }
.login-card label { font-size: .82em; font-weight: 600; margin-bottom: 5px; }
.login-card input {
    padding: 10px 12px; margin-bottom: 14px; border-radius: 8px; border: 1px solid var(--line);
    font: inherit; font-size: .92em; color: var(--ink); background: var(--surface-alt);
}
.login-card input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(102, 126, 234, .2); background: var(--surface); }
.login-card button {
    display: flex; align-items: center; justify-content: center; gap: 8px; margin-top: 4px; padding: 11px; border: 0; border-radius: 8px;
    cursor: pointer; font: inherit; font-weight: 600; color: #fff; background: var(--grad); transition: opacity .2s ease;
}
.login-card button:hover, .login-card button:focus-visible { opacity: .88; outline: none; }

.home-footer { text-align: center; color: rgba(255, 255, 255, .7); font-size: .82em; margin-top: 18px; }

/* ==========================================================================
   Dashboard header
   ========================================================================== */
.dashboard-header {
    background: var(--surface); border-radius: 15px; box-shadow: var(--shadow-lg); margin-bottom: 30px;
    display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px;
    padding: 14px 20px; min-height: 60px;
}
.header-left { display: flex; align-items: center; gap: 14px; }
.dashboard-header h1 { color: var(--ink); font-size: 1.5em; font-weight: 700; }
.dashboard-header h1 i { color: var(--primary); }
.home-link {
    width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; color: var(--primary);
    background: #edf2ff; text-decoration: none; transition: all .25s ease;
}
.home-link:hover { background: var(--grad); color: #fff; transform: translateX(-3px); }

.header-form { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.field { display: flex; align-items: center; gap: 6px; }
.field label { font-weight: 600; color: var(--ink); font-size: .85em; white-space: nowrap; }
.field label i { color: var(--primary); }
.field input[type=date] {
    padding: 6px 10px; border: 2px solid var(--line); border-radius: 8px; font-family: Inter, sans-serif;
    font-size: .85em; color: var(--ink); outline: none; transition: border-color .2s, box-shadow .2s;
}
.field input[type=date]:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(102, 126, 234, .18); }

.btn, .export-btn {
    display: inline-flex; align-items: center; gap: 6px; border: none; border-radius: 8px; cursor: pointer;
    font-family: Inter, sans-serif; font-weight: 600; font-size: .85em; text-decoration: none;
    transition: all .3s ease; white-space: nowrap;
}
.btn { padding: 7px 14px; }
.btn-primary { background: var(--grad); color: #fff; }
.btn-ghost { background: var(--line); color: var(--ink); }
.btn-ghost:hover { background: #cbd5e0; }
.btn:hover, .export-btn:hover { transform: scale(1.05); }
.export-btn { padding: 7px 14px; background: linear-gradient(135deg, #1D6F42 0%, #21a366 100%); color: #fff; }
.export-btn:hover { box-shadow: 0 4px 12px rgba(29, 111, 66, .4); }

/* ==========================================================================
   Summary cards
   ========================================================================== */
.summary-cards-container { display: grid; grid-template-columns: repeat(6, 1fr); gap: 20px; margin-bottom: 30px; }

.summary-card {
    background: var(--surface); border-radius: 15px; padding: 12px; text-align: center; position: relative;
    overflow: hidden; cursor: default; box-shadow: 0 10px 30px rgba(0, 0, 0, .15);
    transition: all .3s ease; opacity: 0; animation: fadeUp .5s ease forwards; animation-delay: var(--delay, 0s);
}
.summary-card:hover { transform: translateY(-5px); box-shadow: 0 15px 40px rgba(0, 0, 0, .25); }
.shimmer::after {
    content: ''; position: absolute; inset: 0; transform: translateX(-100%); pointer-events: none;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .3), transparent); animation: shimmer 2.4s infinite;
}
@keyframes shimmer { 100% { transform: translateX(100%); } }

.card-title { font-size: .9em; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .5px; margin-bottom: 10px; }
.card-count { font-size: 2.5em; font-weight: 700; color: var(--ink); line-height: 1; margin-bottom: 5px; }
.card-subtitle { font-size: .85em; color: var(--faint); font-weight: 500; }
.card-progress-bar { width: 100%; height: 4px; background: var(--line); border-radius: 2px; margin-top: 15px; overflow: hidden; }
.card-progress-fill { height: 100%; width: 0; border-radius: 2px; transition: width 1.1s cubic-bezier(.2, .8, .2, 1); }
.progress-total { background: linear-gradient(90deg, #667eea, #764ba2); }
.progress-booked { background: linear-gradient(90deg, #4299e1, #3182ce); }
.progress-picked { background: linear-gradient(90deg, #ed8936, #dd6b20); }
.progress-invoiced { background: linear-gradient(90deg, #ecc94b, #d69e2e); }
.progress-dispatched { background: linear-gradient(90deg, #48bb78, #38a169); }

/* ==========================================================================
   Table
   ========================================================================== */
.table-wrapper { background: var(--surface); border-radius: 15px; overflow-x: auto; box-shadow: var(--shadow-lg); animation: fadeUp .6s ease .25s both; }
.table-wrapper::-webkit-scrollbar { height: 8px; }
.table-wrapper::-webkit-scrollbar-track { background: #f1f1f1; }
.table-wrapper::-webkit-scrollbar-thumb { background: var(--primary); border-radius: 4px; }
.table-wrapper::-webkit-scrollbar-thumb:hover { background: var(--primary-dark); }

.dispatch-table { width: 100%; border-collapse: collapse; }
.dispatch-table thead { background: var(--grad); color: #fff; }
.dispatch-table thead th { padding: 18px 15px; text-align: left; font-weight: 600; font-size: .9em; text-transform: uppercase; letter-spacing: .5px; }
.dispatch-table tbody tr { border-bottom: 1px solid var(--line); transition: background-color .25s ease; }
.dispatch-table tbody tr.order-row { cursor: pointer; }
.dispatch-table tbody tr.order-row:hover { background-color: var(--surface-alt); }
.dispatch-table tbody tr.order-row.active { background-color: #edf2f7; }
.dispatch-table tbody td { padding: 10px; color: var(--ink); font-size: .95em; }
.dispatch-table a { color: var(--primary); font-weight: 600; text-decoration: none; }
.dispatch-table a:hover { text-decoration: underline; }
.customer-cell { font-weight: 600; color: var(--primary); }

.target-row { background: linear-gradient(135deg, #f7fafc 0%, #edf2f7 100%); font-weight: 600; border-bottom: 3px solid var(--primary) !important; }
.target-label { text-align: center; color: var(--ink); font-size: 1em; padding: 15px !important; }
.target-label i { color: var(--primary); margin-right: 8px; }
.target-pill { background: var(--grad); color: #fff; padding: 8px 16px; border-radius: 20px; font-weight: 700; font-size: .9em; white-space: nowrap; }

/* stage timeline */
.stage-timeline { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }
.stage { display: flex; flex-direction: column; align-items: center; position: relative; }
.stage-icon {
    width: 32px; height: 32px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
    font-weight: 600; font-size: .75em; color: #fff; background: #cbd5e0; position: relative; z-index: 2;
    transition: transform .25s ease;
}
.order-row:hover .stage-icon.completed { transform: scale(1.12); }
.stage-icon.completed { background: linear-gradient(135deg, #48bb78 0%, #38a169 100%); }
.stage-icon.pending { background: #cbd5e0; color: var(--muted); }
.stage-icon.pending .fa-clock { animation: tick 3s linear infinite; }
@keyframes tick { to { transform: rotate(360deg); } }
.stage-icon.target { background: var(--grad); width: 36px; height: 36px; }
.stage-label { font-size: .7em; color: var(--muted); margin-top: 4px; text-align: center; white-space: nowrap; }
.stage-label.strong { font-weight: 700; color: var(--ink); }
.stage-time { font-size: .65em; color: var(--primary); font-weight: 600; margin-top: 2px; }
.stage-connector { width: 60px; height: 2px; background: #cbd5e0; margin: 0 -5px 20px; transition: background .3s; }
.stage-connector.completed { background: var(--ok); }
.stage-connector.target { background: var(--faint); }

.total-cycle-badge {
    background: linear-gradient(135deg, #48bb78 0%, #38a169 100%); color: #fff; padding: 8px 16px; border-radius: 20px;
    font-weight: 600; font-size: .9em; display: inline-block; white-space: nowrap;
}
.total-cycle-badge.late { background: var(--warn); }
.total-cycle-badge.progress { background: #cbd5e0; color: #000; }

.expand-icon { width: 24px; height: 24px; display: flex; align-items: center; justify-content: center; color: var(--primary); font-size: 1.2em; transition: transform .3s ease; }
.expand-icon.rotated { transform: rotate(180deg); }

/* details */
.detail-row { display: none; background: var(--surface-alt); }
.detail-row.show { display: table-row; }
.detail-row td { padding: 0 !important; }
.detail-content { padding: 30px; animation: slideDown .3s ease; }
@keyframes slideDown { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: none; } }
.detail-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 25px; }
.detail-section, .timeline-detail, .product-section { background: var(--surface); padding: 20px; border-radius: 10px; box-shadow: 0 2px 8px rgba(0, 0, 0, .1); }
.detail-section h3, .timeline-detail h3, .product-section h3 { color: var(--ink); font-size: 1.1em; margin-bottom: 15px; padding-bottom: 10px; border-bottom: 2px solid var(--primary); }
.timeline-detail h3 { margin-bottom: 20px; }
.detail-item { display: flex; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.detail-item:last-child, .detail-item.no-border { border-bottom: none; }
.detail-label { color: var(--muted); font-weight: 600; font-size: .9em; }
.detail-value { color: var(--ink); font-weight: 500; text-align: right; word-break: break-all; }

.timeline-step { position: relative; padding-left: 40px; padding-bottom: 25px; }
.timeline-step:last-child { padding-bottom: 0; }
.timeline-step::before { content: ''; position: absolute; left: 12px; top: 0; bottom: -25px; width: 2px; background: linear-gradient(180deg, #48bb78 0%, #667eea 100%); }
.timeline-step:last-child::before { display: none; }
.timeline-dot { position: absolute; left: 0; top: 5px; width: 28px; height: 28px; border-radius: 50%; background: var(--ok); border: 4px solid #fff; box-shadow: 0 0 0 2px var(--ok); }
.timeline-dot.pending { background: #cbd5e0; box-shadow: 0 0 0 2px #cbd5e0; }
.timeline-step-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 5px; }
.timeline-step-title { font-weight: 600; color: var(--ink); }
.timeline-step-duration { background: #edf2f7; color: var(--primary); padding: 4px 12px; border-radius: 12px; font-size: .85em; font-weight: 600; }
.timeline-step-time { color: var(--muted); font-size: .9em; }

.product-table { width: 100%; border-collapse: collapse; margin-top: 10px; }
.product-table thead { background: var(--grad); color: #fff; }
.product-table thead th { padding: 12px; text-align: left; font-weight: 600; font-size: .9em; }
.product-table tbody tr { border-bottom: 1px solid var(--line); }
.product-table tbody tr:last-child { border-bottom: none; }
.product-table tbody tr:hover { background: var(--surface-alt); }
.product-table tbody td { padding: 12px; color: var(--ink); font-size: .9em; }
.product-table tbody td:last-child { font-weight: 600; color: var(--primary); text-align: center; }

.track-button {
    display: inline-flex; align-items: center; gap: 10px; background: var(--grad); color: #fff !important; padding: 12px 24px;
    border-radius: 8px; text-decoration: none !important; font-weight: 600; transition: all .3s ease; margin-top: 10px;
}
.track-button::after { content: '\2192'; font-size: 1.2em; }
.track-button:hover { background: linear-gradient(135deg, #764ba2 0%, #667eea 100%); transform: scale(1.05); box-shadow: 0 5px 15px rgba(102, 126, 234, .4); }

.courier-logo-small { width: 100px; height: 40px; object-fit: contain; vertical-align: middle; background: var(--surface-alt); padding: 5px; border-radius: 5px; }

.error-message { background: #fff5f5; color: #c53030; padding: 30px; border-radius: 10px; border-left: 5px solid #fc8181; text-align: center; font-weight: 600; margin: 20px; }
.no-data { background: var(--surface); padding: 60px; border-radius: 15px; text-align: center; color: var(--muted); }
.no-data h2 { color: var(--ink); margin-bottom: 10px; }

/* ==========================================================================
   Responsive + reduced motion
   ========================================================================== */
@media (max-width: 1200px) {
    .dispatch-table { font-size: .9em; }
    .stage-timeline { flex-direction: column; align-items: flex-start; }
    .stage-connector { display: none; }
    .summary-cards-container { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
}
@media (max-width: 960px) {
    .home-logo { position: static; margin-bottom: 20px; } /* no room beside the title */
    .login-page { min-height: calc(100vh - 84px); }
    .users-page { grid-template-columns: minmax(0, 1fr); padding-top: 0; }
}
@media (max-width: 480px) {
    .home-logo { max-width: 120px; height: auto; } /* leaves room for the Users/Home and Logout buttons */
}
@media (max-width: 768px) {
    body { padding: 10px; }
    .dashboard-header h1 { font-size: 1.2em; }
    .dispatch-table { font-size: .8em; }
    .dispatch-table thead th, .dispatch-table tbody td { padding: 10px 8px; }
    .detail-grid { grid-template-columns: 1fr; }
    .stage-timeline { gap: 5px; }
    .stage-icon { width: 28px; height: 28px; font-size: .7em; }
    .summary-cards-container { grid-template-columns: 1fr; }
    .card-count { font-size: 2em; }
    .home-container { min-height: calc(100vh - 20px); }
    .home-hero h1 { font-size: 1.5em; }
    .portal-grid { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
    .summary-card, .portal-card { opacity: 1; }
}
