:root {
    --bg: #f5f7fb;
    --surface: #ffffff;
    --surface-soft: #f8f9fc;
    --border: #e6e9f0;
    --text: #172033;
    --muted: #758099;
    --primary: #635bff;
    --primary-dark: #5048dc;
    --green: #16a36a;
    --amber: #d98c16;
    --red: #dc4b5f;
    --sidebar: #101522;
    --sidebar-muted: #9ba5bb;
    --shadow: 0 12px 32px rgba(22, 31, 56, .07);
    --radius: 16px;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: "Inter", sans-serif;
    font-size: 14px;
}

a { color: inherit; text-decoration: none; }

button, input, select { font: inherit; }

.app-shell {
    min-height: 100vh;
    display: flex;
}

.sidebar {
    width: 252px;
    min-height: 100vh;
    background: var(--sidebar);
    color: white;
    padding: 26px 16px 18px;
    display: flex;
    flex-direction: column;
    position: fixed;
    inset: 0 auto 0 0;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 12px 28px;
}

.brand-mark {
    width: 38px;
    height: 38px;
    border-radius: 12px;
    display: grid;
    place-items: center;
    background: linear-gradient(135deg, #776fff, #4d46d8);
    font-size: 18px;
    box-shadow: 0 8px 24px rgba(99, 91, 255, .28);
}

.brand strong { display: block; font-size: 15px; letter-spacing: -.2px; }
.brand small { display: block; color: #7f8aa2; font-size: 10px; margin-top: 2px; }

.sidebar-nav { flex: 1; }

.nav-label {
    color: #69748b;
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 1.1px;
    padding: 18px 12px 8px;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 12px;
    margin: 3px 0;
    color: var(--sidebar-muted);
    border-radius: 10px;
    font-weight: 600;
    transition: .15s ease;
}

.nav-link span {
    width: 20px;
    text-align: center;
    font-size: 16px;
}

.nav-link:hover { background: #191f2e; color: white; }
.nav-link.active { background: #252a3b; color: white; box-shadow: inset 3px 0 0 var(--primary); }
.notification-badge {
    margin-left: auto;
    min-width: 18px;
    padding: 2px 5px;
    border-radius: 999px;
    background: var(--primary);
    color: white;
    font-size: 9px;
    font-weight: 800;
    text-align: center;
}

.sidebar-footer {
    border-top: 1px solid #252b39;
    padding: 16px 10px 4px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.sidebar-footer strong { display: block; font-size: 12px; }
.sidebar-footer small { color: #7d879a; font-size: 10px; }

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #31c486;
    box-shadow: 0 0 0 4px rgba(49,196,134,.1);
}

.main {
    margin-left: 252px;
    width: calc(100% - 252px);
    min-height: 100vh;
}

.topbar {
    height: 70px;
    padding: 0 34px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(245,247,251,.92);
    border-bottom: 1px solid var(--border);
    backdrop-filter: blur(12px);
}

.breadcrumb {
    display: flex;
    gap: 10px;
    color: var(--muted);
    font-size: 12px;
}

.breadcrumb strong { color: var(--text); }
.breadcrumb b { color: #c4c9d4; }

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

.environment-badge {
    border: 1px solid #d8d5ff;
    background: #efeeff;
    color: #5c55d8;
    border-radius: 999px;
    padding: 5px 9px;
    font-size: 9px;
    font-weight: 800;
    letter-spacing: .8px;
}

.avatar {
    width: 34px;
    height: 34px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    background: #e9e7ff;
    color: var(--primary);
    font-weight: 800;
}

.page-content {
    max-width: 1500px;
    margin: 0 auto;
    padding: 34px;
}

.page-heading, .detail-heading {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 24px;
    margin-bottom: 28px;
}

.page-heading h1, .detail-heading h1 {
    margin: 4px 0 6px;
    font-size: 30px;
    letter-spacing: -1px;
}

.page-heading p, .detail-heading p {
    margin: 0;
    color: var(--muted);
}

.eyebrow {
    color: var(--primary);
    font-size: 9px;
    font-weight: 800;
    letter-spacing: 1.4px;
}

.back-link {
    display: block;
    color: var(--muted);
    margin-bottom: 16px;
    font-size: 12px;
}

.back-link:hover, .text-link:hover, .invoice-link:hover { color: var(--primary); }

.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 22px;
}

.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    display: flex;
    gap: 14px;
    align-items: center;
    box-shadow: var(--shadow);
}

.stat-card span { display: block; color: var(--muted); font-size: 11px; }
.stat-card strong { display: block; margin-top: 4px; font-size: 25px; letter-spacing: -.8px; }

.stat-icon {
    width: 42px;
    height: 42px;
    display: grid;
    place-items: center;
    border-radius: 12px;
    font-weight: 800;
}
.stat-icon.purple { background: #efeeff; color: var(--primary); }
.stat-icon.green { background: #e9f9f2; color: var(--green); }
.stat-icon.amber { background: #fff5e5; color: var(--amber); }
.stat-icon.red { background: #ffedf0; color: var(--red); }

.panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 20px;
    overflow: hidden;
}

.panel-header {
    padding: 20px 22px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 15px;
}

.panel-header h2 {
    margin: 0;
    font-size: 15px;
    letter-spacing: -.2px;
}

.panel-header p {
    margin: 4px 0 0;
    color: var(--muted);
    font-size: 11px;
}

.text-link { color: var(--primary); font-weight: 700; font-size: 12px; }

.table-wrap { overflow-x: auto; }

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

th {
    text-align: left;
    color: #8992a5;
    background: var(--surface-soft);
    font-size: 9px;
    text-transform: uppercase;
    letter-spacing: .8px;
    font-weight: 800;
    padding: 11px 18px;
    border-top: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

td {
    padding: 15px 18px;
    border-bottom: 1px solid #eef0f5;
    color: #49536a;
    white-space: nowrap;
}

tr:last-child td { border-bottom: 0; }
tr:hover td { background: #fafbfe; }

.invoice-link { display: block; color: var(--text); font-weight: 700; }
td small { display: block; color: #9ba3b4; font-size: 10px; margin-top: 3px; }

.status {
    display: inline-flex;
    padding: 5px 9px;
    border-radius: 999px;
    font-size: 9px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: .5px;
}
.status.processed { color: #16805a; background: #e8f8f1; }
.status.processing { color: #b87412; background: #fff4df; }
.status.uploaded { color: #58667f; background: #eef1f6; }
.status.failed { color: #c43f52; background: #ffedf0; }

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

.actions form { margin: 0; }

.icon-btn {
    width: 30px;
    height: 30px;
    border: 1px solid var(--border);
    background: white;
    border-radius: 8px;
    display: grid;
    place-items: center;
    color: #69748b;
    cursor: pointer;
}
.icon-btn:hover { border-color: #cfd3ff; color: var(--primary); background: #f8f7ff; }
.icon-btn.danger:hover { color: var(--red); border-color: #ffcbd2; background: #fff4f5; }

.btn {
    border: 0;
    border-radius: 10px;
    padding: 10px 15px;
    font-weight: 700;
    font-size: 12px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    transition: .15s ease;
}
.btn-primary { background: var(--primary); color: white; box-shadow: 0 8px 18px rgba(99,91,255,.2); }
.btn-primary:hover { background: var(--primary-dark); transform: translateY(-1px); }
.btn-secondary { background: white; color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { border-color: #c9ccff; color: var(--primary); }
.btn-danger { background: #fff0f2; color: var(--red); border: 1px solid #ffd5db; }
.btn-large { padding: 13px 17px; }
.full { width: 100%; }

.heading-actions { display: flex; gap: 9px; }

.detail-grid {
    display: grid;
    grid-template-columns: 1.8fr 1fr;
    gap: 20px;
}

.info-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0;
    border-top: 1px solid var(--border);
}

.info-grid > div {
    padding: 16px 22px;
    border-bottom: 1px solid #eef0f5;
}
.info-grid > div:nth-child(odd) { border-right: 1px solid #eef0f5; }
.info-grid span { display: block; color: var(--muted); font-size: 10px; margin-bottom: 5px; }
.info-grid strong { color: var(--text); font-size: 12px; }

.amount-panel { height: fit-content; }

.amount-row {
    display: flex;
    justify-content: space-between;
    padding: 17px 22px;
    border-top: 1px solid #eef0f5;
    color: var(--muted);
}
.amount-row strong { color: var(--text); }
.amount-row.total { font-size: 15px; }
.amount-row.total strong { font-size: 20px; }

.toolbar {
    padding: 17px 18px;
    display: flex;
    gap: 10px;
    border-bottom: 1px solid var(--border);
}

.search-box {
    flex: 1;
    max-width: 460px;
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 0 12px;
    height: 38px;
    border: 1px solid var(--border);
    border-radius: 9px;
    background: #fbfcfe;
    color: #9aa3b5;
}
.search-box input { width: 100%; border: 0; outline: 0; background: transparent; color: var(--text); }

.select, .input {
    height: 40px;
    border: 1px solid var(--border);
    border-radius: 9px;
    padding: 0 12px;
    background: white;
    color: var(--text);
    outline: 0;
}
.select:focus, .input:focus { border-color: #aaa6ff; box-shadow: 0 0 0 3px rgba(99,91,255,.08); }

.field-label {
    display: block;
    font-size: 11px;
    font-weight: 700;
    margin: 0 0 7px;
    color: #525d73;
}

.upload-layout {
    display: grid;
    grid-template-columns: minmax(0, 1.7fr) minmax(280px, .8fr);
    gap: 20px;
}

.upload-panel { padding: 26px; }

.upload-panel form > .select,
.upload-panel form > .field-label { margin-bottom: 14px; }

.dropzone {
    margin: 18px 0;
    min-height: 250px;
    border: 1.5px dashed #cdd1df;
    border-radius: 16px;
    background: #fafbfe;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: .15s ease;
}
.dropzone:hover, .dropzone.dragging, .dropzone.has-file {
    border-color: #aaa6ff;
    background: #f7f6ff;
}
.dropzone input { display: none; }
.upload-icon {
    width: 50px; height: 50px;
    display: grid; place-items: center;
    border-radius: 14px;
    background: #efeeff;
    color: var(--primary);
    font-size: 22px;
    margin-bottom: 14px;
}
.dropzone strong { font-size: 14px; }
.dropzone span { color: var(--muted); margin-top: 6px; font-size: 11px; }
.dropzone small { color: #a4aabd; margin-top: 13px; font-size: 9px; }

.upload-flow {
    display: flex;
    align-items: center;
    margin: 20px 0;
}
.flow-step { display: flex; align-items: center; gap: 7px; color: #9aa3b4; font-size: 10px; }
.flow-step span {
    width: 24px; height: 24px; border-radius: 50%;
    display: grid; place-items: center;
    background: #eef0f5;
    font-weight: 800;
}
.flow-step.active { color: var(--primary); }
.flow-step.active span { background: #efeeff; color: var(--primary); }
.flow-line { height: 1px; flex: 1; background: #e4e7ee; margin: 0 8px; }

.side-help { padding: 26px; height: fit-content; }
.help-icon {
    width: 44px; height: 44px; display: grid; place-items: center;
    border-radius: 12px; background: #efeeff; color: var(--primary);
    font-size: 18px; margin-bottom: 18px;
}
.side-help h3 { margin: 0 0 7px; }
.side-help p { color: var(--muted); line-height: 1.65; font-size: 12px; }
.check-list { margin-top: 22px; display: grid; gap: 11px; color: #566077; font-size: 11px; }

.cards-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
}

.entity-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 15px;
    box-shadow: var(--shadow);
    transition: .15s ease;
}
.entity-card:hover { transform: translateY(-2px); border-color: #d4d2ff; box-shadow: 0 16px 34px rgba(22,31,56,.09); }
.entity-icon {
    width: 44px; height: 44px; display: grid; place-items: center;
    border-radius: 12px; background: #efeeff; color: var(--primary);
    font-size: 17px;
}
.entity-content { flex: 1; min-width: 0; }
.entity-content strong { display: block; font-size: 13px; margin-bottom: 5px; }
.entity-content span { display: block; color: var(--muted); font-size: 10px; }
.entity-content small { display: block; color: #a3aabb; font-size: 9px; margin-top: 8px; }
.entity-arrow { color: #9ba3b4; font-size: 18px; }
.compact-card { box-shadow: none; }

.empty-panel { padding: 30px; }
.empty-state {
    min-height: 190px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    color: var(--muted);
}
.empty-state strong { color: var(--text); }
.empty-state .btn { margin-top: 12px; }
.empty-state.compact { min-height: 80px; }

.empty-icon { font-size: 26px; color: #c5c9d6; }

.mini-stat {
    padding: 24px 22px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.mini-stat span { color: var(--muted); }
.mini-stat strong { font-size: 28px; }

.settings-list { display: grid; gap: 12px; max-width: 850px; }
.settings-section {
    margin: 0;
    padding: 20px;
    display: grid;
    grid-template-columns: 44px 1fr auto;
    align-items: center;
    gap: 14px;
}
.settings-section h2 { margin: 0; font-size: 14px; }
.settings-section p { margin: 4px 0 0; color: var(--muted); font-size: 11px; }
.settings-icon {
    width: 42px; height: 42px; border-radius: 12px;
    background: #efeeff; color: var(--primary);
    display: grid; place-items: center;
}
.coming-soon {
    display: inline-flex;
    color: #747e94;
    background: #f0f2f6;
    border-radius: 999px;
    padding: 6px 9px;
    font-size: 9px;
    font-weight: 800;
}

.notifications-list { display: grid; }
.notification-item {
    display: flex;
    gap: 13px;
    padding: 16px 4px;
    color: inherit;
    text-decoration: none;
    border-bottom: 1px solid var(--border);
}
.notification-item:last-child { border-bottom: 0; }
.notification-item:hover { background: #fafaff; }
.notification-item strong { font-size: 13px; }
.notification-item p { margin: 4px 0; color: var(--muted); font-size: 12px; }
.notification-item small { color: var(--muted); font-size: 10px; }
.notification-icon {
    display: grid;
    width: 34px;
    height: 34px;
    place-items: center;
    flex: 0 0 auto;
    border-radius: 10px;
    background: #efeeff;
}

.alert {
    padding: 12px 14px;
    border-radius: 9px;
    margin-bottom: 15px;
    font-size: 11px;
}
.alert-error { color: #b73a4c; background: #fff0f2; border: 1px solid #ffd5db; }

.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(10,15,28,.55);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 20;
    padding: 20px;
}
.modal-backdrop.open { display: flex; }
.modal {
    position: relative;
    width: min(470px, 100%);
    background: white;
    border-radius: 18px;
    padding: 28px;
    box-shadow: 0 30px 80px rgba(0,0,0,.22);
}
.modal h2 { margin: 5px 0 22px; font-size: 20px; }
.modal form { display: grid; gap: 10px; }
.modal form .field-label:not(:first-child) { margin-top: 8px; }
.modal-close {
    position: absolute;
    top: 15px; right: 15px;
    border: 0; background: #f2f3f7; color: #677188;
    width: 30px; height: 30px; border-radius: 8px;
    cursor: pointer;
}

.login-body {
    min-height: 100vh;
    display: grid;
    place-items: center;
    background: radial-gradient(circle at top, #eeedff, var(--bg) 42%);
    padding: 20px;
}
.login-card {
    width: min(430px, 100%);
    background: white;
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 36px;
    box-shadow: 0 24px 70px rgba(22,31,56,.1);
}
.login-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 36px; font-size: 16px; }
.login-card h1 { margin: 6px 0; font-size: 28px; }
.login-card p { color: var(--muted); line-height: 1.6; font-size: 12px; margin-bottom: 24px; }
.login-card form { display: grid; gap: 9px; }
.login-card form .field-label:not(:first-child) { margin-top: 8px; }
.login-card .coming-soon { margin-top: 18px; }

@media (max-width: 1050px) {
    .sidebar { width: 215px; }
    .main { margin-left: 215px; width: calc(100% - 215px); }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .detail-grid, .upload-layout { grid-template-columns: 1fr; }
}

@media (max-width: 760px) {
    .sidebar {
        position: static;
        width: 100%;
        min-height: auto;
        height: auto;
    }
    .app-shell { display: block; }
    .sidebar-nav { display: flex; flex-wrap: wrap; gap: 4px; }
    .nav-label { display: none; }
    .nav-link { margin: 0; }
    .sidebar-footer { display: none; }
    .main { margin-left: 0; width: 100%; }
    .topbar { padding: 0 18px; }
    .page-content { padding: 22px 16px; }
    .page-heading, .detail-heading { align-items: flex-start; flex-direction: column; }
    .stats-grid, .cards-grid { grid-template-columns: 1fr; }
    .info-grid { grid-template-columns: 1fr; }
    .info-grid > div:nth-child(odd) { border-right: 0; }
    .toolbar { flex-direction: column; }
    .search-box { max-width: none; }
    .heading-actions { width: 100%; }
    .heading-actions .btn, .heading-actions form { flex: 1; }
}
/* =========================================================
   AUTH
   ========================================================= */

.logout-form {
    margin: 0;
}

.logout-button {
    height: 34px;
    padding: 0 14px;

    border: 1px solid var(--border);
    border-radius: 8px;

    background: #ffffff;
    color: var(--text);

    font-family: inherit;
    font-size: 13px;
    font-weight: 600;

    cursor: pointer;

    transition:
        background 0.15s ease,
        border-color 0.15s ease,
        box-shadow 0.15s ease,
        color 0.15s ease;
}

.logout-button:hover {
    background: #f7f7ff;
    border-color: #c8c9f5;
    color: var(--primary);
    box-shadow: 0 2px 8px rgba(35, 35, 70, 0.08);
}

.logout-button:active {
    transform: translateY(1px);
}


/* Registration type selector */

.registration-types {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    margin-bottom: 18px;
}

.registration-option {
    position: relative;
    display: block;
    cursor: pointer;
}

.registration-option input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.registration-option-content {
    display: flex;
    flex-direction: column;
    gap: 6px;

    min-height: 82px;
    padding: 14px;

    border: 1px solid var(--border);
    border-radius: 10px;

    background: #ffffff;

    transition:
        border-color 0.15s ease,
        background 0.15s ease,
        box-shadow 0.15s ease,
        transform 0.15s ease;
}

.registration-option-content strong {
    font-size: 13px;
    color: var(--text);
}

.registration-option-content small {
    font-size: 11px;
    line-height: 1.4;
    color: var(--muted);
}

.registration-option:hover .registration-option-content {
    border-color: #c8c9f5;
    transform: translateY(-1px);
}

.registration-option input:checked + .registration-option-content {
    border-color: var(--primary);
    background: #f8f7ff;
    box-shadow: 0 0 0 2px rgba(99, 91, 255, 0.08);
}


/* Auth errors */

.form-error {
    margin-bottom: 16px;
    padding: 10px 12px;

    border-radius: 8px;

    background: #fff1f1;
    border: 1px solid #ffd4d4;

    color: #c0392b;
    font-size: 12px;
}


/* Login ↔ Registration */

/* =========================================================
   AUTH SWITCH
   ========================================================= */

.auth-switch {
    margin-top: 20px;
    padding-top: 18px;

    border-top: 1px solid var(--border);

    text-align: center;

    font-size: 12px;
    line-height: 1.5;
    color: var(--muted);
}

.auth-switch::before {
    content: "or";

    display: block;

    margin-top: -26px;
    margin-bottom: 14px;

    padding: 0 10px;

    background: #ffffff;

    width: fit-content;
    margin-left: auto;
    margin-right: auto;

    color: var(--muted);
    font-size: 11px;
}

.auth-switch a {
    display: inline-flex;
    align-items: center;
    gap: 4px;

    margin-top: 5px;

    color: var(--text);
    font-weight: 700;
    text-decoration: none;

    transition:
        color 0.15s ease,
        transform 0.15s ease;
}

.auth-switch a:hover {
    color: var(--primary);
    text-decoration: none;
    transform: translateX(2px);
}
