:root {
    --primary-blue: #2563eb;
    --primary-dark: #1e40af;
    --accent-teal: #14b8a6;
    --accent-orange: #f97316;
    --accent-green: #22c55e;
    
    --bg-white: #ffffff;
    --bg-gray-50: #f9fafb;
    --bg-gray-100: #f3f4f6;
    
    --text-primary: #111827;
    --text-secondary: #6b7280;
    --text-muted: #9ca3af;
    
    --border-light: #e5e7eb;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.1);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.1);
    --shadow-lg: 0 8px 16px rgba(0,0,0,0.12);
    
    --border-radius-sm: 6px;
    --border-radius-md: 8px;
    --border-radius-lg: 12px;
    --border-radius-xl: 20px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    transition: all 0.3s ease;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: var(--bg-gray-50);
    color: var(--text-primary);
    line-height: 1.6;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

.login-form {
    max-width: 400px;
    margin: 100px auto;
    background: white;
    padding: 40px;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.login-form h1 {
    text-align: center;
    margin-bottom: 10px;
    color: #2563eb;
    font-size: 2.5em;
}

.login-form p {
    text-align: center;
    margin-bottom: 30px;
    color: #666;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
}

.form-group input, .form-group select, .form-group textarea {
    width: 100%;
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 16px;
}

.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
    outline: none;
    border-color: #2563eb;
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.2);
}

button, .button {
    display: inline-block;
    padding: 12px 20px;
    background: var(--primary-blue);
    color: white;
    border: none;
    border-radius: var(--border-radius-md);
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.2s;
    text-align: center;
    min-width: auto;
}

button:hover, .button:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

button:active, .button:active {
    transform: translateY(0);
}

.btn-secondary, .button-secondary {
    background: var(--text-secondary);
}

.btn-secondary:hover, .button-secondary:hover {
    background: #4b5563;
}

.btn-danger, .button-danger {
    background: #dc2626;
}

.btn-danger:hover, .button-danger:hover {
    background: #b91c1c;
}

.btn-success, .button-success {
    background: var(--accent-green);
}

.btn-success:hover, .button-success:hover {
    background: #16a34a;
}

.btn-outline {
    background: transparent;
    color: var(--primary-blue);
    border: 2px solid var(--primary-blue);
}

.btn-outline:hover {
    background: var(--primary-blue);
    color: white;
}

/* Small button variant */
.btn-sm {
    padding: 6px 12px;
    font-size: 14px;
}

/* Large button variant */
.btn-lg {
    padding: 16px 24px;
    font-size: 18px;
}

/* Full width button */
.btn-block {
    width: 100%;
}

/* Icon buttons */
.btn-icon {
    width: 40px;
    height: 40px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Additional button variants */
.btn-blue {
    background: var(--primary-blue);
    color: white;
}

.btn-blue:hover {
    background: var(--primary-dark);
    color: white;
}

.btn-green {
    background: var(--accent-green);
    color: white;
}

.btn-green:hover {
    background: #16a34a;
    color: white;
}

/* Ensure all buttons have consistent border-radius and sizing */
button, .button, .btn-primary, .btn-secondary, .btn-danger, .btn-success, 
.btn-outline, .btn-blue, .btn-green {
    border-radius: var(--border-radius-md);
    font-weight: 500;
    transition: all 0.2s ease;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 40px;
}

/* Sidebar Navigation */
.sidebar {
    position: fixed;
    left: 0;
    top: 0;
    height: 100vh;
    width: 80px;
    background: var(--primary-blue);
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px 0;
    border-radius: 0 var(--border-radius-xl) var(--border-radius-xl) 0;
    box-shadow: var(--shadow-md);
    z-index: 1000;
}

.nav-item {
    width: 48px;
    height: 48px;
    border-radius: var(--border-radius-lg);
    background: transparent;
    border: none;
    color: white;
    font-size: 20px;
    cursor: pointer;
    margin-bottom: 8px;
    transition: background 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.nav-item:hover,
.nav-item.active {
    background: rgba(255, 255, 255, 0.2);
}

/* Top Navigation Bar */
.navbar {
    background: var(--bg-white);
    color: var(--text-primary);
    padding: 15px 0;
    margin-bottom: 30px;
    border-bottom: 1px solid var(--border-light);
    box-shadow: var(--shadow-sm);
}

.navbar.with-sidebar {
    margin-left: 100px;
}

.navbar .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 24px;
    max-width: 1200px;
    margin: 0 auto;
}

.navbar h1 {
    font-size: 1.8em;
    color: var(--primary-blue);
}

.navbar nav {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
}

.navbar nav a {
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: 500;
    padding: 8px 16px;
    border-radius: var(--border-radius-md);
    transition: all 0.2s;
}

.navbar nav a:hover {
    background: var(--bg-gray-50);
    color: var(--primary-blue);
}

.navbar nav a.active {
    background: var(--primary-blue);
    color: white;
}

.card {
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    margin-bottom: 20px;
}

.card-header {
    padding: 20px;
    border-bottom: 1px solid #e5e7eb;
}

.card-body {
    padding: 20px;
}

.grid {
    display: grid;
    gap: 20px;
}

.grid-2 {
    grid-template-columns: 1fr 1fr;
}

.grid-3 {
    grid-template-columns: 1fr 1fr 1fr;
}

.grid-4 {
    grid-template-columns: 1fr 1fr 1fr 1fr;
}

.table {
    width: 100%;
    border-collapse: collapse;
}

.table th, .table td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid #e5e7eb;
}

.table th {
    background: #f9fafb;
    font-weight: 600;
}

.alert {
    padding: 15px;
    border-radius: 4px;
    margin-bottom: 20px;
}

.alert-success {
    background: #dcfce7;
    color: #166534;
    border: 1px solid #bbf7d0;
}

.alert-error {
    background: #fef2f2;
    color: #dc2626;
    border: 1px solid #fecaca;
}

.badge {
    display: inline-block;
    padding: 4px 8px;
    font-size: 12px;
    font-weight: 500;
    border-radius: 4px;
}

.badge-success {
    background: #dcfce7;
    color: #166534;
}

.badge-warning {
    background: #fef3c7;
    color: #d97706;
}

.badge-danger {
    background: #fef2f2;
    color: #dc2626;
}

.badge-info {
    background: #eff6ff;
    color: var(--primary-blue);
}

/* Dashboard Layout */
.dashboard-container {
    padding: 24px;
    background: var(--bg-gray-50);
    min-height: 100vh;
}

.dashboard-container.with-sidebar {
    margin-left: 100px;
}

.dashboard-header {
    margin-bottom: 32px;
}

.dashboard-header h2 {
    font-size: 2rem;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.dashboard-header p {
    color: var(--text-secondary);
    font-size: 1.1rem;
}

/* Metrics Grid */
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 24px;
    margin-bottom: 32px;
}

.metric-card {
    background: var(--bg-white);
    border-radius: var(--border-radius-lg);
    padding: 24px;
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
    gap: 16px;
    transition: transform 0.2s, box-shadow 0.2s;
    border: 1px solid var(--border-light);
}

.metric-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.metric-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.metric-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--border-radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    font-weight: bold;
}

.metric-icon.blue { 
    background: #dbeafe; 
    color: var(--primary-blue); 
}

.metric-icon.green { 
    background: #d1fae5; 
    color: var(--accent-green); 
}

.metric-icon.orange { 
    background: #fed7aa; 
    color: var(--accent-orange); 
}

.metric-icon.teal { 
    background: #ccfbf1; 
    color: var(--accent-teal); 
}

.metric-menu {
    background: none;
    border: none;
    font-size: 20px;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
    border-radius: var(--border-radius-sm);
    transition: background 0.2s;
}

.metric-menu:hover {
    background: var(--bg-gray-50);
}

.metric-label {
    font-size: 0.875rem;
    color: var(--text-secondary);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.metric-value {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1;
}

.metric-chart {
    height: 40px;
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 2px;
}

.metric-chart-bar {
    background: var(--primary-blue);
    border-radius: 2px;
    opacity: 0.7;
    transition: opacity 0.2s;
}

.metric-chart-bar:hover {
    opacity: 1;
}

/* Legacy dashboard stats (for backward compatibility) */
.dashboard-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.stat-card {
    background: var(--bg-white);
    padding: 25px;
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-sm);
    text-align: center;
    transition: transform 0.2s, box-shadow 0.2s;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.stat-value {
    font-size: 2.5em;
    font-weight: bold;
    color: var(--primary-blue);
    margin-bottom: 10px;
}

.stat-label {
    color: var(--text-secondary);
    font-weight: 500;
}

/* Charts Section */
.charts-section {
    display: grid;
    gap: 24px;
    margin-bottom: 32px;
}

.chart-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
}

.chart-container {
    background: var(--bg-white);
    border-radius: var(--border-radius-lg);
    padding: 24px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-light);
    transition: box-shadow 0.2s;
}

.chart-container:hover {
    box-shadow: var(--shadow-md);
}

.chart-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.chart-header h3 {
    font-size: 1.25rem;
    color: var(--text-primary);
    font-weight: 600;
}

.chart-controls {
    display: flex;
    gap: 12px;
    align-items: center;
}

.chart-expand {
    background: none;
    border: none;
    font-size: 18px;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
    border-radius: var(--border-radius-sm);
    transition: background 0.2s;
}

.chart-expand:hover {
    background: var(--bg-gray-50);
}

/* Bar Chart */
.bar-chart {
    display: flex;
    align-items: end;
    justify-content: space-between;
    height: 250px;
    gap: 12px;
    padding: 20px 0;
}

.bar-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.bar {
    width: 100%;
    max-width: 40px;
    background: var(--bg-gray-100);
    border-radius: 4px 4px 0 0;
    transition: background 0.3s;
    min-height: 4px;
}

.bar.active {
    background: var(--primary-blue);
}

.bar-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-align: center;
}

/* Circular Progress */
.retention-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 20px;
}

.circular-progress {
    margin-bottom: 20px;
}

.retention-text {
    margin-bottom: 16px;
}

.retention-label {
    font-size: 0.875rem;
    color: var(--text-secondary);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 8px;
}

.retention-value {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--accent-teal);
}

.retention-description {
    color: var(--text-muted);
    font-size: 0.875rem;
    margin-bottom: 20px;
    max-width: 200px;
}

.view-details-btn {
    background: var(--accent-teal);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: var(--border-radius-md);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s;
}

.view-details-btn:hover {
    background: #0f766e;
}

/* Data Tables */
.data-tables {
    display: grid;
    gap: 24px;
}

.policy-table-container {
    background: var(--bg-white);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-light);
    overflow: hidden;
}

.table-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-light);
    background: var(--bg-gray-50);
}

.table-header h3 {
    font-size: 1.25rem;
    color: var(--text-primary);
    font-weight: 600;
}

.sort-dropdown {
    border: 1px solid var(--border-light);
    border-radius: var(--border-radius-sm);
    padding: 6px 12px;
    background: var(--bg-white);
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.table-content {
    padding: 0;
}

.table-row {
    display: flex;
    align-items: center;
    padding: 16px 24px;
    border-bottom: 1px solid var(--border-light);
    transition: background 0.2s;
}

.table-row:hover {
    background: var(--bg-gray-50);
}

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

.policy-icon {
    width: 40px;
    height: 40px;
    border-radius: var(--border-radius-md);
    background: var(--bg-gray-100);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 16px;
    font-size: 18px;
}

.policy-info {
    flex: 1;
    margin-right: 16px;
}

.policy-name {
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.policy-type {
    font-size: 0.875rem;
    color: var(--text-muted);
}

.policy-value {
    font-weight: 600;
    color: var(--text-primary);
    margin-right: 16px;
    min-width: 80px;
    text-align: right;
}

.policy-location {
    font-size: 0.875rem;
    color: var(--text-muted);
    min-width: 100px;
    text-align: right;
}

/* Responsive Design */
@media (max-width: 1024px) {
    .chart-row {
        grid-template-columns: 1fr;
    }
    
    .metrics-grid {
        grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    }
}

@media (max-width: 768px) {
    .sidebar {
        width: 60px;
        border-radius: 0;
    }
    
    .nav-item {
        width: 40px;
        height: 40px;
        font-size: 16px;
    }
    
    .dashboard-container {
        margin-left: 60px;
        padding: 16px;
    }
    
    .navbar {
        margin-left: 60px;
    }
    
    .metrics-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }
    
    .chart-row {
        gap: 16px;
    }
    
    .table-row {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }
    
    .policy-info {
        margin-right: 0;
    }
}

/* Mobile Navigation Styles */
.mobile-nav-toggle {
    display: none;
    position: fixed;
    top: 16px;
    left: 16px;
    z-index: 1001;
    background: var(--primary-blue);
    color: white;
    border: none;
    width: 48px;
    height: 48px;
    border-radius: 8px;
    font-size: 20px;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.mobile-nav-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 999;
}

.mobile-nav-menu {
    display: none;
    position: fixed;
    top: 0;
    left: -300px;
    width: 280px;
    height: 100%;
    background: white;
    z-index: 1000;
    padding: 20px 0;
    box-shadow: 4px 0 12px rgba(0,0,0,0.1);
    transition: left 0.3s ease;
}

.mobile-nav-menu.open {
    left: 0;
}

.mobile-nav-header {
    padding: 20px;
    border-bottom: 1px solid #e5e7eb;
    margin-bottom: 20px;
}

.mobile-nav-header h2 {
    margin: 0;
    color: var(--primary-blue);
    font-size: 24px;
    font-weight: 700;
}

.mobile-nav-item {
    display: block;
    padding: 16px 20px;
    color: #374151;
    text-decoration: none;
    font-weight: 500;
    border-bottom: 1px solid #f3f4f6;
    transition: background 0.2s;
}

.mobile-nav-item:hover,
.mobile-nav-item.active {
    background: #f8fafc;
    color: var(--primary-blue);
}

.mobile-nav-item.logout {
    color: #dc2626;
    border-top: 1px solid #e5e7eb;
    margin-top: 20px;
}

/* Tablet responsiveness */
@media (max-width: 1024px) and (min-width: 769px) {
    .navbar nav {
        gap: 12px;
    }
    
    .navbar nav a {
        padding: 6px 12px;
        font-size: 14px;
    }
    
    .navbar .container {
        padding: 0 16px;
    }
    
    .navbar h1 {
        font-size: 1.5em;
    }
}

@media (max-width: 768px) {
    .dashboard-container {
        margin-left: 0;
        padding: 12px;
        padding-top: 80px; /* Space for mobile nav button */
    }
    
    .navbar {
        display: none !important; /* Hide desktop navbar on mobile */
    }
    
    .sidebar {
        display: none;
    }
    
    .mobile-nav-toggle {
        display: block;
    }
    
    .mobile-nav-overlay.show {
        display: block;
    }
    
    .mobile-nav-menu.show {
        display: block;
    }
    
    .container {
        padding: 12px;
    }
    
    /* Prevent horizontal scroll */
    body {
        overflow-x: hidden;
    }
    
    /* Stack grid items on mobile */
    .grid {
        grid-template-columns: 1fr !important;
        gap: 16px;
    }
    
    .grid-2, .grid-3, .grid-4 {
        grid-template-columns: 1fr !important;
    }
}

/* Hide mobile navigation on desktop */
@media (min-width: 769px) {
    .mobile-nav-menu,
    .mobile-nav-overlay,
    .mobile-nav-toggle {
        display: none !important;
    }
}
    
    .metric-card {
        padding: 16px;
    }
    
    .chart-container {
        padding: 16px;
    }
}