:root {
    --bg-body: #f1f5f9;
    --bg-surface: #ffffff;
    --bg-sidebar: #0f172a;
    --bg-sidebar-hover: #1e293b;
    --text-main: #0f172a;
    --text-secondary: #475569;
    --text-muted: #64748b;
    --primary: #0891b2;
    --primary-hover: #0e7490;
    --primary-light: #ecfeff;
    --secondary: #0d9488;
    --success: #16a34a;
    --success-bg: #dcfce7;
    --warning: #d97706;
    --warning-bg: #fef3c7;
    --danger: #dc2626;
    --danger-bg: #fee2e2;
    --border: #e2e8f0;
    --radius: 10px;
    --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.06);
    --shadow-md: 0 4px 12px rgba(15, 23, 42, 0.08);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

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

/* Auth / Login Screen */
.login-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
    padding: 1.5rem;
}

.login-card {
    background: var(--bg-surface);
    width: 100%;
    max-width: 420px;
    padding: 2.5rem;
    border-radius: 14px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.25);
}

.login-logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

.login-logo img {
    height: 46px;
    width: auto;
}

.login-card h1 {
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--text-main);
    margin-bottom: 0.35rem;
}

.login-card p.sub {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 1.5rem;
}

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

.sidebar {
    width: 255px;
    background: var(--bg-sidebar);
    color: #f8fafc;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    position: sticky;
    top: 0;
    height: 100vh;
}

.sidebar-brand {
    padding: 1.25rem 1.25rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.sidebar-brand img {
    height: 36px;
    width: auto;
    background: #fff;
    padding: 4px 8px;
    border-radius: 6px;
}

.sidebar-brand-text {
    font-weight: 700;
    font-size: 0.95rem;
    line-height: 1.2;
}

.sidebar-brand-text span {
    display: block;
    font-size: 0.75rem;
    color: #38bdf8;
    font-weight: 500;
}

.sidebar-nav {
    padding: 1rem 0.75rem;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    overflow-y: auto;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.7rem 0.9rem;
    border-radius: 8px;
    color: #cbd5e1;
    text-decoration: none;
    font-weight: 500;
    cursor: pointer;
    border: none;
    background: transparent;
    width: 100%;
    text-align: left;
    font-size: 0.9rem;
    transition: all 0.15s ease;
}

.nav-item:hover {
    background: var(--bg-sidebar-hover);
    color: #ffffff;
}

.nav-item.active {
    background: var(--primary);
    color: #ffffff;
    font-weight: 600;
}

.nav-badge {
    margin-left: auto;
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
    font-size: 0.72rem;
    padding: 0.1rem 0.45rem;
    border-radius: 99px;
}

.nav-badge.warn {
    background: #f59e0b;
    color: #0f172a;
    font-weight: 700;
}

.sidebar-footer {
    padding: 1rem 1.25rem;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    font-size: 0.8rem;
    color: #94a3b8;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

/* Main Content Area */
.main-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.topbar {
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border);
    padding: 0.9rem 1.75rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    position: sticky;
    top: 0;
    z-index: 20;
}

.topbar-title {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--text-main);
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 0.65rem;
}

.content-container {
    padding: 1.75rem;
    max-width: 1440px;
    width: 100%;
    margin: 0 auto;
}

/* KPI Stat Cards */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.stat-card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
    box-shadow: var(--shadow-sm);
}

.stat-label {
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
    margin-bottom: 0.35rem;
}

.stat-value {
    font-size: 1.65rem;
    font-weight: 800;
    color: var(--text-main);
}

.stat-sub {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: 0.25rem;
}

/* Cards & Panels */
.card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    margin-bottom: 1.5rem;
}

.card-header {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.card-header h2, .card-header h3 {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-main);
}

.card-body {
    padding: 1.25rem;
}

.grid-2 {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(380px, 1fr));
    gap: 1.25rem;
}

/* Forms & Controls */
.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 0.85rem;
    margin-bottom: 0.85rem;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.form-group label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="date"],
input[type="url"],
select,
textarea {
    width: 100%;
    padding: 0.55rem 0.75rem;
    border: 1px solid #cbd5e1;
    border-radius: 7px;
    font-size: 0.9rem;
    font-family: inherit;
    color: var(--text-main);
    background: #fff;
    transition: border-color 0.15s;
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(8, 145, 178, 0.12);
}

.checkbox-row {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
    padding-top: 0.25rem;
}

.checkbox-label {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.55rem 1rem;
    border-radius: 7px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    border: 1px solid transparent;
    text-decoration: none;
    transition: all 0.15s ease;
    white-space: nowrap;
}

.btn-primary {
    background: var(--primary);
    color: #fff;
}

.btn-primary:hover {
    background: var(--primary-hover);
}

.btn-secondary {
    background: #fff;
    border-color: #cbd5e1;
    color: var(--text-main);
}

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

.btn-success {
    background: var(--success);
    color: #fff;
}

.btn-danger {
    background: var(--danger-bg);
    color: var(--danger);
}

.btn-danger:hover {
    background: var(--danger);
    color: #fff;
}

.btn-sm {
    padding: 0.3rem 0.65rem;
    font-size: 0.78rem;
    border-radius: 6px;
}

/* Support / HelpWire Link Chips */
.support-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.3rem 0.65rem;
    border-radius: 6px;
    font-size: 0.78rem;
    font-weight: 600;
    text-decoration: none;
    background: #e0f2fe;
    color: #0369a1;
    border: 1px solid #bae6fd;
    transition: all 0.15s;
}

.support-chip:hover {
    background: #0284c7;
    color: #fff;
}

.support-chip.helpwire {
    background: #ecfdf5;
    color: #047857;
    border-color: #a7f3d0;
}

.support-chip.helpwire:hover {
    background: #059669;
    color: #fff;
}

.support-chip.sharepoint {
    background: #eff6ff;
    color: #1d4ed8;
    border-color: #bfdbfe;
}

.support-chip.sharepoint:hover {
    background: #2563eb;
    color: #fff;
}

/* Tables */
.table-wrap {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
}

th {
    background: #f8fafc;
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 0.76rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border);
}

td {
    padding: 0.8rem 1rem;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
    font-size: 0.88rem;
}

tr:hover td {
    background: #f8fafc;
}

/* Status Badges */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.2rem 0.55rem;
    border-radius: 99px;
    font-size: 0.74rem;
    font-weight: 600;
}

.badge-success {
    background: var(--success-bg);
    color: var(--success);
}

.badge-warning {
    background: var(--warning-bg);
    color: var(--warning);
}

.badge-danger {
    background: var(--danger-bg);
    color: var(--danger);
}

.badge-neutral {
    background: #e2e8f0;
    color: #475569;
}

.badge-info {
    background: #e0f2fe;
    color: #0369a1;
}

/* Billed / Unbilled Interactive Toggle Pill */
.billed-toggle {
    cursor: pointer;
    border: 1px solid transparent;
    transition: transform 0.1s;
}

.billed-toggle:hover {
    transform: scale(1.04);
}

/* Modals */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.55);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 100;
    padding: 1rem;
}

.modal-backdrop.open {
    display: flex;
}

.modal {
    background: var(--bg-surface);
    border-radius: 12px;
    width: 100%;
    max-width: 680px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
}

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

.modal-header h3 {
    font-size: 1.1rem;
    font-weight: 700;
}

.modal-body {
    padding: 1.5rem;
}

.modal-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 0.65rem;
}

/* Filter Bar */
.filter-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    align-items: flex-end;
    background: #f8fafc;
    padding: 1rem;
    border-radius: 8px;
    border: 1px solid var(--border);
    margin-bottom: 1.25rem;
}

.filter-bar .form-group {
    min-width: 155px;
    flex: 1;
}

.hidden {
    display: none !important;
}

/* Toast Notification */
.toast-container {
    position: fixed;
    bottom: 1.25rem;
    right: 1.25rem;
    z-index: 200;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.toast {
    background: #0f172a;
    color: #fff;
    padding: 0.75rem 1.1rem;
    border-radius: 8px;
    box-shadow: var(--shadow-md);
    font-size: 0.85rem;
    font-weight: 500;
}

/* Mobile Responsiveness */
@media (max-width: 900px) {
    .app-shell {
        flex-direction: column;
    }
    .sidebar {
        width: 100%;
        height: auto;
        position: static;
    }
    .sidebar-nav {
        flex-direction: row;
        overflow-x: auto;
        padding: 0.5rem;
    }
    .nav-item {
        width: auto;
        white-space: nowrap;
    }
    .grid-2 {
        grid-template-columns: 1fr;
    }
}

/* Print Formatting for Billing Reports */
@media print {
    .sidebar,
    .topbar,
    .no-print,
    .filter-bar,
    .billed-toggle-hint {
        display: none !important;
    }
    body, .main-area, .content-container, .card {
        background: #fff !important;
        box-shadow: none !important;
        border: none !important;
        padding: 0 !important;
        margin: 0 !important;
    }
    .print-header {
        display: block !important;
        margin-bottom: 1.5rem;
        border-bottom: 2px solid #0f172a;
        padding-bottom: 1rem;
    }
}
