/* Дизайн-система -- навмисно та сама, що й у test-cmdb (спільна SaaS-стилістика
   всієї родини проєктів SYD): ті самі токени кольору/тіней/радіусів, той
   самий .app-shell/.app-sidebar/.app-topbar каркас, ті самі .btn/.card/
   .badge/.table/.alert компоненти. */

:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --bg: #f4f6f9;
    --card-bg: #ffffff;
    --border: #e2e8f0;
    --text: #1e293b;
    --text-muted: #64748b;

    --surface-sunken: #f8fafc;
    --surface-hover: #f1f5f9;
    --border-strong: #cbd5e1;
    --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05);
    --shadow-md: 0 1px 3px rgba(15, 23, 42, 0.06), 0 4px 12px rgba(15, 23, 42, 0.05);
    --shadow-lg: 0 8px 24px rgba(15, 23, 42, 0.10), 0 2px 6px rgba(15, 23, 42, 0.06);
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --focus-ring: 0 0 0 3px color-mix(in srgb, var(--primary) 20%, transparent);
    --sidebar-bg: #ffffff;
    --sidebar-border: #eef1f6;
    --sidebar-width: 240px;
    --gradient-primary: linear-gradient(135deg, var(--primary), color-mix(in srgb, var(--primary) 65%, #7c3aed));
    --ease-out: cubic-bezier(.16, 1, .3, 1);
}

* { box-sizing: border-box; }
html { -webkit-font-smoothing: antialiased; scroll-behavior: smooth; }

body {
    margin: 0;
    font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    line-height: 1.5;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { letter-spacing: -0.02em; font-weight: 700; margin-top: 0; }
h1 { font-size: 22px; }
h2 { font-size: 16px; }
.mono { font-family: ui-monospace, "SFMono-Regular", Menlo, monospace; }

@keyframes fadeInUp { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}

.container { max-width: 960px; margin: 0 auto; padding: 24px 16px 48px; }
.container.centered { display: flex; align-items: center; justify-content: center; min-height: 90vh; }
.auth-form { width: 100%; max-width: 380px; text-align: left; }

/* ---- форми/поля ---- */
label { display: block; margin-bottom: 16px; font-size: 14px; font-weight: 600; color: var(--text); }
input[type=text], input[type=email], input[type=password], input[type=search],
input[type=number], input[type=date], input[type=datetime-local], textarea, select {
    display: block;
    width: 100%;
    margin-top: 6px;
    padding: 9px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-family: inherit;
    background: var(--card-bg);
    color: var(--text);
    transition: border-color .12s ease, box-shadow .12s ease;
}
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--primary); box-shadow: var(--focus-ring); }
textarea { resize: vertical; }
.form-row { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px; }
.form-row label { flex: 1; min-width: 160px; margin-bottom: 0; }
.form-row .btn { margin-top: 0; }

/* ---- кнопки ---- */
.btn {
    display: inline-block;
    padding: 9px 16px;
    border-radius: var(--radius-sm);
    border: none;
    font-size: 14px;
    font-family: inherit;
    font-weight: 600;
    line-height: 1.5;
    cursor: pointer;
    text-decoration: none;
    text-align: center;
    transition: background-color .15s ease, box-shadow .15s ease, transform .15s var(--ease-out), filter .15s ease;
}
.btn:hover { text-decoration: none; }
.btn:active { transform: translateY(1px) scale(.98); }
.btn[disabled] { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--gradient-primary); color: #fff; box-shadow: var(--shadow-sm); border: 1px solid transparent; }
.btn-primary:hover { filter: brightness(1.06); box-shadow: var(--shadow-md); transform: translateY(-1px); }
.btn-secondary { background: var(--card-bg); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--surface-hover); border-color: var(--border-strong); }
.btn-danger { background: #fff; color: #b91c1c; border: 1px solid #fecaca; }
.btn-danger:hover { background: #fef2f2; }
.btn-sm { padding: 6px 11px; font-size: 12.5px; }
.btn-block { width: 100%; }
.btn-row { display: flex; align-items: center; gap: 10px; }

/* ---- картки, повідомлення ---- */
.card { background: var(--card-bg); border: 1px solid rgba(15, 23, 42, .06); border-radius: var(--radius-md); box-shadow: var(--shadow-sm); padding: 24px; margin-bottom: 20px; animation: fadeInUp .3s var(--ease-out) both; }
.card h1, .card h2 { margin-top: 0; }
.alert { padding: 12px 16px; border-radius: var(--radius-sm); margin-bottom: 16px; font-size: 14px; border: 1px solid transparent; }
.alert-error { background: #fef2f2; color: #b91c1c; border-color: #fecaca; }
.alert-success { background: #f0fdf4; color: #15803d; border-color: #bbf7d0; }
.alert-info { background: #eff6ff; color: #1d4ed8; border-color: #bfdbfe; }

/* ---- бейджі (пастельна пігулка + крапка кольором самого статусу/мітки --
   структура з cmdb, колір довільний -- у "tasks" кожен простір сам обирає
   колір своїх статусів/пріоритетів/міток). ---- */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    line-height: 1.6;
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex-shrink: 0; }
.chip {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 10.5px;
    font-weight: 600;
}

/* ---- таблиці ---- */
.table-responsive { width: 100%; overflow-x: auto; border-radius: var(--radius-md); }
table.table { width: 100%; border-collapse: collapse; background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius-md); box-shadow: var(--shadow-sm); overflow: hidden; }
table.table th, table.table td { padding: 12px 16px; text-align: left; border-bottom: 1px solid var(--border); font-size: 13.5px; }
table.table th { background: var(--surface-sunken); font-weight: 600; color: var(--text-muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; }
table.table tbody tr:last-child td { border-bottom: none; }
table.table tbody tr:hover td { background: var(--surface-hover); }

/* ============================================================
   App shell -- той самий каркас, що й у test-cmdb: бокова панель
   зліва (лого, навігація, картка користувача внизу), топбар праворуч
   зверху з заголовком сторінки, .app-content під ним.
   ============================================================ */
.app-shell { display: flex; min-height: 100vh; align-items: stretch; }

.app-sidebar {
    width: var(--sidebar-width);
    flex-shrink: 0;
    background: var(--sidebar-bg);
    border-right: 1px solid var(--sidebar-border);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    z-index: 40;
}
.app-sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 18px 20px;
    font-weight: 700;
    font-size: 15px;
    color: var(--text);
    text-decoration: none;
    letter-spacing: -0.01em;
    border-bottom: 1px solid var(--sidebar-border);
}
.app-sidebar-brand:hover { text-decoration: none; }
.app-sidebar-brand-mark { width: 22px; height: 22px; color: var(--primary); flex-shrink: 0; }

.app-sidebar-nav { flex: 1; padding: 12px; display: flex; flex-direction: column; gap: 2px; overflow-y: auto; }
.app-nav-section-label { padding: 14px 12px 4px; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--text-muted); }
.app-nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    text-decoration: none;
    font-size: 13.5px;
    font-weight: 500;
    position: relative;
    transition: background-color .15s ease, color .15s ease;
}
.app-nav-item:hover { background: var(--surface-hover); color: var(--text); text-decoration: none; }
.app-nav-item.active {
    background: linear-gradient(90deg, color-mix(in srgb, var(--primary) 12%, transparent), color-mix(in srgb, var(--primary) 4%, transparent));
    color: var(--primary-dark);
    font-weight: 600;
    box-shadow: inset 3px 0 0 var(--primary);
}
.app-nav-icon { width: 18px; height: 18px; flex-shrink: 0; display: inline-flex; }
.app-nav-icon svg { width: 100%; height: 100%; }
.app-nav-label { flex: 1 1 auto; min-width: 0; }
.app-nav-workspace {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 9px 12px;
    margin-bottom: 4px;
    border-radius: var(--radius-sm);
    background: var(--surface-sunken);
}
.workspace-badge {
    width: 24px; height: 24px; border-radius: 7px; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
    color: #fff; font-size: 10px; font-weight: 700;
}
.app-nav-workspace-name { font-size: 13px; font-weight: 600; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.app-sidebar-footer { padding: 10px; border-top: 1px solid var(--sidebar-border); position: relative; }
.app-user-trigger {
    display: flex; align-items: center; gap: 8px; width: 100%;
    padding: 8px 10px; border-radius: var(--radius-sm);
    background: transparent; border: none; cursor: pointer; text-align: left;
    font-family: inherit; color: var(--text);
}
.app-user-trigger:hover { background: var(--surface-hover); }
.avatar-fallback {
    width: 28px; height: 28px; border-radius: 50%;
    background: var(--primary); color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-size: 12px; font-weight: 700; flex-shrink: 0;
}
.app-user-info { min-width: 0; }
.app-user-name { font-size: 13px; font-weight: 600; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: block; }
.app-user-trigger-chevron { margin-left: auto; color: var(--text-muted); width: 14px; height: 14px; flex-shrink: 0; transition: transform .2s var(--ease-out); }
.app-user-trigger.open .app-user-trigger-chevron { transform: rotate(180deg); }
.app-user-dropdown {
    position: absolute; bottom: calc(100% + 6px); left: 10px; right: 10px;
    background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius-sm);
    box-shadow: var(--shadow-lg); padding: 6px; z-index: 50;
    display: none;
}
.app-user-dropdown.open { display: block; }
.app-user-dropdown a { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 6px; font-size: 13.5px; color: var(--text); text-decoration: none; }
.app-user-dropdown a:hover { background: var(--surface-hover); text-decoration: none; }
.app-user-dropdown-divider { height: 1px; background: var(--border); margin: 4px 6px; }

.app-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.app-topbar {
    display: flex; align-items: center; gap: 12px;
    padding: 16px 28px; background: var(--card-bg);
    border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 30;
}
.app-topbar-title { font-size: 20px; font-weight: 700; margin: 0; letter-spacing: -0.02em; color: var(--text); }
.app-topbar-search { flex: 1; max-width: 360px; margin-left: 16px; }
.app-topbar-search input { margin-top: 0; background: var(--surface-sunken); border-color: transparent; }
.sidebar-toggle {
    display: none; background: var(--card-bg); border: 1px solid var(--border);
    border-radius: var(--radius-sm); width: 34px; height: 34px;
    align-items: center; justify-content: center; cursor: pointer; color: var(--text); flex-shrink: 0;
}
.sidebar-toggle svg { width: 18px; height: 18px; }
.app-sidebar-backdrop { display: none; position: fixed; inset: 0; background: rgba(15, 23, 42, .35); z-index: 39; }
.app-sidebar-backdrop.open { display: block; }

.app-content { flex: 1; max-width: 1400px; width: 100%; margin: 0 auto; padding: 24px 28px 48px; }

.lang-switcher { display: flex; border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; flex-shrink: 0; }
.notif-bell { position: relative; display: inline-flex; align-items: center; justify-content: center; width: 34px; height: 34px; border-radius: 50%; color: var(--text-muted); margin-left: auto; flex-shrink: 0; }
.notif-bell:hover { background: var(--surface-hover); text-decoration: none; }
.notif-badge { position: absolute; top: 2px; right: 2px; background: #dc2626; color: #fff; font-size: 9.5px; font-weight: 700; min-width: 14px; height: 14px; border-radius: 999px; display: flex; align-items: center; justify-content: center; padding: 0 3px; }
.lang-btn { border: none; background: var(--card-bg); color: var(--text-muted); padding: 5px 9px; font-size: 11px; font-weight: 600; cursor: pointer; }
.lang-btn.active { background: var(--primary); color: #fff; }

@media (max-width: 880px) {
    .app-sidebar { position: fixed; left: 0; top: 0; transform: translateX(-100%); transition: transform .2s var(--ease-out); }
    .app-sidebar.open { transform: translateX(0); }
    .sidebar-toggle { display: inline-flex; }
    .app-topbar-search { display: none; }
}

/* ============================================================
   Workspaces list
   ============================================================ */
.workspace-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; margin-bottom: 28px; }
.workspace-card {
    display: flex; align-items: center; gap: 12px; padding: 14px;
    border-radius: var(--radius-md); background: var(--card-bg);
    border: 1px solid var(--border); box-shadow: var(--shadow-sm);
    text-decoration: none; color: var(--text);
    transition: border-color .12s ease, transform .12s ease;
}
.workspace-card:hover { border-color: var(--primary); transform: translateY(-1px); text-decoration: none; }
.workspace-card-name { font-weight: 600; }
.workspace-card-key { font-size: 11.5px; color: var(--text-muted); }

/* ============================================================
   Kanban board
   ============================================================ */
.board { display: flex; gap: 16px; align-items: flex-start; overflow-x: auto; padding-bottom: 8px; }
.board-column { width: 280px; flex-shrink: 0; }
.board-column-head { display: flex; align-items: center; gap: 8px; padding: 0 4px 8px; font-weight: 600; font-size: 13.5px; color: var(--text); }
.board-column-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.board-column-count { color: var(--text-muted); font-weight: 400; }
.board-drop-zone { min-height: 100px; display: flex; flex-direction: column; gap: 8px; padding: 6px; border-radius: var(--radius-md); border: 2px dashed transparent; }
.board-drop-zone.drag-over { border-color: var(--primary); background: var(--surface-hover); }
.issue-card {
    background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius-sm);
    padding: 10px 12px; box-shadow: var(--shadow-sm); cursor: grab;
    transition: box-shadow .12s ease, transform .12s ease;
}
.issue-card:hover { box-shadow: var(--shadow-md); }
.issue-card.dragging { opacity: 0.4; }
.issue-card-title { display: block; font-size: 13.5px; font-weight: 500; margin-bottom: 6px; color: var(--text); text-decoration: none; }
.issue-card-title:hover { color: var(--primary); text-decoration: none; }
.issue-card-labels { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 8px; }
.issue-card-footer { display: flex; align-items: center; justify-content: space-between; }
.issue-card-meta { display: flex; align-items: center; gap: 6px; }
.issue-key { font-size: 11.5px; color: var(--text-muted); }
.points-chip { background: var(--surface-sunken); color: var(--text-muted); font-size: 10px; font-weight: 700; padding: 1px 6px; border-radius: 4px; }
.avatar-sm {
    width: 22px; height: 22px; border-radius: 50%; background: var(--primary); color: #fff;
    display: flex; align-items: center; justify-content: center; font-size: 10px; font-weight: 700; flex-shrink: 0;
}
.avatar-empty { width: 22px; height: 22px; border-radius: 50%; border: 1px dashed var(--border); flex-shrink: 0; }
.empty-column-hint { text-align: center; color: var(--text-muted); font-size: 12px; padding: 24px 8px; }

/* ============================================================
   Issue detail
   ============================================================ */
.issue-layout { display: flex; gap: 24px; align-items: flex-start; }
.issue-main { flex: 1; min-width: 0; }
.issue-side { width: 260px; flex-shrink: 0; display: flex; flex-direction: column; gap: 16px; background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius-md); box-shadow: var(--shadow-sm); padding: 16px; }
.issue-key-line { font-size: 13px; color: var(--text-muted); margin-bottom: 4px; }
.issue-title { font-size: 22px; font-weight: 700; margin: 0 0 16px; letter-spacing: -0.02em; }
.issue-description { white-space: pre-wrap; font-size: 13.5px; line-height: 1.6; margin-bottom: 28px; color: var(--text); }
.section-heading { font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted); margin-bottom: 10px; font-weight: 700; }
.section { margin-bottom: 28px; }
.comment-item { background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px 12px; margin-bottom: 10px; box-shadow: var(--shadow-sm); }
.comment-meta { font-size: 11.5px; color: var(--text-muted); margin-bottom: 4px; }
.comment-body { font-size: 13.5px; white-space: pre-wrap; }
.worklog-item, .activity-item { font-size: 12.5px; color: var(--text-muted); margin-bottom: 6px; }
.issue-side form { margin: 0; }
.issue-side label { margin-bottom: 0; font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--text-muted); font-weight: 700; }
.issue-side input, .issue-side select { margin-top: 4px; }

/* ============================================================
   Members table
   ============================================================ */
.member-row-name { font-weight: 600; color: var(--text); }
.member-row-email { font-size: 12px; color: var(--text-muted); }

@media (max-width: 720px) {
    .issue-layout { flex-direction: column; }
    .issue-side { width: 100%; }
    .app-content { padding: 16px 16px 40px; }
}
