/* ═══════════════════════════════════════════════════════════
   ХМК — Планер | Corporate Light Theme
   ═══════════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;600&family=Manrope:wght@300;400;500;600;700;800&display=swap');

:root {
    --bg-primary: #f1f5f9;
    --bg-secondary: #ffffff;
    --bg-card: #ffffff;
    --bg-card-hover: #f8fafc;
    --bg-input: #f8fafc;
    --border: #e2e8f0;
    --border-active: #1d4ed8;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    --accent: #1d4ed8;
    --accent-hover: #1e40af;
    --accent-soft: rgba(29, 78, 216, 0.08);
    --success: #16a34a;
    --success-soft: rgba(22, 163, 74, 0.10);
    --warning: #d97706;
    --warning-soft: rgba(217, 119, 6, 0.10);
    --danger: #dc2626;
    --danger-soft: rgba(220, 38, 38, 0.10);
    --info: #0284c7;
    --info-soft: rgba(2, 132, 199, 0.10);
    --radius: 10px;
    --radius-sm: 6px;
    --radius-lg: 16px;
    --shadow: 0 1px 8px rgba(15, 23, 42, 0.08);
    --shadow-lg: 0 8px 32px rgba(15, 23, 42, 0.12);
    --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    height: 100%;
}

body {
    font-family: 'Manrope', -apple-system, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

/* ─── Scrollbar ────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg-secondary); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ═══════════════════════════════════════════════════════════
   Login Page
   ═══════════════════════════════════════════════════════════ */

.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-primary);
    border-top: 4px solid var(--accent);
}

.login-card {
    width: 100%;
    max-width: 400px;
    padding: 48px 40px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
}

.login-logo {
    text-align: center;
    margin-bottom: 36px;
}

.login-logo h1 {
    font-size: 1.6rem;
    font-weight: 800;
    letter-spacing: -0.03em;
    color: var(--accent);
}

.login-logo p {
    color: var(--text-muted);
    font-size: 0.85rem;
    margin-top: 6px;
}

/* ═══════════════════════════════════════════════════════════
   Layout
   ═══════════════════════════════════════════════════════════ */

.app-layout {
    display: flex;
    min-height: 100vh;
}

/* ─── Sidebar ──────────────────────────────────────────────── */
.sidebar {
    width: 260px;
    min-height: 100vh;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    z-index: 100;
    transition: transform var(--transition);
}

.sidebar-header {
    padding: 28px 20px 22px;
    border-bottom: 1px solid var(--border);
    text-align: center;
}

.sidebar-header h2 {
    font-size: 2.6rem;
    font-weight: 900;
    letter-spacing: 0.06em;
    line-height: 1;
    margin-bottom: 6px;
    background: linear-gradient(135deg, #1d4ed8 0%, #7c3aed 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.sidebar-header small {
    display: block;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.22em;
    color: #64748b;
}

.sidebar-nav {
    flex: 1;
    padding: 16px 12px;
    overflow-y: auto;
}

.nav-section {
    margin-bottom: 24px;
}

.nav-section-title {
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-muted);
    padding: 0 12px;
    margin-bottom: 8px;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.88rem;
    font-weight: 500;
    transition: all var(--transition);
}

.nav-link:hover {
    background: var(--bg-card-hover);
    color: var(--text-primary);
}

.nav-link.active {
    background: var(--accent-soft);
    color: var(--accent);
}

.nav-link .icon {
    font-size: 1.1rem;
    width: 24px;
    text-align: center;
}

.nav-link .badge {
    margin-left: auto;
    background: var(--danger);
    color: white;
    font-size: 0.7rem;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 10px;
    min-width: 20px;
    text-align: center;
}

.sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--border);
}

.user-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--accent-soft);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--accent);
}

.user-name {
    font-size: 0.85rem;
    font-weight: 600;
}

.user-role {
    font-size: 0.72rem;
    color: var(--text-muted);
}

/* ─── Main Content ────────────────────────────────────────── */
.main-content {
    flex: 1;
    margin-left: 260px;
    min-height: 100vh;
}

.page-header {
    padding: 28px 36px 20px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-secondary);
    position: sticky;
    top: 0;
    z-index: 50;
}

.page-header h1 {
    font-size: 1.5rem;
    font-weight: 800;
    letter-spacing: -0.02em;
}

.page-header p {
    color: var(--text-secondary);
    font-size: 0.85rem;
    margin-top: 2px;
}

.page-header-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.page-body {
    padding: 28px 36px;
}

/* ═══════════════════════════════════════════════════════════
   Dashboard Cards
   ═══════════════════════════════════════════════════════════ */

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 32px;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px 24px;
    transition: all var(--transition);
}

.stat-card:hover {
    border-color: var(--border-active);
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.stat-card .stat-icon {
    font-size: 1.5rem;
    margin-bottom: 12px;
}

.stat-card .stat-value {
    font-size: 2rem;
    font-weight: 800;
    font-family: 'JetBrains Mono', monospace;
    letter-spacing: -0.03em;
}

.stat-card .stat-label {
    font-size: 0.78rem;
    color: var(--text-secondary);
    margin-top: 2px;
}

.stat-card.accent .stat-value { color: var(--accent); }
.stat-card.success .stat-value { color: var(--success); }
.stat-card.warning .stat-value { color: var(--warning); }
.stat-card.danger .stat-value { color: var(--danger); }

/* ═══════════════════════════════════════════════════════════
   Tables
   ═══════════════════════════════════════════════════════════ */

.data-table-wrap {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    margin-bottom: 24px;
}

.data-table-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
}

.data-table-header h3 {
    font-size: 0.95rem;
    font-weight: 700;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th {
    padding: 12px 20px;
    text-align: left;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
}

.data-table td {
    padding: 14px 20px;
    font-size: 0.88rem;
    border-bottom: 1px solid var(--border);
}

.data-table tr:last-child td {
    border-bottom: none;
}

.data-table tr:hover td {
    background: var(--bg-card-hover);
}

.data-table .task-title {
    font-weight: 600;
    color: var(--text-primary);
}

.data-table .task-title a {
    color: inherit;
    text-decoration: none;
}

.data-table .task-title a:hover {
    color: var(--accent);
}

/* ═══════════════════════════════════════════════════════════
   Badges & Tags
   ═══════════════════════════════════════════════════════════ */

.badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    white-space: nowrap;
}

.badge-new { background: var(--accent-soft); color: var(--accent); }
.badge-assigned { background: var(--info-soft); color: var(--info); }
.badge-progress { background: var(--accent-soft); color: var(--accent); }
.badge-clarification { background: var(--warning-soft); color: var(--warning); }
.badge-done { background: var(--success-soft); color: var(--success); }
.badge-closed { background: var(--success-soft); color: var(--success); }
.badge-rework { background: var(--warning-soft); color: var(--warning); }
.badge-not-completed { background: var(--danger-soft); color: var(--danger); }

.badge-low { background: var(--success-soft); color: var(--success); }
.badge-medium { background: var(--warning-soft); color: var(--warning); }
.badge-urgent { background: var(--danger-soft); color: var(--danger); }

.badge-manager { background: var(--accent-soft); color: var(--accent); }
.badge-executor { background: var(--info-soft); color: var(--info); }
.badge-superadmin { background: rgba(168, 85, 247, 0.12); color: #a855f7; }

/* ═══════════════════════════════════════════════════════════
   Forms
   ═══════════════════════════════════════════════════════════ */

.form-group {
    margin-bottom: 20px;
}

.form-label {
    display: block;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.form-input,
.form-select,
.form-textarea {
    width: 100%;
    padding: 11px 14px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.9rem;
    transition: all var(--transition);
    outline: none;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}

.form-textarea {
    min-height: 100px;
    resize: vertical;
}

.form-select {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238b8fa3' stroke-width='2'%3E%3Cpolyline points='6,9 12,15 18,9'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    padding-right: 36px;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

/* ═══════════════════════════════════════════════════════════
   Buttons
   ═══════════════════════════════════════════════════════════ */

.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
    text-decoration: none;
    white-space: nowrap;
}

.btn-primary {
    background: var(--accent);
    color: white;
}
.btn-primary:hover {
    background: var(--accent-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 16px rgba(29, 78, 216, 0.25);
}

.btn-secondary {
    background: var(--bg-card-hover);
    color: var(--text-primary);
    border: 1px solid var(--border);
}
.btn-secondary:hover {
    border-color: var(--text-muted);
}

.btn-success {
    background: var(--success);
    color: white;
}
.btn-success:hover { filter: brightness(1.1); }

.btn-danger {
    background: var(--danger);
    color: white;
}
.btn-danger:hover { filter: brightness(1.1); }

.btn-warning {
    background: var(--warning);
    color: white;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 0.8rem;
}

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    padding: 8px 12px;
}
.btn-ghost:hover {
    color: var(--text-primary);
    background: var(--bg-card-hover);
}

/* ═══════════════════════════════════════════════════════════
   Task Detail
   ═══════════════════════════════════════════════════════════ */

.task-detail {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 28px 32px;
    margin-bottom: 24px;
}

.task-detail-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 24px;
}

.task-detail h2 {
    font-size: 1.3rem;
    font-weight: 700;
}

.task-meta {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.task-meta-item {
    padding: 14px 16px;
    background: var(--bg-secondary);
    border-radius: var(--radius-sm);
}

.task-meta-label {
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.task-meta-value {
    font-size: 0.92rem;
    font-weight: 600;
}

.task-description {
    padding: 20px;
    background: var(--bg-secondary);
    border-radius: var(--radius-sm);
    border-left: 3px solid var(--accent);
    margin-bottom: 24px;
    line-height: 1.7;
}

.task-actions-bar {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

/* ─── History Timeline ─────────────────────────────────────── */
.history-timeline {
    margin-top: 24px;
}

.history-item {
    display: flex;
    gap: 16px;
    padding: 14px 0;
    border-bottom: 1px solid var(--border);
    font-size: 0.85rem;
}

.history-item:last-child { border-bottom: none; }

.history-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent);
    margin-top: 6px;
    flex-shrink: 0;
}

.history-time {
    color: var(--text-muted);
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.78rem;
    white-space: nowrap;
}

.history-text {
    color: var(--text-secondary);
}

.history-comment {
    margin-top: 4px;
    padding: 8px 12px;
    background: var(--bg-secondary);
    border-radius: var(--radius-sm);
    font-style: italic;
    color: var(--text-secondary);
}

/* ═══════════════════════════════════════════════════════════
   Modals
   ═══════════════════════════════════════════════════════════ */

.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    z-index: 200;
    display: none;
    align-items: center;
    justify-content: center;
}

.modal-backdrop.active {
    display: flex;
}

.modal {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 520px;
    max-height: 90vh;
    overflow-y: auto;
    padding: 32px;
    box-shadow: var(--shadow-lg);
}

.modal h3 {
    font-size: 1.15rem;
    font-weight: 700;
    margin-bottom: 20px;
}

.modal-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 24px;
}

/* ═══════════════════════════════════════════════════════════
   Alerts
   ═══════════════════════════════════════════════════════════ */

.alert {
    padding: 14px 18px;
    border-radius: var(--radius-sm);
    font-size: 0.88rem;
    margin-bottom: 20px;
    border: 1px solid;
}

.alert-error {
    background: var(--danger-soft);
    border-color: rgba(220, 38, 38, 0.25);
    color: #b91c1c;
}

.alert-success {
    background: var(--success-soft);
    border-color: rgba(22, 163, 74, 0.25);
    color: #15803d;
}

.alert-info {
    background: var(--info-soft);
    border-color: rgba(2, 132, 199, 0.25);
    color: #0369a1;
}

/* ═══════════════════════════════════════════════════════════
   Empty State
   ═══════════════════════════════════════════════════════════ */

.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}

.empty-state .icon {
    font-size: 3rem;
    margin-bottom: 16px;
    opacity: 0.5;
}

.empty-state h3 {
    font-size: 1.1rem;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

/* ═══════════════════════════════════════════════════════════
   Deadline highlight
   ═══════════════════════════════════════════════════════════ */

.deadline-overdue {
    color: var(--danger) !important;
    font-weight: 700;
}

.deadline-today {
    color: var(--warning) !important;
    font-weight: 600;
}

/* ═══════════════════════════════════════════════════════════
   Filters
   ═══════════════════════════════════════════════════════════ */

.filters-bar {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.filter-btn {
    padding: 7px 16px;
    border: 1px solid var(--border);
    border-radius: 20px;
    background: transparent;
    color: var(--text-secondary);
    font-size: 0.82rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
    font-family: inherit;
}

.filter-btn:hover {
    border-color: var(--text-muted);
    color: var(--text-primary);
}

.filter-btn.active {
    background: var(--accent-soft);
    border-color: var(--accent);
    color: var(--accent);
}

/* ═══════════════════════════════════════════════════════════
   Search bar (tasks page)
   ═══════════════════════════════════════════════════════════ */

.search-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 20px;
    position: relative;
}

.search-bar .search-icon {
    position: absolute;
    left: 12px;
    color: var(--text-muted);
    font-size: 0.9rem;
    pointer-events: none;
}

.search-bar .form-input {
    padding-left: 36px;
    max-width: 360px;
}

.search-count {
    font-size: 0.82rem;
    color: var(--text-muted);
    white-space: nowrap;
}

/* ═══════════════════════════════════════════════════════════
   Mobile top bar & hamburger
   ═══════════════════════════════════════════════════════════ */

.mobile-topbar {
    display: none;
    align-items: center;
    gap: 14px;
    padding: 13px 16px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 150;
}

.mobile-brand {
    font-weight: 800;
    font-size: 1.05rem;
    color: var(--accent);
    letter-spacing: -0.02em;
}

.hamburger-btn {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 5px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    flex-shrink: 0;
}

.hamburger-btn span {
    display: block;
    width: 22px;
    height: 2px;
    background: var(--text-primary);
    border-radius: 2px;
    transition: all var(--transition);
}

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    z-index: 99;
}

.sidebar-overlay.active {
    display: block;
}

/* ═══════════════════════════════════════════════════════════
   Responsive
   ═══════════════════════════════════════════════════════════ */

@media (max-width: 768px) {
    .mobile-topbar {
        display: flex;
    }
    .sidebar {
        transform: translateX(-100%);
    }
    .sidebar.open {
        transform: translateX(0);
    }
    .main-content {
        margin-left: 0;
    }
    .page-body {
        padding: 20px 16px;
    }
    .page-header {
        padding: 20px 16px;
    }
    .form-row {
        grid-template-columns: 1fr;
    }
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    .task-meta {
        grid-template-columns: 1fr 1fr;
    }
    .search-bar .form-input {
        max-width: 100%;
    }
}
