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

:root {
    --bg-page: #303841;
    --bg-surface: #3a444d;
    --bg-muted: #2c333a;
    --bg-strong: #242a30;
    --border: #4a5661;
    --text-primary: #edf2f7;
    --text-secondary: #b4c1cb;
    --accent: #8b5cf6;
    --accent-strong: #7c3aed;
    --accent-soft: #a78bfa;
    --success: #22c55e;
    --warning: #f59e0b;
    --error: #ef4444;
    --radius: 0;
    --space-1: 8px;
    --space-2: 12px;
    --space-3: 16px;
    --space-4: 24px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html,
body {
    width: 100%;
    min-height: 100%;
}

body {
    font-family: 'Inter', sans-serif;
    background: var(--bg-page);
    color: var(--text-primary);
    line-height: 1.5;
    overflow-x: hidden;
}

h1,
h2,
h3 {
    color: var(--text-primary);
    margin-bottom: var(--space-2);
}

p,
small {
    color: var(--text-secondary);
}

a {
    color: var(--accent-soft);
}

.layout {
    min-height: 100vh;
}

.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: 280px;
    max-width: 85vw;
    background: var(--bg-strong);
    color: var(--text-primary);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    transform: translateX(-100%);
    z-index: 30;
}

.sidebar-header {
    padding: var(--space-4);
    border-bottom: 1px solid var(--border);
}

.sidebar-header h2 {
    margin: 0;
    color: var(--text-primary);
    font-size: 1.2rem;
}

.sidebar-nav {
    padding: var(--space-3);
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
}

.nav-item {
    display: block;
    padding: 10px 12px;
    border-radius: var(--radius);
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: 500;
    border: 1px solid transparent;
}

.nav-item:hover {
    background: var(--bg-muted);
    color: var(--text-primary);
    border-color: var(--border);
}

.nav-item.active {
    background: var(--accent);
    color: #ffffff;
    border-color: transparent;
}

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

.content {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.top-bar {
    position: sticky;
    top: 0;
    z-index: 10;
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border);
    padding: var(--space-3) var(--space-4);
    display: flex;
    align-items: center;
    gap: var(--space-3);
}

.top-bar-left {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    margin-right: auto;
}

.top-bar > h1 {
    margin-right: auto;
}

.top-bar h1 {
    margin: 0;
    font-size: 1.9rem;
    font-weight: 700;
}

.nav-toggle-btn {
    width: 42px;
    height: 42px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-strong);
    color: var(--text-primary);
    font-size: 1.35rem;
    cursor: pointer;
}

.user-info {
    background: var(--bg-muted);
    border: 1px solid var(--border);
    border-radius: 0;
    color: var(--text-secondary);
    font-size: 0.85rem;
    padding: 7px 12px;
}

.dashboard-content {
    padding: var(--space-4);
}

.content > .content-card,
.content > .invitations-list,
.content > .alert {
    margin: var(--space-4);
}

.content-card,
.stat-card,
.task-card,
.user-card,
.invitation-card,
.login-box,
fieldset {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.content-card,
.invitation-card,
.login-box,
fieldset {
    padding: var(--space-4);
}

.stats-grid,
.tasks-grid,
.notes-grid,
.users-list,
.action-list,
.invitations-list {
    display: grid;
    gap: var(--space-3);
}

.stats-grid {
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    margin-bottom: var(--space-4);
}

.tasks-grid {
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
}

.notes-grid {
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
}

.users-list,
.action-list,
.invitations-list {
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
}

.stat-card,
.task-card,
.user-card,
.note-card {
    padding: var(--space-3);
}

.note-card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
    box-shadow: 0 10px 22px rgba(15, 20, 26, 0.28);
}

.note-card.shared-note {
    border-left: 4px solid var(--accent-soft);
    background: linear-gradient(180deg, rgba(167, 139, 250, 0.08) 0%, var(--bg-surface) 30%);
}

.note-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: var(--space-2);
}

.note-title p,
.note-description p {
    color: inherit;
}

.note-meta {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-1);
    margin-bottom: var(--space-2);
}

.note-badge {
    display: inline-block;
    border: 1px solid rgba(167, 139, 250, 0.45);
    background: rgba(167, 139, 250, 0.12);
    color: var(--accent-soft);
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    padding: 4px 8px;
    text-transform: uppercase;
}

.note-description {
    color: var(--text-secondary);
    line-height: 1.65;
    border-top: 1px dashed rgba(180, 193, 203, 0.22);
    padding-top: var(--space-2);
}

.note-actions {
    display: flex;
    gap: var(--space-2);
    margin-top: auto;
}

.note-readonly {
    margin-top: auto;
    color: var(--text-secondary);
    font-size: 0.85rem;
    font-weight: 600;
    border-top: 1px dashed rgba(180, 193, 203, 0.22);
    padding-top: var(--space-2);
}

.richtext-hidden {
    display: none;
}

.richtext-wrapper {
    border: 1px solid var(--border);
    background: var(--bg-strong);
}

.richtext-wrapper .ql-toolbar.ql-snow {
    border: 0;
    border-bottom: 1px solid var(--border);
    background: var(--bg-muted);
}

.richtext-wrapper .ql-container.ql-snow {
    border: 0;
    min-height: 120px;
    color: var(--text-primary);
    font-family: inherit;
}

.richtext-wrapper .ql-editor {
    min-height: 120px;
    color: var(--text-primary);
}

.richtext-wrapper .ql-snow .ql-stroke {
    stroke: var(--text-secondary);
}

.richtext-wrapper .ql-snow .ql-fill,
.richtext-wrapper .ql-snow .ql-picker {
    fill: var(--text-secondary);
    color: var(--text-secondary);
}

.note-modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.65);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-3);
    z-index: 60;
}

.note-modal.hidden {
    display: none;
}

.note-modal-card {
    width: min(760px, 100%);
    max-height: 90vh;
    overflow-y: auto;
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--accent-soft);
}

.stat-label {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.dashboard-section {
    margin-bottom: var(--space-4);
}

.section-header,
.task-header,
.btn-group,
.action-buttons,
.form-actions {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    flex-wrap: wrap;
}

.task-header {
    justify-content: space-between;
    margin-bottom: var(--space-2);
}

.task-meta {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
    margin: var(--space-2) 0;
    font-size: 0.9rem;
}

.task-points {
    color: var(--accent-soft);
    font-weight: 600;
}

.task-deadline {
    color: var(--text-secondary);
}

.task-status,
.badge {
    display: inline-block;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    padding: 5px 8px;
    border-radius: 0;
}

.task-status.pending,
.badge-pending {
    background: rgba(245, 158, 11, 0.16);
    color: var(--warning);
}

.task-status.completed,
.badge-accepted {
    background: rgba(34, 197, 94, 0.16);
    color: var(--success);
}

.task-status.failed,
.badge-rejected {
    background: rgba(239, 68, 68, 0.16);
    color: var(--error);
}

.badge-revoked {
    background: rgba(180, 193, 203, 0.18);
    color: var(--text-secondary);
}

.user-card {
    overflow: hidden;
}

.user-card-header {
    background: var(--bg-muted);
    border-bottom: 1px solid var(--border);
    padding: var(--space-3);
}

.user-card-header h3 {
    margin: 0;
}

.user-card-body {
    padding: var(--space-3);
}

form {
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
}

label {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-primary);
}

input[type='text'],
input[type='email'],
input[type='password'],
input[type='number'],
input[type='date'],
input[type='datetime-local'],
textarea,
select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-strong);
    font: inherit;
    color: var(--text-primary);
}

input[type='datetime-local'] {
    color-scheme: dark;
}

input[type='datetime-local']::-webkit-calendar-picker-indicator {
    cursor: pointer;
    opacity: 0.82;
    filter: invert(83%) sepia(10%) saturate(286%) hue-rotate(170deg) brightness(92%) contrast(91%);
}

input[type='datetime-local']:hover::-webkit-calendar-picker-indicator,
input[type='datetime-local']:focus::-webkit-calendar-picker-indicator {
    opacity: 1;
}

input[type='datetime-local']::-webkit-datetime-edit,
input[type='datetime-local']::-webkit-datetime-edit-text,
input[type='datetime-local']::-webkit-datetime-edit-month-field,
input[type='datetime-local']::-webkit-datetime-edit-day-field,
input[type='datetime-local']::-webkit-datetime-edit-year-field,
input[type='datetime-local']::-webkit-datetime-edit-hour-field,
input[type='datetime-local']::-webkit-datetime-edit-minute-field {
    color: var(--text-primary);
}

input:focus,
textarea:focus,
select:focus {
    outline: 2px solid rgba(139, 92, 246, 0.45);
    border-color: var(--accent);
}

input:disabled {
    background: var(--bg-muted);
    color: var(--text-secondary);
}

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

legend {
    padding: 0 var(--space-1);
    font-weight: 700;
    color: var(--text-primary);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid transparent;
    border-radius: var(--radius);
    padding: 10px 14px;
    text-decoration: none;
    font-weight: 600;
    cursor: pointer;
}

.btn-primary {
    background: var(--accent);
    color: #ffffff;
}

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

.btn-secondary {
    background: var(--bg-muted);
    border-color: var(--border);
    color: var(--text-primary);
}

.btn-secondary:hover {
    background: #313943;
}

.btn-danger {
    background: #7f1d1d;
    color: #ffffff;
}

.btn-danger:hover {
    background: #991b1b;
}

.btn-small {
    padding: 7px 10px;
    font-size: 0.85rem;
}

.alert {
    padding: 10px 12px;
    border-radius: var(--radius);
    border: 1px solid;
    margin-bottom: var(--space-3);
}

.alert-error {
    background: rgba(239, 68, 68, 0.12);
    border-color: rgba(239, 68, 68, 0.28);
    color: #fecaca;
}

.alert-success {
    background: rgba(34, 197, 94, 0.12);
    border-color: rgba(34, 197, 94, 0.28);
    color: #bbf7d0;
}

.alert-warning {
    background: rgba(245, 158, 11, 0.12);
    border-color: rgba(245, 158, 11, 0.28);
    color: #fde68a;
}

table {
    width: 100%;
    border-collapse: collapse;
    margin-top: var(--space-3);
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

table th,
table td {
    padding: 10px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

table th {
    background: var(--bg-muted);
    font-size: 0.9rem;
    color: var(--text-primary);
}

table td {
    color: var(--text-secondary);
}

.invitations-table,
.content-card,
.invitation-card {
    overflow-x: auto;
}

.invitation-card h3 {
    margin-bottom: var(--space-1);
}

.invitation-form {
    gap: var(--space-2);
}

.login-container,
.error-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-3);
}

.login-box {
    width: 100%;
    max-width: 420px;
}

.login-box h1,
.subtitle,
.form-footer,
.empty-state,
.text-center {
    text-align: center;
}

.subtitle,
.empty-state {
    color: var(--text-secondary);
}

.empty-state {
    padding: var(--space-4);
    background: var(--bg-surface);
    border: 1px dashed var(--border);
    border-radius: var(--radius);
}

.error-container h1 {
    font-size: clamp(3rem, 8vw, 4.5rem);
    color: #e2e8f0;
    margin-bottom: var(--space-2);
}

.mt-lg {
    margin-top: var(--space-4);
}

.mb-lg {
    margin-bottom: var(--space-4);
}

.p-lg {
    padding: var(--space-4);
}

@media (max-width: 768px) {
    :root {
        --space-1: 6px;
        --space-2: 10px;
        --space-3: 14px;
        --space-4: 18px;
    }

    .sidebar {
        width: min(260px, 88vw);
    }

    .top-bar {
        padding: 12px 14px;
        gap: var(--space-2);
    }

    .top-bar h1 {
        font-size: 1.25rem;
    }

    .dashboard-content {
        padding: var(--space-3);
    }

    .content > .content-card,
    .content > .invitations-list,
    .content > .alert {
        margin: 0 0 var(--space-3);
        padding: var(--space-3);
    }

    .stats-grid,
    .tasks-grid,
    .notes-grid,
    .users-list,
    .action-list,
    .invitations-list {
        grid-template-columns: 1fr;
        gap: var(--space-2);
    }

    .dashboard-section {
        margin-bottom: var(--space-3);
    }

    .task-header {
        flex-direction: column;
        align-items: flex-start;
        gap: var(--space-1);
    }

    .user-info {
        max-width: 46vw;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .btn,
    .btn-small {
        width: 100%;
        min-height: 42px;
    }

    .note-actions {
        flex-direction: column;
    }

    .btn-group,
    .action-buttons,
    .form-actions {
        flex-direction: column;
        align-items: stretch;
    }

    table {
        display: block;
        white-space: nowrap;
    }
}

@media (max-width: 480px) {
    .sidebar {
        width: min(240px, 92vw);
    }

    .top-bar {
        padding: 10px 12px;
    }

    .top-bar h1 {
        font-size: 1.1rem;
    }

    .nav-toggle-btn {
        width: 38px;
        height: 38px;
        font-size: 1.2rem;
    }

    .stat-value {
        font-size: 1.7rem;
    }

    input[type='text'],
    input[type='email'],
    input[type='password'],
    input[type='number'],
    input[type='date'],
    input[type='datetime-local'],
    textarea,
    select {
        padding: 9px 10px;
    }

    .task-status,
    .badge {
        font-size: 0.68rem;
        padding: 4px 7px;
    }
}
