:root {
    --bg: #f3f4f6;
    --bg-dark: #020617;
    --surface: #ffffff;
    --surface-alt: #f8fafc;
    --surface-dark: #0f172a;
    --surface-dark-alt: #111827;
    --line: #e2e8f0;
    --line-dark: #1f2937;
    --text: #0f172a;
    --muted: #64748b;
    --primary: #2563eb;
    --primary-strong: #1d4ed8;
    --success-bg: #dcfce7;
    --success-text: #15803d;
    --warning-bg: #fef3c7;
    --warning-text: #b45309;
    --danger-bg: #ffe4e6;
    --danger-text: #be123c;
    --shadow: 0 24px 48px rgba(15, 23, 42, 0.12);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    background:
        radial-gradient(circle at top left, rgba(37, 99, 235, 0.14), transparent 32%),
        radial-gradient(circle at bottom right, rgba(15, 23, 42, 0.12), transparent 28%),
        linear-gradient(180deg, #f8fafc 0%, #eef2ff 100%);
    color: var(--text);
    font-family: "Avenir Next", "Segoe UI", sans-serif;
}

button,
input,
select,
textarea {
    font: inherit;
}

button {
    cursor: pointer;
}

.hidden {
    display: none !important;
}

.screen {
    min-height: 100vh;
}

.login-screen {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.login-shell {
    width: 100%;
    max-width: 440px;
    animation: fade-up .35s ease;
}

.login-brand {
    text-align: center;
    margin-bottom: 28px;
}

.brand-mark {
    width: 72px;
    height: 72px;
    margin: 0 auto 16px;
    border-radius: 24px;
    display: grid;
    place-items: center;
    background: linear-gradient(135deg, var(--primary), #60a5fa);
    color: #fff;
    font-size: 2rem;
    font-weight: 900;
    box-shadow: 0 18px 40px rgba(37, 99, 235, 0.28);
}

.brand-logo {
    display: flex;
    align-items: center;
    justify-content: center;
}

.brand-logo img {
    display: block;
    width: 100%;
    height: auto;
    object-fit: contain;
}

.brand-logo-login {
    width: 195px;
    margin: 0 auto 12px;
}

.brand-logo-sidebar {
    width: 105px;
    max-width: 100%;
}

.brand-logo-sidebar.compact {
    width: 40px;
}

.brand-logo-sidebar.compact img {
    width: 40px;
    height: 40px;
    object-fit: cover;
    object-position: left center;
    border-radius: 12px;
}

.login-title {
    margin: 0;
    font-size: 2rem;
    font-weight: 800;
    letter-spacing: -.03em;
}

.login-subtitle {
    margin-top: 8px;
    color: var(--muted);
}

.card {
    background: rgba(255, 255, 255, 0.92);
    border: 1px solid rgba(226, 232, 240, 0.86);
    border-radius: 24px;
    box-shadow: var(--shadow);
}

.login-card {
    padding: 32px;
}

.field {
    margin-bottom: 18px;
}

.field-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: .72rem;
    font-weight: 800;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: .08em;
    margin-bottom: 8px;
}

.input {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 16px;
    padding: 14px 16px;
    background: var(--surface-alt);
    color: var(--text);
    transition: border-color .2s ease, box-shadow .2s ease, transform .2s ease;
}

.input:focus {
    outline: none;
    border-color: #93c5fd;
    box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.12);
}

.input-row {
    position: relative;
}

.toggle-password {
    position: absolute;
    top: 50%;
    right: 12px;
    transform: translateY(-50%);
    border: 0;
    background: transparent;
    color: var(--muted);
    font-size: .86rem;
    font-weight: 700;
}

.inline-meta {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 12px;
    margin-bottom: 22px;
    color: var(--muted);
    font-size: .84rem;
}

.remember {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.link-button {
    border: 0;
    background: transparent;
    color: var(--primary);
    font-weight: 700;
}

.primary-button,
.secondary-button,
.ghost-button,
.icon-button {
    border-radius: 16px;
    border: 1px solid transparent;
    transition: transform .18s ease, background-color .18s ease, border-color .18s ease, color .18s ease;
}

.primary-button {
    width: 100%;
    padding: 14px 18px;
    background: var(--primary);
    color: #fff;
    font-weight: 800;
    box-shadow: 0 16px 26px rgba(37, 99, 235, 0.24);
}

.primary-button:hover,
.secondary-button:hover,
.ghost-button:hover,
.icon-button:hover {
    transform: translateY(-1px);
}

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

.secondary-button {
    padding: 10px 14px;
    background: var(--surface);
    border-color: var(--line);
    color: var(--muted);
    font-weight: 700;
}

.ghost-button {
    padding: 10px 16px;
    background: transparent;
    border-color: var(--line);
    color: var(--muted);
    font-weight: 700;
}

.icon-button {
    width: 40px;
    height: 40px;
    background: transparent;
    color: var(--muted);
    border-color: transparent;
}

.alert {
    display: flex;
    gap: 10px;
    align-items: center;
    padding: 12px 14px;
    margin-bottom: 18px;
    border-radius: 16px;
    font-size: .82rem;
    font-weight: 700;
}

.alert-danger {
    background: #fff1f2;
    border: 1px solid #ffe4e6;
    color: var(--danger-text);
}

.helper-note {
    margin-top: 24px;
    text-align: center;
    font-size: .76rem;
    color: #94a3b8;
}

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

.sidebar {
    width: 272px;
    background: rgba(255, 255, 255, 0.94);
    border-right: 1px solid rgba(226, 232, 240, 0.9);
    display: flex;
    flex-direction: column;
    transition: width .25s ease;
    backdrop-filter: blur(18px);
}

.sidebar.collapsed {
    width: 92px;
}

.sidebar-header {
    padding: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.sidebar-header strong {
    font-size: 1.3rem;
    letter-spacing: -.03em;
}

.sidebar-nav {
    flex: 1;
    padding: 8px 16px 18px;
    overflow-y: auto;
}

.nav-section {
    margin-top: 18px;
    margin-bottom: 8px;
    font-size: .66rem;
    font-weight: 800;
    color: #94a3b8;
    letter-spacing: .16em;
    text-transform: uppercase;
    padding: 0 10px;
}

.nav-item {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 14px;
    margin-bottom: 8px;
    border: 0;
    border-radius: 18px;
    background: transparent;
    color: #64748b;
    font-weight: 700;
    text-align: left;
}

.nav-item.active {
    background: var(--primary);
    color: #fff;
    box-shadow: 0 16px 28px rgba(37, 99, 235, 0.22);
}

.nav-icon {
    width: 18px;
    height: 18px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 18px;
}

.svg-icon {
    width: 18px;
    height: 18px;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.sidebar-footer {
    padding: 16px;
    border-top: 1px solid var(--line);
}

.danger-button {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px;
    border: 0;
    border-radius: 18px;
    background: transparent;
    color: #e11d48;
    font-weight: 800;
}

.main {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.topbar {
    height: 72px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 28px;
    background: rgba(255, 255, 255, 0.9);
    border-bottom: 1px solid rgba(226, 232, 240, 0.9);
    backdrop-filter: blur(18px);
}

.topbar-title {
    color: var(--primary);
    font-size: .78rem;
    font-weight: 800;
    letter-spacing: .18em;
}

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

.notification {
    position: relative;
}

.dot {
    position: absolute;
    top: 7px;
    right: 8px;
    width: 8px;
    height: 8px;
    border-radius: 999px;
    background: #f43f5e;
    border: 2px solid #fff;
}

.user-meta {
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-copy {
    text-align: right;
}

.user-copy p,
.user-copy small {
    margin: 0;
}

.user-copy p {
    font-weight: 800;
}

.user-copy small {
    color: #94a3b8;
}

.avatar {
    width: 40px;
    height: 40px;
    border-radius: 999px;
    display: grid;
    place-items: center;
    background: linear-gradient(135deg, #dbeafe, #bfdbfe);
    color: var(--primary);
    border: 1px solid #cbd5e1;
    font-weight: 800;
}

.content {
    flex: 1;
    padding: 28px;
    background: rgba(248, 250, 252, 0.75);
    overflow-y: auto;
}

.container {
    max-width: 1280px;
    margin: 0 auto;
}

.stack {
    display: grid;
    gap: 24px;
    animation: fade-up .26s ease;
}

.section-head,
.toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
}

.section-head h2,
.panel-title {
    margin: 0;
    font-size: 2rem;
    letter-spacing: -.03em;
}

.section-head p {
    margin: 6px 0 0;
    color: var(--muted);
}

.kpi-grid,
.grid-3,
.invoice-kpis,
.project-grid,
.client-grid {
    display: grid;
    gap: 18px;
}

.kpi-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

.grid-3 {
    grid-template-columns: 2fr 1fr;
}

.project-grid,
.client-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.invoice-kpis {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.panel,
.table-card,
.metric-card,
.client-card,
.project-card {
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid rgba(226, 232, 240, 0.84);
    border-radius: 24px;
    box-shadow: 0 16px 32px rgba(15, 23, 42, 0.06);
}

.metric-card {
    padding: 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.metric-card p,
.metric-card h3 {
    margin: 0;
}

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

.metric-card h3 {
    margin-top: 6px;
    font-size: 2rem;
    letter-spacing: -.04em;
}

.metric-icon {
    width: 52px;
    height: 52px;
    border-radius: 18px;
    display: grid;
    place-items: center;
    background: var(--surface-alt);
    color: var(--primary);
}

.metric-icon .svg-icon {
    width: 22px;
    height: 22px;
}

.panel-head {
    padding: 20px 22px;
    border-bottom: 1px solid rgba(226, 232, 240, 0.82);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.panel-list {
    display: grid;
}

.list-row {
    display: flex;
    align-items: center;
    gap: 18px;
    padding: 18px 22px;
    border-top: 1px solid rgba(226, 232, 240, 0.82);
}

.list-row:first-child {
    border-top: 0;
}

.list-grow {
    flex: 1;
    min-width: 0;
}

.eyebrow {
    color: var(--primary);
    font-size: .72rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: .12em;
}

.subtle {
    color: #94a3b8;
    font-size: .78rem;
}

.progress-rail {
    width: 132px;
    height: 8px;
    border-radius: 999px;
    background: #e2e8f0;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    border-radius: inherit;
    background: var(--primary);
}

.badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 7px 10px;
    border-radius: 999px;
    font-size: .64rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: .1em;
}

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

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

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

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

.badge-primary {
    background: #dbeafe;
    color: var(--primary);
}

.toolbar {
    margin-bottom: 18px;
}

.search-wrap {
    position: relative;
    flex: 1;
}

.search-wrap .input {
    padding-left: 44px;
}

.search-icon {
    position: absolute;
    top: 50%;
    left: 16px;
    transform: translateY(-50%);
    color: #94a3b8;
    display: inline-flex;
}

.client-card,
.project-card {
    padding: 22px;
}

.client-top,
.project-top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 16px;
}

.client-head,
.project-head {
    display: flex;
    gap: 14px;
}

.client-initials {
    width: 52px;
    height: 52px;
    border-radius: 18px;
    display: grid;
    place-items: center;
    background: #dbeafe;
    color: var(--primary);
    font-weight: 800;
}

.client-meta,
.project-meta {
    display: grid;
    gap: 10px;
    color: var(--muted);
    font-size: .92rem;
}

.client-meta-item {
    display: flex;
    align-items: center;
    gap: 10px;
}

.client-meta-icon {
    width: 18px;
    height: 18px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #94a3b8;
    flex: 0 0 18px;
}

.client-meta-icon .svg-icon {
    width: 16px;
    height: 16px;
}

.client-foot,
.project-foot {
    margin-top: 18px;
    padding-top: 16px;
    border-top: 1px solid rgba(226, 232, 240, 0.82);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    color: var(--muted);
    font-size: .82rem;
}

.table-card {
    overflow: hidden;
}

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

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

thead {
    background: #f8fafc;
}

th,
td {
    padding: 18px 20px;
    text-align: left;
    font-size: .92rem;
}

th {
    color: var(--muted);
    font-size: .74rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: .1em;
}

tbody tr {
    border-top: 1px solid rgba(226, 232, 240, 0.82);
}

.task-title {
    display: flex;
    align-items: center;
    gap: 12px;
    font-weight: 700;
}

.task-done {
    text-decoration: line-through;
    color: #94a3b8;
}

.mini-avatar {
    width: 28px;
    height: 28px;
    border-radius: 999px;
    display: grid;
    place-items: center;
    background: #dbeafe;
    color: var(--primary);
    font-size: .72rem;
    font-weight: 800;
}

.table-action {
    border: 0;
    background: transparent;
    color: #94a3b8;
    font-weight: 800;
}

.table-icon {
    width: 16px;
    height: 16px;
}

.task-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
}

.icon-action-button {
    width: 34px;
    height: 34px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid rgba(226, 232, 240, 0.95);
    border-radius: 12px;
    background: #fff;
    color: #64748b;
    transition: transform .18s ease, border-color .18s ease, color .18s ease, background-color .18s ease;
}

.icon-action-button:hover {
    transform: translateY(-1px);
    border-color: #bfdbfe;
    color: var(--primary);
    background: #eff6ff;
}

.icon-action-button .svg-icon {
    width: 16px;
    height: 16px;
}

.icon-action-button.danger:hover {
    border-color: #fecdd3;
    color: #e11d48;
    background: #fff1f2;
}

.modal-backdrop {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 20px;
    background: rgba(15, 23, 42, 0.42);
    backdrop-filter: blur(6px);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.modal {
    width: 100%;
    max-width: 520px;
    padding: 24px;
    animation: fade-up .22s ease;
    margin: auto;
}

.modal-notes {
    max-width: 760px;
    display: grid;
    gap: 18px;
}

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

.modal-head h3 {
    margin: 0;
    font-size: 1.5rem;
    letter-spacing: -.03em;
}

.modal-kicker {
    margin: 0 0 6px;
    color: #94a3b8;
    font-size: .78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .12em;
}

.modal-notes .modal-head h3 {
    font-size: 2rem;
    letter-spacing: -.04em;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
}

.form-actions {
    display: flex;
    gap: 12px;
    margin-top: 18px;
}

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

.notes-thread {
    max-height: 420px;
    overflow-y: auto;
    display: grid;
    gap: 14px;
    padding: 6px 4px;
}

.notes-empty {
    padding: 32px 18px;
    text-align: center;
    color: var(--muted);
    background: var(--surface-alt);
    border: 1px dashed var(--line);
    border-radius: 18px;
}

.note-bubble {
    max-width: 82%;
    padding: 14px 16px;
    border-radius: 20px 20px 20px 8px;
    background: #f8fafc;
    border: 1px solid rgba(226, 232, 240, 0.9);
    box-shadow: 0 10px 18px rgba(15, 23, 42, 0.04);
}

.note-own {
    margin-left: auto;
    border-radius: 20px 20px 8px 20px;
    background: #dbeafe;
    border-color: #bfdbfe;
}

.note-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 10px;
    align-items: center;
    margin-bottom: 8px;
    font-size: .76rem;
    color: var(--muted);
}

.note-meta strong {
    color: var(--text);
}

.note-body {
    color: var(--text);
    line-height: 1.5;
    white-space: normal;
    word-break: break-word;
}

.notes-form {
    display: grid;
    gap: 8px;
}

.report-placeholder {
    padding: 44px;
    text-align: center;
    color: var(--muted);
}

@keyframes fade-up {
    from {
        opacity: 0;
        transform: translateY(12px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@media (max-width: 1100px) {
    .kpi-grid,
    .project-grid,
    .client-grid,
    .invoice-kpis {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .grid-3 {
        grid-template-columns: 1fr;
    }
}

body.modal-open {
    overflow: hidden;
}

.users-card-view {
    display: none;
    flex-direction: column;
    gap: 12px;
}

.user-card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 18px;
    padding: 18px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.user-card-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}

.user-card-body {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.user-card-row {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    font-size: .85rem;
    color: var(--text);
}

.user-card-label {
    color: var(--muted);
    font-weight: 600;
    flex-shrink: 0;
}

.user-card-foot {
    display: flex;
    gap: 16px;
    padding-top: 4px;
    border-top: 1px solid var(--line);
}

.hamburger-btn {
    display: none;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
    border-radius: 12px;
    color: var(--primary);
    transition: background-color .18s ease;
}

.hamburger-btn:hover {
    background: rgba(37, 99, 235, 0.08);
}

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    z-index: 99;
}

.sidebar-overlay.visible {
    display: block;
}

@media (max-width: 860px) {
    .hamburger-btn {
        display: flex;
    }

    .app-shell {
        flex-direction: row;
    }

    .sidebar,
    .sidebar.collapsed {
        position: fixed;
        top: 0;
        left: 0;
        height: 100dvh;
        width: 272px;
        z-index: 100;
        transform: translateX(-100%);
        transition: transform 0.25s ease;
        box-shadow: none;
    }

    .sidebar.mobile-open {
        transform: translateX(0);
        box-shadow: 4px 0 24px rgba(0, 0, 0, 0.15);
    }

    .main {
        width: 100%;
    }

    .topbar,
    .content {
        padding-left: 18px;
        padding-right: 18px;
    }

    .section-head,
    .toolbar,
    .inline-meta,
    .form-actions {
        flex-direction: column;
        align-items: stretch;
    }

    .kpi-grid,
    .project-grid,
    .client-grid,
    .invoice-kpis,
    .form-grid {
        grid-template-columns: 1fr;
    }

    .user-copy {
        display: none;
    }

    #toggle-sidebar {
        display: none;
    }

    .users-table-view {
        display: none;
    }

    .users-card-view {
        display: flex;
    }
}
