/* PlateTrace Admin — Leonardo Design System theme (light mode)
   Tokens from the Leonardo brand guidelines V.01 2025:
   red #E4002B, steel greys, Barlow/Chakra Petch (Lynea/Connext stand-ins),
   square corners, hairline borders, restrained shadows. */

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

:root {
    /* ---- Leonardo tokens ---- */
    --leonardo-red: #E4002B;
    --leonardo-red-hover: #B80022;
    --grey-900: #1B272F;
    --grey-700: #37424A;
    --grey-100: #D2CCC4;
    --surface-page: #FFFFFF;
    --surface-warm: #EEECE9;      /* grey-100 38% on white */
    --surface-darker: #10171C;
    --text-muted-ldo: #838A8E;    /* grey-700 62% on white */
    --border-subtle: #DBDDDE;     /* grey-700 18% on white */
    --focus-ring: #5AAFF8;        /* blue-300 */
    --success: #00A878;
    --warning: #F95618;
    --info: #5AAFF8;

    --font-display: 'Chakra Petch', Arial, sans-serif;
    --font-sans: 'Barlow', Arial, sans-serif;

    --shadow-card: 0 1px 2px rgba(27, 39, 47, 0.06), 0 8px 24px rgba(27, 39, 47, 0.08);
    --ease-brand: cubic-bezier(0.4, 0, 0.2, 1);
    --dur-fast: 120ms;

    --sidebar-width: 240px;
    --topbar-height: 56px;

    /* ---- Bootstrap overrides ---- */
    --bs-primary: var(--leonardo-red);
    --bs-primary-rgb: 228, 0, 43;
    --bs-secondary: var(--grey-700);
    --bs-secondary-rgb: 55, 66, 74;
    --bs-success: var(--success);
    --bs-success-rgb: 0, 168, 120;
    --bs-warning: var(--warning);
    --bs-warning-rgb: 249, 86, 24;
    --bs-info: var(--info);
    --bs-info-rgb: 90, 175, 248;
    --bs-danger: var(--leonardo-red);
    --bs-danger-rgb: 228, 0, 43;
    --bs-body-color: var(--grey-700);
    --bs-body-color-rgb: 55, 66, 74;
    --bs-body-bg: var(--surface-warm);
    --bs-body-font-family: var(--font-sans);
    --bs-border-color: var(--border-subtle);
    --bs-border-radius: 0;
    --bs-border-radius-sm: 0;
    --bs-border-radius-lg: 0;
    --bs-border-radius-xl: 0;
    --bs-link-color: var(--leonardo-red);
    --bs-link-color-rgb: 228, 0, 43;
    --bs-link-hover-color: var(--leonardo-red-hover);
    --bs-link-hover-color-rgb: 184, 0, 34;
    --bs-emphasis-color: var(--grey-900);
    --bs-emphasis-color-rgb: 27, 39, 47;
}

body {
    background-color: var(--surface-warm);
    font-family: var(--font-sans);
    font-size: 0.95rem;
    font-weight: 400;
    color: var(--grey-700);
}

/* Headings — Connext Sans stand-in; brand allows Light/Regular/Medium only */
h1, h2, h3, h4, h5, h6,
.h1, .h2, .h3, .h4, .h5, .h6 {
    font-family: var(--font-display);
    color: var(--grey-900);
    letter-spacing: 0.01em;
}

h1.fw-bold, h2.fw-bold, h3.fw-bold, h4.fw-bold, h5.fw-bold, h6.fw-bold {
    font-weight: 500 !important;
}

.text-muted {
    color: var(--text-muted-ldo) !important;
}

.bg-light {
    background-color: var(--surface-warm) !important;
}

/* ---- Sidebar (dark surface) ---- */
#sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    background-color: var(--grey-900) !important;
}

#sidebar .brand-symbol {
    height: 22px;
    width: auto;
}

#sidebar .brand-name {
    font-family: var(--font-display);
    font-weight: 500;
    font-size: 16px;
    letter-spacing: 0.02em;
}

/* Prototype 1c: text-only nav, flush full-width links, 3px red active edge */
#sidebar .nav {
    padding: 4px 0 !important;
}

#sidebar .nav-link {
    color: rgba(255, 255, 255, 0.65);
    border-radius: 0;
    border-left: 3px solid transparent;
    padding: 9px 20px 9px 17px;
    margin-bottom: 0;
    font-size: 13.5px;
    transition: background-color var(--dur-fast) var(--ease-brand), color var(--dur-fast) var(--ease-brand);
}

#sidebar .nav-link i {
    display: none;
}

#sidebar .nav-link:hover {
    color: #fff;
    background-color: rgba(255, 255, 255, 0.05);
}

#sidebar .nav-link.active {
    color: #fff;
    background-color: rgba(255, 255, 255, 0.08);
    border-left-color: var(--leonardo-red);
    font-weight: 400;
}

#sidebar .sidebar-user {
    border-top: 1px solid rgba(255, 255, 255, 0.1) !important;
}

.sidebar-email {
    font-size: 12.5px;
    color: rgba(255, 255, 255, 0.8);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.role-pill {
    padding: 2px 8px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.12);
    color: rgba(255, 255, 255, 0.75);
    font: 600 10px 'Barlow', sans-serif;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

.signout-link {
    background: none;
    border: none;
    padding: 0;
    font: 400 12px 'Barlow', sans-serif;
    color: rgba(255, 255, 255, 0.5);
    cursor: pointer;
}

.signout-link:hover {
    color: #fff;
}

/* Topbar plan pill (prototype: green tinted, tracked caps) */
.navbar .navbar-brand {
    font-family: var(--font-display) !important;
    font-weight: 500 !important;
    color: var(--grey-900) !important;
}

.plan-pill {
    padding: 2px 10px;
    border-radius: 999px;
    background: rgba(0, 168, 120, 0.1);
    border: 1px solid rgba(0, 168, 120, 0.25);
    color: var(--success);
    font: 600 10.5px 'Barlow', sans-serif;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

#sidebar .badge {
    border-radius: 50rem; /* pill allowed for small tags */
}

/* ---- Cards: flat, square, hairline border ---- */
.card {
    border-radius: 0;
    border: 1px solid var(--border-subtle) !important;
    box-shadow: none !important;
    background-color: var(--surface-page);
}

.card.shadow-sm {
    box-shadow: var(--shadow-card) !important;
}

/* Card headers: tracked caps per prototype (RECENT ACTIVITY, CAPTURE, ...) */
.card-header {
    border-radius: 0 !important;
    background-color: var(--surface-page) !important;
    border-bottom: 1px solid var(--border-subtle);
    font-family: 'Barlow', Arial, sans-serif;
    font-size: 11px;
    font-weight: 500;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--text-muted-ldo);
    padding: 13px 16px;
}

.card-header h5, .card-header h6 {
    font: inherit;
    color: inherit;
    margin: 0;
    letter-spacing: inherit;
    text-transform: inherit;
}

.card-header a {
    font: 400 12px 'Barlow', Arial, sans-serif;
    letter-spacing: normal;
    text-transform: none;
    text-decoration: none;
}

/* Dashboard (prototype 1c) */
.dash-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 20px;
}

.stat-card {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 18px;
}

.stat-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    flex: none;
}

.stat-num {
    display: block;
    font-family: var(--font-display);
    font-size: 28px;
    font-weight: 600;
    color: var(--grey-900);
    line-height: 1;
}

.stat-lbl {
    font-size: 12.5px;
    color: var(--text-muted-ldo);
}

.dash-grid {
    display: grid;
    grid-template-columns: 3fr 2fr;
    gap: 16px;
    align-items: start;
}

@media (max-width: 992px) {
    .dash-grid { grid-template-columns: 1fr; }
}

.feed-row {
    display: grid;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    border-bottom: 1px solid var(--border-subtle);
    font-size: 13px;
    color: var(--grey-700);
}

.feed-row:last-child {
    border-bottom: none;
}

.feed-row .mono-sm {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 12px;
}

/* ---- Tables ---- */
/* Bootstrap 5.3 defaults table bg to --bs-body-bg (our warm grey);
   make tables transparent so they take their card's white background */
.table {
    --bs-table-bg: transparent;
}

.table th {
    font-family: var(--font-sans);
    font-weight: 500;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--text-muted-ldo);
    border-bottom-width: 1px;
}

.table-light {
    --bs-table-bg: var(--surface-warm);
}

.table td {
    font-size: 0.875rem;
}

.table-hover > tbody > tr:hover > * {
    --bs-table-bg-state: var(--surface-warm);
}

/* ---- Topbar ---- */
.navbar.border-bottom {
    height: var(--topbar-height);
    position: sticky;
    top: 0;
    z-index: 100;
    border-color: var(--border-subtle) !important;
}

#page-content-wrapper {
    min-height: 100vh;
    overflow-x: hidden;
}

/* ---- Buttons: square, darken on hover (no shrink) ---- */
.btn {
    border-radius: 0;
    font-size: 0.875rem;
    font-weight: 500;
    transition: background-color var(--dur-fast) var(--ease-brand), border-color var(--dur-fast) var(--ease-brand), color var(--dur-fast) var(--ease-brand);
}

.btn-sm { border-radius: 0; }
.btn-lg { border-radius: 0; }

.btn-primary {
    --bs-btn-bg: var(--leonardo-red);
    --bs-btn-border-color: var(--leonardo-red);
    --bs-btn-hover-bg: var(--leonardo-red-hover);
    --bs-btn-hover-border-color: var(--leonardo-red-hover);
    --bs-btn-active-bg: #8E001A;
    --bs-btn-active-border-color: #8E001A;
    --bs-btn-disabled-bg: var(--leonardo-red);
    --bs-btn-disabled-border-color: var(--leonardo-red);
}

.btn-outline-primary {
    --bs-btn-color: var(--leonardo-red);
    --bs-btn-border-color: var(--leonardo-red);
    --bs-btn-hover-bg: var(--leonardo-red);
    --bs-btn-hover-border-color: var(--leonardo-red);
    --bs-btn-active-bg: var(--leonardo-red-hover);
    --bs-btn-active-border-color: var(--leonardo-red-hover);
}

.btn-outline-danger {
    --bs-btn-color: var(--leonardo-red);
    --bs-btn-border-color: var(--leonardo-red);
    --bs-btn-hover-bg: var(--leonardo-red);
    --bs-btn-hover-border-color: var(--leonardo-red);
}

.btn-outline-secondary {
    --bs-btn-color: var(--grey-700);
    --bs-btn-border-color: var(--grey-700);
    --bs-btn-hover-bg: var(--grey-700);
    --bs-btn-hover-border-color: var(--grey-700);
}

/* ---- Forms: square, blue focus ring ---- */
.form-control, .form-select {
    border-radius: 0;
    font-size: 0.875rem;
    border-color: var(--border-subtle);
}

.form-control:focus, .form-select:focus {
    border-color: var(--focus-ring);
    box-shadow: 0 0 0 3px rgba(90, 175, 248, 0.25);
}

.form-check-input:checked {
    background-color: var(--leonardo-red);
    border-color: var(--leonardo-red);
}

.form-check-input:focus {
    border-color: var(--focus-ring);
    box-shadow: 0 0 0 3px rgba(90, 175, 248, 0.25);
}

/* ---- Badges: pills stay (small tags only, per brand) ---- */
.badge {
    font-weight: 500;
    letter-spacing: 0.02em;
}

/* ---- Alerts / dropdowns / modals: square ---- */
.alert {
    border-radius: 0;
}

.dropdown-menu {
    border-radius: 0;
    box-shadow: var(--shadow-card);
    border: 1px solid var(--border-subtle);
    min-width: 220px;
}

/* ---- Pagination ---- */
.pagination {
    --bs-pagination-border-radius: 0;
    --bs-pagination-color: var(--grey-700);
    --bs-pagination-active-bg: var(--leonardo-red);
    --bs-pagination-active-border-color: var(--leonardo-red);
    --bs-pagination-hover-color: var(--leonardo-red-hover);
    --bs-pagination-focus-color: var(--leonardo-red-hover);
    --bs-pagination-focus-box-shadow: 0 0 0 3px rgba(90, 175, 248, 0.25);
}

.page-link { border-radius: 0 !important; }

/* ---- Tables: let dropdowns escape the responsive wrapper on desktop ----
   .table-responsive's overflow clips absolutely-positioned dropdown menus.
   Desktop tables fit their cards, so overflow can be visible there; the
   scroll behavior stays on small screens where it's actually needed. */
@media (min-width: 992px) {
    .table-responsive {
        overflow: visible;
    }
}

/* ---- Records: uniform plate thumbnails + filter builder ---- */
.plate-thumb {
    width: 72px;
    height: 34px;
    object-fit: cover;
    border: 1px solid var(--border-subtle);
    display: block;
    flex: none;
}

.plate-thumb.empty {
    border-style: dashed;
    background: var(--surface-warm);
}

.cond {
    display: flex;
    gap: 6px;
    align-items: center;
}

.cond .form-select { max-width: 190px; }
.cond .form-control { max-width: 240px; }

.chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: #fff;
    border: 1px solid var(--border-subtle);
    font-size: 12.5px;
    padding: 3px 8px 3px 10px;
    color: var(--grey-700);
}

.chip b { font-weight: 600; color: var(--grey-900); }

.chip a {
    color: var(--text-muted-ldo);
    text-decoration: none;
    font-weight: 700;
    font-size: 13px;
    line-height: 1;
}

.chip a:hover { color: var(--leonardo-red); }

/* ---- Record detail: property rows with confidence bars ---- */
.attr {
    display: grid;
    grid-template-columns: 84px 1fr 96px 40px;
    gap: 10px;
    align-items: center;
    font-size: 0.875rem;
    color: var(--grey-700);
}

.attr + .attr { margin-top: 10px; }

.attr .k {
    color: var(--text-muted-ldo);
    font-size: 0.8125rem;
}

.attr .bar {
    height: 6px;
    background: var(--surface-warm);
}

.attr .bar i {
    display: block;
    height: 6px;
    background: var(--success);
}

.attr .n {
    font-size: 12px;
    color: var(--text-muted-ldo);
    text-align: right;
}

/* ---- Watch list hits in the records table ---- */
tr.watchlist-hit > td {
    background-color: rgba(228, 0, 43, 0.04);
}

tr.watchlist-hit > td:first-child {
    box-shadow: inset 3px 0 0 var(--leonardo-red);
}

/* ---- Monospace ---- */
.font-monospace {
    font-size: 0.85em;
}

.alert .font-monospace {
    font-size: 0.875rem;
    word-break: break-all;
    line-height: 1.6;
}

/* ---- Login page ---- */
body.bg-light .card {
    border-radius: 0;
    box-shadow: var(--shadow-card) !important;
}

.login-symbol {
    height: 56px;
    width: auto;
}

/* ---- Stat cards ---- */
.card-body .rounded-3 {
    width: 52px;
    height: 52px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    border-radius: 0 !important;
}

/* ---- Scrollbar ---- */
#sidebar::-webkit-scrollbar { width: 4px; }
#sidebar::-webkit-scrollbar-track { background: transparent; }
#sidebar::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.2); border-radius: 0; }

/* ---- Responsive ---- */
@media (max-width: 768px) {
    #sidebar {
        display: none !important;
    }
}
