:root {
    --sidebar-bg: #ffffff;
    --sidebar-hover: rgba(30,87,153,0.08);
    --sidebar-active: #1e5799;
    --sidebar-text: #1e293b;
    --sidebar-text-active: #ffffff;
    --sidebar-width: 240px;
    --content-bg: #f1f5f9;
    --card-bg: #ffffff;
    --border: #e2e8f0;
    --primary: #1e5799;
    --text: #1e293b;
    --text-muted: #64748b;
}

* { box-sizing: border-box; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 14px;
    color: var(--text);
    background: var(--content-bg);
    margin: 0;
}

/* Layout */
.app-layout {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background: #fff;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    z-index: 100;
    flex-shrink: 0;
    border-right: 1px solid #d0dce8;
}

.sidebar-brand {
    padding: 14px 16px 12px;
    border-bottom: 1px solid rgba(30,87,153,0.15);
    background: rgba(255,255,255,0.82);
}
.sidebar-brand img {
    width: 100%;
    max-width: 190px;
    display: block;
    margin: 0 auto;
}

.sidebar-nav {
    list-style: none;
    padding: 10px 0;
    margin: 0;
    flex: 1;
    overflow-y: auto;
}
.sidebar-nav li a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 16px;
    color: var(--sidebar-text);
    text-decoration: none;
    transition: all 0.15s;
    border-radius: 0;
    font-size: 13.5px;
    font-weight: 500;
}
.sidebar-nav li a:hover { background: var(--sidebar-hover); color: var(--sidebar-active); }
.sidebar-nav li a.active { background: var(--sidebar-active); color: #fff; }
.sidebar-nav li a i { font-size: 15px; width: 18px; text-align: center; color: inherit; }

.nav-section {
    padding: 14px 16px 4px;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: #7a96ae;
}

.sidebar-user {
    padding: 12px 16px;
    border-top: 1px solid rgba(30,87,153,0.15);
    display: flex;
    align-items: center;
    gap: 10px;
    background: rgba(255,255,255,0.82);
}
.user-avatar {
    width: 32px; height: 32px;
    border-radius: 50%;
    background: var(--sidebar-active);
    color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 13px;
    flex-shrink: 0;
}
.user-details { flex: 1; min-width: 0; }
.user-name { color: #1e293b; font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-role { color: #64748b; font-size: 11px; }
.logout-btn { color: #64748b; text-decoration: none; font-size: 16px; }
.logout-btn:hover { color: #ef4444; }

/* Main content */
.main-content {
    margin-left: var(--sidebar-width);
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.page-header {
    background: var(--card-bg);
    border-bottom: 1px solid var(--border);
    padding: 16px 28px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.page-header h1 {
    margin: 0;
    font-size: 20px;
    font-weight: 700;
    color: var(--text);
}

.page-body {
    padding: 24px 28px;
    flex: 1;
}

/* Table */
.table-wrap {
    background: var(--card-bg);
    border-radius: 10px;
    border: 1px solid var(--border);
    overflow: hidden;
}

.cargo-table {
    margin: 0;
    font-size: 13.5px;
}
.cargo-table thead th {
    background: #f8fafc;
    color: var(--text-muted);
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 10px 14px;
    border-bottom: 1px solid var(--border);
    border-top: none;
}
.cargo-table tbody td {
    padding: 11px 14px;
    vertical-align: middle;
    border-bottom: 1px solid #f1f5f9;
}
.cargo-table tbody tr:last-child td { border-bottom: none; }
.cargo-table tbody tr:hover td { background: #f8fafc; }

.badge-num {
    background: #eff6ff;
    color: var(--primary);
    font-weight: 700;
    padding: 3px 8px;
    border-radius: 6px;
    font-size: 12px;
}
.badge-num.muted {
    background: #f1f5f9;
    color: var(--text-muted);
}

.transport-badge {
    background: #f0fdf4;
    color: #166534;
    padding: 2px 8px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
}

.archived-row td { opacity: 0.75; }

code {
    background: #f1f5f9;
    color: #0f172a;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 12px;
}

/* Directories */
.dir-panel {
    background: var(--card-bg);
    border-radius: 10px;
    border: 1px solid var(--border);
    overflow: hidden;
}
.dir-panel-header {
    padding: 14px 18px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-weight: 600;
}

/* Nav tabs override */
.nav-tabs .nav-link {
    color: var(--text-muted);
    font-size: 13.5px;
    font-weight: 500;
}
.nav-tabs .nav-link.active {
    color: var(--primary);
    font-weight: 600;
}

/* Submenu items in sidebar */
.submenu-item {
    padding-left: 44px !important;
    font-size: 13px !important;
}
.submenu-item i { font-size: 13px !important; }

/* Domain badge */
.domain-badge {
    display: inline-block;
    background: #e0f2fe;
    color: #0369a1;
    padding: 2px 7px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.5px;
    text-transform: lowercase;
}

/* TEU badge */
.teu-badge {
    background: #fef9c3;
    color: #713f12;
    padding: 2px 8px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
}

/* Buttons */
.btn-xs {
    padding: 2px 6px;
    font-size: 12px;
}

/* Login */
.login-body {
    background: linear-gradient(135deg, #0f172a 0%, #1e3a5f 100%);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}
.login-wrap {
    width: 100%;
    max-width: 400px;
    padding: 20px;
}
.login-card {
    background: var(--card-bg);
    border-radius: 16px;
    padding: 40px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}
.login-logo {
    text-align: center;
    margin-bottom: 32px;
}
.login-logo i {
    font-size: 48px;
    color: var(--primary);
}
.login-logo h1 {
    font-size: 28px;
    font-weight: 800;
    margin: 8px 0 4px;
    color: var(--text);
}
.login-logo p {
    color: var(--text-muted);
    font-size: 13px;
    margin: 0;
}

/* Utilities */
.btn-primary { background-color: var(--primary); border-color: var(--primary); }
.btn-primary:hover { background-color: #1d4ed8; border-color: #1d4ed8; }

/* Sortable column indicators */
th.sortable { user-select: none; }
th.sort-asc::after  { content: ' ▲'; font-size: 10px; color: var(--primary); }
th.sort-desc::after { content: ' ▼'; font-size: 10px; color: var(--primary); }

/* Filter bar (work / archive) */
.filter-bar {
    display: flex;
    gap: 12px;
    align-items: flex-end;
    flex-wrap: wrap;
}
.filter-group { display: flex; flex-direction: column; }
.filter-label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-muted); margin-bottom: 4px; }

/* Transport badges (work table) */
.t-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
}
.t-badge.sea     { background: #e0f2fe; color: #0369a1; }
.t-badge.air     { background: #fef3c7; color: #92400e; }
.t-badge.rail    { background: #f0fdf4; color: #166534; }
.t-badge.truck   { background: #fdf2f8; color: #9d174d; }

/* Incoterms badge */
.inco-badge {
    display: inline-block;
    background: #f1f5f9;
    color: var(--text);
    padding: 2px 8px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
}

/* Booking link in table */
.booking-link { color: var(--primary); font-weight: 600; text-decoration: none; }
.booking-link:hover { text-decoration: underline; }

/* ---- Booking form layout ---- */
.booking-layout {
    display: flex;
    gap: 20px;
    align-items: flex-start;
}

.booking-left {
    flex: 0 0 55%;
    max-width: 55%;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 22px 24px;
}

.booking-right {
    flex: 1;
    min-width: 0;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 18px 20px;
    position: sticky;
    top: 20px;
}

/* Row/col helpers inside booking form */
.brow {
    display: flex;
    gap: 12px;
    margin-bottom: 10px;
    align-items: flex-start;
}
.bcol  { flex: 1; min-width: 0; }
.bcol-sm { flex: 0 0 140px; }

.bsection { margin-bottom: 12px; }

.blabel {
    display: block;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    color: var(--text-muted);
    margin-bottom: 3px;
}

/* Booking metadata row at top */
.booking-meta {
    display: flex;
    gap: 24px;
    align-items: center;
    margin-bottom: 16px;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--border);
}
.meta-label {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    color: var(--text-muted);
    margin-right: 6px;
}
.booking-number-display {
    font-size: 15px;
    color: var(--primary);
    font-family: 'Courier New', monospace;
}

/* Section title (Containers / B/L / Trucks) */
.section-title {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    color: var(--text-muted);
    margin-bottom: 6px;
}

/* Dynamic rows (containers, docs, trucks, invoice lines, cost rows) */
.dynamic-row {
    display: flex;
    gap: 6px;
    align-items: center;
    margin-bottom: 5px;
}
.row-num {
    font-size: 12px;
    color: var(--text-muted);
    width: 18px;
    flex-shrink: 0;
    text-align: right;
}

/* Invoice block */
.invoice-block {
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 10px 12px;
    margin-bottom: 8px;
    background: #fafcff;
}
.invoice-header {
    display: flex;
    align-items: center;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    color: var(--text-muted);
    margin-bottom: 8px;
}
.invoice-line {
    display: flex;
    gap: 6px;
    align-items: center;
    margin-bottom: 5px;
}
.invoice-subtotal {
    font-size: 12px;
    color: var(--text-muted);
    text-align: right;
    margin-top: 6px;
    padding-top: 6px;
    border-top: 1px dashed var(--border);
}

/* Finance panel (right column) */
.finance-block {
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 12px 14px;
    margin-bottom: 4px;
}
.finance-title {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    margin-bottom: 10px;
}
.finance-currency-row {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}
.finance-total {
    font-size: 13px;
    color: var(--text);
    border-top: 1px solid var(--border);
    padding-top: 8px;
    margin-top: 6px;
}

/* Profit label */
.profit-label { font-size: 14px; }
.profit-pos { color: #16a34a; }
.profit-neg { color: #dc2626; }

/* Cost row */
.cost-row { flex-wrap: wrap; }

/* Invoicing page */
.inv-currency-header {
    font-size: 16px;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 8px;
    padding-left: 4px;
}

/* Booking action buttons bar */
.booking-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    padding-top: 12px;
    border-top: 1px solid var(--border);
}
