/* ============================================================
   DESIGN TOKENS
   ============================================================ */

:root {
    --app-bg: #f7f8fa;
    --surface: #ffffff;
    --surface-subtle: #f2f4f7;
    --text: #172033;
    --text-muted: #667085;
    --text-light: #98a2b3;
    --border: #e4e7ec;
    --border-strong: #d0d5dd;
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --primary-soft: #eff6ff;
    --success: #15803d;
    --success-soft: #ecfdf3;
    --warning: #b45309;
    --warning-soft: #fffaeb;
    --danger: #b42318;
    --danger-soft: #fff1f0;
    --sidebar-width: 240px;
    --topbar-height: 68px;
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.05);
    --shadow-md: 0 8px 24px rgba(16, 24, 40, 0.08);
}


/* ============================================================
   BASE
   ============================================================ */

html {
    font-size: 14px;
}

html,
body {
    min-height: 100%;
}

body {
    margin: 0;
    color: var(--text);
    background: var(--app-bg);
    font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

a {
    text-decoration: none;
}

button,
input,
select,
textarea {
    font: inherit;
}


/* ============================================================
   BOOTSTRAP OVERRIDES
   ============================================================ */

.btn {
    min-height: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    font-weight: 500;
}

.btn-sm {
    min-height: 34px;
}

.btn-lg {
    min-height: 48px;
    padding-left: 20px;
    padding-right: 20px;
}

.form-label {
    margin-bottom: 6px;
    color: var(--text);
    font-size: 12px;
    font-weight: 600;
}

.form-control,
.form-select {
    min-height: 42px;
    color: var(--text);
    background-color: #fff;
    border-color: var(--border);
    border-radius: var(--radius-sm);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

    .form-control::placeholder {
        color: var(--text-light);
    }

    .form-control:hover,
    .form-select:hover {
        border-color: var(--border-strong);
    }

    .form-control:focus,
    .form-select:focus {
        border-color: var(--primary);
        box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.10);
    }

.app-btn-primary {
    color: #fff;
    background: var(--primary);
    border-color: var(--primary);
}

    .app-btn-primary:hover,
    .app-btn-primary:focus {
        color: #fff;
        background: var(--primary-hover);
        border-color: var(--primary-hover);
    }


/* ============================================================
   BRAND
   ============================================================ */

.brand-mark {
    width: 36px;
    height: 36px;
    flex: 0 0 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    background: var(--primary);
    border-radius: 10px;
    font-size: 18px;
}


/* ============================================================
   PUBLIC LAYOUT
   ============================================================ */

.public-body {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background: #fff;
}

    .public-body > main {
        flex: 1;
    }

.public-header {
    height: 72px;
    background: rgba(255, 255, 255, 0.96);
    border-bottom: 1px solid var(--border);
}

.public-navbar {
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.public-brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    color: var(--text);
    font-size: 18px;
    font-weight: 700;
}

    .public-brand:hover {
        color: var(--text);
    }

.public-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.public-signin {
    color: var(--text);
    text-decoration: none;
}

    .public-signin:hover {
        color: var(--primary);
    }


/* ============================================================
   HERO
   ============================================================ */

.hero-section {
    padding: 96px 0;
    overflow: hidden;
    background: radial-gradient( circle at 85% 20%, rgba(37, 99, 235, 0.08), transparent 30% ), #fff;
}

.hero-badge {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    margin-bottom: 20px;
    padding: 6px 10px;
    color: var(--primary);
    background: var(--primary-soft);
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
}

.hero-title {
    max-width: 650px;
    margin: 0;
    color: var(--text);
    font-size: clamp(2.5rem, 5vw, 4.5rem);
    font-weight: 750;
    letter-spacing: -0.045em;
    line-height: 1.03;
}

    .hero-title span {
        display: block;
        color: var(--primary);
    }

.hero-description {
    max-width: 580px;
    margin: 24px 0 0;
    color: var(--text-muted);
    font-size: 18px;
    line-height: 1.7;
}

.hero-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 30px;
}

.hero-points {
    display: flex;
    flex-wrap: wrap;
    gap: 22px;
    margin-top: 26px;
    color: var(--text-muted);
    font-size: 13px;
}

    .hero-points i {
        margin-right: 5px;
        color: var(--success);
    }


/* ============================================================
   INVOICE PREVIEW
   ============================================================ */

.invoice-preview {
    max-width: 520px;
    margin-left: auto;
    padding: 30px;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    transform: rotate(1deg);
}

.invoice-preview-header {
    display: flex;
    justify-content: space-between;
    gap: 20px;
}

.preview-company {
    font-size: 17px;
    font-weight: 700;
}

.preview-invoice-title {
    font-size: 22px;
    font-weight: 750;
}

.preview-muted {
    margin-top: 4px;
    color: var(--text-muted);
    font-size: 10px;
}

.preview-divider {
    height: 1px;
    margin: 22px 0;
    background: var(--border);
}

.preview-customer {
    display: flex;
    flex-direction: column;
    gap: 3px;
    padding: 12px;
    background: var(--surface-subtle);
    border-radius: var(--radius-sm);
}

    .preview-customer small {
        color: var(--text-muted);
        font-size: 9px;
    }

    .preview-customer span {
        color: var(--text-muted);
        font-size: 11px;
    }

.preview-table {
    margin-top: 22px;
}

.preview-table-header,
.preview-table-row {
    display: grid;
    grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr) minmax(0, 1.2fr);
    gap: 12px;
    padding: 10px 4px;
}

.preview-table-header {
    color: var(--text-muted);
    background: var(--surface-subtle);
    font-size: 9px;
    font-weight: 600;
}

.preview-table-row {
    border-bottom: 1px solid var(--border);
    font-size: 11px;
}

    .preview-table-header span:nth-child(n+2),
    .preview-table-row span:nth-child(n+2) {
        text-align: right;
    }

.preview-total {
    width: 65%;
    margin-top: 18px;
    margin-left: auto;
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 13px;
    background: var(--surface-subtle);
    border-radius: var(--radius-sm);
    font-size: 11px;
}


/* ============================================================
   FEATURES
   ============================================================ */

.features-section {
    padding: 90px 0;
    background: var(--app-bg);
}

.section-heading {
    max-width: 620px;
    margin: 0 auto 48px;
    text-align: center;
}

    .section-heading > span {
        color: var(--primary);
        font-size: 13px;
        font-weight: 600;
    }

    .section-heading h2 {
        margin-top: 8px;
        font-size: clamp(2rem, 4vw, 2.8rem);
        font-weight: 700;
        letter-spacing: -0.03em;
    }

    .section-heading p {
        margin-top: 12px;
        color: var(--text-muted);
        font-size: 16px;
    }

.feature-card {
    height: 100%;
    padding: 24px;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

    .feature-card:hover {
        transform: translateY(-3px);
        border-color: var(--border-strong);
        box-shadow: var(--shadow-md);
    }

.feature-icon {
    width: 42px;
    height: 42px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 18px;
    color: var(--primary);
    background: var(--primary-soft);
    border-radius: 10px;
    font-size: 18px;
}

.feature-card h3 {
    margin-bottom: 0;
    font-size: 16px;
    font-weight: 650;
}

.feature-card p {
    margin: 8px 0 0;
    color: var(--text-muted);
    font-size: 13px;
    line-height: 1.6;
}


/* ============================================================
   PUBLIC FOOTER
   ============================================================ */

.public-footer {
    padding: 28px 0;
    background: #fff;
    border-top: 1px solid var(--border);
}

.public-footer-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
}


/* ============================================================
   AUTHENTICATED APPLICATION
   ============================================================ */

.app-body {
    min-height: 100vh;
    overflow-x: hidden;
    background: var(--app-bg);
}

.app-shell {
    min-height: 100vh;
}


/* ============================================================
   SIDEBAR
   ============================================================ */

.app-sidebar {
    position: fixed;
    z-index: 1040;
    top: 0;
    bottom: 0;
    left: 0;
    width: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    background: #fff;
    border-right: 1px solid var(--border);
}

.sidebar-header {
    height: var(--topbar-height);
    flex: 0 0 var(--topbar-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 18px;
    border-bottom: 1px solid var(--border);
}

.sidebar-brand {
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text);
    font-size: 17px;
    font-weight: 700;
}

    .sidebar-brand:hover {
        color: var(--text);
    }

    .sidebar-brand > span:last-child {
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

.sidebar-close {
    width: 36px;
    height: 36px;
    flex: 0 0 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    color: var(--text-muted);
    background: transparent;
    border: 0;
    border-radius: var(--radius-sm);
    font-size: 18px;
}

    .sidebar-close:hover {
        color: var(--text);
        background: var(--surface-subtle);
    }

.sidebar-nav {
    flex: 1;
    padding: 16px 12px;
    overflow-x: hidden;
    overflow-y: auto;
}

.sidebar-section + .sidebar-section {
    margin-top: 22px;
}

.sidebar-label {
    padding: 0 10px 7px;
    color: var(--text-light);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.sidebar-link {
    min-height: 42px;
    display: flex;
    align-items: center;
    gap: 11px;
    margin-bottom: 2px;
    padding: 0 10px;
    color: var(--text-muted);
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 500;
    transition: color 0.15s ease, background 0.15s ease;
}

    .sidebar-link i {
        width: 20px;
        flex: 0 0 20px;
        text-align: center;
        font-size: 16px;
    }

    .sidebar-link span {
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .sidebar-link:hover {
        color: var(--text);
        background: var(--surface-subtle);
    }

    .sidebar-link.active {
        color: var(--primary);
        background: var(--primary-soft);
        font-weight: 600;
    }

.sidebar-footer {
    flex: 0 0 auto;
    padding: 12px;
    background: #fff;
    border-top: 1px solid var(--border);
}


/* ============================================================
   COMPANY IDENTITY
   ============================================================ */

.company-avatar {
    position: relative;
    width: 40px;
    height: 40px;
    flex: 0 0 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    color: var(--primary);
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 10px;
}

.company-avatar-image {
    width: 100%;
    height: 100%;
    display: block;
    padding: 3px;
    object-fit: contain;
}

.company-avatar-fallback {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary);
    background: var(--primary-soft);
    font-size: 17px;
}

.company-avatar-topbar {
    width: 36px;
    height: 36px;
    flex-basis: 36px;
    border-radius: 9px;
}


/* ============================================================
   SIDEBAR COMPANY
   ============================================================ */

.sidebar-company {
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 7px;
    color: var(--text);
    border-radius: var(--radius-sm);
    transition: background 0.15s ease;
}

    .sidebar-company:hover {
        color: var(--text);
        background: var(--surface-subtle);
    }

.sidebar-user-info {
    min-width: 0;
    flex: 1;
    display: flex;
    flex-direction: column;
}

    .sidebar-user-info strong {
        overflow: hidden;
        color: var(--text);
        font-size: 12px;
        font-weight: 600;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .sidebar-user-info span {
        overflow: hidden;
        margin-top: 2px;
        color: var(--text-muted);
        font-size: 10px;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

.sidebar-signout {
    min-height: 36px;
    display: flex;
    align-items: center;
    gap: 9px;
    margin-top: 5px;
    padding: 8px;
    color: var(--text-muted);
    border-radius: var(--radius-sm);
    font-size: 12px;
    transition: color 0.15s ease, background 0.15s ease;
}

    .sidebar-signout i {
        width: 20px;
        text-align: center;
    }

    .sidebar-signout:hover {
        color: var(--danger);
        background: var(--danger-soft);
    }

/* ============================================================
   ACCOUNT INFORMATION
   ============================================================ */

.account-info-field {
    min-height: 42px;
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 9px 12px;
    color: var(--text);
    background: var(--surface-subtle);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 13px;
}

    .account-info-field i {
        flex: 0 0 auto;
        color: var(--text-muted);
        font-size: 14px;
    }

    .account-info-field span {
        min-width: 0;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }


/* ============================================================
   MAIN APPLICATION
   ============================================================ */

.app-main {
    min-height: 100vh;
    margin-left: var(--sidebar-width);
}


/* ============================================================
   TOP BAR
   ============================================================ */

.app-topbar {
    position: sticky;
    z-index: 1020;
    top: 0;
    height: var(--topbar-height);
    display: flex;
    align-items: center;
    padding: 0 28px;
    background: rgba(255, 255, 255, 0.94);
    border-bottom: 1px solid var(--border);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

.topbar-spacer {
    flex: 1;
}

.topbar-account {
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 5px 7px;
    color: var(--text);
    border-radius: 10px;
    transition: color 0.15s ease, background 0.15s ease;
}

    .topbar-account:hover {
        color: var(--text);
        background: var(--surface-subtle);
    }

.topbar-company {
    min-width: 0;
    flex-direction: column;
    line-height: 1.25;
}

    .topbar-company strong {
        max-width: 180px;
        overflow: hidden;
        color: var(--text);
        font-size: 12px;
        font-weight: 600;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .topbar-company span {
        max-width: 180px;
        overflow: hidden;
        margin-top: 2px;
        color: var(--text-muted);
        font-size: 10px;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

.topbar-chevron {
    margin-left: 2px;
    color: var(--text-muted);
    font-size: 10px;
}

.mobile-menu-button {
    width: 38px;
    height: 38px;
    flex: 0 0 38px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    color: var(--text);
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 20px;
    transition: background 0.15s ease, border-color 0.15s ease;
}

    .mobile-menu-button:hover {
        background: var(--surface-subtle);
        border-color: var(--border-strong);
    }


/* ============================================================
   APPLICATION CONTENT
   ============================================================ */

.app-content {
    padding: 30px;
}

.app-content-inner {
    width: 100%;
    max-width: 1440px;
    margin: 0 auto;
}


/* ============================================================
   PAGE HEADER
   ============================================================ */

.page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 26px;
}

.page-title {
    margin: 0;
    color: var(--text);
    font-size: 26px;
    font-weight: 700;
    letter-spacing: -0.025em;
    line-height: 1.2;
}

.page-description {
    max-width: 700px;
    margin: 6px 0 0;
    color: var(--text-muted);
    font-size: 13px;
    line-height: 1.5;
}


/* ============================================================
   CARDS
   ============================================================ */

.app-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
}

.app-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 18px 22px;
    border-bottom: 1px solid var(--border);
}

.app-card-title {
    margin: 0;
    font-size: 14px;
    font-weight: 650;
}

.app-card-body {
    padding: 22px;
}


/* ============================================================
   TABLES
   ============================================================ */

.app-table-container {
    width: 100%;
    overflow-x: auto;
    border-radius: inherit;
}

.app-table {
    width: 100%;
    margin: 0;
    border-collapse: separate;
    border-spacing: 0;
}

    .app-table > :not(caption) > * > * {
        padding: 14px 16px;
        border-bottom-color: var(--border);
    }

    .app-table thead th {
        color: var(--text-muted);
        background: #fcfcfd;
        border-bottom: 1px solid var(--border);
        font-size: 11px;
        font-weight: 600;
        letter-spacing: 0.025em;
        text-transform: uppercase;
        white-space: nowrap;
    }

    .app-table tbody td {
        vertical-align: middle;
        color: var(--text);
        font-size: 13px;
    }

    .app-table tbody tr:last-child td {
        border-bottom: 0;
    }

    .app-table tbody tr {
        transition: background 0.15s ease;
    }

        .app-table tbody tr:hover {
            background: #fafbfc;
        }


/* ============================================================
   STATUS BADGES
   ============================================================ */

.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 8px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 600;
    white-space: nowrap;
}

.status-success {
    color: var(--success);
    background: var(--success-soft);
}

.status-warning {
    color: var(--warning);
    background: var(--warning-soft);
}

.status-danger {
    color: var(--danger);
    background: var(--danger-soft);
}


/* ============================================================
   MOBILE SIDEBAR OVERLAY
   ============================================================ */

.sidebar-overlay {
    display: none;
}


/* ============================================================
   TABLET / SMALL DESKTOP
   ============================================================ */

@media (max-width: 991.98px) {

    .app-sidebar {
        transform: translateX(-100%);
        box-shadow: var(--shadow-md);
        transition: transform 0.22s ease;
    }

        .app-sidebar.show {
            transform: translateX(0);
        }

    .sidebar-overlay {
        position: fixed;
        z-index: 1030;
        inset: 0;
        background: rgba(16, 24, 40, 0.35);
        opacity: 0;
        transition: opacity 0.2s ease;
    }

        .sidebar-overlay.show {
            display: block;
            opacity: 1;
        }

    body.sidebar-open {
        overflow: hidden;
    }

    .app-main {
        margin-left: 0;
    }

    .app-topbar {
        padding: 0 18px;
    }

    .app-content {
        padding: 22px 18px;
    }

    .hero-section {
        padding: 65px 0;
    }

    .invoice-preview {
        margin: 20px auto 0;
        transform: none;
    }
}


/* ============================================================
   MOBILE
   ============================================================ */

@media (max-width: 575.98px) {

    .public-header {
        height: 64px;
    }

    .public-actions .public-signin {
        display: none;
    }

    .public-brand {
        font-size: 16px;
    }

    .brand-mark {
        width: 32px;
        height: 32px;
        flex-basis: 32px;
        font-size: 16px;
    }

    .hero-section {
        padding: 52px 0;
    }

    .hero-title {
        font-size: 2.55rem;
    }

    .hero-description {
        font-size: 16px;
    }

    .hero-actions {
        flex-direction: column;
    }

        .hero-actions .btn {
            width: 100%;
        }

    .hero-points {
        flex-direction: column;
        gap: 8px;
    }

    .invoice-preview {
        padding: 20px;
    }

    .preview-total {
        width: 100%;
    }

    .features-section {
        padding: 60px 0;
    }

    .public-footer-content {
        flex-direction: column;
        align-items: flex-start;
    }

    .app-topbar {
        height: 60px;
        padding: 0 14px;
    }

    .app-content {
        padding: 18px 14px;
    }

    .page-header {
        flex-direction: column;
        margin-bottom: 20px;
    }

        .page-header .btn {
            width: 100%;
        }

    .page-title {
        font-size: 22px;
    }

    .app-card-header,
    .app-card-body {
        padding-left: 16px;
        padding-right: 16px;
    }

    .company-avatar-topbar {
        width: 34px;
        height: 34px;
        flex-basis: 34px;
    }

    .topbar-account {
        padding: 3px;
    }

    .topbar-chevron {
        display: none;
    }
}


/* ============================================================
   ACCESSIBILITY / MOTION
   ============================================================ */

@media (prefers-reduced-motion: reduce) {

    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;
        transition-duration: 0.01ms !important;
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
    }
}
