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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: #f0f2f5;
    min-height: 100vh;
    color: #333;
}

/* ── Top bar ── */
.topbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 60px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    box-shadow: 0 2px 20px rgba(0, 0, 0, 0.15);
    z-index: 100;
}

.topbar-brand {
    font-size: 20px;
    font-weight: 700;
    color: #fff;
    letter-spacing: 0.5px;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.topbar-user {
    color: rgba(255,255,255,0.85);
    font-size: 14px;
    font-weight: 500;
}

.session-timer {
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: help;
    position: relative;
}

.session-timer:hover::after {
    content: attr(title);
    position: absolute;
    bottom: -28px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0,0,0,0.8);
    color: #fff;
    font-size: 11px;
    font-weight: 500;
    padding: 4px 10px;
    border-radius: 6px;
    white-space: nowrap;
    pointer-events: none;
    z-index: 200;
}

.btn-logout {
    background: rgba(255,255,255,0.2);
    color: #fff;
    border: 1px solid rgba(255,255,255,0.3);
    border-radius: 8px;
    padding: 8px 18px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.2s;
}

.btn-logout:hover {
    background: rgba(255,255,255,0.3);
}

/* ── Sidebar ── */
.sidebar {
    position: fixed;
    top: 60px;
    left: 0;
    bottom: 0;
    width: 240px;
    background: #fff;
    box-shadow: 2px 0 12px rgba(0,0,0,0.06);
    overflow-y: auto;
    z-index: 90;
    padding: 12px 0;
}

.sidebar ul {
    list-style: none;
}

.sidebar li a {
    display: block;
    padding: 10px 20px;
    color: #555;
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    transition: background 0.15s, color 0.15s;
}

.sidebar li a:hover {
    background: #f0f2ff;
    color: #667eea;
}

.sidebar li.divider {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #aaa;
    padding: 16px 20px 6px;
    font-weight: 600;
}

/* ── Main content ── */
.main-content {
    margin-left: 240px;
    margin-top: 60px;
    padding: 28px 32px;
    min-height: calc(100vh - 60px);
}

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

.page-header h1 {
    font-size: 24px;
    font-weight: 700;
    color: #222;
}

/* ── Cards ── */
.card {
    background: #fff;
    border-radius: 14px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.06);
    padding: 24px;
    margin-bottom: 24px;
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid #eee;
}

.card-header h2 {
    font-size: 18px;
    font-weight: 600;
}

/* ── Stat cards (dashboard) ── */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 28px;
}

.stat-card {
    background: #fff;
    border-radius: 14px;
    padding: 20px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.06);
    text-align: center;
    transition: transform 0.2s, box-shadow 0.2s;
    text-decoration: none;
    color: inherit;
    display: block;
}

.stat-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(0,0,0,0.1);
}

.stat-card .stat-number {
    font-size: 32px;
    font-weight: 700;
    color: #667eea;
}

.stat-card .stat-label {
    font-size: 13px;
    color: #888;
    margin-top: 4px;
}

.stat-card.pending .stat-number { color: #e67e22; }
.stat-card.success .stat-number { color: #2ecc71; }
.stat-card.danger .stat-number { color: #e74c3c; }

/* ── Tables ── */
.table-wrapper {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

table th {
    background: #f8f9fa;
    text-align: left;
    padding: 10px 10px;
    font-weight: 600;
    color: #555;
    border-bottom: 2px solid #e8e8e8;
    white-space: nowrap;
}

table td {
    padding: 8px 10px;
    border-bottom: 1px solid #f0f0f0;
    vertical-align: middle;
    overflow-wrap: break-word;
    word-break: break-word;
}

table tr:hover td {
    background: #fafbff;
}

/* ── Status badges ── */
.badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
}

.badge-pending { background: #fef3cd; color: #856404; }
.badge-approved { background: #d4edda; color: #155724; }
.badge-completed { background: #cce5ff; color: #004085; }
.badge-cancelled { background: #f8d7da; color: #721c24; }
.badge-active { background: #d4edda; color: #155724; }
.badge-expired { background: #f8d7da; color: #721c24; }
.badge-released { background: #cce5ff; color: #004085; }
.badge-partial { background: #fff3cd; color: #856404; }
.badge-in-transit { background: #cce5ff; color: #004085; }
.badge-delivered { background: #d4edda; color: #155724; }
.badge-received { background: #e8daef; color: #6c3483; }
.badge-submitted { background: #d5f5e3; color: #1e8449; }

.badge-pbg-pending { background: #fef3cd; color: #856404; }
.badge-invoice-pending { background: #fff3e0; color: #e65100; }
.badge-dcc-pending { background: #fce4ec; color: #c62828; }
.badge-dispatch-pending { background: #e8eaf6; color: #283593; }
.badge-delivery-pending { background: #f3e5f5; color: #6a1b9a; }
.badge-bill-submission-pending { background: #e0f7fa; color: #00695c; }
.badge-payment-received-by-company-pending { background: #e8f5e9; color: #1b5e20; }
.badge-debit-note-pending { background: #fff8e1; color: #f57f17; }
.badge-payment-to-us-pending { background: #ede7f6; color: #4527a0; }
.badge-completed { background: #d4edda; color: #155724; }

/* ── Buttons ── */
.btn {
    display: inline-block;
    padding: 8px 18px;
    border: none;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.2s, transform 0.15s;
}

.btn:hover { transform: translateY(-1px); }

.btn-primary { background: #667eea; color: #fff; }
.btn-primary:hover { background: #5a6fd6; }

.btn-success { background: #2ecc71; color: #fff; }
.btn-success:hover { background: #27ae60; }

.btn-danger { background: #e74c3c; color: #fff; }
.btn-danger:hover { background: #c0392b; }

.btn-warning { background: #f39c12; color: #fff; }
.btn-warning:hover { background: #d68910; }

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

/* ── Forms ── */
.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

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

.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: #555;
    margin-bottom: 6px;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 10px 14px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 14px;
    transition: border-color 0.2s;
    background: #fafafa;
    outline: none;
    font-family: inherit;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    border-color: #667eea;
    background: #fff;
}

.form-group textarea {
    min-height: 80px;
    resize: vertical;
}

.form-actions {
    display: flex;
    gap: 12px;
    align-items: center;
    margin-top: 8px;
}

/* ── Filters ── */
.filters {
    display: flex;
    gap: 12px;
    align-items: center;
    flex-wrap: wrap;
    margin-bottom: 20px;
    padding: 16px;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}

.filters input,
.filters select {
    padding: 8px 12px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 13px;
    outline: none;
}

.filters input:focus,
.filters select:focus {
    border-color: #667eea;
}

.filters label {
    font-size: 13px;
    font-weight: 600;
    color: #666;
}

/* ── Flash messages ── */
.flash {
    padding: 14px 16px;
    border-radius: 10px;
    margin-bottom: 20px;
    font-size: 14px;
    font-weight: 500;
}

.flash-success { background: #d4edda; color: #155724; border: 1px solid #c3e6cb; }
.flash-error { background: #f8d7da; color: #721c24; border: 1px solid #f5c6cb; }
.alert { padding: 14px 16px; border-radius: 10px; margin-bottom: 20px; font-size: 14px; font-weight: 500; }
.alert-danger { background: #f8d7da; color: #721c24; border: 1px solid #f5c6cb; }

/* ── Utility ── */
.text-right { text-align: right; }
.text-center { text-align: center; }
.mt-4 { margin-top: 16px; }
.mb-4 { margin-bottom: 16px; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.gap-2 { gap: 8px; }

/* ── Searchable dropdown ── */
.searchable-wrapper {
    position: relative;
}
.searchable-wrapper select {
    display: none;
}
.searchable-input {
    width: 100%;
    padding: 8px 10px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 14px;
    outline: none;
    background: #fff;
    cursor: text;
    box-sizing: border-box;
    font-family: inherit;
}
.searchable-input:focus {
    border-color: #667eea;
}
.searchable-options {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    max-height: 200px;
    overflow-y: auto;
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 0 0 8px 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    z-index: 999;
    display: none;
}
.searchable-options div {
    padding: 8px 10px;
    cursor: pointer;
    font-size: 14px;
}
.searchable-options div:hover,
.searchable-options div.highlight {
    background: #f0f2ff;
    color: #667eea;
}
.searchable-options div.selected {
    font-weight: 600;
    background: #e8eaff;
}

/* ── Responsive ── */
@media (max-width: 768px) {
    .sidebar { width: 200px; }
    .main-content { margin-left: 200px; padding: 20px 16px; }
    .form-grid { grid-template-columns: 1fr; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 576px) {
    .sidebar { display: none; }
    .main-content { margin-left: 0; padding: 16px; }
    .topbar-user { display: none; }
    .stats-grid { grid-template-columns: 1fr; }
}


/* Date input DD-MM-YYYY */
input.dt { width: 140px; }
input.dt:focus { border-color: #667eea; }

/* ── Collapsible card ── */
.collapse-toggle { cursor:pointer; user-select:none; font-size:14px; color:#999; margin-right:8px; transition:transform .2s; display:inline-flex; align-items:center; width:16px; justify-content:center; }
.collapse-toggle.collapsed { transform:rotate(-90deg); }
.card-header { display:flex; align-items:center; justify-content:space-between; }
.card-header-left { display:flex; align-items:center; gap:4px; }
.card-header-right { display:flex; align-items:center; gap:8px; }
.card-body { transition:max-height .3s ease; overflow:hidden; }
.card-body.collapsed { max-height:0 !important; padding:0 !important; }

/* ── Table search ── */
.table-search { padding:4px 10px; border:1px solid #ddd; border-radius:6px; font-size:12px; outline:none; width:160px; transition:border-color .2s; }
.table-search:focus { border-color:#667eea; }
.table-search::placeholder { color:#bbb; }

/* ── Client-side pagination ── */
.table-pagination { display:flex; justify-content:center; align-items:center; gap:6px; padding:10px 0 4px; font-size:12px; }
.table-pagination .page-btn { padding:2px 10px; border:1px solid #ddd; border-radius:4px; background:#fff; color:#555; cursor:pointer; font-size:12px; }
.table-pagination .page-btn:hover:not(.disabled) { background:#667eea; color:#fff; border-color:#667eea; }
.table-pagination .page-btn.disabled { opacity:0.4; cursor:default; }
.table-pagination .page-btn.active { background:#667eea; color:#fff; border-color:#667eea; font-weight:600; }
.table-pagination .page-info { color:#888; margin:0 4px; }

/* Pipeline Progress Board */
.stage-pill { display:inline-flex;align-items:center;justify-content:center;width:28px;height:28px;border-radius:50%;font-size:13px;font-weight:700;line-height:1;cursor:default; }
.stage-done { background:#d4edda;color:#155724; }
.stage-warn { background:#fff3cd;color:#856404; }
.stage-na { background:#e9ecef;color:#6c757d; }
.progress-bar { height:8px;background:#e9ecef;border-radius:4px;overflow:hidden;margin-bottom:2px; }
.progress-fill { height:100%;background:linear-gradient(90deg,#667eea,#764ba2);border-radius:4px;transition:width .4s; }

/* ── Loading overlay ── */
.loading-overlay { position:fixed; inset:0; background:rgba(255,255,255,0.8); z-index:9999; display:none; align-items:center; justify-content:center; flex-direction:column; gap:16px; }
.loading-overlay.active { display:flex; }
.loading-spinner { width:48px; height:48px; border:4px solid #e0e0e0; border-top-color:#667eea; border-radius:50%; animation:spin .8s linear infinite; }
@keyframes spin { to { transform:rotate(360deg); } }
.loading-text { color:#555; font-size:15px; font-weight:500; }


