@import url('https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.1/css/all.min.css');

:root {
    --hinoki: #185310;
    --hinoki-dark: #0e3208;
    --hinoki-light: #2a7a1a;
    --sidebar-w: 240px;
}

/* ── Layout ── */
body { margin: 0; background: #f4f6f5; font-family: 'Segoe UI', system-ui, sans-serif; }

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

.sidebar {
    width: var(--sidebar-w);
    background: var(--hinoki);
    color: #fff;
    position: fixed;
    top: 0; left: 0;
    height: 100vh;
    display: flex;
    flex-direction: column;
    z-index: 300;
    box-shadow: 2px 0 8px rgba(0,0,0,.2);
}

.main-content {
    margin-left: var(--sidebar-w);
    flex: 1;
    min-height: 100vh;
    min-width: 0;   /* prevent flex children from overflowing */
}

/* ── Sidebar brand ── */
.sidebar-brand {
    padding: 22px 20px 18px;
    border-bottom: 1px solid rgba(255,255,255,.12);
}
.sidebar-brand .brand-name {
    font-size: 1.45rem;
    font-weight: 700;
    letter-spacing: .5px;
    display: block;
}
.sidebar-brand .brand-sub {
    font-size: .72rem;
    opacity: .65;
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* ── Nav items ── */
.sidebar-nav { flex: 1; padding: 12px 0; }

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 20px;
    color: rgba(255,255,255,.78);
    text-decoration: none;
    font-size: .93rem;
    transition: background .15s, color .15s;
    border-left: 3px solid transparent;
}
.nav-item:hover { background: rgba(255,255,255,.1); color: #fff; }
.nav-item.active { background: rgba(255,255,255,.14); color: #fff; border-left-color: #fff; }
.nav-item .nav-icon { font-size: 1.05rem; width: 20px; text-align: center; }

/* ── Sidebar footer ── */
.sidebar-footer {
    padding: 14px 16px;
    border-top: 1px solid rgba(255,255,255,.12);
}
.btn-logout {
    width: 100%;
    background: transparent;
    border: 1px solid rgba(255,255,255,.3);
    color: rgba(255,255,255,.8);
    padding: 7px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-size: .88rem;
    transition: all .15s;
}
.btn-logout:hover { background: rgba(255,255,255,.1); color: #fff; }

/* ── Hinoki brand button ── */
.btn-hinoki {
    background: var(--hinoki);
    border-color: var(--hinoki);
    color: #fff;
}
.btn-hinoki:hover {
    background: var(--hinoki-dark);
    border-color: var(--hinoki-dark);
    color: #fff;
}

/* ── Page header ── */
.page-header {
    padding: 28px 28px 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
}
.page-header h1 {
    font-size: 1.55rem;
    font-weight: 700;
    color: #1a1a1a;
    margin: 0;
}

/* ── Status badges ── */
.badge-status {
    font-size: .77rem;
    padding: 4px 10px;
    border-radius: 20px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .4px;
}
.status-open      { background: #d1fae5; color: #065f46; }
.status-shipping  { background: #dbeafe; color: #1e40af; }
.status-arrived   { background: #f3e8ff; color: #6b21a8; }
.status-closed    { background: #f1f5f9; color: #475569; }
.status-waiting   { background: #fef3c7; color: #92400e; }
.status-customs   { background: #fee2e2; color: #991b1b; }

/* ── Cost delta ── */
.delta-positive { color: #dc2626; font-weight: 600; }
.delta-negative { color: #16a34a; font-weight: 600; }
.delta-zero     { color: #6b7280; }

/* ── Cards ── */
.stat-card {
    background: #fff;
    border-radius: 10px;
    padding: 20px 22px;
    box-shadow: 0 1px 3px rgba(0,0,0,.07);
    height: 100%;
}
.stat-card .stat-label { font-size: .8rem; color: #6b7280; text-transform: uppercase; letter-spacing: .5px; }
.stat-card .stat-value { font-size: 1.6rem; font-weight: 700; color: #111; margin-top: 2px; }
.stat-card .stat-sub   { font-size: .82rem; color: #9ca3af; margin-top: 2px; }

/* ── Login page ── */
.login-body { background: var(--hinoki); min-height: 100vh; display: flex; align-items: center; justify-content: center; }
.login-card {
    background: #fff;
    border-radius: 14px;
    padding: 44px 40px;
    width: 360px;
    box-shadow: 0 8px 40px rgba(0,0,0,.25);
}
.login-brand { text-align: center; margin-bottom: 32px; }
.login-brand h1 { font-size: 2rem; font-weight: 800; color: var(--hinoki); margin: 0; }
.login-brand p  { color: #6b7280; margin: 4px 0 0; font-size: .9rem; }

/* ── Table tweaks ── */
.table th { font-size: .8rem; text-transform: uppercase; letter-spacing: .4px; color: #6b7280; font-weight: 600; }
.table-hover tbody tr:hover { background: #f0faf0; }

/* ── Detail panels ── */
.detail-section { background: #fff; border-radius: 10px; padding: 22px 24px; box-shadow: 0 1px 3px rgba(0,0,0,.07); margin-bottom: 20px; }
.detail-section h5 { font-size: .85rem; text-transform: uppercase; letter-spacing: .6px; color: var(--hinoki); font-weight: 700; margin-bottom: 16px; border-bottom: 2px solid #d1fae5; padding-bottom: 8px; }

/* ── Flash messages ── */
.flash-success { background: #d1fae5; border: 1px solid #6ee7b7; color: #065f46; border-radius: 8px; padding: 10px 16px; margin-bottom: 16px; }

/* ── Financial breakdown ── */
.finance-row { display: flex; justify-content: space-between; align-items: center; padding: 7px 0; border-bottom: 1px solid #f3f4f6; font-size: .9rem; }
.finance-row:last-child { border-bottom: none; }
.finance-row.total { font-weight: 700; font-size: 1rem; padding-top: 10px; }
.split-badge { display: inline-flex; align-items: center; justify-content: space-between; background: #f0faf0; border-radius: 8px; padding: 8px 14px; font-size: .88rem; width: 100%; margin-bottom: 6px; }
.split-badge .name { color: #374151; font-weight: 600; }
.split-badge .amount { color: var(--hinoki); font-weight: 700; }

/* ── Info grid (customer detail) ── */
.info-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 18px 24px;
}
.info-label {
    display: block;
    font-size: .71rem;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: .55px;
    font-weight: 600;
    margin-bottom: 3px;
}
.info-value {
    display: block;
    font-size: .92rem;
    font-weight: 600;
    color: #1a1a1a;
}

/* ── Sidebar overlay (mobile) ── */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.5);
    z-index: 499;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}
.sidebar-overlay.open { display: block; }

/* ── Mobile top bar ── */
.mobile-topbar {
    display: none;           /* hidden on desktop */
    position: fixed;
    top: 0; left: 0; right: 0;
    height: 52px;
    background: var(--hinoki);
    align-items: center;
    justify-content: space-between;
    z-index: 100;
    box-shadow: 0 2px 8px rgba(0,0,0,.2);
}

.mob-hamburger {
    background: none;
    border: none;
    color: #fff;
    font-size: 1.25rem;
    width: 52px;
    height: 52px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    -webkit-tap-highlight-color: transparent;
}

.mob-brand {
    font-size: .9rem;
    font-weight: 700;
    letter-spacing: 2.5px;
    color: #c9a96e;
    flex: 1;
    text-align: center;
}

/* ── Responsive breakpoints ── */
@media (max-width: 768px) {

    /* Show the mobile top bar */
    .mobile-topbar { display: flex; }

    /* Sidebar becomes a slide-in drawer, sitting above the overlay */
    .sidebar {
        z-index: 500;
        transform: translateX(-100%);
        transition: transform .28s cubic-bezier(.4, 0, .2, 1);
    }
    .sidebar.open { transform: translateX(0); }

    /* Main content fills the screen below the 52px top bar */
    .main-content {
        margin-left: 0;
        padding-top: 52px;
        width: 100%;
        overflow-x: hidden;
    }

    /* Prevent body from scrolling while sidebar drawer is open */
    body { overflow-x: hidden; }

    /* Page header */
    .page-header {
        padding: 16px 16px 0;
        margin-bottom: 16px;
        flex-wrap: wrap;
        gap: 10px;
        align-items: center;
    }
    .page-header h1 { font-size: 1.2rem; margin: 0; }

    /* Container spacing */
    .container-fluid { padding: 14px 16px !important; }

    /* Detail panels & stat cards */
    .detail-section { padding: 16px 14px; }
    .stat-card      { padding: 16px 14px; }
    .stat-card .stat-value { font-size: 1.3rem; }

    /* Info grids: 2 columns on tablets */
    .info-grid { grid-template-columns: repeat(2, 1fr); }

    /* Smooth momentum scroll on tables */
    .table-responsive { -webkit-overflow-scrolling: touch; }

    /* Finance */
    .finance-row { font-size: .85rem; }

    /* Login page card */
    .login-card {
        width: calc(100vw - 40px);
        max-width: 340px;
        padding: 32px 22px;
    }
}

@media (max-width: 480px) {
    .info-grid { grid-template-columns: 1fr; }
    .page-header h1 { font-size: 1.05rem; }
    .container-fluid { padding: 10px 12px !important; }
    .stat-card .stat-value { font-size: 1.15rem; }
}

/* ═══════════════════════════════════════
   MOBILE CARD LIST  (used in d-md-none blocks)
   ═══════════════════════════════════════ */
.m-card {
    background: #fff;
    border-radius: 10px;
    padding: 13px 15px;
    margin-bottom: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,.07);
    border: 1px solid #f0f0f0;
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: inherit;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: background .1s;
}
.m-card:hover, .m-card:focus { background: #f5f9f5; color: inherit; text-decoration: none; }
.m-card:active { background: #edf5ed; }
.m-card.starred { border-left: 3px solid #f59e0b; }

.m-card-body { flex: 1; min-width: 0; }

.m-card-title {
    font-weight: 600;
    font-size: .92rem;
    color: #111;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.m-card-sub {
    font-size: .75rem;
    color: #9ca3af;
    margin-top: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.m-card-meta {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 4px;
    flex-shrink: 0;
    text-align: right;
}
.m-card-value { font-size: .88rem; font-weight: 700; color: #111; }
.m-card-arrow { color: #d1d5db; font-size: .72rem; margin-left: 2px; flex-shrink: 0; }

/* ═══════════════════════════════════════
   BOX ITEM CARDS  (expandable, mobile-only)
   ═══════════════════════════════════════ */
.bic {
    background: #fff;
    border-radius: 10px;
    margin-bottom: 8px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0,0,0,.07);
    border: 1px solid #f0f0f0;
}
.bic-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 13px 14px;
    cursor: pointer;
    user-select: none;
    -webkit-user-select: none;
    -webkit-tap-highlight-color: transparent;
}
.bic-info { flex: 1; min-width: 0; }
.bic-name {
    font-weight: 600;
    font-size: .92rem;
    color: #111;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.bic-sub {
    font-size: .72rem;
    color: #9ca3af;
    margin-top: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.bic-cost-col {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 2px;
    flex-shrink: 0;
}
.bic-cost { font-size: .9rem; font-weight: 700; color: #111827; }
.bic-chevron {
    color: #d1d5db;
    font-size: .68rem;
    transition: transform .2s ease;
    flex-shrink: 0;
    margin-left: 2px;
}
.bic-header[aria-expanded="true"] .bic-chevron { transform: rotate(180deg); }
.bic-body {
    padding: 0 14px 12px;
    border-top: 1px solid #f3f4f6;
    padding-top: 10px;
}
.bic-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: .82rem;
    padding: 5px 0;
    border-bottom: 1px solid #f9fafb;
}
.bic-row:last-of-type { border-bottom: none; }
.bic-row-label { color: #9ca3af; }
.bic-link {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    margin-top: 10px;
    padding: 9px 12px;
    background: #f0faf0;
    border-radius: 7px;
    color: #185310;
    font-size: .82rem;
    font-weight: 600;
    text-decoration: none;
    transition: background .15s;
}
.bic-link:hover { background: #d1fae5; color: #185310; }

/* ═══════════════════════════════════════
   MOBILE PAGE HEADER  (replaces desktop header on mobile)
   ═══════════════════════════════════════ */
@media (max-width: 768px) {
    /* Consistent touch target for all small buttons */
    .btn-sm { min-height: 36px; }

    /* Uniform stat card row: 2 per row on mobile */
    .row.g-3 > [class*="col-md-2"],
    .row.g-3 > [class*="col-md-3"] {
        flex: 0 0 50%;
        max-width: 50%;
    }

    /* Financial KPI + split cards: force equal height per row */
    .kpi-card, .split-card { height: 100%; }
}
