/* =========================================================
   TaskFlow — минималистичный air-дизайн
   Светлый фон, свободное пространство, чёткая сетка, тени
   ========================================================= */

:root {
    --bg: #f7f7f9;
    --surface: #ffffff;
    --surface-2: #f1f1f4;
    --text: #1c1c28;
    --text-muted: #6b6b7b;
    --border: #e4e4ea;
    --primary: #4f46e5;
    --primary-dark: #4338ca;
    --accent: #0ea5e9;
    --danger: #e11d48;
    --success: #16a34a;
    --warning: #d97706;

    --red: rgba(225, 29, 72, 0.5);
    --green: rgba(22, 163, 74, 0.5);
    --yellow: rgba(217, 119, 6, 0.5);
    --gray: rgba(107, 107, 123, 0.5);

    --radius: 12px;
    --radius-sm: 8px;
    --shadow: 0 1px 3px rgba(28, 28, 40, 0.06), 0 4px 16px rgba(28, 28, 40, 0.05);
    --shadow-sm: 0 1px 2px rgba(28, 28, 40, 0.05);
    --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
        "Helvetica Neue", Arial, sans-serif;
}

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

html {
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    min-height: 100vh;
}

a {
    color: var(--primary);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

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

.container {
    width: 100%;
    max-width: 1080px;
    margin: 0 auto;
    padding: 24px 20px 64px;
    flex: 1;
}

/* ---------- Навигация ---------- */

.navbar {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 50;
}

.navbar-inner {
    max-width: 1080px;
    margin: 0 auto;
    padding: 0 20px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.brand {
    font-weight: 700;
    font-size: 18px;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 8px;
}

.brand:hover {
    text-decoration: none;
}

.brand .logo {
    width: 26px;
    height: 26px;
    border-radius: 8px;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    display: inline-block;
}

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

.nav-link {
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    font-size: 14px;
    font-weight: 500;
}

.nav-link:hover {
    background: var(--surface-2);
    text-decoration: none;
    color: var(--text);
}

.nav-link.active {
    background: var(--surface-2);
    color: var(--primary);
}

.nav-user {
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--text-muted);
    font-size: 14px;
}

.nav-user-name {
    color: var(--text);
    font-weight: 600;
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.nav-user-name:hover {
    text-decoration: underline;
}

/* ---------- Кнопки ---------- */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 9px 16px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.15s, border-color 0.15s, box-shadow 0.15s;
}

.btn:hover {
    background: var(--surface-2);
    text-decoration: none;
}

.btn-primary {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}

.btn-primary:hover {
    background: var(--primary-dark);
    color: #fff;
}

.btn-danger {
    background: transparent;
    border-color: var(--danger);
    color: var(--danger);
}

.btn-danger:hover {
    background: var(--danger);
    color: #fff;
}

.btn-sm {
    padding: 5px 10px;
    font-size: 13px;
}

.btn-block {
    width: 100%;
}

.btn[disabled] {
    opacity: 0.5;
    pointer-events: none;
}

/* ---------- Карточки и сетка ---------- */

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 20px;
}

.grid {
    display: grid;
    gap: 16px;
}

.grid-2 {
    grid-template-columns: repeat(2, 1fr);
}

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

@media (max-width: 900px) {
    .grid-3 {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 640px) {
    .grid-2,
    .grid-3 {
        grid-template-columns: 1fr;
    }
}

/* ---------- Заголовки ---------- */

h1,
h2,
h3,
h4 {
    font-weight: 700;
    line-height: 1.2;
    color: var(--text);
}

h1 {
    font-size: 28px;
    margin-bottom: 8px;
}

h2 {
    font-size: 20px;
}

h3 {
    font-size: 16px;
}

.page-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 24px;
    flex-wrap: wrap;
}

.page-head .subtitle {
    color: var(--text-muted);
    font-size: 14px;
}

/* ---------- Формы ---------- */

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

label,
.form-label {
    display: block;
    margin-bottom: 6px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text);
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="date"],
input[type="time"],
input[type="datetime-local"],
input[type="url"],
select,
textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text);
    font-size: 14px;
    font-family: inherit;
    transition: border-color 0.15s, box-shadow 0.15s;
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.15);
}

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

.checkbox-row {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
}

.checkbox-row input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--primary);
}

.form-actions {
    display: flex;
    gap: 10px;
    margin-top: 20px;
    flex-wrap: wrap;
}

.helptext,
.form-hint {
    color: var(--text-muted);
    font-size: 12px;
    margin-top: 4px;
}

.errorlist {
    list-style: none;
    color: var(--danger);
    font-size: 13px;
    margin: 6px 0;
}

.field-errors {
    color: var(--danger);
    font-size: 13px;
    margin-top: 4px;
}

.interval-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.interval-row {
    align-items: end;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border);
}

.interval-row:last-child {
    border-bottom: none;
}

/* ---------- Уведомления ---------- */

.messages {
    margin-bottom: 20px;
}

.alert {
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    margin-bottom: 10px;
    font-size: 14px;
    background: var(--surface);
}

.alert-success {
    border-color: rgba(22, 163, 74, 0.4);
    background: rgba(22, 163, 74, 0.08);
    color: var(--success);
}

.alert-error {
    border-color: rgba(225, 29, 72, 0.4);
    background: rgba(225, 29, 72, 0.08);
    color: var(--danger);
}

.alert-info {
    border-color: rgba(14, 165, 233, 0.4);
    background: rgba(14, 165, 233, 0.08);
    color: var(--accent);
}

/* ---------- Список задач ---------- */

.task-list {
    list-style: none;
}

.task-item {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    padding: 16px;
    margin-bottom: 12px;
    display: flex;
    align-items: flex-start;
    gap: 12px;
}

.task-check {
    flex-shrink: 0;
    margin-top: 2px;
}

.task-check input[type="checkbox"] {
    width: 20px;
    height: 20px;
    accent-color: var(--success);
    cursor: pointer;
}

.task-main {
    flex: 1;
    min-width: 0;
}

.task-title {
    font-size: 15px;
    font-weight: 500;
}

.task-title.completed {
    text-decoration: line-through;
    color: var(--text-muted);
}

.task-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 6px;
    font-size: 12px;
    color: var(--text-muted);
}

.task-actions {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
}

.badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 500;
    background: var(--surface-2);
    color: var(--text-muted);
    border: 1px solid var(--border);
}

.badge-important {
    background: rgba(225, 29, 72, 0.1);
    color: var(--danger);
    border-color: rgba(225, 29, 72, 0.3);
}

.badge-urgent {
    background: rgba(217, 119, 6, 0.1);
    color: var(--warning);
    border-color: rgba(217, 119, 6, 0.3);
}

.badge-deadline {
    background: rgba(14, 165, 233, 0.1);
    color: var(--accent);
    border-color: rgba(14, 165, 233, 0.3);
}

/* ---------- Фильтры ---------- */

.filters {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 20px;
    align-items: end;
}

.filters .form-group {
    margin-bottom: 0;
}

.filters select,
.filters input {
    width: auto;
    min-width: 160px;
}

/* ---------- Подзадачи ---------- */

.subtask-list {
    list-style: none;
    margin-top: 12px;
}

.subtask-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: var(--radius-sm);
    background: var(--surface-2);
    margin-bottom: 6px;
    font-size: 14px;
}

.subtask-row .subtask-title {
    flex: 1;
}

.subtask-row .subtask-title.completed {
    text-decoration: line-through;
    color: var(--text-muted);
}

.subtask-add {
    margin-top: 10px;
}

.subtask-form-row {
    display: flex;
    gap: 8px;
    align-items: center;
}

.subtask-form-row input[type="text"] {
    flex: 1;
}

/* ---------- Формы регистрации / входа ---------- */

.auth-wrap {
    max-width: 400px;
    margin: 48px auto;
}

.auth-card {
    padding: 32px;
}

.auth-logo {
    width: 48px;
    height: 48px;
    border-radius: 14px;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    margin: 0 auto 16px;
}

.auth-title {
    text-align: center;
    font-size: 22px;
    margin-bottom: 4px;
}

.auth-subtitle {
    text-align: center;
    color: var(--text-muted);
    font-size: 14px;
    margin-bottom: 24px;
}

/* ---------- Потоки ---------- */

.stream-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow-sm);
    margin-bottom: 12px;
}

.stream-color {
    width: 20px;
    height: 20px;
    border-radius: 6px;
    flex-shrink: 0;
}

.stream-name {
    flex: 1;
    font-weight: 500;
}

.stream-windows {
    color: var(--text-muted);
    font-size: 13px;
}

/* ---------- Quick Capture ---------- */

.quick-capture {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 16px;
    margin-bottom: 24px;
}

.quick-capture .qc-form {
    display: flex;
    gap: 10px;
}

.quick-capture input[type="text"] {
    flex: 1;
    font-size: 15px;
    padding: 12px 14px;
}

/* ---------- Матрица Эйзенхауэра ---------- */

.matrix {
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 1fr 1fr;
    gap: 14px;
}

.matrix-quadrant {
    border-radius: var(--radius);
    padding: 18px;
    min-height: 260px;
    display: flex;
    flex-direction: column;
}

.matrix-quadrant.red {
    background: var(--red);
}

.matrix-quadrant.green {
    background: var(--green);
}

.matrix-quadrant.yellow {
    background: var(--yellow);
}

.matrix-quadrant.gray {
    background: var(--gray);
}

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

.quadrant-title {
    font-weight: 700;
    font-size: 15px;
}

.quadrant-hint {
    position: relative;
    cursor: help;
    background: rgba(255, 255, 255, 0.7);
    border-radius: 50%;
    width: 22px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
    color: var(--text);
    flex-shrink: 0;
}

.quadrant-hint .hint-popup {
    display: none;
    position: absolute;
    right: 0;
    top: 28px;
    width: 240px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow);
    padding: 10px 12px;
    font-size: 13px;
    font-weight: 400;
    color: var(--text);
    z-index: 30;
}

.quadrant-hint:hover .hint-popup,
.quadrant-hint:focus .hint-popup {
    display: block;
}

.quadrant-list {
    list-style: none;
    flex: 1;
}

.quadrant-item {
    background: var(--surface);
    border-radius: var(--radius-sm);
    padding: 8px 12px;
    margin-bottom: 8px;
    box-shadow: var(--shadow-sm);
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
}

.quadrant-item .q-title {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.quadrant-item .q-actions {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
}

.icon-btn {
    background: var(--surface-2);
    border: none;
    border-radius: 6px;
    width: 26px;
    height: 26px;
    cursor: pointer;
    font-size: 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
}

.icon-btn:hover {
    background: var(--border);
}

.icon-btn.active {
    background: var(--primary);
    color: #fff;
}

@media (max-width: 760px) {
    .matrix {
        grid-template-columns: 1fr;
    }
}

/* ---------- Планировщик ---------- */

.timeline {
    position: relative;
    padding-left: 60px;
    margin-top: 12px;
}

.timeline-hours {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 48px;
    border-right: 1px solid var(--border);
}

.timeline-hour {
    position: absolute;
    right: 8px;
    transform: translateY(-50%);
    font-size: 11px;
    color: var(--text-muted);
}

.timeline-track {
    position: relative;
    height: 1440px;
    background: linear-gradient(
        to bottom,
        var(--border) 1px,
        transparent 1px
    );
    background-size: 100% 60px;
    border-radius: var(--radius-sm);
}

.timeline-block {
    position: absolute;
    left: 6px;
    right: 6px;
    border-radius: var(--radius-sm);
    padding: 8px 10px;
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
    background: var(--surface);
    font-size: 13px;
    cursor: grab;
}

.timeline-block:hover {
    box-shadow: var(--shadow);
}

.timeline-block .tb-title {
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.timeline-block .tb-time {
    font-size: 11px;
    color: var(--text-muted);
}

.timeline-block .tb-remove {
    position: absolute;
    top: 4px;
    right: 4px;
}

.gap-section {
    margin-top: 20px;
    border: 1px dashed var(--accent);
    border-radius: var(--radius);
    padding: 14px 16px;
    background: rgba(14, 165, 233, 0.06);
}

.gap-section h3 {
    color: var(--accent);
    margin-bottom: 10px;
}

.planner-controls {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
    margin-bottom: 16px;
}

/* ---------- Статистика dashboard ---------- */

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

@media (max-width: 760px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }
}

.stat-card {
    text-align: center;
    padding: 24px 16px;
}

.stat-value {
    font-size: 34px;
    font-weight: 700;
    color: var(--primary);
}

.stat-label {
    color: var(--text-muted);
    font-size: 13px;
    margin-top: 4px;
}

/* ---------- Футер ---------- */

.footer {
    padding: 24px 20px;
    text-align: center;
    color: var(--text-muted);
    font-size: 13px;
    border-top: 1px solid var(--border);
    background: var(--surface);
}

/* ---------- Пустое состояние ---------- */

.empty-state {
    text-align: center;
    padding: 48px 20px;
    color: var(--text-muted);
}

.empty-state .empty-icon {
    font-size: 40px;
    margin-bottom: 12px;
}

/* ---------- Прочее ---------- */

.muted {
    color: var(--text-muted);
}

.mb-0 {
    margin-bottom: 0;
}

.mb-1 {
    margin-bottom: 8px;
}

.mb-2 {
    margin-bottom: 16px;
}

.mb-3 {
    margin-bottom: 24px;
}

.mt-1 {
    margin-top: 8px;
}

.mt-2 {
    margin-top: 16px;
}

.mt-3 {
    margin-top: 24px;
}

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

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

.text-primary {
    color: var(--primary);
}

.d-flex {
    display: flex;
}

.justify-between {
    justify-content: space-between;
}

.align-center {
    align-items: center;
}

.gap-2 {
    gap: 16px;
}

.line-through {
    text-decoration: line-through;
}
