:root {
    --bg: #0f1115;
    --surface: #171a21;
    --surface-2: #1f232c;
    --border: #2a2f3a;
    --text: #e8eaed;
    --text-muted: #8b93a3;
    --primary: #6366f1;
    --primary-hover: #4f52d9;
    --danger: #ef4444;
    --success: #22c55e;
    --warn: #f59e0b;
    --radius: 10px;
    --shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

#root { min-height: 100vh; }

button {
    cursor: pointer;
    border: none;
    border-radius: 8px;
    padding: 0.55rem 1rem;
    font-size: 0.9rem;
    font-weight: 600;
    background: var(--primary);
    color: white;
    transition: background 0.15s ease;
}
button:hover { background: var(--primary-hover); }
button:disabled { opacity: 0.5; cursor: not-allowed; }
button.secondary { background: var(--surface-2); color: var(--text); border: 1px solid var(--border); }
button.secondary:hover { background: #2a2f3a; }
button.danger { background: var(--danger); }
button.danger:hover { background: #d63b3b; }
button.icon { padding: 0.4rem 0.55rem; }

input, textarea, select {
    background: var(--surface-2);
    border: 1px solid var(--border);
    color: var(--text);
    border-radius: 8px;
    padding: 0.6rem 0.7rem;
    font-size: 0.9rem;
    width: 100%;
    font-family: inherit;
}
input:focus, textarea:focus, select:focus {
    outline: none;
    border-color: var(--primary);
}
label {
    display: block;
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 0.3rem;
    font-weight: 600;
}
.field { margin-bottom: 1rem; }

/* ---- auth screens ---- */
.auth-shell {
    min-height: 100vh;
    display: grid;
    place-items: center;
    background: radial-gradient(circle at top, #1b1e27, var(--bg) 60%);
}
.auth-card {
    width: 360px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 2rem;
    box-shadow: var(--shadow);
}
.auth-card h1 {
    margin: 0 0 0.25rem;
    font-size: 1.4rem;
}
.auth-card p.sub {
    color: var(--text-muted);
    margin: 0 0 1.5rem;
    font-size: 0.85rem;
}
.auth-card .error {
    background: rgba(239, 68, 68, 0.12);
    border: 1px solid rgba(239, 68, 68, 0.4);
    color: #fca5a5;
    padding: 0.6rem 0.8rem;
    border-radius: 8px;
    font-size: 0.85rem;
    margin-bottom: 1rem;
}
.auth-card .hint {
    margin-top: 1.2rem;
    font-size: 0.78rem;
    color: var(--text-muted);
    line-height: 1.5;
}

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

.topbar {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.75rem 1.25rem;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}
.topbar .brand { font-weight: 700; font-size: 1.05rem; display: flex; align-items: center; gap: 0.5rem; }
.topbar .brand .dot { width: 10px; height: 10px; border-radius: 3px; background: var(--primary); display: inline-block; }
.topbar select { width: auto; min-width: 180px; }
.topbar .spacer { flex: 1; }
.topbar .user-badge {
    display: flex; align-items: center; gap: 0.5rem;
    font-size: 0.85rem; color: var(--text-muted);
}
.role-pill {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    padding: 0.15rem 0.5rem;
    border-radius: 999px;
    background: rgba(99, 102, 241, 0.18);
    color: #a5a8ff;
    letter-spacing: 0.03em;
}
.role-pill.admin { background: rgba(245, 158, 11, 0.18); color: #fbbf24; }

.board-area {
    flex: 1;
    overflow-x: auto;
    padding: 1.25rem;
    display: flex;
    align-items: flex-start;
    gap: 1rem;
}

.column {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    width: 290px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    max-height: 100%;
}
.column.drop-target { border-color: var(--primary); }
.column-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.85rem 0.9rem 0.6rem;
}
.column-header h3 { margin: 0; font-size: 0.95rem; }
.column-header .count {
    font-size: 0.75rem;
    color: var(--text-muted);
    background: var(--surface-2);
    padding: 0.05rem 0.5rem;
    border-radius: 999px;
}
.column-body {
    padding: 0 0.6rem 0.6rem;
    overflow-y: auto;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
    min-height: 40px;
}
.column-footer { padding: 0.5rem 0.6rem 0.75rem; }
.column-footer button { width: 100%; }

.card {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.7rem 0.75rem;
    cursor: grab;
    transition: transform 0.1s ease, border-color 0.1s ease;
}
.card:hover { border-color: #3a4050; }
.card.dragging { opacity: 0.4; }
.card .title { font-size: 0.87rem; font-weight: 600; margin-bottom: 0.45rem; line-height: 1.3; }
.card .meta { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; }
.priority-badge {
    font-size: 0.68rem;
    font-weight: 700;
    padding: 0.12rem 0.45rem;
    border-radius: 999px;
    text-transform: uppercase;
}
.priority-low { background: rgba(34, 197, 94, 0.15); color: #4ade80; }
.priority-medium { background: rgba(245, 158, 11, 0.15); color: #fbbf24; }
.priority-high { background: rgba(239, 68, 68, 0.15); color: #f87171; }

.avatar {
    width: 22px; height: 22px;
    border-radius: 50%;
    background: var(--primary);
    color: white;
    font-size: 0.68rem;
    font-weight: 700;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}
.unassigned { color: var(--text-muted); font-size: 0.72rem; }

.add-column {
    flex-shrink: 0;
    width: 240px;
}
.add-column button { width: 100%; }
.add-column-form {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.75rem;
    width: 240px;
    flex-shrink: 0;
}
.add-column-form .row { display: flex; gap: 0.5rem; margin-top: 0.5rem; }

/* ---- modal ---- */
.modal-backdrop {
    position: fixed; inset: 0;
    background: rgba(0, 0, 0, 0.55);
    display: grid; place-items: center;
    z-index: 50;
    padding: 1rem;
}
.modal {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    width: 100%;
    max-width: 460px;
    max-height: 90vh;
    overflow-y: auto;
    padding: 1.5rem;
    box-shadow: var(--shadow);
}
.modal.wide { max-width: 640px; }
.modal-header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 1.2rem;
}
.modal-header h2 { margin: 0; font-size: 1.1rem; }
.modal-header button { background: transparent; color: var(--text-muted); padding: 0.2rem 0.5rem; font-size: 1.1rem; }
.modal-actions { display: flex; justify-content: space-between; gap: 0.5rem; margin-top: 1.5rem; }
.modal-actions .right { display: flex; gap: 0.5rem; margin-left: auto; }

.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0.8rem; }

table.users-table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
table.users-table th, table.users-table td {
    text-align: left; padding: 0.5rem 0.4rem; border-bottom: 1px solid var(--border);
}
table.users-table th { color: var(--text-muted); font-weight: 600; font-size: 0.75rem; text-transform: uppercase; }

.empty-state {
    color: var(--text-muted);
    text-align: center;
    padding: 3rem 1rem;
    font-size: 0.9rem;
}

.toast {
    position: fixed;
    bottom: 1.25rem;
    right: 1.25rem;
    background: var(--surface-2);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 0.75rem 1rem;
    border-radius: 8px;
    box-shadow: var(--shadow);
    font-size: 0.85rem;
    z-index: 100;
}
.toast.error { border-color: rgba(239, 68, 68, 0.4); color: #fca5a5; }
