/* Enamel Premium Design System (Apple-Minimal) */
:root {
    --brand: #8c65e5;
    --brand-hover: #7b58cb;
    --bg: #f6f7fb;
    --surface: #ffffff;
    --text: #0f172a;
    --muted: #64748b;
    --border: #e2e8f0;

    --success-bg: #dbeafe;
    /* using blueish tint for paid sometimes? Reference said soft green */
    --success-text: #166534;
    --warning-bg: #fef3c7;
    --warning-text: #92400e;
    --danger-bg: #fee2e2;
    --danger-text: #991b1b;

    --shadow: 0 10px 30px rgba(15, 23, 42, 0.04);
    --shadow-sm: 0 4px 14px rgba(15, 23, 42, 0.03);

    --radius: 14px;
    --radius-sm: 10px;

    --sidebar-width: 260px;
    --topbar-height: 64px;
}

/* Reset & Base */
*,
*::before,
*::after {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

a {
    text-decoration: none;
    color: inherit;
    transition: color 0.2s;
}

h1,
h2,
h3,
h4 {
    margin: 0;
    font-weight: 600;
    color: var(--text);
}

/* Layout Shell */
.app-shell {
    display: flex;
    min-height: 100vh;
}

.main-content {
    margin-left: var(--sidebar-width);
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.content-wrapper {
    padding: 30px;
    max-width: 1400px;
    margin: 0 auto;
    width: 100%;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background: var(--surface);
    border-right: 1px solid var(--border);
    position: fixed;
    height: 100vh;
    padding: 24px;
    overflow-y: auto;
    z-index: 50;
    transition: transform 0.3s ease;
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 18px;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 40px;
}

.nav-group {
    margin-bottom: 30px;
}

.nav-header {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--muted);
    margin-bottom: 12px;
    font-weight: 600;
    padding-left: 10px;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    color: var(--muted);
    border-radius: var(--radius-sm);
    font-weight: 500;
    margin-bottom: 4px;
    position: relative;
}

.nav-link:hover {
    color: var(--brand);
    background: #f8fafc;
}

.nav-link.active {
    color: var(--brand);
    background: #f3f0ff;
    /* Soft brand tint */
}

.nav-link.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 6px;
    bottom: 6px;
    width: 3px;
    background: var(--brand);
    border-radius: 0 4px 4px 0;
}

.nav-icon {
    width: 18px;
    height: 18px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
}

/* Topbar */
.topbar {
    height: var(--topbar-height);
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 32px;
    position: sticky;
    top: 0;
    z-index: 40;
}

.topbar-left h1 {
    font-size: 18px;
}

.topbar-left span {
    color: var(--muted);
    font-size: 13px;
    margin-left: 10px;
    font-weight: 400;
}

.search-bar {
    position: relative;
    width: 380px;
}

.search-input {
    width: 100%;
    padding: 10px 16px 10px 40px;
    border-radius: var(--radius);
    /* Pill shape sort of, or rounded rect */
    border: 1px solid var(--border);
    background: var(--bg);
    font-size: 14px;
    transition: all 0.2s;
    outline: none;
}

.search-input:focus {
    background: var(--surface);
    border-color: var(--brand);
    box-shadow: 0 0 0 3px rgba(140, 101, 229, 0.1);
}

.search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--muted);
    width: 16px;
    height: 16px;
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* Components: Cards */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: var(--shadow-sm);
    margin-bottom: 24px;
    position: relative;
}

.card-title {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.kpi-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.kpi-icon {
    width: 32px;
    height: 32px;
    background: #f3f0ff;
    color: var(--brand);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 12px;
}

.kpi-label {
    color: var(--muted);
    font-size: 13px;
    font-weight: 500;
    margin-bottom: 4px;
}

.kpi-value {
    font-size: 24px;
    font-weight: 700;
    color: var(--text);
    font-variant-numeric: tabular-nums;
}

.kpi-sub {
    font-size: 12px;
    color: var(--success-text);
    margin-top: 4px;
}

/* Components: Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 40px;
    padding: 0 16px;
    border-radius: var(--radius-sm);
    font-weight: 500;
    font-size: 14px;
    border: 1px solid transparent;
    cursor: pointer;
    transition: all 0.2s;
    gap: 8px;
}

.btn-sm {
    height: 32px;
    padding: 0 12px;
    font-size: 13px;
}

.btn-primary {
    background: var(--brand);
    color: white;
    box-shadow: 0 2px 5px rgba(140, 101, 229, 0.3);
}

.btn-primary:hover {
    background: var(--brand-hover);
    transform: translateY(-1px);
}

.btn-secondary {
    background: var(--surface);
    border-color: var(--border);
    color: var(--text);
}

.btn-secondary:hover {
    background: #f8fafc;
    border-color: #cbd5e1;
}

.btn-ghost {
    background: transparent;
    color: var(--muted);
    height: auto;
    padding: 6px;
}

.btn-ghost:hover {
    color: var(--text);
    background: #f1f5f9;
}

/* Components: Table */
.table-wrap {
    width: 100%;
    overflow-x: auto;
    border-radius: var(--radius-sm);
    /* Inner radius */
    /* Often we put table directly in card without wrap border for minimal look */
}

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

.table th {
    text-align: left;
    padding: 12px 16px;
    color: var(--muted);
    font-weight: 500;
    font-size: 13px;
    border-bottom: 1px solid var(--border);
    height: 44px;
}

.table td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    height: 56px;
    /* Comfortable touch target */
}

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

.table tr:hover td {
    background: #f8fafc;
}

.table-dense td {
    height: 44px;
    padding: 8px 16px;
}

/* Chips */
.chip {
    padding: 4px 10px;
    border-radius: 99px;
    font-size: 12px;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
}

.chip-green {
    background: #dcfce7;
    color: #166534;
}

.chip-amber,
.chip-yellow {
    background: #fef3c7;
    color: #92400e;
}

.chip-blue,
.chip-purple {
    background: #f3f0ff;
    color: #6b21a8;
}

.chip-gray {
    background: #f1f5f9;
    color: #475569;
}

/* Utilities */
.grid-4 {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 24px;
}

.grid-dash {
    display: grid;
    grid-template-columns: 2.5fr 1fr;
    gap: 24px;
}

/* 70/30 approx */
.d-flex {
    display: flex;
}

.gap-2 {
    gap: 8px;
}

.justify-between {
    justify-content: space-between;
}

.align-center {
    align-items: center;
}

.text-right {
    text-align: right;
}

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

.w-full {
    width: 100%;
}

.mb-4 {
    margin-bottom: 24px;
}

.font-tabular {
    font-variant-numeric: tabular-nums;
}

.font-bold {
    font-weight: 600;
    color: var(--text);
}

/* Forms */
.form-control {
    width: 100%;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--bg);
    font-size: 14px;
    transition: all 0.2s;
}

.form-control:focus {
    background: var(--surface);
    border-color: var(--brand);
    outline: none;
}

.form-label {
    display: block;
    margin-bottom: 6px;
    font-weight: 500;
    font-size: 13px;
}

/* Mobile */
.mobile-toggle {
    display: none;
}

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

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

    .sidebar {
        transform: translateX(-100%);
        box-shadow: 10px 0 20px rgba(0, 0, 0, 0.1);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .main-content {
        margin-left: 0;
    }

    .mobile-toggle {
        display: block;
        border: none;
        background: none;
        font-size: 20px;
    }

    .search-bar {
        display: none;
    }

    /* Hide global search on mobile for simplicity */
}