@import url('https://fonts.googleapis.com/css2?family=Manrope:wght@400;500;600;700;800&display=swap');

:root {
    --bg-main: #12091f;
    --bg-soft: #1b1030;
    --bg-card: #24153f;
    --bg-card-hover: #2b1950;
    --border: #4b2f7e;
    --text-main: #f4ecff;
    --text-muted: #bcabd9;
    --accent: #8f5bff;
    --accent-strong: #a572ff;
    --success: #37d59c;
    --error: #ff6f91;
    --shadow: 0 14px 36px rgba(7, 2, 16, 0.55);
    color-scheme: dark;
    --font-main: "Manrope", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: var(--font-main);
    font-size: 16px;
    line-height: 1.45;
    background:
        radial-gradient(circle at 8% -10%, rgba(143, 91, 255, 0.23), transparent 46%),
        radial-gradient(circle at 92% 0%, rgba(82, 26, 168, 0.3), transparent 38%),
        var(--bg-main);
    color: var(--text-main);
    animation: pageFadeIn 0.35s ease;
}

.page {
    max-width: 1480px;
    margin: 0 auto;
    padding: 28px 32px 40px;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 36px;
}

.logo {
    font-size: 42px;
    font-weight: 800;
    color: var(--accent-strong);
    line-height: 1;
    letter-spacing: 1px;
}

.nav {
    display: flex;
    gap: 30px;
    align-items: center;
    flex-wrap: wrap;
}

.nav a {
    display: inline-flex;
    align-items: center;
    text-decoration: none;
    color: var(--text-muted);
    font-size: 20px;
    font-weight: 500;
    line-height: 1;
    transition: color 0.2s ease;
}

.nav a:hover,
.nav a.active {
    color: var(--text-main);
}

.flash {
    padding: 14px 16px;
    border-radius: 12px;
    margin-bottom: 20px;
}

.success {
    background: rgba(55, 213, 156, 0.16);
    border: 1px solid rgba(55, 213, 156, 0.44);
    color: #b9ffe6;
}

.error {
    background: rgba(255, 111, 145, 0.14);
    border: 1px solid rgba(255, 111, 145, 0.42);
    color: #ffd5df;
}

.card {
    background: linear-gradient(180deg, rgba(43, 25, 80, 0.78), rgba(31, 18, 58, 0.9));
    border: 1px solid var(--border);
    border-radius: 20px;
    box-shadow: var(--shadow);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.card:hover {
    transform: translateY(-2px);
    box-shadow: 0 18px 40px rgba(7, 2, 16, 0.62);
}

.btn {
    display: inline-block;
    padding: 12px 18px;
    border-radius: 12px;
    border: 1px solid #7247c5;
    background: linear-gradient(135deg, var(--accent), #6a45bf);
    color: #fff;
    text-decoration: none;
    cursor: pointer;
    font-size: 15px;
    font-weight: 700;
    transition: transform 0.2s ease, filter 0.2s ease;
}

.btn:hover {
    filter: brightness(1.08);
    transform: translateY(-1px);
}

.btn.secondary {
    background: #3e2a64;
}

.form-input {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid #5a3a92;
    border-radius: 12px;
    box-sizing: border-box;
    font-size: 15px;
    color: var(--text-main);
    background: rgba(20, 12, 36, 0.72);
}

select.form-input {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    padding-right: 42px;
    min-height: 44px;
    line-height: 1.35;
    cursor: pointer;
    background-color: rgba(20, 12, 36, 0.72);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23d9c7ff' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 16px 16px;
}

select.form-input:focus {
    outline: none;
    border-color: var(--accent-strong);
    box-shadow: 0 0 0 1px rgba(165, 114, 255, 0.35);
}

select.form-input:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

select.form-input option,
select.form-input optgroup {
    background-color: var(--bg-soft);
    color: var(--text-main);
}

input[type="datetime-local"].form-input,
input[type="date"].form-input,
input[type="time"].form-input,
input[type="month"].form-input,
input[type="week"].form-input {
    color-scheme: dark;
    min-height: 44px;
    line-height: 1.35;
}

input[type="number"].form-input {
    min-height: 46px;
    line-height: 1.35;
}

input[type="datetime-local"].form-input::-webkit-calendar-picker-indicator,
input[type="date"].form-input::-webkit-calendar-picker-indicator,
input[type="month"].form-input::-webkit-calendar-picker-indicator,
input[type="week"].form-input::-webkit-calendar-picker-indicator {
    cursor: pointer;
    opacity: 0.95;
    filter: invert(1) brightness(1.35) saturate(0.3);
}

input[type="time"].form-input::-webkit-calendar-picker-indicator {
    cursor: pointer;
    opacity: 0.95;
    filter: invert(1) brightness(1.35) saturate(0.3);
}

.form-input:focus-visible {
    outline: none;
    border-color: var(--accent-strong);
    box-shadow: 0 0 0 1px rgba(165, 114, 255, 0.35);
}

.form-group {
    margin-bottom: 18px;
}

label.form-check {
    display: inline-flex;
    align-items: center;
    margin-bottom: 0;
    padding-left: 34px;
    min-height: 28px;
    position: relative;
    cursor: pointer;
    font-weight: 600;
    color: var(--text-muted);
    user-select: none;
}

.form-check-input {
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 22px;
    height: 22px;
    margin: 0;
    opacity: 0;
    cursor: pointer;
    z-index: 2;
}

.form-check-input:disabled {
    cursor: not-allowed;
}

.form-check-input:disabled + .form-check-box {
    opacity: 0.5;
}

.form-check-box {
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 22px;
    height: 22px;
    border-radius: 7px;
    border: 2px solid #5a3a92;
    background: rgba(20, 12, 36, 0.92);
    box-sizing: border-box;
    pointer-events: none;
    transition: border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
}

.form-check-input:focus-visible + .form-check-box {
    outline: none;
    box-shadow: 0 0 0 2px rgba(165, 114, 255, 0.45);
    border-color: var(--accent-strong);
}

.form-check-input:checked + .form-check-box {
    background: linear-gradient(135deg, var(--accent), #6a45bf);
    border-color: var(--accent-strong);
}

.form-check-input:checked + .form-check-box::after {
    content: "";
    position: absolute;
    left: 7px;
    top: 3px;
    width: 5px;
    height: 10px;
    border: solid #fff;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

.form-check-text {
    line-height: 1.35;
    color: var(--text-muted);
}

label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: var(--text-muted);
}

.grid-two {
    display: grid;
    grid-template-columns: 1.1fr 0.9fr;
    gap: 28px;
}

.stack {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.section-title {
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 22px;
}

.muted {
    margin-top: 24px;
    color: var(--text-muted);
    font-size: 15px;
}

.center-card {
    width: min(92vw, 860px);
    margin: 40px auto;
    padding: 40px 44px;
}

.auth-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.center-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.auth-title {
    margin: 0 0 20px;
    font-size: 30px;
}

.auth-text {
    font-size: 16px;
    line-height: 1.5;
    margin: 0 0 24px;
    color: var(--text-muted);
}

.qr-box {
    background: #fff;
    display: inline-block;
    padding: 16px;
    border-radius: 16px;
    margin-bottom: 20px;
}

.link {
    color: #d9c7ff;
    word-break: break-all;
}

.auth-form .form-group {
    margin-bottom: 18px;
}

.auth-page .auth-title {
    font-size: 34px;
    margin-bottom: 24px;
}

.auth-page .btn {
    padding: 14px 18px;
    font-size: 16px;
}

.settings-page {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    min-height: calc(100vh - 200px);
}

.settings-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 28px;
    width: 100%;
    max-width: 960px;
    align-items: stretch;
}

.settings-card {
    padding: 28px;
    display: flex;
    flex-direction: column;
    min-height: 100%;
    height: auto;
    box-sizing: border-box;
}

.settings-card .stack {
    flex: 1 1 auto;
}

.settings-card .muted {
    margin-top: auto;
}

@media (max-width: 900px) {
    .settings-grid {
        grid-template-columns: 1fr;
        max-width: 560px;
    }
}

.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: rgba(6, 3, 11, 0.78);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.22s ease, visibility 0.22s ease;
}

.modal-overlay.is-open {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

.modal-panel {
    width: min(820px, 100%);
    max-height: calc(100vh - 48px);
    overflow: auto;
    padding: 28px;
    border-radius: 20px;
    border: 1px solid var(--border);
    background: var(--bg-card);
    box-shadow: var(--shadow);
    opacity: 0;
    transform: translateY(14px) scale(0.98);
    transition: opacity 0.22s ease, transform 0.22s ease;
}

.modal-panel .form-input,
.modal-panel textarea.form-input {
    background-color: var(--bg-soft);
}

.modal-overlay.is-open .modal-panel {
    opacity: 1;
    transform: translateY(0) scale(1);
}

.modal-panel--wide {
    width: min(900px, 100%);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 18px;
}

.modal-title {
    margin: 0;
    font-size: 24px;
    font-weight: 700;
    color: var(--text-main);
}

.modal-close {
    border: 1px solid var(--border);
    background: var(--bg-card);
    color: var(--text-main);
    width: 36px;
    height: 36px;
    border-radius: 10px;
    cursor: pointer;
    font-size: 22px;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

@keyframes pageFadeIn {
    from {
        opacity: 0;
        transform: translateY(6px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Owner shell with left burger-style navigation */
.app-shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 260px minmax(0, 1fr);
}

.sidebar {
    position: sticky;
    top: 0;
    min-height: 100vh;
    padding: 28px 20px;
    border-right: 1px solid rgba(143, 91, 255, 0.22);
    background: linear-gradient(180deg, rgba(27, 16, 48, 0.96), rgba(18, 9, 31, 0.96));
    box-shadow: 14px 0 36px rgba(7, 2, 16, 0.24);
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 34px;
}

.sidebar-burger {
    width: 42px;
    height: 42px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 14px;
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.04);
    color: var(--text-main);
    font-size: 28px;
    line-height: 1;
}

.sidebar .logo {
    font-size: 32px;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.sidebar-link {
    display: flex;
    align-items: center;
    min-height: 50px;
    padding: 14px 16px;
    border-radius: 16px;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 18px;
    font-weight: 700;
    border: 1px solid transparent;
    transition: 0.2s ease;
}

.sidebar-link:hover {
    color: var(--text-main);
    background: rgba(255, 255, 255, 0.045);
    border-color: rgba(143, 91, 255, 0.22);
}

.sidebar-link.active {
    color: #fff;
    background: linear-gradient(135deg, rgba(143, 91, 255, 0.92), rgba(106, 69, 191, 0.92));
    border-color: rgba(165, 114, 255, 0.75);
    box-shadow: 0 14px 30px rgba(88, 45, 170, 0.22);
}

.page-with-sidebar {
    max-width: none;
    width: 100%;
    min-width: 0;
}

.settings-page--wide {
    align-items: flex-start;
    min-height: auto;
}

.settings-shell {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
}

.settings-tabs {
    min-height: auto;
    padding: 10px;
    margin-bottom: 24px;
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.settings-tab {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    padding: 11px 16px;
    border-radius: 14px;
    color: var(--text-muted);
    text-decoration: none;
    font-weight: 700;
    border: 1px solid transparent;
}

.settings-tab:hover,
.settings-tab.active {
    color: #fff;
    background: rgba(143, 91, 255, 0.22);
    border-color: rgba(143, 91, 255, 0.45);
}

.crm-hero {
    min-height: auto;
    padding: 28px 30px;
    margin-bottom: 24px;
}

.crm-hero .section-title {
    margin-bottom: 8px;
}

.crm-hero-text {
    margin-top: 0;
}

@media (max-width: 900px) {
    .app-shell {
        grid-template-columns: 1fr;
    }

    .sidebar {
        position: relative;
        min-height: auto;
        padding: 18px 18px 14px;
        border-right: 0;
        border-bottom: 1px solid rgba(143, 91, 255, 0.22);
    }

    .sidebar-brand {
        margin-bottom: 16px;
    }

    .sidebar-nav {
        flex-direction: row;
        overflow-x: auto;
        padding-bottom: 4px;
    }

    .sidebar-link {
        flex: 0 0 auto;
        min-height: 44px;
        font-size: 16px;
    }
}

html {
    scroll-behavior: smooth;
}

/* Global typography: Manrope across all app UI */
html,
body,
button,
input,
textarea,
select {
    font-family: var(--font-main) !important;
}

.app-shell,
.app-shell *,
.page,
.page *,
.card,
.card *,
.sidebar,
.sidebar *,
.modal,
.modal *,
.app-modal,
.app-modal * {
    font-family: var(--font-main) !important;
}

.card-value,
.small-card-value,
.stats-big,
.metric-value,
.stat-value,
.kpi-number,
.big-number {
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.03em;
}
