/* ── MPC SCS Design System ─────────────────────────────────────── */
:root {
    --primary: #1e3c72;
    --primary-light: #2a5298;
    --text: #1e3c72;
    --text-muted: #5a6a85;
    --text-light: #9aa5b4;
    --border: #e8ecf1;
    --bg: #f5f7fa;
    --white: #ffffff;
    --green: #10b981;
    --red: #ef4444;
    --yellow: #f59e0b;
    --purple: #8b5cf6;
    --blue: #3b82f6;
    --radius: 8px;
    --radius-lg: 12px;
    --shadow: 0 1px 3px rgba(30, 60, 114, 0.06);
    --shadow-md: 0 4px 16px rgba(30, 60, 114, 0.08);
    --sidebar-width: 240px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: 'Inter', 'Segoe UI', -apple-system, sans-serif;
    color: var(--text);
    background: var(--bg);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

/* ── Sidebar ──────────────────────────────────────────────────── */
.sidebar {
    position: fixed;
    left: 0; top: 0; bottom: 0;
    width: var(--sidebar-width);
    background: var(--white);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    z-index: 100;
}

.sidebar-header {
    padding: 1.25rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.sidebar-logo {
    width: 100%;
    max-width: 130px;
    height: auto;
}

.sidebar-badge {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    color: white;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.05em;
}

.sidebar-nav {
    flex: 1;
    padding: 0.75rem 0;
    overflow-y: auto;
}

.nav-group-label {
    padding: 0.5rem 1.25rem 0.25rem;
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    opacity: 0.6;
    margin-top: 0.5rem;
}

.nav-group-label:first-child { margin-top: 0; }

.nav-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.65rem 1.25rem;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.15s;
    border-left: 3px solid transparent;
}

.nav-item svg {
    width: 20px; height: 20px;
    flex-shrink: 0;
}

.nav-item:hover {
    color: var(--primary);
    background: rgba(30, 60, 114, 0.04);
}

.nav-item.active {
    color: var(--primary);
    background: rgba(30, 60, 114, 0.06);
    border-left-color: var(--primary);
}

.sidebar-footer {
    padding: 1rem 1.25rem;
    border-top: 1px solid var(--border);
}

.user-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}

.user-avatar {
    width: 36px; height: 36px;
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.85rem;
}

.user-name { font-weight: 600; font-size: 0.85rem; }
.user-role { font-size: 0.75rem; color: var(--text-light); }

.logout-btn { font-size: 0.85rem; }

/* ── Mobile Header ────────────────────────────────────────────── */
.mobile-header {
    display: none;
    position: fixed; top: 0; left: 0; right: 0;
    height: 56px;
    background: var(--white);
    border-bottom: 1px solid var(--border);
    padding: 0 1rem;
    align-items: center;
    gap: 1rem;
    z-index: 99;
}

.menu-toggle {
    background: none; border: none; cursor: pointer;
    color: var(--text); padding: 4px;
}

.menu-toggle svg { width: 24px; height: 24px; }

.mobile-logo { height: 32px; width: auto; }

/* ── Main Content ─────────────────────────────────────────────── */
.main-content {
    margin-left: var(--sidebar-width);
    padding: 2rem;
    min-height: 100vh;
}

/* ── Page Header ──────────────────────────────────────────────── */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.page-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary);
}

.page-subtitle {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-top: 0.15rem;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.breadcrumb {
    font-size: 0.85rem;
    color: var(--text-light);
    margin-bottom: 0.35rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.breadcrumb a {
    color: var(--text-muted);
    text-decoration: none;
}

.breadcrumb a:hover { color: var(--primary); }

/* ── Cards ────────────────────────────────────────────────────── */
.card {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
}

.card-header {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border);
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--primary);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.card-body {
    padding: 1.5rem;
}

/* ── Status Cards (Dashboard) ─────────────────────────────────── */
.status-cards {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

.status-card {
    flex: 1;
    min-width: 100px;
    padding: 1rem;
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    text-align: center;
    text-decoration: none;
    transition: all 0.15s;
    cursor: pointer;
}

.status-card:hover {
    border-color: var(--card-color, var(--primary));
    box-shadow: var(--shadow-md);
}

.status-card.active {
    border-color: var(--card-color, var(--primary));
    background: color-mix(in srgb, var(--card-color, var(--primary)) 6%, white);
}

.status-count {
    display: block;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--card-color, var(--primary));
}

.status-label {
    display: block;
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 0.15rem;
}

/* ── Detail Layout ────────────────────────────────────────────── */
.detail-grid {
    display: grid;
    grid-template-columns: 1.2fr 0.8fr;
    gap: 1.5rem;
}

.detail-list { display: flex; flex-direction: column; gap: 0.75rem; }

.detail-item {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid #f0f2f5;
}

.detail-label {
    font-size: 0.85rem;
    color: var(--text-light);
    font-weight: 500;
}

.detail-value {
    font-size: 0.9rem;
    color: var(--text);
    font-weight: 500;
}

/* ── Tables ───────────────────────────────────────────────────── */
.table-wrapper { overflow-x: auto; }

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.table th {
    text-align: left;
    padding: 0.5rem 0.75rem;
    font-weight: 600;
    font-size: 0.8rem;
    color: var(--text-light);
    text-transform: uppercase;
    letter-spacing: 0.03em;
    border-bottom: 2px solid var(--border);
    white-space: nowrap;
}

.table td {
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid #f0f2f5;
    vertical-align: middle;
}

.table tbody tr:hover { background: rgba(30, 60, 114, 0.02); }

/* ── Badges ───────────────────────────────────────────────────── */
.badge {
    display: inline-block;
    padding: 0.2rem 0.65rem;
    border-radius: 50px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.badge-open { background: #dbeafe; color: #1e40af; }
.badge-in-transit, .badge-intransit { background: #ede9fe; color: #5b21b6; }
.badge-at-port, .badge-atport { background: #fef3c7; color: #92400e; }
.badge-clearing { background: #fce7f3; color: #9d174d; }
.badge-cleared { background: #d1fae5; color: #065f46; }
.badge-delivered { background: #ecfdf5; color: #047857; }
.badge-closed { background: #f1f5f9; color: #64748b; }
.badge-cancelled { background: #fef2f2; color: #991b1b; }
.badge-pending { background: #fef3c7; color: #92400e; }
.badge-partial { background: #fce7f3; color: #9d174d; }
.badge-paid { background: #d1fae5; color: #065f46; }
.badge-overdue { background: #fef2f2; color: #991b1b; }
.badge-ordered { background: #e0e7ff; color: #3730a3; }
.badge-incoming { background: #ede9fe; color: #5b21b6; }
.badge-active { background: #d1fae5; color: #065f46; }
.badge-inactive { background: #f3f4f6; color: #6b7280; }
.badge-admin { background: #fce7f3; color: #9d174d; }
.badge-manager { background: #ede9fe; color: #5b21b6; }
.badge-logistics { background: #dbeafe; color: #1e40af; }
.badge-buyer { background: #d1fae5; color: #065f46; }

/* ── Buttons ──────────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.55rem 1.25rem;
    border-radius: var(--radius);
    font-size: 0.9rem;
    font-weight: 500;
    text-decoration: none;
    border: none;
    cursor: pointer;
    transition: all 0.15s;
    font-family: inherit;
    white-space: nowrap;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    color: white;
}

.btn-primary:hover { opacity: 0.9; transform: translateY(-1px); box-shadow: var(--shadow-md); }

.btn-ghost {
    background: transparent;
    color: var(--text-muted);
    border: 1px solid var(--border);
}

.btn-ghost:hover { border-color: var(--primary); color: var(--primary); }

.btn-danger {
    background: var(--red);
    color: white;
}

.btn-danger:hover { opacity: 0.9; }

.btn-sm { padding: 0.35rem 0.75rem; font-size: 0.8rem; }
.btn-lg { padding: 0.75rem 2rem; font-size: 1rem; }
.btn-full { width: 100%; justify-content: center; }

/* ── Forms ─────────────────────────────────────────────────────── */
.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.form-group { display: flex; flex-direction: column; gap: 0.35rem; }
.form-group-wide { grid-column: 1 / -1; }

.form-group label {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-muted);
}

.form-group input,
.form-group select,
.form-group textarea {
    padding: 0.6rem 0.85rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.9rem;
    font-family: inherit;
    color: var(--text);
    background: var(--white);
    transition: border-color 0.15s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary-light);
    box-shadow: 0 0 0 3px rgba(42, 82, 152, 0.1);
}

.form-group textarea { resize: vertical; }

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    margin-top: 1.5rem;
}

.form-hint {
    font-size: 0.75rem;
    color: var(--text-light);
    margin-top: 0.25rem;
}

.input-search {
    padding: 0.45rem 0.85rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.85rem;
    font-family: inherit;
    min-width: 200px;
}

.input-search:focus {
    outline: none;
    border-color: var(--primary-light);
}

/* ── Tabs ──────────────────────────────────────────────────────── */
.tabs {
    display: flex;
    gap: 0;
    border-bottom: 2px solid var(--border);
    margin-bottom: 1.5rem;
}

.tab {
    padding: 0.75rem 1.25rem;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-muted);
    text-decoration: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    cursor: pointer;
    transition: all 0.15s;
    background: none;
    border-top: none;
    border-left: none;
    border-right: none;
    font-family: inherit;
}

.tab:hover {
    color: var(--primary);
}

.tab.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* ── Flash Messages ───────────────────────────────────────────── */
.flash-messages { margin-bottom: 1.5rem; }

.flash {
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    font-size: 0.9rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.flash-success { background: #ecfdf5; color: #065f46; border: 1px solid #a7f3d0; }
.flash-error { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }
.flash-info { background: #eff6ff; color: #1e40af; border: 1px solid #bfdbfe; }
.flash-warning { background: #fffbeb; color: #92400e; border: 1px solid #fde68a; }

.flash-close {
    background: none; border: none; cursor: pointer;
    font-size: 1.2rem; color: inherit; opacity: 0.6;
    padding: 0 0.25rem;
}

.flash-close:hover { opacity: 1; }

/* ── Empty State ──────────────────────────────────────────────── */
.empty-state {
    text-align: center;
    padding: 3rem 1.5rem;
    color: var(--text-muted);
}

.empty-state svg { color: var(--text-light); margin-bottom: 1rem; }
.empty-state h3 { font-size: 1.1rem; color: var(--text); margin-bottom: 0.5rem; }
.empty-state p { font-size: 0.9rem; margin-bottom: 1.25rem; }

/* ── Auth Page ────────────────────────────────────────────────── */
.auth-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg);
    padding: 2rem;
}

.auth-card {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    padding: 2.5rem;
    width: 100%;
    max-width: 400px;
    text-align: center;
}

.auth-logo img { max-width: 200px; margin-bottom: 1.5rem; }
.auth-title { font-size: 1.25rem; color: var(--primary); margin-bottom: 0.25rem; }
.auth-subtitle { color: var(--text-muted); font-size: 0.9rem; margin-bottom: 1.5rem; }

.auth-form { text-align: left; }
.auth-form .form-group { margin-bottom: 1rem; }
.auth-form .btn { margin-top: 0.5rem; }

/* ── Utility ──────────────────────────────────────────────────── */
.text-muted { color: var(--text-muted); }
.text-light { color: var(--text-light); }
.text-bold { font-weight: 600; }
.text-danger { color: var(--red); }
.link { color: var(--primary); text-decoration: none; font-weight: 500; }
.link:hover { text-decoration: underline; }

/* ── Filter Pills ────────────────────────────────────────────── */
.filter-pills {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.pill {
    display: inline-block;
    padding: 0.35rem 0.85rem;
    border-radius: 50px;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-muted);
    background: var(--white);
    border: 1px solid var(--border);
    text-decoration: none;
    transition: all 0.15s;
}

.pill:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.pill.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

/* ── Pagination ──────────────────────────────────────────────── */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    padding: 1rem;
    border-top: 1px solid var(--border);
}

.pagination-info {
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* ── Responsive ───────────────────────────────────────────────── */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.25s;
        box-shadow: var(--shadow-md);
    }

    .sidebar.open { transform: translateX(0); }

    .mobile-header { display: flex; }

    .main-content {
        margin-left: 0;
        padding: 1.25rem;
        padding-top: calc(56px + 1.25rem);
    }

    .page-header { flex-direction: column; }
    .header-actions { width: 100%; }

    .detail-grid { grid-template-columns: 1fr; }
    .form-grid { grid-template-columns: 1fr; }

    .status-cards { flex-wrap: wrap; }
    .status-card { min-width: 80px; flex: unset; }

    .tabs { overflow-x: auto; }
}
