@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

:root {
    --navy: #0f2b46;
    --navy-light: #1a3d5c;
    --blue: #2563eb;
    --blue-hover: #1d4ed8;
    --green: #059669;
    --green-bg: #ecfdf5;
    --green-border: #a7f3d0;
    --red: #dc2626;
    --red-bg: #fef2f2;
    --red-border: #fecaca;
    --amber: #d97706;
    --amber-bg: #fffbeb;
    --amber-border: #fde68a;
    --gray-50: #f8fafc;
    --gray-100: #f1f5f9;
    --gray-200: #e2e8f0;
    --gray-300: #cbd5e1;
    --gray-400: #94a3b8;
    --gray-500: #64748b;
    --gray-600: #475569;
    --gray-700: #334155;
    --gray-900: #0f172a;
    --radius: 8px;
    --radius-sm: 6px;
    --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.06);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.07), 0 2px 4px rgba(0,0,0,0.06);
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--gray-100);
    color: var(--gray-900);
    line-height: 1.5;
    font-size: 15px;
    -webkit-font-smoothing: antialiased;
}

/* ---- Header ---- */
header {
    background: var(--navy);
    padding: 0 1.5rem;
    height: 75px;
    position: sticky;
    top: 0;
    z-index: 50;
}

nav {
    display: flex;
    align-items: center;
    height: 75px;
    max-width: 1120px;
    margin: 0 auto;
    gap: 2rem;
}

.logo {
    display: flex;
    align-items: center;
    text-decoration: none;
}

.nav-links {
    display: flex;
    gap: 0.25rem;
    flex: 1;
}

.nav-links a {
    color: var(--gray-300);
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 500;
    padding: 0.375rem 0.75rem;
    border-radius: var(--radius-sm);
    transition: color 0.15s, background 0.15s;
}

.nav-links a:hover,
.nav-links a.active {
    color: #fff;
    background: rgba(255,255,255,0.1);
}

.nav-user {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-left: auto;
}

.nav-username {
    color: var(--gray-400);
    font-size: 0.8125rem;
}

.nav-logout {
    color: var(--gray-400);
    text-decoration: none;
    font-size: 0.8125rem;
    padding: 0.25rem 0.625rem;
    border: 1px solid rgba(255,255,255,0.15);
    border-radius: var(--radius-sm);
    transition: all 0.15s;
}

.nav-logout:hover {
    color: #fff;
    border-color: rgba(255,255,255,0.3);
}

/* ---- Layout ---- */
.refresh-bar {
    max-width: 1120px;
    margin: 0 auto;
    padding: 0.75rem 1.5rem 0;
    display: flex;
    justify-content: flex-end;
}

.btn-refresh {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1.25rem;
    background: var(--blue);
    color: #fff;
    border: none;
    border-radius: var(--radius);
    font-size: 0.875rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    box-shadow: var(--shadow-md);
    transition: background 0.15s, transform 0.1s;
}

.btn-refresh:hover { background: var(--blue-hover); }
.btn-refresh:active { transform: scale(0.97); }
.btn-refresh svg { flex-shrink: 0; }

main {
    max-width: 1120px;
    margin: 0 auto;
    padding: 1rem 1.5rem 3rem;
}

/* ---- Typography ---- */
h1 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--gray-900);
    letter-spacing: -0.02em;
}

h2 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--gray-700);
    margin-bottom: 0.75rem;
}

/* ---- Cards ---- */
.card {
    background: #fff;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--shadow);
}

.card + .card { margin-top: 1rem; }

/* ---- Page header ---- */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
}

.page-header h1 { margin: 0; }

/* ---- Stat cards ---- */
.stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

.stat-card {
    background: #fff;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    padding: 1rem 1.25rem;
    box-shadow: var(--shadow);
}

.stat-value {
    font-size: 1.75rem;
    font-weight: 700;
    line-height: 1.2;
    color: var(--gray-900);
}

.stat-label {
    font-size: 0.8125rem;
    color: var(--gray-500);
    font-weight: 500;
    margin-top: 0.125rem;
}

.stat-card.stat-pending .stat-value { color: var(--amber); }
.stat-card.stat-processing .stat-value { color: var(--blue); }
.stat-card.stat-errors .stat-value { color: var(--red); }
.stat-card.stat-completed .stat-value { color: var(--green); }

/* ---- Tabs ---- */
.tabs {
    display: flex;
    gap: 0.25rem;
    margin-bottom: 1rem;
    border-bottom: 2px solid var(--gray-200);
    padding-bottom: 0;
}

.tab {
    padding: 0.625rem 1rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--gray-500);
    text-decoration: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: color 0.15s, border-color 0.15s;
    cursor: pointer;
}

.tab:hover { color: var(--gray-700); }

.tab.active {
    color: var(--blue);
    border-bottom-color: var(--blue);
}

.tab-count {
    background: var(--gray-100);
    color: var(--gray-600);
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.125rem 0.5rem;
    border-radius: 10px;
    margin-left: 0.375rem;
}

.tab.active .tab-count {
    background: #dbeafe;
    color: var(--blue);
}

/* ---- Tables ---- */
table {
    width: 100%;
    border-collapse: collapse;
}

thead th {
    text-align: left;
    padding: 0.625rem 0.75rem;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--gray-500);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    border-bottom: 1px solid var(--gray-200);
    background: var(--gray-50);
}

tbody td {
    padding: 0.75rem;
    font-size: 0.875rem;
    border-bottom: 1px solid var(--gray-100);
    color: var(--gray-700);
}

tbody tr:hover { background: var(--gray-50); }
tbody tr:last-child td { border-bottom: none; }

td a {
    color: var(--blue);
    text-decoration: none;
    font-weight: 500;
}

td a:hover { text-decoration: underline; }

.table-wrap {
    background: #fff;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
}

.table-empty {
    padding: 3rem 1.5rem;
    text-align: center;
    color: var(--gray-400);
    font-size: 0.9375rem;
}

/* ---- Status badges ---- */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.1875rem 0.625rem;
    border-radius: 10px;
    font-size: 0.75rem;
    font-weight: 600;
    white-space: nowrap;
}

.badge::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
}

.badge-ok { background: var(--green-bg); color: var(--green); }
.badge-ok::before { background: var(--green); }

.badge-pending { background: var(--gray-100); color: var(--gray-500); }
.badge-pending::before { background: var(--gray-400); }

.badge-error { background: var(--red-bg); color: var(--red); }
.badge-error::before { background: var(--red); }

.badge-warn { background: var(--amber-bg); color: var(--amber); }
.badge-warn::before { background: var(--amber); }

.badge-processing { background: #dbeafe; color: var(--blue); }
.badge-processing::before { background: var(--blue); animation: pulse 1.5s ease-in-out infinite; }

@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.3; } }

/* ---- Role badge ---- */
.role-badge {
    padding: 0.1875rem 0.5rem;
    border-radius: 10px;
    font-size: 0.75rem;
    font-weight: 600;
}

.role-admin { background: #dbeafe; color: #1e40af; }
.role-medewerker { background: var(--gray-100); color: var(--gray-600); }

/* ---- Buttons ---- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.375rem;
    padding: 0.5rem 1rem;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.15s;
    text-decoration: none;
    line-height: 1.4;
}

.btn-primary {
    background: var(--blue);
    color: #fff;
    border-color: var(--blue);
}
.btn-primary:hover { background: var(--blue-hover); border-color: var(--blue-hover); }
.btn-primary:disabled { background: var(--gray-300); border-color: var(--gray-300); cursor: not-allowed; }

.btn-secondary {
    background: #fff;
    color: var(--gray-700);
    border-color: var(--gray-300);
}
.btn-secondary:hover { background: var(--gray-50); border-color: var(--gray-400); }

.btn-danger {
    background: var(--red);
    color: #fff;
    border-color: var(--red);
}
.btn-danger:hover { background: #b91c1c; }

.btn-small {
    padding: 0.3125rem 0.625rem;
    font-size: 0.8125rem;
}

.btn-full { width: 100%; }

.btn-remove {
    background: none;
    border: none;
    color: var(--gray-400);
    font-size: 1.125rem;
    padding: 0.25rem 0.5rem;
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: color 0.15s, background 0.15s;
}

.btn-remove:hover { color: var(--red); background: var(--red-bg); }

/* ---- Forms ---- */
.field { margin-bottom: 0.875rem; }

.field label {
    display: block;
    font-weight: 500;
    font-size: 0.8125rem;
    color: var(--gray-600);
    margin-bottom: 0.3125rem;
}

.field input,
.field select {
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    font-family: inherit;
    color: var(--gray-900);
    background: #fff;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.field input:focus,
.field select:focus {
    outline: none;
    border-color: var(--blue);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.field input[readonly] {
    background: var(--gray-50);
    color: var(--gray-500);
}

/* ---- Order info section ---- */
.order-info { margin-bottom: 1rem; }

.info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 0.75rem 1.5rem;
}

.info-item label {
    display: block;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--gray-400);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 0.125rem;
}

.info-item span {
    font-size: 0.9375rem;
    color: var(--gray-900);
    font-weight: 500;
}

/* ---- Parcel rows ---- */
.parcels-section { margin-bottom: 1rem; }

.parcel-row {
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-sm);
    padding: 0.875rem;
    margin-bottom: 0.5rem;
    background: var(--gray-50);
    transition: border-color 0.15s;
}

.parcel-row:hover { border-color: var(--gray-300); }

.parcel-fields {
    display: flex;
    gap: 0.625rem;
    align-items: flex-end;
    flex-wrap: wrap;
}

.parcel-fields .field {
    flex: 1;
    min-width: 100px;
    margin-bottom: 0;
}

/* ---- Action buttons ---- */
.action-buttons {
    display: flex;
    gap: 0.625rem;
    margin-top: 1rem;
}

/* ---- Merge bar ---- */
.merge-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #dbeafe;
    border: 1px solid #93c5fd;
    border-radius: var(--radius);
    padding: 0.625rem 1rem;
    margin-bottom: 0.75rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--navy);
}

/* ---- Alerts ---- */
.error {
    background: var(--red-bg);
    border: 1px solid var(--red-border);
    color: #991b1b;
    padding: 0.75rem 1rem;
    border-radius: var(--radius-sm);
    margin-bottom: 1rem;
    font-size: 0.875rem;
}

.success {
    background: var(--green-bg);
    border: 1px solid var(--green-border);
    color: #065f46;
    padding: 0.75rem 1rem;
    border-radius: var(--radius-sm);
    margin-bottom: 1rem;
    font-size: 0.875rem;
}

/* ---- Error rows ---- */
.error-row { background: #fff5f5; }
.error-cell {
    font-size: 0.8125rem;
    color: var(--red);
    max-width: 220px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ---- Log section ---- */
.log-entries { display: flex; flex-direction: column; gap: 0.5rem; }

.log-entry {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--gray-100);
    font-size: 0.875rem;
}

.log-entry:last-child { border-bottom: none; }

.log-label {
    font-weight: 600;
    color: var(--gray-500);
    min-width: 140px;
    font-size: 0.8125rem;
}

.log-ok { color: var(--green); font-weight: 600; }
.log-pending { color: var(--gray-400); }

.log-error-entry {
    background: var(--red-bg);
    border-radius: var(--radius-sm);
    padding: 0.5rem 0.75rem;
    border-bottom: none;
}

.log-error-entry span:last-child { color: var(--red); font-weight: 500; }

/* ---- Login page ---- */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: var(--navy);
    background-image:
        radial-gradient(ellipse at 30% 0%, rgba(37, 99, 235, 0.15) 0%, transparent 60%),
        radial-gradient(ellipse at 70% 100%, rgba(37, 99, 235, 0.1) 0%, transparent 60%);
}

.login-card {
    background: #fff;
    padding: 2.5rem;
    border-radius: 12px;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.2);
}

.login-card h1 {
    text-align: center;
    margin-bottom: 0.25rem;
    font-size: 1.375rem;
}

.login-subtitle {
    text-align: center;
    color: var(--gray-500);
    margin-bottom: 1.75rem;
    font-size: 0.9375rem;
}

.login-card .btn { margin-top: 0.5rem; }

/* ---- Admin user form ---- */
.user-form { max-width: 640px; }

.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0 1.25rem;
}

.form-actions {
    margin-top: 1.5rem;
    display: flex;
    gap: 0.625rem;
    padding-top: 1.25rem;
    border-top: 1px solid var(--gray-200);
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 500;
    font-size: 0.875rem;
    color: var(--gray-700);
    cursor: pointer;
    padding-top: 1.5rem;
}

.checkbox-label input[type="checkbox"] { width: auto; accent-color: var(--blue); }

/* ---- Responsive ---- */
@media (max-width: 768px) {
    .stats { grid-template-columns: repeat(2, 1fr); }
    .form-grid { grid-template-columns: 1fr; }
    .parcel-fields { flex-direction: column; }
    .parcel-fields .field { min-width: 100%; }
    .page-header { flex-direction: column; align-items: flex-start; gap: 0.75rem; }
    .nav-username { display: none; }
    nav { gap: 1rem; }
    .table-wrap { overflow-x: auto; }
}
