/* ===== CSS Variables & Reset ===== */
:root {
    --primary: #2d3a8c;
    --primary-light: #4a5bc7;
    --primary-dark: #1e2a6e;
    --accent: #6366f1;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --info: #3b82f6;

    --bg-primary: #11131a;
    --bg-secondary: #161926;
    --bg-card: #1c1f2e;
    --bg-hover: #24283b;
    --bg-input: #1e2235;

    --text-primary: #b4bcce;
    --text-secondary: #949ab5;
    --text-muted: #626a84;

    --border: #23273a;
    --border-light: #2d324d;

    --sidebar-width: 240px;
    --radius: 12px;
    --radius-sm: 8px;
    --shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    --transition: all 0.2s ease;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* Prevent transitions on page load to avoid flash */
.preload-transitions * {
    -webkit-transition: none !important;
    -moz-transition: none !important;
    -ms-transition: none !important;
    -o-transition: none !important;
    transition: none !important;
}

body {
    font-family: 'Noto Sans Thai', 'Inter', sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    font-size: 16px;
    /* Base size bumped +2 */
}

/* ===== Sidebar ===== */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    z-index: 100;
    overflow-y: auto;
    transition: var(--transition);
}

.sidebar.sidebar-collapsed {
    width: 60px;
}

.sidebar-header {
    padding: 24px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 12px;
    transition: var(--transition);
}

.sidebar.sidebar-collapsed .sidebar-header {
    padding: 24px 10px;
    justify-content: center;
}

.sidebar-header .logo {
    font-size: 30px;
    line-height: 1;
    transition: var(--transition);
}

.sidebar.sidebar-collapsed .logo {
    display: none;
}

.sidebar-header h2 {
    font-size: 18px;
    font-weight: 600;
    background: linear-gradient(135deg, var(--accent), var(--primary-light));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    transition: var(--transition);
    white-space: nowrap;
    overflow: hidden;
}

.sidebar.sidebar-collapsed h2 {
    display: none;
}

.sidebar-toggle {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 24px;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
}

.sidebar-toggle:hover {
    color: var(--accent);
}

.sidebar.sidebar-collapsed .sidebar-toggle {
    margin: 0 auto;
}

.nav-links {
    list-style: none;
    padding: 12px 10px;
    flex: 1;
}

.nav-links a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: var(--radius-sm);
    transition: var(--transition);
    font-size: 16px;
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
}

.sidebar.sidebar-collapsed .nav-links a {
    padding: 12px;
    justify-content: center;
}

.sidebar.sidebar-collapsed .nav-links a span:not(.icon) {
    display: none;
}

/* Tooltip for collapsed mode */
.sidebar.sidebar-collapsed .nav-links a {
    position: relative;
}

.sidebar.sidebar-collapsed .nav-links a::after {
    content: attr(title);
    position: absolute;
    left: 100%;
    top: 50%;
    transform: translateY(-50%);
    background: var(--bg-hover);
    color: var(--text-primary);
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: var(--transition);
    z-index: 1000;
    margin-left: 10px;
    visibility: hidden;
}

.sidebar.sidebar-collapsed .nav-links a:hover::after {
    opacity: 1;
    visibility: visible;
}

.nav-links a:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.nav-links a.active {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.2), rgba(45, 58, 140, 0.2));
    color: var(--accent);
    font-weight: 500;
    border: 1px solid rgba(99, 102, 241, 0.3);
}

.nav-links .icon {
    font-size: 20px;
    width: 26px;
    text-align: center;
}

.sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--border);
    color: var(--text-muted);
    font-size: 11px;
    transition: var(--transition);
    white-space: nowrap;
    overflow: hidden;
}

.sidebar.sidebar-collapsed .sidebar-footer {
    display: none;
}

/* ===== Main Content ===== */
.content {
    margin-left: var(--sidebar-width);
    padding: 30px;
    min-height: 100vh;
    transition: var(--transition);
}

body.sidebar-is-collapsed .content {
    margin-left: 60px;
}

/* ===== Page Header ===== */
.page-header {
    margin-bottom: 30px;
}

.page-header h1 {
    font-size: 30px;
    font-weight: 700;
    background: linear-gradient(135deg, var(--text-primary), var(--accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.page-header .subtitle {
    color: var(--text-secondary);
    margin-top: 4px;
    font-size: 16px;
}

.header-with-actions {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 16px;
}

.header-actions {
    display: flex;
    gap: 10px;
}

/* ===== Cards ===== */
.card {
    background: var(--bg-card);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    margin-bottom: 24px;
    overflow: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.card:hover {
    border-color: var(--accent);
    transform: translateY(-2px);
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.45);
    filter: brightness(1.05);
}

/* Disable hover effect for large containers that are just wrappers */
#policies-section:hover,
#customer-info:hover,
#vehicles-section:hover {
    transform: none;
    box-shadow: none;
    filter: none;
    border-color: var(--border);
}

/* Fix for auto-scroll issue: Add margin-top for anchors instead of padding on root */
[id^="policy-"],
[id^="bill-"],
[id^="docs-"],
[id^="bills-"],
[id^="installments-"],
[id^="inst-"] {
    scroll-margin-top: 120px;
}

.card-header {
    padding: 18px 24px;
    border-bottom: 1px solid var(--border);
}

.card-header h2 {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
}

.card-header h3 {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-secondary);
}

.card-body {
    padding: 24px;
}

.card-info {
    border-color: rgba(99, 102, 241, 0.3);
    background: rgba(99, 102, 241, 0.05);
}

/* ===== Stats Grid ===== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.stat-card {
    border-radius: var(--radius);
    padding: 24px;
    display: flex;
    align-items: center;
    gap: 16px;
    border: 1px solid transparent;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.stat-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
    filter: brightness(1.1);
}

.stat-icon {
    font-size: 36px;
    line-height: 1;
}

.stat-value {
    font-size: 34px;
    font-weight: 700;
    line-height: 1.2;
}

.stat-label {
    font-size: 15px;
    color: rgba(255, 255, 255, 0.7);
    font-weight: 400;
}

.gradient-blue {
    background: linear-gradient(135deg, #1e3a8a, #3b82f6);
    color: white;
}

.gradient-green {
    background: linear-gradient(135deg, #065f46, #10b981);
    color: white;
}

.gradient-purple {
    background: linear-gradient(135deg, #4c1d95, #8b5cf6);
    color: white;
}

.gradient-orange {
    background: linear-gradient(135deg, #92400e, #f59e0b);
    color: white;
}

/* ===== Grid Layouts ===== */
.grid-2col {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
}

@media (max-width: 1024px) {
    .grid-2col {
        grid-template-columns: 1fr;
    }
}

/* ===== Tables ===== */
.table {
    width: 100%;
    border-collapse: collapse;
}

.table th,
.table td {
    padding: 10px 14px;
    text-align: left;
    border-bottom: 1px solid var(--border);
    font-size: 15px;
}

.table th {
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    background: rgba(255, 255, 255, 0.02);
}

.table-hover tbody tr:hover {
    background: var(--bg-hover);
}

.table .text-right {
    text-align: right;
}

.table .text-bold {
    font-weight: 600;
}

.table .text-lg {
    font-size: 18px;
}

.table .total-row {
    border-top: 2px solid var(--accent);
}

.table .total-row td {
    font-weight: 700;
    color: var(--accent);
}

.table .muted-row td {
    color: var(--text-muted);
    font-size: 14px;
}

.table-compact th,
.table-compact td {
    padding: 6px 10px;
    font-size: 16px;
}

.clickable-row {
    cursor: pointer;
}

/* ===== Search ===== */
.search-form,
.quick-search-form {
    display: flex;
    gap: 12px;
}

.search-input-lg {
    flex: 1;
    padding: 14px 20px;
    background: var(--bg-input);
    border: 2px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-size: 18px;
    font-family: inherit;
    outline: none;
    transition: var(--transition);
}

.search-input-lg:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

.search-input-lg::placeholder {
    color: var(--text-muted);
}

/* Override Browser Autofill Background */
input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus,
input:-webkit-autofill:active {
    -webkit-box-shadow: 0 0 0 30px var(--bg-input) inset !important;
    -webkit-text-fill-color: var(--text-primary) !important;
    transition: background-color 5000s ease-in-out 0s;
}

/* ===== Buttons ===== */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    transition: var(--transition);
    white-space: nowrap;
}

.btn:hover {
    transform: translateY(-1px);
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--accent));
    color: white;
}

.btn-primary:hover {
    background: linear-gradient(135deg, var(--primary-dark), var(--primary));
}

.btn-secondary {
    background: var(--bg-hover);
    color: var(--text-primary);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    background: var(--border-light);
}

.btn-success {
    background: linear-gradient(135deg, #065f46, var(--success));
    color: white;
}

.btn-danger {
    background: var(--danger);
    color: white;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 14px;
}

.btn-lg {
    padding: 14px 28px;
    font-size: 18px;
}

/* ===== Badge & Status Boxes===== */
.badge {
    display: inline-block;
    padding: 3px 10px;
    background: rgba(99, 102, 241, 0.15);
    color: var(--accent);
    border-radius: 20px;
    font-size: 14px;
    font-weight: 600;
}

.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.85rem;
    font-weight: 600;
    white-space: nowrap;
}

.status-pending {
    background-color: rgba(245, 158, 11, 0.15);
    color: #f59e0b;
    border: 1px solid rgba(245, 158, 11, 0.3);
}

.status-paid {
    background-color: rgba(16, 185, 129, 0.15);
    color: #10b981;
    border: 1px solid rgba(16, 185, 129, 0.3);
}

.status-overdue {
    background-color: rgba(239, 68, 68, 0.15);
    color: #ef4444;
    border: 1px solid rgba(239, 68, 68, 0.3);
}

/* Alert Item Hover (for Analytics/Dashboard) */
.alert-item {
    transition: all 0.2s ease;
}

.alert-item:hover {
    background: var(--bg-hover) !important;
    transform: translateX(4px);
    border-left: 3px solid var(--accent);
}

/* Conditional Date Colors */
.date-emergency {
    color: #fca5a5 !important;
}

/* Softer Red (Emergency) */
.date-warning {
    color: #fcd34d !important;
}

/* Softer Yellow (Warning) */

/* Yellow */
.date-safe {
    color: #4ade80 !important;
}

/* Green */

.badge-date {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 20px;
    margin-bottom: 4px;
    font-weight: 600;
    font-size: 0.85rem;
}

.badge-date.emergency {
    background-color: #808000;
    /* Olive */
    color: #cbd5e1;
    /* Light Grey/Blue */
    border: 1px solid rgba(0, 0, 0, 0.2);
}

.badge-date.warning {
    background-color: #808000;
    /* Olive */
    color: #cbd5e1;
    /* Light Grey/Blue */
    border: 1px solid rgba(0, 0, 0, 0.2);
}

.badge-date.safe {
    background-color: #808000;
    /* Olive */
    color: #cbd5e1;
    /* Light Grey/Blue */
    border: 1px solid rgba(0, 0, 0, 0.2);
}

/* ===== Info Grid ===== */
.info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 16px;
}

.info-item {
    text-align: center;
}

.info-item label {
    display: block;
    font-size: 14px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
    font-weight: 600;
}

.info-item span {
    display: block;
    font-size: 19px;
    font-weight: 500;
}

.info-notes {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

/* ===== Vehicle Cards ===== */
.vehicle-cards {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
}

.vehicle-card {
    padding: 16px 24px;
    background: var(--bg-hover);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    min-width: 200px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.vehicle-card:hover {
    border-color: var(--accent);
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.4);
    filter: brightness(1.1);
}

.vehicle-plate {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-secondary);
    font-family: 'Inter', monospace;
}

.vehicle-model {
    color: var(--text-secondary);
    font-size: 15px;
    margin-top: 4px;
}

.vehicle-tax {
    color: var(--text-muted);
    font-size: 14px;
    margin-top: 8px;
}

/* ===== Policy Timeline ===== */
.policy-timeline {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.policy-item {
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    overflow: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    filter: brightness(1);
}

.policy-item:hover {
    border-color: var(--accent);
    filter: brightness(1.1);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.45);
    transform: translateY(-3px);
    z-index: 10;
}

.policy-header {
    padding: 12px 20px;
    background: var(--bg-hover);
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.policy-period {
    font-weight: 700;
    font-size: 19px;
    color: var(--accent);
}

.policy-company {
    font-size: 15px;
}

.policy-type {
    color: var(--text-secondary);
    font-size: 16px;
}

.policy-details {
    padding: 16px 20px;
}

.payment-status {
    margin-top: 12px;
    padding: 10px 16px;
    background: rgba(16, 185, 129, 0.1);
    border: 1px solid rgba(16, 185, 129, 0.2);
    border-radius: var(--radius-sm);
    color: var(--success);
    font-size: 15px;
}

.installments {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

.installments h4 {
    font-size: 16px;
    margin-bottom: 10px;
    color: var(--text-secondary);
}

/* ===== Forms ===== */
.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 16px;
    margin-bottom: 20px;
}

.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-size: 15px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.form-control {
    width: 100%;
    padding: 12px 16px;
    background: rgba(30, 34, 53, 0.7); /* Slightly translucent for depth */
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    color: #e2e8f0; /* Brighter text for better contrast */
    font-family: inherit;
    font-size: 15px; /* Slightly larger */
    outline: none;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.1);
}

.form-control::placeholder {
    color: var(--text-muted);
}

.form-control:hover {
    border-color: var(--text-muted);
    background: rgba(30, 34, 53, 0.9);
}

.form-control:focus {
    border-color: var(--accent);
    background: var(--bg-input);
    color: white;
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.25);
    transform: translateY(-1px);
}

textarea.form-control {
    resize: vertical;
    min-height: 60px;
}

select.form-control {
    cursor: pointer;
}

.form-actions {
    display: flex;
    gap: 12px;
    margin-top: 24px;
    padding-top: 24px;
    border-top: 1px solid var(--border);
    justify-content: flex-end;
}

/* ===== Empty State ===== */
.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-muted);
}

.empty-icon {
    font-size: 48px;
    margin-bottom: 12px;
    opacity: 0.5;
}

.empty-state p {
    font-size: 17px;
}

.text-muted {
    color: var(--text-muted);
}

/* ===== Flash Messages ===== */
.flash-messages {
    margin-bottom: 24px;
}

.flash {
    padding: 14px 20px;
    border-radius: var(--radius-sm);
    font-size: 16px;
    margin-bottom: 8px;
    animation: slideIn 0.3s ease;
}

.flash-success {
    background: rgba(16, 185, 129, 0.1);
    border: 1px solid rgba(16, 185, 129, 0.3);
    color: var(--success);
}

.flash-error {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: var(--danger);
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ===== Code ===== */
code {
    font-family: 'Inter', monospace;
    background: var(--bg-hover);
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 15px;
    color: var(--accent);
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
    .sidebar {
        width: 60px;
    }

    .sidebar-header h2,
    .nav-links a span:not(.icon),
    .sidebar-footer {
        display: none;
    }

    .sidebar-header {
        justify-content: center;
        padding: 16px;
    }

    .nav-links a {
        justify-content: center;
        padding: 12px;
    }

    .content {
        margin-left: 60px;
        padding: 16px;
    }

    .stats-grid {
        grid-template-columns: 1fr 1fr;
    }

    .header-with-actions {
        flex-direction: column;
    }
}

/* ===== Print ===== */
@media print {

    .sidebar,
    .flash-messages,
    .header-actions {
        display: none !important;
    }

    .content {
        margin-left: 0;
        padding: 0;
    }

    body {
        background: white;
        color: black;
    }

    .card {
        border: 1px solid #ddd;
        background: white;
    }
}

/* ===== Search History Badges ===== */
.badge-history {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border);
    border-radius: 20px;
    color: var(--text-primary);
    text-decoration: none;
    font-size: 0.9rem;
    transition: all 0.2s ease;
}

.badge-history:hover {
    background: var(--accent);
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
    border-color: var(--accent);
}

.badge-history .count {
    background: rgba(0, 0, 0, 0.2);
    padding: 1px 6px;
    border-radius: 10px;
    font-size: 0.75rem;
    font-weight: 700;
}

/* ===== Phase 35: Grouped Policy Summary ===== */
.policy-summary-container {
    display: flex;
    flex-direction: column;
    gap: 24px;
    margin-bottom: 30px;
}

.plate-group-card {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px;
}

.plate-group-header {
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    padding-bottom: 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.plate-label {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.plate-value,
.plate-value code {
    font-size: 1.5rem;
    font-weight: 700;
    font-family: inherit;
    color: var(--text-secondary);
}

.plate-header-link {
    text-decoration: none;
    color: inherit;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s ease;
}

.plate-header-link:hover {
    transform: translateX(5px);
    color: var(--accent);
}

.plate-link-detailed {
    text-decoration: none;
    color: inherit;
    transition: all 0.2s ease;
}

.plate-link-detailed:hover {
    color: var(--accent);
}

.plate-link-detailed:hover code {
    background: var(--accent-transparent);
    border-color: var(--accent);
}

.vehicle-plate-link {
    text-decoration: none;
    color: inherit;
    display: block;
    transition: transform 0.2s ease;
}

.vehicle-plate-link:hover {
    transform: translateY(-2px);
}

.vehicle-plate-link:hover .vehicle-plate {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
}

.plate-group-card:target {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.2);
    animation: highlight-pulse 2s ease-out;
}

@keyframes highlight-pulse {
    0% {
        background: rgba(16, 185, 129, 0.1);
    }

    100% {
        background: rgba(255, 255, 255, 0.02);
    }
}

.policy-summary-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
}

@media (max-width: 1600px) {
    .policy-summary-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 1200px) {
    .policy-summary-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .policy-summary-grid {
        grid-template-columns: 1fr;
    }
}

.summary-card {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 14px;
    text-decoration: none;
    color: var(--text-primary);
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    gap: 8px;
    position: relative;
    overflow: hidden;
}

.summary-card:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: var(--accent);
    transform: translateY(-4px);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.2);
}

.summary-card .summary-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border);
    padding: 8px 12px;
    margin: -14px -14px 4px -14px;
    background: rgba(255, 255, 255, 0.04);
}

.summary-card .summary-card-header.card-header-emergency {
    /* Old: #CD5C5C */
    background-color: #9b4d4d !important;
}

.summary-card .summary-card-header.card-header-warning {
    /* Old: #EEE8AA */
    background-color: #c4b454 !important;
}

.summary-card .summary-card-header.card-header-safe {
    /* Old: #3CB371 */
    background-color: #4d8c6d !important;
}

.summary-card .summary-card-header.card-header-emergency .year,
.summary-card .summary-card-header.card-header-emergency .plate,
.summary-card .summary-card-header.card-header-safe .year,
.summary-card .summary-card-header.card-header-safe .plate,
.summary-card .summary-card-header.card-header-warning .year,
.summary-card .summary-card-header.card-header-warning .plate {
    color: #f8fafc !important;
    /* Brighter off-white */
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

.policy-header .vehicle-nav-link {
    text-decoration: none;
    font-size: 1.4rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s ease;
    cursor: pointer;
    line-height: 1;
}

.policy-header .vehicle-nav-link:hover {
    transform: scale(1.2);
}

/* Highlight target policy item */
.policy-item:target {
    animation: highlight-pulse 2s ease-out;
    border-color: var(--accent) !important;
    box-shadow: 0 0 25px rgba(99, 102, 241, 0.4);
}

.summary-card .year {
    font-weight: 700;
    font-size: 1.25rem;
    color: var(--accent);
}

.summary-card .plate {
    font-size: 1rem;
    color: var(--text-secondary);
}

.summary-card .doc-line {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-bottom: 6px;
    padding-bottom: 4px;
    border-bottom: 1px dotted rgba(255, 255, 255, 0.1);
}

.summary-card-body {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.mini-row {
    display: grid;
    grid-template-columns: 65px 1fr 95px 85px;
    gap: 8px;
    font-size: 0.85rem;
    align-items: center;
    line-height: 1.4;
}

.mini-row span {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.mini-row .label {
    color: var(--text-muted);
    font-weight: 600;
}

.mini-row .val {
    color: var(--text-primary);
}

.mini-row .date {
    color: var(--text-secondary);
    text-align: right;
    font-size: 0.82rem;
}

.mini-row .price {
    font-weight: 700;
    text-align: right;
    color: var(--text-primary);
}

/* Row-specific colors */
.mini-row.insurance .price {
    color: #93c5fd;
}

.mini-row.prb .price {
    color: #4ade80;
}

.mini-row.tax .price {
    color: #facc15;
}

.mini-row.service .price {
    color: #fb923c;
}

.summary-card .summary-card-footer {
    margin-top: auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 8px;
    border-top: 1px dashed var(--border);
}

.summary-card .total-label {
    font-size: 0.9rem;
    color: var(--text-muted);
}

.summary-card .total-value {
    font-weight: 700;
    color: var(--success);
    font-size: 1.25rem;
}

@media (max-width: 1200px) {
    .policy-summary-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .policy-summary-grid {
        grid-template-columns: 1fr;
    }
}

/* ===== Policy Summary Quick Links ===== */
.policy-summary-box {
    background: rgba(255, 255, 255, 0.03);
    border: 1px dashed var(--border);
    border-radius: var(--radius-md);
    padding: 12px;
    margin-bottom: 24px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.summary-item {
    display: flex;
    align-items: center;
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    text-decoration: none;
    color: var(--text-primary);
    font-size: 0.95rem;
    transition: all 0.2s ease;
    border-left: 3px solid transparent;
}

.summary-item:hover {
    background: var(--bg-hover);
    border-left-color: var(--accent);
    padding-left: 18px;
    color: var(--accent);
}

.summary-item .dot {
    margin-right: 10px;
    color: var(--accent);
    font-size: 0.8rem;
}

.summary-item .doc-info {
    font-size: 0.85rem;
    opacity: 0.6;
    margin-left: 8px;
}

.summary-item .total {
    margin-left: auto;
    font-weight: 600;
    color: var(--success);
}