/* ============================================================
   Theme system: two independent axes
   - MODE (data-mode): day / night - brightness, top-bar toggle
   - THEME (data-theme): default / red / blue / purple / beige / matrix - color identity
   Matrix ignores mode entirely (always its own black/green look).
   ============================================================ */

:root {
    --radius: 10px;
    --rain-opacity: 0;
}

* { box-sizing: border-box; }

select, option {
    background: var(--input-bg);
    color: var(--text);
}

/* ---- Default color, Night mode (the original baseline look) ---- */
body[data-theme="default"][data-mode="night"], body {
    --bg: #17181c;
    --panel: #1f2126;
    --border: #2c2f36;
    --text: #e8e9ec;
    --muted: #9a9ea6;
    --accent: #e0335c;
    --green: #1f9d55;
    --amber: #b8860b;
    --purple: #7b3fa0;
    --input-bg: #14161a;
    color-scheme: dark;
}

/* ---- Default color, Day mode ---- */
body[data-theme="default"][data-mode="day"] {
    --bg: #f4f5f7;
    --panel: #ffffff;
    --border: #dfe2e6;
    --text: #1c1e21;
    --muted: #6b7280;
    --accent: #e0335c;
    --green: #1f9d55;
    --amber: #a86f00;
    --purple: #7b3fa0;
    --input-bg: #f9fafb;
    color-scheme: light;
}

/* ---- Red ---- */
body[data-theme="red"][data-mode="night"] {
    --bg: #1c1315; --panel: #26181b; --border: #3d252a; --text: #f4e6e7; --muted: #b98d92;
    --accent: #dc2626; --green: #1f9d55; --amber: #b8860b; --purple: #7b3fa0; --input-bg: #180f11;
    color-scheme: dark;
}
body[data-theme="red"][data-mode="day"] {
    --bg: #fdf2f2; --panel: #ffffff; --border: #f3d4d4; --text: #3a1418; --muted: #a06a6e;
    --accent: #dc2626; --green: #1f9d55; --amber: #a86f00; --purple: #7b3fa0; --input-bg: #fff8f8;
    color-scheme: light;
}

/* ---- Blue ---- */
body[data-theme="blue"][data-mode="night"] {
    --bg: #0f1620; --panel: #16212f; --border: #263b52; --text: #e8edf4; --muted: #90a5bd;
    --accent: #2563eb; --green: #1f9d55; --amber: #b8860b; --purple: #7b3fa0; --input-bg: #0b1119;
    color-scheme: dark;
}
body[data-theme="blue"][data-mode="day"] {
    --bg: #f1f5fb; --panel: #ffffff; --border: #d3e0f0; --text: #132238; --muted: #5c7291;
    --accent: #2563eb; --green: #1f9d55; --amber: #a86f00; --purple: #7b3fa0; --input-bg: #f7faff;
    color-scheme: light;
}

/* ---- Purple ---- */
body[data-theme="purple"][data-mode="night"] {
    --bg: #180f1f; --panel: #22152c; --border: #3b2449; --text: #efe3f4; --muted: #ab8fc4;
    --accent: #9333ea; --green: #1f9d55; --amber: #b8860b; --purple: #a855f7; --input-bg: #130b19;
    color-scheme: dark;
}
body[data-theme="purple"][data-mode="day"] {
    --bg: #f7f1fb; --panel: #ffffff; --border: #e6d4f0; --text: #2c1638; --muted: #8266a0;
    --accent: #9333ea; --green: #1f9d55; --amber: #a86f00; --purple: #a855f7; --input-bg: #fbf7fd;
    color-scheme: light;
}

/* ---- Beige ---- */
body[data-theme="beige"][data-mode="night"] {
    --bg: #1c1810; --panel: #241f16; --border: #3d3320; --text: #f0e6d2; --muted: #a89572;
    --accent: #c98a4b; --green: #1f9d55; --amber: #b8860b; --purple: #7b3fa0; --input-bg: #171309;
    color-scheme: dark;
}
body[data-theme="beige"][data-mode="day"] {
    --bg: #f5efe3; --panel: #fffdf8; --border: #e3d5bc; --text: #3a2f1f; --muted: #8a7757;
    --accent: #b8763f; --green: #1f9d55; --amber: #a86f00; --purple: #7b3fa0; --input-bg: #faf6ee;
    color-scheme: light;
}

/* ---- Matrix - exclusive to Super Admin, ignores mode entirely ---- */
body[data-theme="matrix"] {
    --bg: #000000;
    --panel: #030905;
    --border: #114023;
    --text: #33ff66;
    --muted: #1f8a44;
    --accent: #00ff41;
    --green: #00ff41;
    --amber: #7fff9e;
    --purple: #00ff41;
    --input-bg: #001a08;
    color-scheme: dark;
    font-family: 'Courier New', Courier, monospace;
    --rain-opacity: 0.18;
}
/* Bright green backgrounds need dark text, not white, to stay readable */
body[data-theme="matrix"] .form-actions button,
body[data-theme="matrix"] .theme-btn.active,
body[data-theme="matrix"] .btn-danger,
body[data-theme="matrix"] .auth-box button { color: #001505; font-weight: 700; }
body[data-theme="matrix"] .project-card:hover,
body[data-theme="matrix"] .task-row.is-done .task-name { text-shadow: 0 0 4px rgba(0,255,65,0.5); }
/* Panels get a solid-ish backdrop so rain doesn't fight with text inside them */
body[data-theme="matrix"] .panel,
body[data-theme="matrix"] .form-card,
body[data-theme="matrix"] .group,
body[data-theme="matrix"] .project-card,
/*body[data-theme="matrix"] .auth-box,*/
body[data-theme="matrix"] .comment,
body[data-theme="matrix"] table.permission-grid,
body[data-theme="matrix"] .users-table { background: rgba(3, 9, 5, 0.92); }

#matrix-rain {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    z-index: -1;
    opacity: var(--rain-opacity, 0);
    pointer-events: none;
}

body[data-mode="day"] .icon-btn,
body[data-mode="day"] .chip { color: #4b5563; }
body[data-mode="day"] dialog#activity-dialog::backdrop,
body[data-mode="day"] dialog#comments-dialog::backdrop,
body[data-mode="day"] dialog#notes-dialog::backdrop { background: rgba(0,0,0,0.35); }

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

a { color: #6ea8fe; }

/* --- Auth page --- */
.auth-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
}
.auth-box {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 32px;
    width: 320px;
}
.auth-box h1 { font-size: 18px; margin: 0 0 4px; color: var(--muted); text-align: center; }
.auth-box h2 { margin: 0 0 20px; }
.auth-box label { display: block; margin: 12px 0 4px; font-size: 13px; color: var(--muted); }

/* Glass-morphism treatment for the login box on the always-matrix login page */
.auth-box-glass {
    background: #03090500;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    border: 1px solid rgba(0, 255, 65, 0.25);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
    position: relative;
    z-index: 1;
}
.auth-box input {
    width: 100%;
    padding: 10px;
    background: var(--input-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
}
.auth-box button {
    width: 100%;
    margin-top: 20px;
    padding: 10px;
    background: var(--accent);
    border: none;
    border-radius: var(--radius);
    color: white;
    font-weight: 600;
    cursor: pointer;
}
.auth-box button:hover { opacity: 0.9; }

/* --- Alerts --- */
.alert {
    padding: 10px 14px;
    border-radius: var(--radius);
    margin-bottom: 16px;
    font-size: 14px;
}
.alert-error { background: var(--panel); color: var(--text); border: 1px solid var(--border); border-left: 4px solid #dc3545; }
.alert-success { background: var(--panel); color: var(--text); border: 1px solid var(--border); border-left: 4px solid var(--border); }

/* --- App shell --- */
.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 24px;
    background: var(--panel);
    border-bottom: 1px solid var(--border);
}
.brand { font-weight: 700; }
.user-info { font-size: 14px; color: var(--muted); }
.content { padding: 24px; }

/* --- Status badges --- */
.badge { padding: 3px 10px; border-radius: 4px; font-size: 12px; font-weight: 600; display: inline-block; }
.badge-completed { background: rgba(31,157,85,0.15); color: var(--green); }
.badge-waiting { background: rgba(184,134,11,0.15); color: var(--amber); }
.badge-pending { background: rgba(123,63,160,0.15); color: var(--purple); }
.badge-not_started { background: rgba(154,158,166,0.15); color: var(--muted); }

.badge-select {
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
    border: none;
    cursor: pointer;
    background: rgba(154,158,166,0.15);
    color: var(--muted);
}
.badge-select.badge-completed { background: rgba(31,157,85,0.15); color: var(--green); }
.badge-select.badge-waiting { background: rgba(184,134,11,0.15); color: var(--amber); }
.badge-select.badge-pending { background: rgba(123,63,160,0.15); color: var(--purple); }
.badge-select option { background: var(--panel); color: var(--text); }

.inline-form { display: inline; }

/* --- Board groups + table --- */
.group {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 20px;
    overflow: hidden;
}
.group summary {
    cursor: pointer;
    padding: 12px 16px;
    font-weight: 600;
    list-style: none;
    display: flex;
    align-items: center;
    gap: 10px;
    border-bottom: 1px solid var(--border);
}
.group summary::-webkit-details-marker { display: none; }
.group .count { color: var(--muted); font-weight: 400; font-size: 13px; }

table.board { width: 100%; border-collapse: collapse; }
table.board th {
    text-align: left;
    font-size: 12px;
    color: var(--muted);
    text-transform: uppercase;
    padding: 10px 16px;
    border-bottom: 1px solid var(--border);
}
table.board td { padding: 10px 16px; border-bottom: 1px solid var(--border); font-size: 14px; }
table.board tr:last-child td { border-bottom: none; }
table.board a { color: var(--text); text-decoration: none; font-weight: 500; }
table.board a:hover { text-decoration: underline; }

.task-done a { text-decoration: line-through; color: var(--muted); }
.comment-count { font-size: 12px; color: var(--muted); margin-left: 8px; }
.desc-cell { color: var(--muted); font-size: 13px; }
.muted { color: var(--muted); }

/* --- Forms (new task / users / comments) --- */
.content.narrow { max-width: 680px; margin: 0 auto; }
.content.wide { max-width: 1100px; margin: 0 auto; }
.form-card {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    margin: 16px 0;
    max-width: 520px;
}
.form-card label { display: block; margin: 12px 0 4px; font-size: 13px; color: var(--muted); }
.form-card input, .form-card textarea, .form-card select {
    width: 100%;
    padding: 9px;
    background: var(--input-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-family: inherit;
}
select {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath fill='%239a9ea6' d='M6 8 0 0h12z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    background-size: 10px 7px;
    padding-right: 28px !important;
}
.form-actions { margin-top: 16px; display: flex; gap: 10px; }
.form-actions button, .btn-secondary, .btn-danger {
    padding: 9px 16px;
    border-radius: var(--radius);
    border: none;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    font-size: 14px;
}
.form-actions button { background: var(--accent); color: white; }
.btn-secondary { background: transparent; color: var(--muted); border: 1px solid var(--border) !important; display: inline-flex; align-items: center; }
.btn-danger { background: var(--panel); color: #dc3545; border: 1px solid var(--border); margin: 10px 0; }

/* --- Task detail page --- */
.task-header { display: flex; align-items: center; gap: 14px; margin-bottom: 16px; }
.task-header h1 { margin: 0; font-size: 22px; }
.meta-table { width: 100%; border-collapse: collapse; margin-bottom: 20px; }
.meta-table th { text-align: left; color: var(--muted); font-weight: 400; padding: 8px 12px 8px 0; width: 140px; vertical-align: top; }
.meta-table td { padding: 8px 12px 8px 0; }
.description-block { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; }
/* ---- Canonical data table style - used by Manage Users, Roles list, and the permission grid ---- */
.data-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    font-size: 14px;
}
.data-table th, .data-table td {
    padding: 10px 14px;
    border-bottom: 1px solid var(--border);
    text-align: left;
    white-space: nowrap;
}
.data-table td:first-child { display: flex; align-items: center; gap: 6px; }
.data-table th {
    color: var(--muted);
    font-weight: 400;
    font-size: 12px;
    text-transform: uppercase;
    background: rgba(128,128,128,0.06);
}
.data-table tr:last-child td { border-bottom: none; }

.btn-link {
    background: none;
    border: none;
    padding: 0;
    color: #6ea8fe;
    text-decoration: underline;
    cursor: pointer;
    font-size: 13px;
}
.btn-link-danger { color: #dc3545; }

.comments { margin: 16px 0; }
.comment { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; margin-bottom: 10px; }
.comment-meta { font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.comment-body { font-size: 14px; }

/* ============================================================
   Interactive board (ported + adapted design)
   ============================================================ */

.board-toolbar {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 14px;
}
.btn-ghost {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text);
    padding: 8px 14px;
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
}
.btn-ghost:hover { border-color: var(--accent); }

.project-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 14px;
    margin-top: 16px;
}
.project-card {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    transition: border-color 0.15s;
}
.project-card:hover { border-color: var(--accent); }
.project-card-link {
    display: block;
    text-decoration: none;
    color: var(--text);
}
.project-card-link h3 { margin: 0 0 6px; font-size: 16px; }
.project-card-link .project-meta { font-size: 12px; color: var(--muted); display: flex; gap: 10px; margin-top: 8px; }
.project-card-actions {
    margin-top: 12px;
    padding-top: 10px;
    border-top: 1px solid var(--border);
    font-size: 13px;
}

.group-head {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    border-left: 3px solid var(--accent);
}
.group-toggle {
    background: none;
    border: none;
    color: var(--muted);
    cursor: pointer;
    font-size: 14px;
    padding: 0;
    width: 18px;
}
.group-name {
    font-weight: 600;
    outline: none;
    padding: 2px 4px;
    border-radius: 4px;
}
.group-name[contenteditable="true"]:hover,
.group-name[contenteditable="true"]:focus {
    background: rgba(255,255,255,0.06);
}
.group-head .delete-group { margin-left: auto; }

.board-header-row, .task-row {
    display: grid;
    grid-template-columns: 36px 2.2fr 1fr 1.3fr 1fr 1fr 40px;
    grid-template-areas: "check name creator assignee status due actions";
    align-items: center;
    gap: 8px;
    padding: 0 16px;
}
.board-header-row {
    padding-top: 10px;
    padding-bottom: 10px;
    font-size: 11px;
    text-transform: uppercase;
    color: var(--muted);
    border-bottom: 1px solid var(--border);
}
.task-row {
    padding-top: 10px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border);
    font-size: 14px;
}
.task-row:last-of-type { border-bottom: none; }
.task-row.is-done .task-name { text-decoration: line-through; color: var(--muted); }
.task-row.is-overdue .cell-due { color: #dc3545; font-weight: 600; }

.cell { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.cell-check { grid-area: check; display: flex; justify-content: center; }
.cell-name {
    grid-area: name;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    white-space: nowrap;
}
.task-name { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.cell-name-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-left: auto;
    flex-shrink: 0;
}
.cell-creator { grid-area: creator; display: flex; align-items: center; gap: 6px; }
.cell-assignee { grid-area: assignee; display: flex; align-items: center; gap: 6px; }
.cell-status { grid-area: status; }
.cell-due { grid-area: due; }
.cell-actions { grid-area: actions; display: flex; justify-content: flex-end; }

.editable-text {
    outline: none;
    border-radius: 4px;
    padding: 2px 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.editable-text[contenteditable="true"]:hover,
.editable-text[contenteditable="true"]:focus {
    background: rgba(255,255,255,0.06);
    white-space: normal;
}

.icon-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 13px;
    padding: 2px 4px;
    border-radius: 4px;
    color: var(--muted);
    flex-shrink: 0;
}
.icon-btn:hover { background: rgba(255,255,255,0.08); color: var(--text); }

.avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    color: white;
    font-size: 10px;
    font-weight: 700;
    flex-shrink: 0;
    object-fit: cover;
    vertical-align: middle;
}

.assignee-select, .status-select, .date-input {
    width: 100%;
    background: var(--input-bg);
    border: 1px solid var(--border);
    color: var(--text);
    border-radius: var(--radius);
    padding: 5px 6px;
    font-size: 13px;
}
.status-select { border: none; font-weight: 600; cursor: pointer; }
.date-input::-webkit-calendar-picker-indicator {
    filter: invert(0.85);
    cursor: pointer;
}

.chip {
    font-size: 11px;
    color: var(--muted);
    text-decoration: none;
    background: rgba(255,255,255,0.06);
    padding: 3px 8px;
    border-radius: var(--radius);
    flex-shrink: 0;
    border: none;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 3px;
}
.chip:hover { color: var(--text); background: rgba(255,255,255,0.1); }

.pill {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
}
.pill-grey   { background: rgba(154,158,166,0.15); color: #9a9ea6; --pill-grey-fg: #9a9ea6; }
.pill-purple { background: rgba(123,63,160,0.18);  color: #b98ee0; --pill-purple-fg: #b98ee0; }
.pill-blue   { background: rgba(45,125,210,0.18);  color: #6ea8fe; --pill-blue-fg: #6ea8fe; }
.pill-amber  { background: rgba(184,134,11,0.18);  color: #e0b84a; --pill-amber-fg: #e0b84a; }
.pill-green  { background: rgba(31,157,85,0.18);   color: #4ecb87; --pill-green-fg: #4ecb87; }
.pill-red    { background: rgba(192,57,43,0.18);   color: #ff8a8a; --pill-red-fg: #ff8a8a; }

.add-task-row {
    width: 100%;
    text-align: left;
    background: none;
    border: none;
    color: var(--muted);
    padding: 10px 16px;
    cursor: pointer;
    font-size: 13px;
}
.add-task-row:hover { color: var(--text); background: rgba(255,255,255,0.04); }

.empty { padding: 16px; }

/* ---- activity dialog (comments + notes, tabbed) ---- */
dialog#activity-dialog {
    background: var(--panel);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    width: 460px;
    max-width: 90vw;
}
dialog#activity-dialog::backdrop { background: rgba(0,0,0,0.6); }

.activity-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 14px;
    border-bottom: 1px solid var(--border);
}
.activity-tab {
    background: none;
    border: none;
    color: var(--muted);
    padding: 8px 14px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
}
.activity-tab.active { color: var(--text); border-bottom-color: var(--accent); }

#activity-list {
    max-height: 320px;
    overflow-y: auto;
    margin-bottom: 14px;
}
#activity-list .comment {
    background: var(--input-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 10px 12px;
    margin-bottom: 8px;
}
#activity-list .comment-meta { font-size: 12px; color: var(--muted); margin-bottom: 4px; overflow: hidden; display: flex; align-items: center; gap: 6px; }
#activity-list .comment-meta .entry-delete { margin-left: auto; float: none !important; }
#activity-list .comment-body { font-size: 14px; white-space: pre-wrap; }
#activity-textarea {
    width: 100%;
    background: var(--input-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    padding: 10px;
    font-family: inherit;
    margin-bottom: 12px;
}

/* ---- toast ---- */
.toast {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: var(--panel);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 10px 16px;
    border-radius: var(--radius);
    font-size: 13px;
    opacity: 0;
    transform: translateY(8px);
    transition: opacity 0.2s, transform 0.2s;
    z-index: 1000;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast-error { border-color: #dc3545; color: #dc3545; }

@media (max-width: 720px) {
    .content { padding: 12px; }

    .board-header-row { display: none; }

    .task-row {
        display: grid;
        grid-template-columns: auto 1fr auto;
        grid-template-areas:
            "check name actions"
            ".     assignee assignee"
            ".     status due";
        row-gap: 8px;
        column-gap: 10px;
        padding: 12px;
        margin: 10px;
        background: var(--input-bg);
        border: 1px solid var(--border);
        border-radius: var(--radius);
    }
    .task-row:last-of-type { border-bottom: 1px solid var(--border); }

    .cell-creator { display: none; }
    .cell-name { white-space: normal; }
    .task-name { white-space: normal; }
    .cell-assignee { display: flex; align-items: center; gap: 6px; }
    .cell-status, .cell-due { display: flex; align-items: center; }
    .status-select, .assignee-select, .date-input { font-size: 13px; padding: 7px 8px; }

    .group-head { padding: 12px; }
    .add-task-row { padding: 12px 16px; }

    dialog#activity-dialog, dialog#comments-dialog { width: 92vw; }

    .project-grid { grid-template-columns: 1fr; }
}

/* ---- Roles & Permissions grid (extends .data-table) ---- */
.permission-grid-wrap { overflow-x: auto; margin: 16px 0; }
table.permission-grid {
    font-size: 13px;
    min-width: 100%;
}
table.permission-grid th, table.permission-grid td {
    border-right: 1px solid var(--border);
    white-space: nowrap;
}
table.permission-grid th.perm-category {
    text-align: center;
    background: rgba(255,255,255,0.03);
}
table.permission-grid th.perm-col { font-size: 12px; }
table.permission-grid td.perm-col { text-align: center; }
table.permission-grid td.role-name-cell { font-weight: 600; }
table.permission-grid input[type="checkbox"] { width: 16px; height: 16px; cursor: pointer; }
table.permission-grid input[type="checkbox"]:disabled { cursor: not-allowed; opacity: 0.6; }

/* ---- Avatar picker (account settings) ---- */
.avatar-current { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.avatar-preview {
    width: 80px; height: 80px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--border);
}
.avatar-preview-fallback {
    width: 80px; height: 80px;
    font-size: 24px;
}
.preset-grid {
    display: flex;
    gap: 8px;
    max-width: 100%;
    margin-top: 10px;
    overflow-x: auto;
    padding-bottom: 4px;
}
.preset-grid .preset-btn { flex-shrink: 0; }
.preset-btn {
    background: none;
    border: 2px solid transparent;
    border-radius: 50%;
    padding: 2px;
    cursor: pointer;
    width: 56px;
    height: 56px;
}
.preset-btn:hover { border-color: var(--accent); }
.preset-btn img { width: 100%; height: 100%; border-radius: 50%; display: block; }

/* board assignee avatar sizing now set inline per-call via render_avatar_html() */

/* ---- Side drawer navigation ---- */
#side-drawer {
    position: fixed;
    top: 0;
    left: 0;
    width: 250px;
    height: 100vh;
    background: var(--panel);
    border-right: 1px solid var(--border);
    transform: translateX(-100%);
    transition: transform 0.22s ease;
    z-index: 300;
    display: flex;
    flex-direction: column;
    padding: 0 0 16px;
    overflow-y: auto;
}
#side-drawer.open { transform: translateX(0); }

.drawer-brand {
    padding: 16px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 8px;
}
.drawer-logo { max-height: 36px; max-width: 100%; display: block; }
.drawer-brand-text { font-weight: 700; font-size: 16px; }

.drawer-link {
    display: block;
    padding: 12px 16px;
    color: var(--text);
    text-decoration: none;
    font-size: 14px;
}
.drawer-link:hover { background: rgba(128,128,128,0.1); }
.drawer-link.active { border-left: 3px solid var(--accent); background: rgba(128,128,128,0.08); }

#drawer-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 250;
    display: none;
}
#drawer-overlay.open { display: block; }

.drawer-toggle-btn {
    background: none;
    border: none;
    color: var(--text);
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
    padding: 4px 8px;
}

.topbar .brand { display: flex; align-items: center; gap: 10px; }
.topbar-logo { max-height: 28px; max-width: 160px; vertical-align: middle; object-fit: contain; }

@media (max-width: 720px) {
    #side-drawer { width: 82vw; max-width: 280px; }
}

/* ---- Theme picker ---- */
.theme-options { display: flex; gap: 12px; flex-wrap: wrap; }
.theme-btn {
    padding: 14px 22px;
    border-radius: var(--radius);
    border: 2px solid var(--border);
    cursor: pointer;
    font-weight: 600;
    font-size: 14px;
    min-width: 100px;
}
.theme-btn.active { border-color: var(--accent); }
.theme-btn-night { background: #17181c; color: #e8e9ec; }
.theme-btn-day { background: #f4f5f7; color: #1c1e21; border-color: #dfe2e6; }
.theme-btn-day.active { border-color: var(--accent); }
.theme-btn-matrix { background: #000000; color: #00ff41; font-family: 'Courier New', monospace; }
.theme-btn-red { background: #26181b; color: #f4e6e7; }
.theme-btn-blue { background: #16212f; color: #e8edf4; }
.theme-btn-purple { background: #22152c; color: #efe3f4; }
.theme-btn-beige { background: #fffdf8; color: #3a2f1f; border-color: #e3d5bc; }

/* ---- Day/Night mode toggle switch (top bar) ---- */
.mode-toggle { display: inline-flex; align-items: center; gap: 5px; vertical-align: middle; }
.mode-icon { font-size: 13px; line-height: 1; opacity: 0.8; }
.toggle-switch {
    position: relative;
    width: 38px;
    height: 20px;
    background: var(--border);
    border-radius: var(--radius);
    border: none;
    cursor: pointer;
    padding: 0;
    flex-shrink: 0;
}
.toggle-knob {
    position: absolute;
    top: 2px;
    left: 2px;
    width: 16px;
    height: 16px;
    background: var(--accent);
    border-radius: 50%;
    transition: transform 0.2s ease;
}
.toggle-switch.is-night .toggle-knob { transform: translateX(18px); }

/* ---- Range slider (Matrix rain intensity) ---- */
input[type="range"] {
    accent-color: var(--text);
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    width: 100%;
    background: transparent;
    cursor: pointer;
    padding: 0;
    border: none;
    height: 20px;
    margin: 0;
}
input[type="range"]::-webkit-slider-runnable-track {
    background: var(--border);
    height: 4px;
    border-radius: 2px;
}
input[type="range"]::-moz-range-track {
    background: var(--border);
    height: 4px;
    border-radius: 2px;
    border: none;
}
input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--text);
    margin-top: -6px;
    cursor: pointer;
}
input[type="range"]::-moz-range-thumb {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--text);
    border: none;
    cursor: pointer;
}

/* ---- Compact top bar on mobile: hide role name, show power icon instead of "Log out" text ---- */
.logout-icon { display: none; color: #dc3545; vertical-align: middle; }
.logout-icon svg { display: block; }
@media (max-width: 720px) {
    .role-label { display: none; }
    .logout-text { display: none; }
    .logout-icon { display: inline-block; }
    .user-info { gap: 4px; }
    .topbar-logo { max-height: 24px; max-width: 100px; }
}

.login-logo { display: block; max-width: 100%; max-height: 64px; object-fit: contain; margin: 0 auto 10px; }
