:root {
    --color-bg: #0f172a;
    --color-surface: rgba(15, 23, 42, 0.75);
    --color-accent: #3b82f6;
    --color-accent-dark: #1d4ed8;
    --color-success: #16a34a;
    --color-warning: #f97316;
    --color-danger: #ef4444;
    --color-muted: rgba(255, 255, 255, 0.65);
    --color-border: rgba(148, 163, 184, 0.2);
    --font-base: 'Segoe UI', 'Inter', -apple-system, BlinkMacSystemFont, 'Helvetica Neue', Arial, sans-serif;
    --shadow-soft: 0 18px 28px -18px rgba(15, 23, 42, 0.9);
    --radius-base: 18px;
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: var(--font-base);
    background: radial-gradient(circle at top left, #1e293b, #030712);
    color: #f8fafc;
    line-height: 1.5;
}

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

.app-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 1.5rem;
    padding: 2.5rem clamp(1.5rem, 5vw, 4rem);
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.2), rgba(56, 189, 248, 0.12));
    border-bottom: 1px solid rgba(148, 163, 184, 0.2);
}

.app-header h1 {
    margin: 0 0 0.35rem;
    font-size: clamp(2rem, 3vw, 2.6rem);
    font-weight: 600;
    letter-spacing: -0.02em;
}

.app-header p {
    margin: 0;
    max-width: 40ch;
    color: var(--color-muted);
}

.app-header .brand {
    display: flex;
    align-items: center;
    gap: 1.25rem;
}

.brand-logo {
    width: 110px;
    max-height: 60px;
    height: auto;
    object-fit: contain;
    border-radius: 10px;
    box-shadow: 0 8px 20px -16px rgba(15, 23, 42, 0.9);
}

.header-actions {
    display: flex;
    gap: 0.75rem;
    align-items: center;
}

.app-content {
    padding: clamp(1.5rem, 4vw, 3rem);
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.6rem;
    border-radius: 999px;
    border: 1px solid transparent;
    font-weight: 600;
    letter-spacing: 0.01em;
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.2s ease, background 0.2s ease, border-color 0.2s ease;
}

.button.primary {
    background: linear-gradient(135deg, var(--color-accent), var(--color-accent-dark));
    color: #f8fafc;
    box-shadow: 0 10px 20px -10px rgba(59, 130, 246, 0.75);
}

.button.ghost {
    background: transparent;
    border-color: rgba(148, 163, 184, 0.3);
    color: #e2e8f0;
}

.button.danger {
    background: linear-gradient(135deg, #ef4444, #b91c1c);
    color: #fee2e2;
    box-shadow: 0 12px 28px -14px rgba(239, 68, 68, 0.75);
}

.button:hover,
.button:focus-visible {
    transform: translateY(-2px);
}

.button[disabled] {
    opacity: 0.55;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.button.primary:hover,
.button.primary:focus-visible {
    box-shadow: 0 18px 32px -12px rgba(59, 130, 246, 0.8);
}

.button.small {
    padding: 0.45rem 1rem;
    font-size: 0.85rem;
}

.button.small.ghost {
    border-color: rgba(148, 163, 184, 0.35);
}

.button.ghost:hover,
.button.ghost:focus-visible {
    border-color: rgba(148, 163, 184, 0.5);
    background: rgba(59, 130, 246, 0.12);
}

.button.danger:hover,
.button.danger:focus-visible {
    box-shadow: 0 22px 40px -16px rgba(239, 68, 68, 0.85);
}

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

.metric-card {
    background: rgba(15, 23, 42, 0.65);
    border: 1px solid rgba(148, 163, 184, 0.15);
    padding: 1.5rem;
    border-radius: var(--radius-base);
    box-shadow: var(--shadow-soft);
    -webkit-backdrop-filter: blur(16px);
    backdrop-filter: blur(16px);
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.metric-card strong {
    font-size: 1.6rem;
    font-weight: 600;
}

.metric-card.small {
    font-size: 0.85rem;
    color: var(--color-muted);
}

.metric-card.warning {
    border-color: rgba(249, 115, 22, 0.35);
}

.metric-card.success {
    border-color: rgba(22, 163, 74, 0.35);
}

.metric-card.ghost {
    border-style: dashed;
    border-color: rgba(148, 163, 184, 0.35);
}

.metric-title {
    font-size: 0.9rem;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--color-muted);
}

.card {
    background: var(--color-surface);
    border-radius: var(--radius-base);
    border: 1px solid rgba(148, 163, 184, 0.2);
    box-shadow: var(--shadow-soft);
    -webkit-backdrop-filter: blur(18px);
    backdrop-filter: blur(18px);
    padding: 1.75rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.card-header {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 1rem;
    align-items: center;
}

.card-header h2 {
    margin: 0;
    font-size: 1.35rem;
    font-weight: 600;
}

.card-header p {
    margin: 0.25rem 0 0;
    color: var(--color-muted);
}

.filters-form {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

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

.form-grid label {
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
    font-size: 0.9rem;
}

.form-grid span {
    color: var(--color-muted);
    letter-spacing: 0.04em;
    text-transform: uppercase;
    font-size: 0.75rem;
}

input,
select,
textarea {
    width: 100%;
    border-radius: 12px;
    border: 1px solid rgba(148, 163, 184, 0.25);
    background: rgba(2, 6, 23, 0.4);
    padding: 0.75rem 1rem;
    color: #f8fafc;
    font-size: 0.95rem;
    transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

input:focus-visible,
select:focus-visible,
textarea:focus-visible {
    outline: none;
    border-color: rgba(59, 130, 246, 0.7);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.25);
    background: rgba(15, 23, 42, 0.75);
}

textarea {
    resize: vertical;
    min-height: 140px;
}

.form-actions {
    display: flex;
    justify-content: flex-end;
}

.form-actions .button {
    min-width: 200px;
}

.form-grid .full-width {
    grid-column: 1 / -1;
}

.checkbox {
    flex-direction: row;
    align-items: center;
    gap: 0.75rem;
    padding: 0.6rem 0.85rem;
    border-radius: 12px;
    border: 1px dashed rgba(148, 163, 184, 0.45);
    background: rgba(15, 23, 42, 0.45);
}

.checkbox input {
    width: 1.1rem;
    height: 1.1rem;
    margin: 0;
}

.checkbox span {
    text-transform: none;
    letter-spacing: normal;
    color: #f8fafc;
}

.table-wrapper {
    overflow-x: auto;
    border-radius: 14px;
    border: 1px solid rgba(148, 163, 184, 0.25);
}

.table-form {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.table-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
}

input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
}

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 840px;
}

thead {
    background: rgba(15, 23, 42, 0.9);
}

th,
td {
    padding: 0.95rem 1.1rem;
    text-align: left;
    border-bottom: 1px solid rgba(148, 163, 184, 0.12);
}

th {
    font-weight: 500;
    font-size: 0.8rem;
    color: var(--color-muted);
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

th:last-child,
td:last-child {
    text-align: right;
}

th:first-child,
td:first-child {
    width: 46px;
    text-align: center;
}

td.actions-cell {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    justify-content: flex-end;
    align-items: center;
}

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

.summary-grid p {
    margin: 0.25rem 0 0;
    color: #f8fafc;
    font-size: 1rem;
}

.preview {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    border: 1px solid rgba(148, 163, 184, 0.25);
    border-radius: 12px;
    background: rgba(15, 23, 42, 0.45);
}

.preview-actions {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

tbody tr:hover {
    background: rgba(59, 130, 246, 0.08);
}

tbody tr.overdue {
    background: rgba(239, 68, 68, 0.08);
}

.status {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.4rem 0.9rem;
    border-radius: 999px;
    font-weight: 600;
    font-size: 0.78rem;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.status-paid {
    background: rgba(22, 163, 74, 0.18);
    color: #4ade80;
}

.status-pending {
    background: rgba(59, 130, 246, 0.18);
    color: #93c5fd;
}

.status-late {
    background: rgba(239, 68, 68, 0.2);
    color: #fca5a5;
}

.status-cancelled {
    background: rgba(148, 163, 184, 0.2);
    color: rgba(148, 163, 184, 0.9);
}

.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.6rem;
    border-radius: 999px;
    font-size: 0.7rem;
    letter-spacing: 0.04em;
    margin-top: 0.4rem;
}

.badge.late {
    background: rgba(239, 68, 68, 0.16);
    color: #fecaca;
}

.badge.neutral {
    background: rgba(59, 130, 246, 0.16);
    color: #bfdbfe;
}

.notes {
    display: inline-block;
    max-width: 26ch;
    color: rgba(226, 232, 240, 0.88);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.muted {
    color: var(--color-muted);
    font-size: 0.8rem;
}

.alert {
    border-radius: 14px;
    padding: 1.1rem 1.35rem;
    display: flex;
    gap: 0.75rem;
    align-items: flex-start;
    border: 1px solid transparent;
}

.alert.success {
    background: rgba(22, 163, 74, 0.15);
    border-color: rgba(34, 197, 94, 0.35);
}

.alert.error {
    background: rgba(239, 68, 68, 0.18);
    border-color: rgba(248, 113, 113, 0.35);
}

.alert ul {
    margin: 0;
    padding-left: 1.1rem;
}

.empty-state {
    text-align: center;
    padding: 2.5rem 1rem;
    border-radius: 14px;
    background: rgba(15, 23, 42, 0.4);
    border: 1px dashed rgba(148, 163, 184, 0.2);
    color: rgba(226, 232, 240, 0.85);
}

.import-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.file-field {
    position: relative;
    border: 1px dashed rgba(148, 163, 184, 0.4);
    border-radius: 14px;
    padding: 1.2rem;
    text-align: center;
    cursor: pointer;
    background: rgba(15, 23, 42, 0.45);
}

.file-field input {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
}

.file-field span {
    color: #cbd5f5;
    font-weight: 500;
}

.app-footer {
    padding: 1.5rem;
    text-align: center;
    color: var(--color-muted);
    font-size: 0.85rem;
}

@media (max-width: 960px) {
    .app-header {
        text-align: center;
    }

    .app-header .brand {
        flex-direction: column;
    }

    .brand-logo {
        width: 96px;
        max-height: 52px;
    }

    .app-header p {
        margin: 0 auto;
    }

    .header-actions {
        justify-content: center;
        width: 100%;
    }

    .card {
        padding: 1.35rem;
    }

    .form-grid {
        grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    }

    table {
        min-width: 760px;
    }
}

@media (max-width: 680px) {
    .dashboard {
        grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    }

    .metric-card {
        padding: 1.2rem;
    }

    .card-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .form-actions {
        flex-direction: column;
        gap: 0.75rem;
    }

    .form-actions .button {
        width: 100%;
    }
}

/* Auth Pages */
.auth-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
}

.auth-card {
    width: 100%;
    max-width: 400px;
    background: var(--color-surface);
    border-radius: var(--radius-base);
    border: 1px solid rgba(148, 163, 184, 0.2);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    -webkit-backdrop-filter: blur(20px);
    backdrop-filter: blur(20px);
    padding: 2.5rem;
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.auth-header {
    text-align: center;
}

.auth-header h1 {
    font-size: 1.8rem;
    font-weight: 700;
    margin: 0 0 0.5rem;
    color: #f8fafc;
}

.auth-header p {
    margin: 0;
    color: var(--color-muted);
    font-size: 0.95rem;
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.auth-actions {
    margin-top: 1rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.auth-actions .button {
    width: 100%;
}

.auth-footer {
    text-align: center;
    font-size: 0.9rem;
    color: var(--color-muted);
}

.auth-footer a {
    color: var(--color-accent);
    font-weight: 500;
    transition: color 0.2s ease;
}

.auth-footer a:hover {
    color: var(--color-accent-dark);
    text-decoration: underline;
}

/* Autocomplete Custom Styling */
.autocomplete-container {
    position: relative;
    width: 100%;
}

.autocomplete-dropdown {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    z-index: 1000;
    max-height: 200px;
    overflow-y: auto;
    background: rgba(15, 23, 42, 0.95);
    -webkit-backdrop-filter: blur(12px);
    backdrop-filter: blur(12px);
    border: 1px solid rgba(148, 163, 184, 0.25);
    border-radius: 8px;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.6);
}

.autocomplete-item {
    padding: 0.65rem 0.9rem;
    cursor: pointer;
    color: #e2e8f0;
    font-size: 0.88rem;
    transition: background 0.15s ease, color 0.15s ease;
}

.autocomplete-item:hover,
.autocomplete-item.active {
    background: rgba(59, 130, 246, 0.25);
    color: #ffffff;
}

.autocomplete-no-results {
    padding: 0.65rem 0.9rem;
    color: var(--color-muted);
    font-size: 0.85rem;
    font-style: italic;
}