:root {
    --primary: #e64b45;
    --secondary: #198fa8;
    --dark: #172536;
    --app-bg: #f4f6f9;
    --surface: #fff;
    --muted: #748195;
    --border: #e7ebf0;
    --sidebar-width: 264px;
    --sidebar-collapsed-width: 82px;
}

html { min-width: 320px; }
body {
    min-height: 100vh;
    background: var(--app-bg);
    color: #253346;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-size: .94rem;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, h5, h6 {
    color: #19283a;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-weight: 700;
    letter-spacing: -.025em;
}

a { color: #247c91; }
a:hover { color: #185b6b; }
.text-muted { color: var(--muted) !important; }
.fw-medium { font-weight: 600 !important; }

.app { display: flex; min-height: 100vh; }

.sidebar {
    position: fixed;
    z-index: 1040;
    inset: 0 auto 0 0;
    display: flex;
    flex-direction: column;
    width: var(--sidebar-width);
    overflow-x: hidden;
    overflow-y: auto;
    background: var(--dark);
    color: #cad4df;
    box-shadow: 12px 0 32px rgba(17, 31, 48, .08);
    transition: width .22s ease, transform .25s ease;
    scrollbar-color: #405167 transparent;
    scrollbar-width: thin;
}

.sidebar .brand {
    display: flex;
    flex: 0 0 78px;
    align-items: center;
    gap: .8rem;
    min-width: 0;
    padding: 0 1.25rem;
    border-bottom: 1px solid rgba(255,255,255,.08);
    background: #1d2d40;
    color: #fff;
    text-decoration: none;
}

.sidebar .brand-logo {
    flex: 0 0 44px;
    width: 44px;
    height: 44px;
    border-radius: 12px;
    background: #fff;
    object-fit: contain;
}

.brand-copy { min-width: 0; overflow: hidden; white-space: nowrap; }
.brand-copy strong { display: block; font-size: 1.08rem; font-weight: 700; line-height: 1.2; }
.brand-copy small { color: #a9b7c7; font-size: .66rem; letter-spacing: .09em; text-transform: uppercase; }

.sidebar .nav-group {
    display: flex;
    min-height: 38px;
    align-items: center;
    overflow: visible;
    padding: .8rem 1.35rem .35rem;
    color: #8191a4;
    font-size: .66rem;
    font-weight: 700;
    letter-spacing: .12em;
    line-height: 1.4;
    text-transform: uppercase;
    white-space: nowrap;
}
.sidebar .nav-group span { display: block; }

.sidebar a.nav-link-x {
    position: relative;
    display: flex;
    align-items: center;
    gap: .9rem;
    min-height: 46px;
    margin: 2px .7rem;
    padding: .65rem .85rem;
    overflow: hidden;
    border-radius: 10px;
    color: #c4cfdb;
    font-size: .9rem;
    font-weight: 500;
    text-decoration: none;
    white-space: nowrap;
    transition: background .16s ease, color .16s ease;
}

.sidebar a.nav-link-x i { flex: 0 0 20px; width: 20px; color: #94a6ba; text-align: center; }
.sidebar a.nav-link-x:hover { background: rgba(255,255,255,.07); color: #fff; }
.sidebar a.nav-link-x.active { background: rgba(230,75,69,.18); color: #fff; font-weight: 600; }
.sidebar a.nav-link-x.active i { color: #ff8a83; }

.main {
    flex: 1;
    min-width: 0;
    margin-left: var(--sidebar-width);
    transition: margin-left .22s ease;
}

.topbar {
    position: sticky;
    z-index: 1020;
    top: 0;
    display: flex;
    align-items: center;
    min-height: 72px;
    gap: 1rem;
    padding: .65rem 1.75rem;
    border-bottom: 1px solid var(--border);
    background: rgba(255,255,255,.96);
    box-shadow: 0 4px 18px rgba(26, 42, 62, .035);
    backdrop-filter: blur(12px);
}

.topbar-company { overflow: hidden; color: var(--muted); font-size: .84rem; text-overflow: ellipsis; white-space: nowrap; }
.topbar-user { display: flex; align-items: center; gap: .9rem; margin-left: auto; }
.topbar-user-copy { text-align: right; line-height: 1.35; }
.topbar-user-copy .badge { margin-top: 2px; font-size: .65rem; font-weight: 600; }
.topbar form { margin: 0; }
.topbar form .btn { display: inline-flex; align-items: center; justify-content: center; width: 38px; height: 38px; border-radius: 10px; }
.sidebar-toggle {
    display: inline-flex;
    flex: 0 0 40px;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: #fff;
    color: #34465b;
    font-size: 1rem;
}
.sidebar-toggle:hover, .sidebar-toggle:focus-visible { border-color: #cbd5e0; background: #f7f9fb; }

.content { width: 100%; max-width: 1680px; margin: 0 auto; padding: 1.7rem 1.75rem 3rem; }
.page-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1.4rem; }
.page-head h1 { margin: 0; font-size: clamp(1.4rem, 2.1vw, 1.8rem); }
.page-head .text-muted { margin-top: .25rem; font-size: .85rem; }

.btn {
    min-height: 40px;
    border-radius: 9px;
    font-size: .86rem;
    font-weight: 600;
    transition: background-color .16s ease, border-color .16s ease, box-shadow .16s ease, transform .16s ease;
}
.btn:hover { transform: translateY(-1px); }
.btn-primary { border-color: var(--primary); background: var(--primary); box-shadow: 0 5px 12px rgba(230,75,69,.15); }
.btn-primary:hover, .btn-primary:focus { border-color: #cf3d37; background: #cf3d37; }
.btn-secondary { border-color: #66768a; background: #66768a; }
.btn-light, .btn-outline-secondary { border-color: var(--border); }
.btn-sm { min-height: 32px; border-radius: 7px; }

.card {
    min-width: 0;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: var(--surface);
    box-shadow: 0 5px 18px rgba(28, 45, 66, .045);
}
.card-header {
    padding: 1rem 1.2rem;
    border-bottom: 1px solid var(--border);
    border-radius: 14px 14px 0 0 !important;
    background: #fff;
    color: #233348;
    font-size: .94rem;
    font-weight: 700;
}
.card-body { padding: 1.2rem; }
.card > .table-responsive:last-child, .card > .table-responsive:last-child table { border-radius: 0 0 14px 14px; }

.kpi {
    position: relative;
    height: 100%;
    overflow: hidden;
    border-left: 0;
    background: #fff;
}
.kpi::before { position: absolute; inset: 0 auto 0 0; width: 4px; background: var(--primary); content: ''; }
.kpi.kpi-blue::before { background: #198fa8; }
.kpi.kpi-dark::before { background: #46566c; }
.kpi.kpi-green::before { background: #2a9d70; }
.kpi .card-body { min-height: 112px; padding: 1.15rem 1.25rem; }
.kpi .label { color: var(--muted); font-size: .72rem; font-weight: 700; letter-spacing: .065em; text-transform: uppercase; }
.kpi .value { margin-top: .35rem; color: #1c2a3b; font-size: clamp(1.35rem, 2vw, 1.7rem); font-weight: 700; letter-spacing: -.04em; line-height: 1.25; overflow-wrap: anywhere; }
.kpi .icon { display: inline-flex; align-items: center; justify-content: center; width: 46px; height: 46px; border-radius: 13px; background: #fff2f1; color: #e8756f; font-size: 1.15rem; }
.kpi-blue .icon { background: #eaf7fa; color: #198fa8; }
.kpi-dark .icon { background: #eef1f5; color: #596b82; }
.kpi-green .icon { background: #eaf7f0; color: #2a9d70; }

.table-responsive { border-radius: 0; }
.table { color: #314155; }
.table > :not(caption) > * > * { padding: .78rem .9rem; vertical-align: middle; }
.table thead th {
    border-bottom: 1px solid var(--border);
    background: #f8fafc;
    color: #718096;
    font-size: .69rem;
    font-weight: 700;
    letter-spacing: .07em;
    text-transform: uppercase;
    white-space: nowrap;
}
.table tbody tr:last-child > * { border-bottom: 0; }
.table-actions { text-align: right; white-space: nowrap; }
.table a { font-weight: 600; text-decoration: none; }
.table a:hover { text-decoration: underline; }

.form-label { margin-bottom: .4rem; color: #34465b; font-size: .82rem; font-weight: 600; }
.form-control, .form-select {
    min-height: 42px;
    border-color: #dce3eb;
    border-radius: 9px;
    color: #26374b;
    font-size: .9rem;
}
textarea.form-control { min-height: 100px; }
.form-control::placeholder { color: #a0acba; }
.form-control:focus, .form-select:focus { border-color: #e88782; box-shadow: 0 0 0 .2rem rgba(230,75,69,.12); }
.input-group-text { border-color: #dce3eb; border-radius: 9px 0 0 9px; background: #f7f9fb; color: #53647a; }
.form-check-input:checked { border-color: var(--primary); background-color: var(--primary); }
.alert { border: 0; border-radius: 11px; }
.badge { border-radius: 6px; font-weight: 600; letter-spacing: .01em; }
.list-group-item { border-color: var(--border); padding: .85rem 1.2rem; }
.pagination { flex-wrap: wrap; gap: .2rem; }
.pagination .page-link { border-color: var(--border); border-radius: 7px; color: #486176; }
.pagination .active .page-link { border-color: var(--primary); background: var(--primary); }

.dashboard-hero {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    min-height: 142px;
    margin-bottom: 1.3rem;
    padding: 1.6rem 1.8rem;
    overflow: hidden;
    border-radius: 16px;
    background: linear-gradient(115deg, #1a2b3f 0%, #253b53 72%, #314b65 100%);
    color: #fff;
}
.dashboard-hero::after { position: absolute; top: -78px; right: 19%; width: 220px; height: 220px; border: 1px solid rgba(255,255,255,.08); border-radius: 50%; box-shadow: 0 0 0 28px rgba(255,255,255,.025), 0 0 0 60px rgba(255,255,255,.02); content: ''; pointer-events: none; }
.dashboard-hero h1 { position: relative; z-index: 1; margin: 0; color: #fff; font-size: clamp(1.45rem, 2vw, 1.9rem); }
.dashboard-hero p { position: relative; z-index: 1; margin: .35rem 0 0; color: #c1ccd8; font-size: .88rem; }
.dashboard-hero .btn { position: relative; z-index: 1; flex: 0 0 auto; }
.dashboard-alerts .list-group { border-radius: 0 0 14px 14px; }
.dashboard-alert-link { display: block; color: inherit; text-decoration: none; }
.dashboard-alert-link:hover { background: #f8fafc; color: inherit; }

.sidebar-backdrop { display: none; }
.app.sidebar-collapsed .sidebar { width: var(--sidebar-collapsed-width); }
.app.sidebar-collapsed .main { margin-left: var(--sidebar-collapsed-width); }
.app.sidebar-collapsed .brand { justify-content: center; padding: 0; }
.app.sidebar-collapsed .brand-copy, .app.sidebar-collapsed .nav-group span, .app.sidebar-collapsed .nav-link-x span { display: none; }
.app.sidebar-collapsed .nav-group { min-height: 13px; height: 13px; margin: .35rem .9rem; padding: 0; border-top: 1px solid rgba(255,255,255,.08); }
.app.sidebar-collapsed .nav-link-x { justify-content: center; margin: 2px .65rem !important; padding: .65rem .2rem !important; }
.app.sidebar-collapsed .nav-link-x i { flex-basis: 22px; font-size: 1rem; }

.login-wrap { display: flex; min-height: 100vh; }
.login-art { display: none; flex: 1; align-items: flex-end; padding: 3rem; background: linear-gradient(rgba(17,31,48,.64),rgba(17,31,48,.64)), url('../img/aktransport.jpg') center/cover; color: #fff; }
.login-panel { display: flex; width: 100%; max-width: 480px; margin: 0 auto; padding: 3rem 2.5rem; flex-direction: column; justify-content: center; background: #fff; }
.login-logo { width: 52px; height: 52px; border-radius: 12px; object-fit: contain; }
@media (min-width: 992px) { .login-art { display: flex; } .login-panel { margin: 0; } }

@media (max-width: 991.98px) {
    .sidebar { width: min(var(--sidebar-width), calc(100vw - 64px)); transform: translateX(-105%); }
    .sidebar.open { transform: translateX(0); }
    .main, .app.sidebar-collapsed .main { margin-left: 0; }
    .app.sidebar-collapsed .sidebar { width: min(var(--sidebar-width), calc(100vw - 64px)); }
    .app.sidebar-collapsed .brand { justify-content: flex-start; padding: 0 1.25rem; }
    .app.sidebar-collapsed .brand-copy, .app.sidebar-collapsed .nav-group span, .app.sidebar-collapsed .nav-link-x span { display: initial; }
    .app.sidebar-collapsed .nav-group { min-height: 38px; height: auto; margin: 0; padding: .8rem 1.35rem .35rem; border-top: 0; }
    .app.sidebar-collapsed .nav-link-x { justify-content: flex-start; margin: 2px .7rem !important; padding: .65rem .85rem !important; }
    .app.sidebar-collapsed .nav-link-x i { flex-basis: 20px; }
    .sidebar-backdrop { position: fixed; z-index: 1035; inset: 0; display: block; visibility: hidden; border: 0; background: rgba(11, 22, 36, .48); opacity: 0; transition: opacity .2s ease, visibility .2s ease; }
    body.sidebar-open { overflow: hidden; }
    body.sidebar-open .sidebar-backdrop { visibility: visible; opacity: 1; }
    .topbar { min-height: 66px; padding: .6rem 1.1rem; }
    .content { padding: 1.35rem 1.1rem 2.5rem; }
}

@media (max-width: 767.98px) {
    body { font-size: .9rem; }
    .topbar-company { display: none; }
    .topbar { gap: .6rem; }
    .topbar-user { gap: .55rem; }
    .content { padding: 1.1rem .85rem 2rem; }
    .page-head { align-items: flex-start; margin-bottom: 1rem; }
    .page-head > .btn, .page-head > div > .btn { max-width: 100%; }
    .page-head .d-flex { width: 100%; }
    .page-head .d-flex .btn { flex: 1 1 auto; }
    .dashboard-hero { min-height: 0; align-items: flex-start; flex-direction: column; padding: 1.35rem; }
    .dashboard-hero .btn { width: 100%; }
    .card-body { padding: 1rem; }
    .card-header { padding: .9rem 1rem; }
    .kpi .card-body { min-height: 96px; padding: 1rem; }
    .kpi .icon { width: 40px; height: 40px; }
    .table > :not(caption) > * > * { padding: .65rem .72rem; }
    .table-responsive { overflow-x: auto; -webkit-overflow-scrolling: touch; }
    .table-responsive > .table { min-width: 640px; }
    .form-actions, .mt-4.d-flex.gap-2 { flex-wrap: wrap; }
    .form-actions > .btn, .mt-4.d-flex.gap-2 > .btn { flex: 1 1 auto; }
    .input-group > .form-control, .input-group > .form-select { min-width: 0; }
    .login-panel { padding: 2.2rem 1.35rem; }
}

@media (max-width: 420px) {
    .topbar-user-copy .badge { max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .topbar-user-copy .fw-medium { max-width: 132px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .page-head .btn { font-size: .8rem; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; }
}

@media print {
    .sidebar, .topbar, .sidebar-backdrop, .no-print { display: none !important; }
    .main, .app.sidebar-collapsed .main { margin: 0; }
    body { background: #fff; }
    .content { max-width: none; padding: 0; }
    .card { border: 1px solid #ddd; box-shadow: none; }
}
