:root {
    --ag-primary: #DC1F26;
    --ag-primary-dark: #B7181E;
    --ag-primary-soft: #FDECEC;
    --ag-secondary: #29294B;
    --ag-heading: #1C1C33;
    --ag-body: #696981;
    --ag-muted: #97A1C0;
    --ag-bg: #F6F7FB;
    --ag-sidebar: #ffffff;
    --ag-border: #E7E9F2;
    --ag-success: #009966;
    --ag-warning: #F5A70D;
    --ag-info: #5955D1;
    --ag-danger: #F83636;
    --ag-radius: 16px;
    --ag-shadow: 0 10px 30px rgba(28, 28, 51, 0.06);
    --sidebar-w: 268px;
    --header-h: 72px;
}

* { box-sizing: border-box; }

html, body {
    min-height: 100%;
}

body {
    font-family: "Instrument Sans", system-ui, sans-serif;
    font-size: 0.875rem;
    font-weight: 500;
    line-height: 1.6;
    color: var(--ag-body);
    background: var(--ag-bg);
    margin: 0;
}

h1, h2, h3, h4, h5, h6, .heading {
    color: var(--ag-heading);
    font-weight: 700;
}

a { color: var(--ag-primary); text-decoration: none; }
a:hover { color: var(--ag-primary-dark); }

.page-layout {
    min-height: 100vh;
}

.app-sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: var(--sidebar-w);
    background: var(--ag-sidebar);
    border-right: 1px solid var(--ag-border);
    overflow: hidden;
    z-index: 1040;
    display: flex;
    flex-direction: column;
    transition: transform .25s ease;
}

.sidebar-brand {
    height: 72px;
    min-height: 72px;
    max-height: 72px;
    display: flex;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 1px solid var(--ag-border);
    overflow: hidden;
    flex-shrink: 0;
}

.brand-link {
    display: flex;
    align-items: center;
    width: 100%;
    height: 100%;
}

.brand-logo {
    display: block;
    width: 100%;
    height: 100%;
    max-width: 100%;
    max-height: 48px;
    object-fit: contain;
    object-position: left center;
}

.header-brand {
    display: flex;
    align-items: center;
    height: 40px;
    max-width: 168px;
    overflow: hidden;
    flex: 0 1 auto;
}
.header-brand img {
    display: block;
    width: auto;
    height: 36px;
    max-width: 168px;
    object-fit: contain;
    object-position: left center;
}

.sidebar-scroll { flex: 1; overflow: auto; padding: 1rem 0.85rem; }
.sidebar-label {
    font-size: .7rem;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--ag-muted);
    padding: 0 .65rem .45rem;
    font-weight: 700;
}

.sidebar-nav { display: flex; flex-direction: column; gap: 4px; }

.sidebar-nav .nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--ag-heading);
    border-radius: 12px;
    padding: .7rem .85rem;
    font-weight: 600;
}

.sidebar-nav .nav-link i { width: 18px; height: 18px; color: var(--ag-muted); }
.sidebar-nav .nav-link:hover { background: #F4F5FB; color: var(--ag-heading); }
.sidebar-nav .nav-link.active {
    background: var(--ag-primary-soft);
    color: var(--ag-primary);
}
.sidebar-nav .nav-link.active i { color: var(--ag-primary); }

.sidebar-foot { padding: 1rem; }
.upgrade-card {
    background: linear-gradient(180deg, #fff 0%, #F8F8FF 100%);
    border: 1px solid var(--ag-border);
    border-radius: 18px;
    padding: 1rem;
}
.upgrade-title { font-weight: 700; color: var(--ag-heading); margin-bottom: .25rem; }
.upgrade-card p { font-size: .78rem; margin-bottom: .8rem; }

.app-header {
    position: sticky;
    top: 0;
    z-index: 1030;
    margin-left: var(--sidebar-w);
    height: var(--header-h);
    background: rgba(246, 247, 251, .92);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--ag-border);
}

.app-header-inner {
    height: 100%;
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0 1.25rem;
}

.app-toggler {
    width: 40px;
    height: 40px;
    border: 0;
    background: #fff;
    border-radius: 12px;
    box-shadow: var(--ag-shadow);
    color: var(--ag-heading);
}

.header-search {
    position: relative;
    flex: 1;
    max-width: 360px;
}
.header-search i {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    width: 16px;
    height: 16px;
    color: var(--ag-muted);
}
.header-search .form-control {
    padding-left: 38px;
    background: #fff;
    border: 0;
    box-shadow: var(--ag-shadow);
    height: 42px;
}

.header-end {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: .75rem;
}

.user-chip {
    display: flex;
    align-items: center;
    gap: 10px;
    border: 0;
    background: #fff;
    border-radius: 999px;
    padding: 6px 10px 6px 6px;
    box-shadow: var(--ag-shadow);
}
.user-meta { text-align: left; line-height: 1.15; }
.user-meta strong { display: block; font-size: .82rem; color: var(--ag-heading); }
.user-meta small { color: var(--ag-muted); font-size: .7rem; }
.avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: var(--ag-primary);
    color: #fff;
    display: grid;
    place-items: center;
    font-weight: 700;
}
.user-menu { min-width: 220px; border: 0; box-shadow: var(--ag-shadow); border-radius: 14px; padding: .4rem; }
.user-menu .dropdown-item { border-radius: 10px; display: flex; align-items: center; gap: 8px; }
.user-menu .dropdown-item i { width: 16px; height: 16px; }

.app-content {
    margin-left: var(--sidebar-w);
    padding: 1.25rem 1.25rem 5.5rem;
    min-height: calc(100vh - var(--header-h));
}

.content-inner { max-width: 1320px; margin: 0 auto; }

.page-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.25rem;
    flex-wrap: wrap;
}
.page-head h1 { font-size: 1.35rem; margin: 0; }
.breadcrumb { margin: 0; background: none; padding: 0; font-size: .8rem; }
.breadcrumb-item + .breadcrumb-item::before { content: "›"; }

.card {
    border: 0;
    border-radius: var(--ag-radius);
    box-shadow: var(--ag-shadow);
    background: #fff;
}
.card-header {
    background: transparent;
    border-bottom: 1px solid var(--ag-border);
    padding: 1rem 1.15rem;
    font-weight: 700;
    color: var(--ag-heading);
}
.card-body { padding: 1.15rem; }

.stat-card {
    padding: 1.15rem;
    height: 100%;
}
.stat-card .stat-icon {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    display: grid;
    place-items: center;
}
.stat-card .stat-icon i { width: 20px; height: 20px; }
.stat-card .stat-label { color: var(--ag-muted); font-size: .8rem; font-weight: 600; }
.stat-card .stat-value { font-size: 1.55rem; font-weight: 700; color: var(--ag-heading); line-height: 1.2; }
.stat-card .stat-sub { font-size: .78rem; }

.icon-red { background: var(--ag-primary-soft); color: var(--ag-primary); }
.icon-purple { background: #EEEDFB; color: #5955D1; }
.icon-green { background: #E6F6F0; color: var(--ag-success); }
.icon-orange { background: #FEF5E3; color: var(--ag-warning); }

.btn {
    border-radius: 10px;
    font-weight: 600;
    padding: .5rem 1rem;
}
.btn-primary {
    --bs-btn-bg: var(--ag-primary);
    --bs-btn-border-color: var(--ag-primary);
    --bs-btn-hover-bg: var(--ag-primary-dark);
    --bs-btn-hover-border-color: var(--ag-primary-dark);
    --bs-btn-active-bg: var(--ag-primary-dark);
    --bs-btn-active-border-color: var(--ag-primary-dark);
}
.btn-soft {
    background: var(--ag-primary-soft);
    color: var(--ag-primary);
    border: 0;
}
.btn-soft:hover { background: #f8d4d5; color: var(--ag-primary-dark); }
.btn-light { background: #F2F2F6; border: 0; color: var(--ag-heading); }
.btn-icon {
    width: 36px;
    height: 36px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.form-label { font-weight: 600; color: var(--ag-heading); }
.form-control, .form-select {
    border-radius: 10px;
    border-color: var(--ag-border);
    min-height: 44px;
    box-shadow: none;
}
.form-control:focus, .form-select:focus {
    border-color: #f0b1b3;
    box-shadow: 0 0 0 .2rem rgba(220, 31, 38, .12);
}

.plate-input {
    font-size: 1.35rem;
    font-weight: 700;
    letter-spacing: .12em;
    text-transform: uppercase;
    text-align: center;
}
.plate-scan-actions {
    margin-top: .85rem;
}
.plate-scan-actions .btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 48px;
}
.plate-scan-actions .btn i {
    width: 18px;
    height: 18px;
}
.plate-scan-actions .btn.loading {
    pointer-events: none;
    opacity: .75;
}

.badge { font-weight: 600; border-radius: 999px; padding: .4em .7em; }
.bg-success-subtle { background: #E6F6F0 !important; color: var(--ag-success) !important; }
.bg-danger-subtle { background: #FEECEC !important; color: var(--ag-danger) !important; }
.bg-warning-subtle { background: #FEF5E3 !important; color: #b47a07 !important; }
.bg-info-subtle { background: #EEEDFB !important; color: #5955D1 !important; }
.bg-primary-subtle { background: var(--ag-primary-soft) !important; color: var(--ag-primary) !important; }

.table { color: var(--ag-body); }
.table thead th {
    color: var(--ag-muted);
    font-size: .75rem;
    letter-spacing: .04em;
    text-transform: uppercase;
    font-weight: 700;
    border-bottom-color: var(--ag-border);
    white-space: nowrap;
}
.table tbody td { vertical-align: middle; border-color: var(--ag-border); }
.table-hover tbody tr:hover { background: #FBFBFE; }

.plate-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: #111;
    color: #fff;
    border-radius: 8px;
    padding: 4px 10px;
    font-weight: 700;
    letter-spacing: .06em;
    font-size: .82rem;
}
.plate-chip b { color: #fff; }
.plate-chip span { color: #ff5a5f; }

.item-row { background: #FBFBFE; border: 1px dashed var(--ag-border); border-radius: 12px; padding: .75rem; margin-bottom: .6rem; }

.card-list { display: none; }
.job-card {
    background: #fff;
    border-radius: 16px;
    box-shadow: var(--ag-shadow);
    padding: 1rem;
    margin-bottom: .85rem;
}
.job-card .top {
    display: flex;
    justify-content: space-between;
    gap: .75rem;
    align-items: flex-start;
    margin-bottom: .6rem;
}
.job-meta { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; font-size: .8rem; }
.job-meta span { color: var(--ag-muted); display: block; }
.job-meta strong { color: var(--ag-heading); }
.job-card .actions { display: flex; gap: .5rem; margin-top: .85rem; }

.filter-bar {
    display: flex;
    gap: .6rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}
.filter-bar .form-control, .filter-bar .form-select { min-height: 42px; }

.timeline { position: relative; padding-left: 1.2rem; }
.timeline::before {
    content: "";
    position: absolute;
    left: 6px;
    top: 4px;
    bottom: 4px;
    width: 2px;
    background: var(--ag-border);
}
.timeline-item { position: relative; padding-bottom: 1rem; }
.timeline-item::before {
    content: "";
    position: absolute;
    left: -1.05rem;
    top: 6px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--ag-primary);
}

.empty-state { text-align: center; padding: 2.5rem 1rem; color: var(--ag-muted); }
.empty-state i { width: 42px; height: 42px; margin-bottom: .6rem; }

.auth-wrap {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 1.05fr .95fr;
    background: var(--ag-bg);
}
.auth-visual {
    background: #0B0B0B;
    color: #fff;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 2.5rem;
    position: relative;
    overflow: hidden;
}
.auth-visual::after {
    content: "";
    position: absolute;
    width: 420px;
    height: 420px;
    right: -120px;
    bottom: -80px;
    background: radial-gradient(circle, rgba(220,31,38,.45), transparent 70%);
}
.auth-visual img.logo-mark {
    width: 88px;
    height: 88px;
    border-radius: 22px;
    position: relative;
    z-index: 1;
}
.auth-logo {
    display: block;
    max-width: 220px;
    max-height: 64px;
    width: auto;
    height: auto;
    object-fit: contain;
    margin: 0 auto 1.1rem;
}
.auth-copy { position: relative; z-index: 1; max-width: 420px; }
.auth-copy h2 { color: #fff; font-size: 2rem; }
.auth-panel { display: grid; place-items: center; padding: 2rem 1.25rem; }
.auth-card {
    width: 100%;
    max-width: 440px;
    background: #fff;
    border-radius: 24px;
    box-shadow: var(--ag-shadow);
    padding: 2rem 1.75rem;
}
.password-wrap { position: relative; }
.password-wrap .toggle-pass {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    border: 0;
    background: transparent;
    color: var(--ag-muted);
}

.mobile-nav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1050;
    background: #fff;
    border-top: 1px solid var(--ag-border);
    display: flex;
    justify-content: space-around;
    align-items: flex-end;
    padding: .45rem .4rem calc(.45rem + env(safe-area-inset-bottom));
}
.mobile-nav a {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    color: var(--ag-muted);
    font-size: .68rem;
    font-weight: 700;
    min-width: 52px;
}
.mobile-nav a i { width: 20px; height: 20px; }
.mobile-nav a.active { color: var(--ag-primary); }
.mobile-nav a.fab {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: var(--ag-primary);
    color: #fff !important;
    justify-content: center;
    margin-top: -22px;
    box-shadow: 0 10px 20px rgba(220,31,38,.35);
}
.mobile-nav a.fab i { width: 24px; height: 24px; }

.sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(12, 12, 24, .35);
    z-index: 1035;
}

.install-bar {
    display: none;
    position: fixed;
    left: 12px;
    right: 12px;
    bottom: 78px;
    z-index: 1060;
    background: #111;
    color: #fff;
    border-radius: 14px;
    padding: .85rem 1rem;
    box-shadow: var(--ag-shadow);
}
.install-bar.show { display: flex; align-items: center; gap: .75rem; }
.install-bar .btn { white-space: nowrap; }

@media (max-width: 991.98px) {
    .app-sidebar { transform: translateX(-105%); }
    .page-layout.sidebar-open .app-sidebar { transform: none; }
    .page-layout.sidebar-open .sidebar-backdrop { display: block; }
    .app-header, .app-content { margin-left: 0; }
}

@media (max-width: 767.98px) {
    .table-desktop { display: none !important; }
    .card-list { display: block; }
    .app-content { padding: 1rem 0.85rem 6.2rem; }
    .stat-card .stat-value { font-size: 1.3rem; }
    .auth-wrap { grid-template-columns: 1fr; }
    .auth-visual { min-height: 220px; padding: 1.5rem; }
    .auth-visual img.logo { max-width: 180px; }
}

@media (min-width: 768px) {
    .mobile-nav { display: none !important; }
}

.print-sheet { display: none; }
@media print {
    .app-sidebar, .app-header, .mobile-nav, .no-print { display: none !important; }
    .app-content { margin: 0; padding: 0; }
    .print-sheet { display: block; }
    body { background: #fff; }
}
