/* ===========================================
   Medina Metrics - Tailwind Design System
   Matches React frontend exactly
   =========================================== */

/* ========================================
   CSS Variables / Design Tokens
   ======================================== */
:root {
    --background: 220 20% 97%;
    --foreground: 220 15% 15%;
    --card: 0 0% 100%;
    --card-foreground: 220 15% 15%;
    --popover: 0 0% 100%;
    --popover-foreground: 220 15% 15%;
    --primary: 21 93% 58%;
    --primary-foreground: 0 0% 100%;
    --secondary: 0 0% 11%;
    --secondary-foreground: 0 0% 100%;
    --muted: 220 15% 96%;
    --muted-foreground: 220 10% 45%;
    --accent: 142 76% 45%;
    --accent-foreground: 0 0% 100%;
    --destructive: 0 84% 60%;
    --destructive-foreground: 0 0% 100%;
    --border: 220 15% 90%;
    --input: 220 15% 90%;
    --ring: 21 93% 58%;
    --radius: 0.75rem;

    --success: 142 76% 45%;
    --success-foreground: 0 0% 100%;
    --warning: 38 92% 50%;
    --warning-foreground: 0 0% 100%;
    --info: 199 89% 48%;
    --info-foreground: 0 0% 100%;

    --sidebar-background: 0 0% 11%;
    --sidebar-foreground: 0 0% 90%;
    --sidebar-primary: 21 93% 58%;
    --sidebar-primary-foreground: 0 0% 100%;
    --sidebar-accent: 0 0% 15%;
    --sidebar-accent-foreground: 0 0% 90%;
    --sidebar-border: 0 0% 20%;

    --chart-1: 21 93% 58%;
    --chart-2: 142 76% 45%;
    --chart-3: 38 92% 50%;
    --chart-4: 280 87% 65%;
    --chart-5: 340 82% 52%;

    --sidebar-width: 260px;
    --sidebar-collapsed-width: 56px;
}

html.dark {
    --background: 220 25% 8%;
    --foreground: 220 15% 90%;
    --card: 220 25% 10%;
    --card-foreground: 220 15% 90%;
    --popover: 220 25% 10%;
    --popover-foreground: 220 15% 90%;
    --primary: 21 93% 58%;
    --primary-foreground: 0 0% 100%;
    --secondary: 0 0% 15%;
    --secondary-foreground: 0 0% 95%;
    --muted: 220 20% 15%;
    --muted-foreground: 220 15% 60%;
    --accent: 142 76% 50%;
    --accent-foreground: 0 0% 100%;
    --destructive: 0 72% 50%;
    --destructive-foreground: 0 0% 100%;
    --border: 220 20% 18%;
    --input: 220 20% 18%;
    --ring: 21 93% 58%;

    --success: 142 76% 50%;
    --warning: 38 92% 60%;
    --info: 199 89% 55%;

    --sidebar-background: 0 0% 6%;
    --sidebar-foreground: 0 0% 85%;
    --sidebar-accent: 0 0% 12%;
    --sidebar-accent-foreground: 0 0% 85%;
    --sidebar-border: 0 0% 15%;
}

/* ========================================
   Base Styles
   ======================================== */
*, *::before, *::after {
    box-sizing: border-box;
    border-color: hsl(var(--border));
}

body {
    background-color: hsl(var(--background));
    color: hsl(var(--foreground));
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    margin: 0;
    min-height: 100vh;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

a { color: hsl(var(--primary)); text-decoration: none; }
a:hover { text-decoration: underline; }

hr {
    border: 0;
    border-top: 1px solid hsl(var(--border));
    margin: 16px 0;
}

code {
    background-color: hsl(var(--muted));
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 13px;
    color: hsl(var(--foreground));
}

strong, b { font-weight: 600; }

h1, h2, h3, h4, h5, h6 {
    color: hsl(var(--foreground));
    margin-top: 0;
    line-height: 1.3;
}

h1.h3, .h3 { font-size: 24px; font-weight: 700; }
h2.h5, .h5 { font-size: 16px; font-weight: 600; }
h6 { font-size: 14px; font-weight: 600; margin-bottom: 8px; }

small, .small { font-size: 12px; }

/* ========================================
   Bootstrap Grid System (Compat)
   ======================================== */
.container-fluid {
    width: 100%;
    padding-left: 16px;
    padding-right: 16px;
}

.row {
    display: flex;
    flex-wrap: wrap;
    margin-left: -8px;
    margin-right: -8px;
}

.row.g-3 { margin-left: -6px; margin-right: -6px; }
.row.g-3 > [class*="col"] { padding-left: 6px; padding-right: 6px; margin-bottom: 12px; }
.row.g-4 { margin-left: -12px; margin-right: -12px; }
.row.g-4 > [class*="col"] { padding-left: 12px; padding-right: 12px; margin-bottom: 24px; }

[class*="col"] {
    padding-left: 8px;
    padding-right: 8px;
    width: 100%;
}

.col { flex: 1 0 0; }
.col-12 { width: 100%; flex: 0 0 100%; }

@media (min-width: 576px) {
    .col-sm-4 { flex: 0 0 33.333%; max-width: 33.333%; }
    .col-sm-6 { flex: 0 0 50%; max-width: 50%; }
}

@media (min-width: 768px) {
    .col-md-2 { flex: 0 0 16.666%; max-width: 16.666%; }
    .col-md-3 { flex: 0 0 25%; max-width: 25%; }
    .col-md-4 { flex: 0 0 33.333%; max-width: 33.333%; }
    .col-md-5 { flex: 0 0 41.666%; max-width: 41.666%; }
    .col-md-6 { flex: 0 0 50%; max-width: 50%; }
    .col-md-8 { flex: 0 0 66.666%; max-width: 66.666%; }
    .col-md-9 { flex: 0 0 75%; max-width: 75%; }
}

@media (min-width: 1024px) {
    .col-lg { flex: 1 0 0; }
}

@media (min-width: 1280px) {
    .col-xl-4 { flex: 0 0 33.333%; max-width: 33.333%; }
}

/* ========================================
   Sidebar
   ======================================== */
.sidebar {
    width: var(--sidebar-width);
    min-height: 100vh;
    background-color: hsl(var(--sidebar-background));
    color: hsl(var(--sidebar-foreground));
    position: sticky;
    top: 0;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    transition: width 0.2s ease;
    z-index: 40;
    border-right: 1px solid hsl(var(--sidebar-border));
}

.sidebar-header {
    height: 64px;
    display: flex;
    align-items: center;
    padding: 0 16px;
    gap: 12px;
    border-bottom: 1px solid hsl(var(--sidebar-border));
    cursor: pointer;
    transition: background-color 0.15s;
}

.sidebar-header:hover {
    background-color: hsl(var(--sidebar-accent) / 0.5);
}

.sidebar-logo-icon {
    width: 32px;
    height: 32px;
    background: linear-gradient(135deg, hsl(var(--sidebar-primary)), hsl(var(--sidebar-primary) / 0.8));
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.sidebar-logo-icon svg {
    width: 16px;
    height: 16px;
    color: hsl(var(--sidebar-primary-foreground));
}

.sidebar-brand h1 {
    font-size: 16px;
    font-weight: 700;
    color: hsl(var(--sidebar-foreground));
    margin: 0;
    line-height: 1.2;
}

.sidebar-brand p {
    font-size: 12px;
    color: hsl(var(--sidebar-foreground) / 0.6);
    margin: 0;
}

.sidebar-label {
    font-size: 12px;
    font-weight: 500;
    color: hsl(var(--sidebar-foreground) / 0.5);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 16px 16px 8px;
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 4px 8px;
}

.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 12px;
    border-radius: 6px;
    color: hsl(var(--sidebar-foreground));
    text-decoration: none;
    font-size: 14px;
    transition: all 0.15s;
}

.sidebar-nav a:hover {
    background-color: hsl(var(--sidebar-accent));
    color: hsl(var(--sidebar-accent-foreground));
}

.sidebar-nav a.active {
    background-color: hsl(var(--sidebar-accent));
    color: hsl(var(--sidebar-primary));
    font-weight: 500;
}

.sidebar-nav a svg,
.sidebar-nav a i {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    font-size: 16px;
}

.sidebar-divider {
    height: 1px;
    background-color: hsl(var(--sidebar-border));
    margin: 8px 12px;
}

.sidebar-footer {
    padding: 8px;
    border-top: 1px solid hsl(var(--sidebar-border));
}

.sidebar-footer a,
.sidebar-footer button {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 12px;
    border-radius: 6px;
    color: hsl(var(--sidebar-foreground));
    text-decoration: none;
    font-size: 14px;
    background: none;
    border: none;
    width: 100%;
    cursor: pointer;
    transition: all 0.15s;
}

.sidebar-footer a:hover,
.sidebar-footer button:hover {
    background-color: hsl(var(--sidebar-accent));
}

/* ========================================
   Main Layout
   ======================================== */
.app-layout {
    display: flex;
    min-height: 100vh;
    width: 100%;
}

.main-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    overflow-x: hidden;
}

.top-header {
    height: 56px;
    display: flex;
    align-items: center;
    padding: 0 16px;
    border-bottom: 1px solid hsl(var(--border));
    background-color: hsl(var(--background));
    position: sticky;
    top: 0;
    z-index: 10;
    gap: 8px;
}

.top-header-actions {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 8px;
}

.main-content {
    flex: 1;
    padding: 24px;
}

.app-footer {
    border-top: 1px solid hsl(var(--border));
    padding: 8px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.app-footer p {
    font-size: 12px;
    color: hsl(var(--muted-foreground));
    margin: 0;
}

.app-footer a {
    color: hsl(var(--primary));
    text-decoration: none;
}

.app-footer a:hover {
    text-decoration: underline;
}

/* ========================================
   Card Component
   ======================================== */
.card {
    background-color: hsl(var(--card));
    color: hsl(var(--card-foreground));
    border-radius: var(--radius);
    border: 1px solid hsl(var(--border));
    box-shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1);
}

.card-header {
    padding: 16px 24px;
    border-bottom: 1px solid hsl(var(--border));
}

.card-header h2,
.card-header h3,
.card-header h5,
.card-header h6 {
    margin: 0;
    font-weight: 600;
}

.card-body {
    padding: 24px;
}

.card-body.p-0 {
    padding: 0;
}

.card-body.p-2 {
    padding: 8px;
}

.card-footer {
    padding: 16px 24px;
    border-top: 1px solid hsl(var(--border));
}

.card-title {
    font-size: 16px;
    font-weight: 600;
    margin: 0;
}

.card-subtitle {
    font-size: 14px;
    color: hsl(var(--muted-foreground));
}

.card-description {
    font-size: 14px;
    color: hsl(var(--muted-foreground));
    margin-top: 4px;
}

.card-text {
    margin: 0;
}

.card-img-top {
    border-radius: var(--radius) var(--radius) 0 0;
    width: 100%;
    object-fit: cover;
}

.card.h-100 { height: 100%; }
.card.border-primary { border-color: hsl(var(--primary)); }
.card.border-success { border-color: hsl(var(--success)); }
.card.border-warning { border-color: hsl(var(--warning)); }
.card.border-info { border-color: hsl(var(--info)); }
.card.border-danger { border-color: hsl(var(--destructive)); }
.card.border-secondary { border-color: hsl(var(--muted-foreground) / 0.3); }

/* ========================================
   Buttons
   ======================================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border-radius: calc(var(--radius) - 2px);
    font-size: 14px;
    font-weight: 500;
    padding: 8px 16px;
    cursor: pointer;
    border: 1px solid transparent;
    transition: all 0.15s;
    text-decoration: none;
    line-height: 1.5;
    white-space: nowrap;
    color: hsl(var(--foreground));
}

.btn:hover { text-decoration: none; }
.btn:disabled { opacity: 0.5; pointer-events: none; }

.btn-primary {
    background-color: hsl(var(--primary));
    color: hsl(var(--primary-foreground));
}
.btn-primary:hover {
    background-color: hsl(var(--primary) / 0.9);
    color: hsl(var(--primary-foreground));
}

.btn-secondary {
    background-color: hsl(var(--secondary));
    color: hsl(var(--secondary-foreground));
}

.btn-success {
    background-color: hsl(var(--success));
    color: hsl(var(--success-foreground));
}
.btn-success:hover {
    background-color: hsl(var(--success) / 0.9);
    color: hsl(var(--success-foreground));
}

.btn-info {
    background-color: hsl(var(--info));
    color: hsl(var(--info-foreground));
}

.btn-warning {
    background-color: hsl(var(--warning));
    color: hsl(var(--warning-foreground));
}

.btn-danger {
    background-color: hsl(var(--destructive));
    color: hsl(var(--destructive-foreground));
}

.btn-light {
    background-color: hsl(var(--card));
    color: hsl(var(--foreground));
    border: 1px solid hsl(var(--border));
}

.btn-outline, .btn-outline-secondary {
    border: 1px solid hsl(var(--border));
    background: transparent;
    color: hsl(var(--foreground));
}
.btn-outline:hover, .btn-outline-secondary:hover {
    background-color: hsl(var(--muted));
    color: hsl(var(--foreground));
}

.btn-outline-primary {
    border: 1px solid hsl(var(--primary));
    background: transparent;
    color: hsl(var(--primary));
}
.btn-outline-primary:hover {
    background-color: hsl(var(--primary));
    color: hsl(var(--primary-foreground));
}

.btn-outline-success {
    border: 1px solid hsl(var(--success));
    background: transparent;
    color: hsl(var(--success));
}
.btn-outline-success:hover {
    background-color: hsl(var(--success));
    color: hsl(var(--success-foreground));
}

.btn-outline-danger {
    border: 1px solid hsl(var(--destructive));
    background: transparent;
    color: hsl(var(--destructive));
}
.btn-outline-danger:hover {
    background-color: hsl(var(--destructive));
    color: hsl(var(--destructive-foreground));
}

.btn-outline-warning {
    border: 1px solid hsl(var(--warning));
    background: transparent;
    color: hsl(var(--warning));
}
.btn-outline-warning:hover {
    background-color: hsl(var(--warning));
    color: hsl(var(--warning-foreground));
}

.btn-ghost {
    background: transparent;
    color: hsl(var(--foreground));
    border: none;
}
.btn-ghost:hover {
    background-color: hsl(var(--muted));
}

.btn-destructive {
    background-color: hsl(var(--destructive));
    color: hsl(var(--destructive-foreground));
}

.btn-close {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 18px;
    color: hsl(var(--muted-foreground));
    opacity: 0.6;
    padding: 4px;
    line-height: 1;
}
.btn-close:hover { opacity: 1; }

.btn-sm {
    font-size: 12px;
    padding: 4px 12px;
}

.btn-lg {
    font-size: 16px;
    padding: 12px 24px;
}

.btn-icon {
    width: 36px;
    height: 36px;
    padding: 0;
    border-radius: calc(var(--radius) - 2px);
}

.btn-group {
    display: inline-flex;
    gap: 0;
}
.btn-group .btn {
    border-radius: 0;
}
.btn-group .btn:first-child {
    border-radius: calc(var(--radius) - 2px) 0 0 calc(var(--radius) - 2px);
}
.btn-group .btn:last-child,
.btn-group form:last-child .btn {
    border-radius: 0 calc(var(--radius) - 2px) calc(var(--radius) - 2px) 0;
}
.btn-group-sm .btn { font-size: 12px; padding: 4px 10px; }

.btn.w-100 { width: 100%; }

/* ========================================
   Form Controls
   ======================================== */
.form-label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 6px;
    color: hsl(var(--foreground));
}

.form-control,
.form-select {
    width: 100%;
    padding: 8px 12px;
    font-size: 14px;
    border: 1px solid hsl(var(--input));
    border-radius: calc(var(--radius) - 2px);
    background-color: hsl(var(--background));
    color: hsl(var(--foreground));
    transition: border-color 0.15s, box-shadow 0.15s;
    outline: none;
    font-family: inherit;
}

.form-control:focus,
.form-select:focus {
    border-color: hsl(var(--ring));
    box-shadow: 0 0 0 2px hsl(var(--ring) / 0.2);
}

.form-control::placeholder {
    color: hsl(var(--muted-foreground));
}

.form-control-sm {
    padding: 4px 8px;
    font-size: 13px;
}

.form-control-lg {
    padding: 12px 16px;
    font-size: 18px;
}

textarea.form-control {
    resize: vertical;
    min-height: 60px;
}

/* Input Group */
.input-group {
    display: flex;
    gap: 0;
}
.input-group .form-control {
    border-radius: calc(var(--radius) - 2px) 0 0 calc(var(--radius) - 2px);
    flex: 1;
}
.input-group .btn {
    border-radius: 0 calc(var(--radius) - 2px) calc(var(--radius) - 2px) 0;
}

/* Form Check / Switch */
.form-check {
    display: flex;
    align-items: center;
    gap: 8px;
}

.form-check-input {
    width: 16px;
    height: 16px;
    accent-color: hsl(var(--primary));
    cursor: pointer;
}

.form-check-label {
    font-size: 14px;
    cursor: pointer;
    user-select: none;
}

.form-check.form-switch {
    position: relative;
}

.form-switch .form-check-input {
    width: 36px;
    height: 20px;
    appearance: none;
    -webkit-appearance: none;
    background-color: hsl(var(--muted));
    border-radius: 12px;
    position: relative;
    cursor: pointer;
    transition: background-color 0.2s;
    border: 1px solid hsl(var(--border));
}

.form-switch .form-check-input::before {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background-color: white;
    top: 1px;
    left: 1px;
    transition: transform 0.2s;
    box-shadow: 0 1px 2px rgb(0 0 0 / 0.2);
}

.form-switch .form-check-input:checked {
    background-color: hsl(var(--primary));
    border-color: hsl(var(--primary));
}

.form-switch .form-check-input:checked::before {
    transform: translateX(16px);
}

/* ========================================
   Tables
   ======================================== */
.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

table, .table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

table th, .table th {
    font-weight: 500;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: hsl(var(--muted-foreground));
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid hsl(var(--border));
    white-space: nowrap;
}

table td, .table td {
    padding: 12px 16px;
    border-bottom: 1px solid hsl(var(--border));
    color: hsl(var(--foreground));
    vertical-align: middle;
}

table.table-sm th,
table.table-sm td {
    padding: 8px 12px;
}

table.table-hover tbody tr:hover,
.table-hover tbody tr:hover {
    background-color: hsl(var(--muted) / 0.5);
}

table tbody tr:last-child td {
    border-bottom: none;
}

.table-light, thead.table-light {
    background-color: hsl(var(--muted) / 0.5);
}

thead.sticky-top {
    position: sticky;
    top: 0;
    z-index: 1;
    background-color: hsl(var(--card));
}

tfoot {
    font-weight: 600;
}

tfoot td {
    border-top: 2px solid hsl(var(--border));
}

/* ========================================
   Badge
   ======================================== */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 10px;
    border-radius: 9999px;
    font-size: 12px;
    font-weight: 500;
    line-height: 1.5;
}

.bg-primary { background-color: hsl(var(--primary)); color: hsl(var(--primary-foreground)); }
.bg-success { background-color: hsl(var(--success)); color: hsl(var(--success-foreground)); }
.bg-warning { background-color: hsl(var(--warning)); color: hsl(var(--warning-foreground)); }
.bg-danger { background-color: hsl(var(--destructive)); color: hsl(var(--destructive-foreground)); }
.bg-info { background-color: hsl(var(--info)); color: hsl(var(--info-foreground)); }
.bg-secondary { background-color: hsl(var(--muted)); color: hsl(var(--muted-foreground)); }
.bg-dark { background-color: hsl(var(--secondary)); color: hsl(var(--secondary-foreground)); }
.bg-light { background-color: hsl(var(--muted)); color: hsl(var(--foreground)); }

.badge.bg-primary { background-color: hsl(var(--primary) / 0.15); color: hsl(var(--primary)); }
.badge.bg-success { background-color: hsl(var(--success) / 0.15); color: hsl(var(--success)); }
.badge.bg-warning { background-color: hsl(var(--warning) / 0.15); color: hsl(var(--warning)); }
.badge.bg-danger { background-color: hsl(var(--destructive) / 0.15); color: hsl(var(--destructive)); }
.badge.bg-info { background-color: hsl(var(--info) / 0.15); color: hsl(var(--info)); }
.badge.bg-secondary { background-color: hsl(var(--muted)); color: hsl(var(--muted-foreground)); }
.badge.bg-dark { background-color: hsl(var(--secondary)); color: hsl(var(--secondary-foreground)); }
.badge.bg-light { background-color: hsl(var(--muted)); color: hsl(var(--foreground)); }

.badge.text-dark { color: hsl(var(--foreground)); }

.badge.fs-5 { font-size: 16px; padding: 4px 14px; }
.badge.fs-6 { font-size: 14px; padding: 3px 12px; }

/* Opacity variants for cards */
.bg-warning.bg-opacity-10 { background-color: hsl(var(--warning) / 0.1) !important; color: hsl(var(--foreground)); }
.bg-primary.bg-opacity-10 { background-color: hsl(var(--primary) / 0.1) !important; color: hsl(var(--foreground)); }
.bg-info.bg-opacity-10 { background-color: hsl(var(--info) / 0.1) !important; color: hsl(var(--foreground)); }
.bg-success.bg-opacity-10 { background-color: hsl(var(--success) / 0.1) !important; color: hsl(var(--foreground)); }
.bg-secondary.bg-opacity-10 { background-color: hsl(var(--muted-foreground) / 0.1) !important; color: hsl(var(--foreground)); }
.bg-opacity-25 { opacity: 0.85; }

.border-warning { border-color: hsl(var(--warning)) !important; }
.border-primary { border-color: hsl(var(--primary)) !important; }
.border-info { border-color: hsl(var(--info)) !important; }
.border-success { border-color: hsl(var(--success)) !important; }
.border-secondary { border-color: hsl(var(--muted-foreground) / 0.3) !important; }

/* ========================================
   Metric Card
   ======================================== */
.metric-card {
    display: flex;
    align-items: center;
    gap: 16px;
}

.metric-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.metric-icon.primary { background-color: hsl(var(--primary) / 0.1); color: hsl(var(--primary)); }
.metric-icon.success { background-color: hsl(var(--success) / 0.1); color: hsl(var(--success)); }
.metric-icon.warning { background-color: hsl(var(--warning) / 0.1); color: hsl(var(--warning)); }
.metric-icon.info { background-color: hsl(var(--info) / 0.1); color: hsl(var(--info)); }
.metric-icon.destructive { background-color: hsl(var(--destructive) / 0.1); color: hsl(var(--destructive)); }

.metric-label { font-size: 14px; color: hsl(var(--muted-foreground)); margin: 0; }
.metric-value { font-size: 24px; font-weight: 700; margin: 0; line-height: 1.2; }
.metric-change {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    font-weight: 500;
    padding: 2px 8px;
    border-radius: 9999px;
}

.metric-change.positive { background-color: hsl(var(--success) / 0.1); color: hsl(var(--success)); }
.metric-change.negative { background-color: hsl(var(--destructive) / 0.1); color: hsl(var(--destructive)); }
.metric-subtext { font-size: 12px; color: hsl(var(--muted-foreground)); margin-left: 8px; }

/* ========================================
   Alerts / Flash Messages
   ======================================== */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius);
    margin-bottom: 16px;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.alert-success {
    background-color: hsl(var(--success) / 0.1);
    color: hsl(var(--success));
    border: 1px solid hsl(var(--success) / 0.2);
}

.alert-danger, .alert-error {
    background-color: hsl(var(--destructive) / 0.1);
    color: hsl(var(--destructive));
    border: 1px solid hsl(var(--destructive) / 0.2);
}

.alert-warning {
    background-color: hsl(var(--warning) / 0.1);
    color: hsl(var(--warning));
    border: 1px solid hsl(var(--warning) / 0.2);
}

.alert-info {
    background-color: hsl(var(--info) / 0.1);
    color: hsl(var(--info));
    border: 1px solid hsl(var(--info) / 0.2);
}

.alert .btn-close {
    margin-left: auto;
}

.alert-dismissible { position: relative; }

/* ========================================
   Modal
   ======================================== */
.modal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 1050;
    align-items: center;
    justify-content: center;
}

.modal.show,
.modal[style*="display: block"] {
    display: flex !important;
}

.modal::before {
    content: '';
    position: fixed;
    inset: 0;
    background: rgb(0 0 0 / 0.5);
}

.modal-dialog {
    position: relative;
    width: 100%;
    max-width: 500px;
    margin: 16px;
    z-index: 1;
}

.modal-dialog.modal-sm { max-width: 350px; }
.modal-dialog.modal-lg { max-width: 700px; }

.modal-content {
    background-color: hsl(var(--card));
    border-radius: var(--radius);
    border: 1px solid hsl(var(--border));
    box-shadow: 0 20px 25px -5px rgb(0 0 0 / 0.1);
}

.modal-header {
    padding: 16px 24px;
    border-bottom: 1px solid hsl(var(--border));
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-title {
    font-size: 18px;
    font-weight: 600;
    margin: 0;
}

.modal-body {
    padding: 24px;
}

.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid hsl(var(--border));
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

/* ========================================
   List Group
   ======================================== */
.list-group {
    display: flex;
    flex-direction: column;
    border-radius: var(--radius);
    border: 1px solid hsl(var(--border));
    overflow: hidden;
}

.list-group-flush {
    border: none;
    border-radius: 0;
}

.list-group-item {
    padding: 12px 16px;
    border-bottom: 1px solid hsl(var(--border));
    background-color: hsl(var(--card));
    color: hsl(var(--foreground));
    text-decoration: none;
    display: block;
}

.list-group-item:last-child {
    border-bottom: none;
}

.list-group-item-action {
    cursor: pointer;
    transition: background-color 0.15s;
    display: flex;
    align-items: center;
    gap: 8px;
}

.list-group-item-action:hover {
    background-color: hsl(var(--muted));
    text-decoration: none;
}

.list-group-item-action.active {
    background-color: hsl(var(--primary) / 0.1);
    color: hsl(var(--primary));
    font-weight: 500;
}

.list-group-item.px-0 { padding-left: 0; padding-right: 0; }

/* ========================================
   Pagination
   ======================================== */
.pagination {
    display: flex;
    list-style: none;
    padding: 0;
    margin: 0;
    gap: 4px;
}

.page-item { display: inline-block; }

.page-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 6px 12px;
    font-size: 14px;
    border: 1px solid hsl(var(--border));
    border-radius: calc(var(--radius) - 2px);
    color: hsl(var(--foreground));
    text-decoration: none;
    background-color: hsl(var(--card));
    transition: all 0.15s;
    min-width: 36px;
}

.page-link:hover {
    background-color: hsl(var(--muted));
    text-decoration: none;
}

.page-item.active .page-link {
    background-color: hsl(var(--primary));
    color: hsl(var(--primary-foreground));
    border-color: hsl(var(--primary));
}

.page-item.disabled .page-link {
    opacity: 0.5;
    pointer-events: none;
}

/* ========================================
   Nav Pills (Tabs)
   ======================================== */
.nav {
    display: flex;
    list-style: none;
    padding: 0;
    margin: 0;
}

.nav-pills {
    gap: 4px;
}

.nav-item { display: inline-block; }

.nav-link {
    display: inline-flex;
    align-items: center;
    padding: 6px 16px;
    font-size: 14px;
    border-radius: calc(var(--radius) - 2px);
    color: hsl(var(--foreground));
    text-decoration: none;
    transition: all 0.15s;
    cursor: pointer;
}

.nav-link:hover {
    background-color: hsl(var(--muted));
    text-decoration: none;
}

.nav-link.active {
    background-color: hsl(var(--primary));
    color: hsl(var(--primary-foreground));
}

/* ========================================
   Progress Bar
   ======================================== */
.progress {
    width: 100%;
    height: 8px;
    border-radius: 9999px;
    background-color: hsl(var(--muted));
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    border-radius: 9999px;
    transition: width 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 600;
    color: white;
}

.progress-bar.bg-success { background-color: hsl(var(--success)); }
.progress-bar.bg-warning { background-color: hsl(var(--warning)); }
.progress-bar.bg-danger { background-color: hsl(var(--destructive)); }
.progress-bar.bg-primary { background-color: hsl(var(--primary)); }
.progress-bar.bg-info { background-color: hsl(var(--info)); }

/* ========================================
   Dropdown
   ======================================== */
.dropdown {
    position: relative;
    display: inline-block;
}

.dropdown-menu {
    position: absolute;
    right: 0;
    top: 100%;
    min-width: 200px;
    background-color: hsl(var(--popover));
    color: hsl(var(--popover-foreground));
    border: 1px solid hsl(var(--border));
    border-radius: var(--radius);
    box-shadow: 0 10px 15px -3px rgb(0 0 0 / 0.1);
    padding: 4px;
    z-index: 50;
    display: none;
}

.dropdown-menu.show {
    display: block;
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    font-size: 14px;
    color: hsl(var(--foreground));
    text-decoration: none;
    border-radius: calc(var(--radius) - 4px);
    cursor: pointer;
    border: none;
    background: none;
    width: 100%;
}

.dropdown-item:hover {
    background-color: hsl(var(--muted));
    text-decoration: none;
}

.dropdown-divider {
    height: 1px;
    background-color: hsl(var(--border));
    margin: 4px 0;
}

/* ========================================
   Avatar
   ======================================== */
.avatar {
    width: 36px;
    height: 36px;
    border-radius: 9999px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 14px;
    flex-shrink: 0;
    cursor: pointer;
}

.avatar-sm { width: 32px; height: 32px; font-size: 12px; }

.avatar-primary {
    background-color: hsl(var(--primary));
    color: hsl(var(--primary-foreground));
}

.avatar-muted {
    background-color: hsl(var(--muted));
    color: hsl(var(--muted-foreground));
}

.avatar-initial {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: inherit;
    font-weight: 600;
    color: hsl(var(--primary-foreground));
}

.rounded-circle { border-radius: 9999px !important; }
.bg-info .avatar-initial { color: white; }

/* ========================================
   Auth Page
   ======================================== */
.auth-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    background: linear-gradient(135deg, hsl(var(--primary) / 0.1), hsl(var(--background)), hsl(var(--accent) / 0.1));
}

.auth-card {
    width: 100%;
    max-width: 420px;
}

.auth-card .card {
    box-shadow: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
}

.auth-logo-icon {
    width: 64px;
    height: 64px;
    margin: 0 auto 16px;
    background: linear-gradient(135deg, hsl(var(--primary)), hsl(var(--primary) / 0.8));
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px hsl(var(--primary) / 0.3);
}

.auth-logo-icon svg,
.auth-logo-icon i {
    width: 32px;
    height: 32px;
    font-size: 32px;
    color: hsl(var(--primary-foreground));
}

.auth-title { font-size: 30px; font-weight: 700; text-align: center; margin: 0; }
.auth-description { font-size: 16px; color: hsl(var(--muted-foreground)); text-align: center; margin-top: 8px; }
.auth-footer { text-align: center; margin-top: 16px; font-size: 14px; color: hsl(var(--muted-foreground)); }

/* ========================================
   Kanban Board
   ======================================== */
.kanban-grid {
    display: grid;
    grid-template-columns: repeat(1, 1fr);
    gap: 16px;
}

@media (min-width: 768px) {
    .kanban-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (min-width: 1024px) {
    .kanban-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (min-width: 1280px) {
    .kanban-grid {
        grid-template-columns: repeat(5, 1fr);
    }
}

.kanban-col {
    display: flex;
    flex-direction: column;
}

.kanban-col-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px !important;
    background-color: transparent !important;
    border-bottom: 1px solid hsl(var(--border)) !important;
}

.kanban-col-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 15px;
}

.badge-outline {
    display: inline-flex;
    align-items: center;
    padding: 2px 10px;
    border-radius: 9999px;
    font-size: 12px;
    font-weight: 500;
    border: 1px solid hsl(var(--border));
    background: transparent;
    color: hsl(var(--foreground));
}

.kanban-scroll {
    overflow-y: auto;
    max-height: calc(100vh - 280px);
    min-height: 200px;
    padding: 12px !important;
}

.kanban-card {
    background-color: hsl(var(--card));
    border: 1px solid hsl(var(--border));
    border-radius: calc(var(--radius) - 2px);
    cursor: grab;
    transition: box-shadow 0.15s, transform 0.15s;
}

.kanban-card:hover {
    box-shadow: 0 4px 12px rgb(0 0 0 / 0.1);
    transform: translateY(-1px);
}

.kanban-card:active { cursor: grabbing; }

.kanban-card-alert {
    border-radius: calc(var(--radius) - 4px);
    border: 1px solid hsl(var(--warning) / 0.5);
    background-color: hsl(var(--warning) / 0.1);
    padding: 8px;
    color: hsl(var(--warning));
}

.kanban-column {
    background-color: hsl(var(--muted) / 0.3);
    border-radius: 0 0 var(--radius) var(--radius);
}

.opacity-50 { opacity: 0.5; }

/* ========================================
   Charts
   ======================================== */
canvas { max-width: 100%; }

/* ========================================
   Toast / showToast helper
   ======================================== */
.toast-container {
    position: fixed;
    top: 16px;
    right: 16px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    padding: 12px 20px;
    border-radius: var(--radius);
    font-size: 14px;
    animation: fadeIn 0.3s ease-out;
    box-shadow: 0 10px 15px -3px rgb(0 0 0 / 0.1);
    max-width: 400px;
}

/* ========================================
   Utility Classes
   ======================================== */
/* Text Colors */
.text-muted { color: hsl(var(--muted-foreground)) !important; }
.text-primary { color: hsl(var(--primary)) !important; }
.text-success { color: hsl(var(--success)) !important; }
.text-warning { color: hsl(var(--warning)) !important; }
.text-danger, .text-destructive { color: hsl(var(--destructive)) !important; }
.text-info { color: hsl(var(--info)) !important; }
.text-secondary { color: hsl(var(--muted-foreground)) !important; }
.text-white { color: white !important; }
.text-white-50 { color: rgb(255 255 255 / 0.5) !important; }
.text-dark { color: hsl(var(--foreground)) !important; }
.text-dark-50 { color: hsl(var(--foreground) / 0.5) !important; }

/* Text */
.text-center { text-align: center !important; }
.text-end { text-align: right !important; }
.text-start { text-align: left !important; }
.text-sm { font-size: 14px; }
.text-xs { font-size: 12px; }
.text-lg { font-size: 18px; }
.text-xl { font-size: 20px; }
.text-2xl { font-size: 24px; }
.text-3xl { font-size: 30px; }
.text-truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.text-decoration-none { text-decoration: none !important; }
.font-medium { font-weight: 500; }
.font-semibold { font-weight: 600; }
.font-bold, .fw-bold { font-weight: 700 !important; }
.fw-bold { font-weight: 700 !important; }
.fs-1 { font-size: 2.5rem; }
.fs-3 { font-size: 1.75rem; }
.fs-5 { font-size: 1.25rem; }
.fs-6 { font-size: 1rem; }
.opacity-75 { opacity: 0.75; }

/* Backgrounds */
.bg-transparent { background-color: transparent !important; }
.bg-muted { background-color: hsl(var(--muted)); }
.bg-card { background-color: hsl(var(--card)); }

/* Margins */
.mb-0 { margin-bottom: 0 !important; }
.mb-1 { margin-bottom: 4px !important; }
.mb-2 { margin-bottom: 8px !important; }
.mb-3 { margin-bottom: 12px !important; }
.mb-4 { margin-bottom: 16px !important; }
.mb-6 { margin-bottom: 24px !important; }
.mt-0 { margin-top: 0 !important; }
.mt-1 { margin-top: 4px !important; }
.mt-2 { margin-top: 8px !important; }
.mt-3 { margin-top: 12px !important; }
.mt-4 { margin-top: 16px !important; }
.me-1 { margin-right: 4px !important; }
.me-2 { margin-right: 8px !important; }
.me-3 { margin-right: 12px !important; }
.ms-1 { margin-left: 4px !important; }
.ms-2 { margin-left: 8px !important; }
.ms-3 { margin-left: 12px !important; }
.ms-auto { margin-left: auto !important; }
.ml-auto { margin-left: auto; }
.mr-2 { margin-right: 8px; }
.my-0 { margin-top: 0 !important; margin-bottom: 0 !important; }

/* Padding */
.p-0 { padding: 0 !important; }
.p-2 { padding: 8px !important; }
.p-3 { padding: 12px !important; }
.p-4 { padding: 16px !important; }
.p-6 { padding: 24px !important; }
.px-0 { padding-left: 0 !important; padding-right: 0 !important; }
.px-4 { padding-left: 16px; padding-right: 16px; }
.py-2 { padding-top: 8px !important; padding-bottom: 8px !important; }
.py-3 { padding-top: 12px !important; padding-bottom: 12px !important; }
.py-4 { padding-top: 16px !important; padding-bottom: 16px !important; }
.py-5 { padding-top: 24px !important; padding-bottom: 24px !important; }
.pt-2 { padding-top: 8px !important; }

/* Gaps */
.gap-2 { gap: 8px !important; }
.gap-3 { gap: 12px !important; }
.gap-4 { gap: 16px !important; }

/* Sizing */
.w-full, .w-100 { width: 100% !important; }
.h-full, .h-100 { height: 100% !important; }

/* Display */
.d-none { display: none !important; }
.d-block { display: block !important; }
.d-flex { display: flex !important; }
.d-inline { display: inline !important; }
.d-inline-flex { display: inline-flex !important; }
.d-grid { display: grid !important; }
.d-inline-block { display: inline-block !important; }

/* Flexbox */
.flex-wrap { flex-wrap: wrap !important; }
.flex-column, .flex-col { flex-direction: column !important; }
.flex-row { flex-direction: row !important; }
.flex-grow-1 { flex-grow: 1 !important; }
.flex-shrink-0 { flex-shrink: 0 !important; }
.flex-1 { flex: 1 !important; }
.align-items-center { align-items: center !important; }
.align-items-start { align-items: flex-start !important; }
.align-items-end { align-items: flex-end !important; }
.justify-content-between { justify-content: space-between !important; }
.justify-content-center { justify-content: center !important; }
.justify-content-end { justify-content: flex-end !important; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }

/* Position */
.position-relative, .relative { position: relative; }
.position-absolute { position: absolute; }
.position-fixed { position: fixed; }

/* Border */
.border { border: 1px solid hsl(var(--border)); }
.border-b, .border-bottom { border-bottom: 1px solid hsl(var(--border)); }
.border-t, .border-top { border-top: 1px solid hsl(var(--border)); }

/* Rounded */
.rounded { border-radius: var(--radius); }
.rounded-full, .rounded-circle { border-radius: 9999px !important; }
.rounded-lg { border-radius: var(--radius); }

/* Overflow */
.overflow-hidden { overflow: hidden; }
.overflow-x-auto { overflow-x: auto; }
.overflow-y-auto { overflow-y: auto; }

/* Misc */
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hidden { display: none; }
.block { display: block; }
.flex { display: flex; }
.inline-flex { display: inline-flex; }
.items-center { align-items: center; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }
.space-y-2 > * + * { margin-top: 8px; }
.space-y-4 > * + * { margin-top: 16px; }

.img-fluid { max-width: 100%; height: auto; }

/* ========================================
   Grid System (custom utility)
   ======================================== */
.grid { display: grid; gap: 16px; }
.grid-cols-1 { grid-template-columns: repeat(1, 1fr); }
.grid-cols-2 { grid-template-columns: repeat(2, 1fr); }
.grid-cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid-cols-4 { grid-template-columns: repeat(4, 1fr); }

@media (min-width: 640px) {
    .sm\:grid-cols-2 { grid-template-columns: repeat(2, 1fr); }
}
@media (min-width: 768px) {
    .md\:grid-cols-2 { grid-template-columns: repeat(2, 1fr); }
    .md\:grid-cols-3 { grid-template-columns: repeat(3, 1fr); }
}
@media (min-width: 1024px) {
    .lg\:grid-cols-2 { grid-template-columns: repeat(2, 1fr); }
    .lg\:grid-cols-3 { grid-template-columns: repeat(3, 1fr); }
    .lg\:grid-cols-4 { grid-template-columns: repeat(4, 1fr); }
}
@media (min-width: 1280px) {
    .xl\:grid-cols-4 { grid-template-columns: repeat(4, 1fr); }
}

/* ========================================
   Responsive
   ======================================== */
@media (max-width: 1023px) {
    .sidebar {
        display: none;
    }
    
    .sidebar.mobile-open {
        display: flex;
        position: fixed;
        left: 0;
        top: 0;
        bottom: 0;
        z-index: 50;
    }

    .mobile-overlay {
        display: none;
        position: fixed;
        inset: 0;
        background-color: rgb(0 0 0 / 0.5);
        z-index: 45;
    }

    .mobile-overlay.show {
        display: block;
    }
    
    .main-content {
        padding: 12px;
    }

    .mobile-trigger {
        display: flex !important;
    }
}

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

    .mobile-overlay {
        display: none !important;
    }
}

/* ========================================
   Theme Toggle
   ======================================== */
.theme-toggle {
    background: none;
    border: none;
    cursor: pointer;
    width: 36px;
    height: 36px;
    border-radius: calc(var(--radius) - 2px);
    display: flex;
    align-items: center;
    justify-content: center;
    color: hsl(var(--foreground));
    transition: background-color 0.15s;
}

.theme-toggle:hover {
    background-color: hsl(var(--muted));
}

html.dark .icon-sun { display: none; }
html.dark .icon-moon { display: inline-block; }
html:not(.dark) .icon-sun { display: inline-block; }
html:not(.dark) .icon-moon { display: none; }

/* ========================================
   Scrollbar
   ======================================== */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: hsl(var(--muted-foreground) / 0.3); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: hsl(var(--muted-foreground) / 0.5); }

/* ========================================
   Print
   ======================================== */
@media print {
    .sidebar, .top-header, .app-footer, .btn, .no-print {
        display: none !important;
    }
    .main-wrapper { width: 100%; }
    .card { border: 1px solid #ddd; break-inside: avoid; }
}

/* ========================================
   Animations
   ======================================== */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

.fade-in { animation: fadeIn 0.3s ease-out; }
.fade.show { opacity: 1; }

/* Loading overlay */
.loading-overlay {
    position: fixed;
    inset: 0;
    background: rgb(0 0 0 / 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

/* Separator */
.separator {
    position: relative;
    text-align: center;
    margin: 16px 0;
}

.separator::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    height: 1px;
    background-color: hsl(var(--border));
}

.separator span {
    position: relative;
    background-color: hsl(var(--card));
    padding: 0 8px;
    font-size: 12px;
    text-transform: uppercase;
    color: hsl(var(--muted-foreground));
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 32px 16px;
    color: hsl(var(--muted-foreground));
}

.empty-state i, .empty-state svg {
    font-size: 48px;
    margin-bottom: 12px;
    opacity: 0.5;
}

/* ========================================
   Error Pages
   ======================================== */
.error-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, hsl(var(--sidebar-background)), hsl(var(--secondary)));
}

.error-container {
    text-align: center;
    color: white;
}

.error-code {
    font-size: 8rem;
    font-weight: 700;
    opacity: 0.3;
    line-height: 1;
}

.error-message {
    font-size: 1.5rem;
    margin-bottom: 2rem;
}

/* ========================================
   Page Header
   ======================================== */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
    flex-wrap: wrap;
    gap: 12px;
}

.page-header h1 {
    font-size: 24px;
    font-weight: 700;
    margin: 0;
}

/* ========================================
   showToast JS helper styles
   ======================================== */
.toast-success { background-color: hsl(var(--success)); color: white; }
.toast-danger { background-color: hsl(var(--destructive)); color: white; }
.toast-warning { background-color: hsl(var(--warning)); color: white; }
.toast-info { background-color: hsl(var(--info)); color: white; }
