/* ── Theme tokens ── */
:root,
[data-theme="dark"] {
    --bg-main: #0d1117;
    --bg-card: #161b22;
    --bg-col: #010409;
    --bg-bar: #161b22;
    --text: #c9d1d9;
    --text-dim: #8b949e;
    --border: #30363d;
    --accent: #58a6ff;
    --accent-dim: #388bfd22;
    --input-bg: #0d1117;
    --btn-primary: #238636;
    --shadow: rgba(0, 0, 0, 0.4);
    --status-aperto: #8b949e;
    --status-preso: #d29922;
    --status-fixing: #a371f7;
    --status-testing: #1f6feb;
    --status-chiuso: #238636;
    --stats-w: 700px;
    --expand-w: calc(100vw - 700px);
    --bar-h: 44px;
}

[data-theme="light"] {
    --bg-main: #f6f8fa;
    --bg-card: #ffffff;
    --bg-col: #eaeef2;
    --bg-bar: #ffffff;
    --text: #1f2328;
    --text-dim: #656d76;
    --border: #d0d7de;
    --accent: #0969da;
    --accent-dim: #0969da15;
    --input-bg: #ffffff;
    --btn-primary: #1a7f37;
    --shadow: rgba(0, 0, 0, 0.12);
    --status-aperto: #656d76;
    --status-preso: #9a6700;
    --status-fixing: #8250df;
    --status-testing: #0550ae;
    --status-chiuso: #1a7f37;
}

/* ── Reset ── */
*,
*::before,
*::after {
    box-sizing: border-box;
}

body,
html {
    height: 100%;
    margin: 0;
    font-family: 'SF Mono', 'Fira Code', monospace;
    background: var(--bg-main);
    color: var(--text);
    overflow: hidden;
}

/* ── Lucide icons ── */
.lc {
    display: inline-block;
    vertical-align: middle;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
    flex-shrink: 0;
}

.lc-logo {
    width: 18px;
    height: 18px;
}

.lc-sm {
    width: 14px;
    height: 14px;
}

.lc-xs {
    width: 12px;
    height: 12px;
}

.lc-tl {
    width: 11px;
    height: 11px;
    opacity: 0.6;
}

.lc-fu {
    width: 11px;
    height: 11px;
}

.lc-del {
    width: 14px;
    height: 14px;
    color: #f85149;
}

.lc-chev {
    width: 12px;
    height: 12px;
    opacity: 0.55;
}

.mg-chevron {
    width: 11px;
    height: 11px;
    opacity: 0.55;
}

/* ── View tabs (Bug / Feature / Ideas) ── */
.view-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 14px;
    border-bottom: 1px solid var(--border);
    padding-bottom: 10px;
}

.view-tab {
    flex: 1;
    padding: 5px 6px;
    background: none;
    border: 1px solid var(--border);
    color: var(--text-dim);
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.68rem;
    font-family: inherit;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    margin: 0;
    width: auto;
    transition: border-color .15s, color .15s, background .15s;
}

.view-tab:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.view-tab.active {
    border-color: var(--accent);
    color: var(--accent);
    background: var(--accent-dim);
}

/* Forms tab */
.tab-form {
    display: none;
}

.tab-form.active {
    display: flex;
    flex-direction: column;
}

/* ── Boards area ── */
.boards-area {
    flex: 1;
    display: flex;
    min-width: 0;
    overflow: hidden;
}

.tab-board {
    display: none;
    flex: 1;
    gap: 12px;
    overflow: hidden;
}

.tab-board.active {
    display: flex;
}

/* ── Tab switcher (nuovo markup) ── */
.tab-switcher {
    display: flex;
    gap: 2px;
    align-items: center;
    background: var(--bg-col);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 2px;
}

.tab-btn {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 0.68rem;
    padding: 4px 10px;
    border-radius: 4px;
    border: none;
    background: none;
    color: var(--text-dim);
    cursor: pointer;
    font-family: inherit;
    margin: 0;
    width: auto;
    transition: background .15s, color .15s;
}

.tab-btn:hover {
    color: var(--text);
    background: var(--accent-dim);
}

.tab-btn.active {
    background: var(--bg-card);
    color: var(--accent);
    border: 1px solid var(--border);
    box-shadow: 0 1px 3px var(--shadow);
}

.tab-panel {
    display: none;
}

.tab-panel.active {
    display: flex;
}

/* ── Promote button ── */
button.btn-s {
    width: auto;
    margin-top: 0;
    background: transparent;
    color: var(--text);
    border: 1px solid var(--border);
    font-weight: normal;
    letter-spacing: normal;
    text-transform: none;
}

.btn-promote {
    border-color: #3fb95055;
    background: #3fb95018;
    color: var(--status-chiuso);
}

.btn-promote:hover {
    background: #3fb95030 !important;
    border-color: var(--status-chiuso) !important;
    color: var(--status-chiuso) !important;
}

/* ── Extra status colors ── */
.status-planned {
    border-left-color: var(--accent);
}

.search-box {
    display: flex;
    align-items: center;
    gap: 0;
    position: relative;
}

.search-input {
    width: 0;
    max-width: 0;
    padding: 4px 0;
    margin: 0;
    border: 1px solid transparent;
    background: transparent;
    color: var(--text);
    font-size: 0.72rem;
    font-family: inherit;
    border-radius: 4px;
    transition: width .25s ease, max-width .25s ease, padding .25s ease,
        border-color .25s ease, background .25s ease;
    overflow: hidden;
    outline: none;
}

.search-box.open .search-input {
    width: 200px;
    max-width: 200px;
    padding: 4px 28px 4px 8px;
    border-color: var(--accent);
    background: var(--input-bg);
}

.search-clear {
    position: absolute;
    right: 6px;
    background: none;
    border: none;
    color: var(--text-dim);
    cursor: pointer;
    padding: 0;
    margin: 0;
    width: auto;
    display: flex;
    align-items: center;
}

.search-clear:hover {
    color: var(--text);
}

/* ── Bug categoria badge ── */
.bug-cat {
    margin-left: auto;
    font-size: 0.52rem;
    color: var(--text-dim);
    background: var(--accent-dim);
    border: 1px solid var(--border);
    padding: 1px 5px;
    border-radius: 8px;
    white-space: nowrap;
    opacity: 0.8;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

/* ── Global bar ── */
.global-bar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--bar-h);
    background: var(--bg-bar);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 14px;
    gap: 10px;
    z-index: 60;
    box-shadow: 0 1px 4px var(--shadow);
}

.global-bar-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.global-bar-right {
    display: flex;
    align-items: center;
    gap: 6px;
}

.global-logo {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.95rem;
    font-weight: bold;
    color: var(--accent);
    white-space: nowrap;
}

.project-pill {
    display: flex;
    align-items: center;
    gap: 5px;
    background: var(--accent-dim);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 2px 8px;
}

.project-pill-btn {
    background: var(--accent-dim) !important;
    border-radius: 12px !important;
    padding: 3px 10px !important;
    gap: 5px !important;
}

.project-pill-root {
    font-size: 0.68rem;
    font-weight: bold;
    color: var(--accent);
}

.project-pill-name {
    font-size: 0.65rem;
    color: var(--text-dim);
}

.gbar-sep {
    width: 1px;
    height: 18px;
    background: var(--border);
    margin: 0 2px;
}

.gbar-btn {
    background: none;
    border: 1px solid var(--border);
    color: var(--text-dim);
    border-radius: 4px;
    padding: 4px 8px;
    font-size: 0.7rem;
    cursor: pointer;
    white-space: nowrap;
    width: auto;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 5px;
    transition: border-color .15s, color .15s;
    font-family: inherit;
}

.gbar-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.icon-btn {
    padding: 6px 8px;
}

.gbar-dropdown {
    position: relative;
}

/* Ponte invisibile per non far chiudere il menu muovendo il mouse */
.gbar-dropdown::after {
    content: "";
    position: absolute;
    top: 100%;
    left: 0;
    width: 100%;
    height: 12px;
    z-index: 10;
}

.gbar-dropdown-menu {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    min-width: 180px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 6px;
    box-shadow: 0 4px 16px var(--shadow);
    z-index: 200;
}

.gbar-dropdown-menu > .gbar-dropdown-item:first-child,
.gbar-dropdown-menu > .gbar-dropdown-submenu:first-child .gbar-submenu-trigger {
    border-top-left-radius: 6px;
    border-top-right-radius: 6px;
}

.gbar-dropdown-menu > .gbar-dropdown-item:last-child,
.gbar-dropdown-menu > .gbar-dropdown-submenu:last-child .gbar-submenu-trigger {
    border-bottom-left-radius: 6px;
    border-bottom-right-radius: 6px;
}

.gbar-dropdown-menu-right {
    left: auto;
    right: 0;
}

.gbar-dropdown:hover .gbar-dropdown-menu {
    display: block;
}

.gbar-dropdown-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 12px;
    font-size: 0.7rem;
    color: var(--text);
    text-decoration: none;
    cursor: pointer;
    font-family: inherit;
    background: none;
    border: none;
    width: 100%;
    text-align: left;
}

.gbar-dropdown-item:hover {
    background: var(--accent-dim);
}

.gbar-dropdown-item.active {
    color: var(--accent);
}

.di-root {
    font-weight: bold;
    color: var(--accent);
    min-width: 32px;
}

.gbar-dropdown-submenu {
    position: relative;
}

.gbar-submenu-trigger {
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
}

.gbar-submenu-panel {
    display: none;
    position: absolute;
    left: 100%;
    top: 0;
    background: var(--bg-bar);
    border: 1px solid var(--border);
    border-radius: 6px;
    min-width: 180px;
    box-shadow: 0 4px 16px var(--shadow);
    z-index: 70;
}

.gbar-dropdown-submenu:hover .gbar-submenu-panel {
    display: block;
}

.di-name {
    color: var(--text-dim);
}

.gbar-dropdown-sep {
    border-top: 1px solid var(--border);
    margin: 2px 0;
}

/* ── Layout ── */
.dashboard {
    display: flex;
    height: calc(100vh - var(--bar-h));
    margin-top: var(--bar-h);
    padding: 12px;
    gap: 12px;
}

/* ── Sidebar form ── */
.column-left {
    flex: 0 0 230px;
    border-right: 1px solid var(--border);
    padding-right: 12px;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.column-left::after {
    content: "DVL v1.0-b37W - Made in Milan, IT with love but also with some sort of revenge by SCTD - ©2026";
    display: block;
    margin-top: auto;
    padding-top: 24px;
    font-size: 0.6rem;
    color: var(--text-dim);
    opacity: 0.55;
    line-height: 1.5;
}

label {
    display: block;
    margin-top: 10px;
    font-size: 0.76rem;
    color: var(--text-dim);
}

.label-note {
    font-size: 0.65rem;
    color: var(--text-dim);
    font-weight: normal;
}

input,
textarea,
select {
    width: 100%;
    background: var(--input-bg);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 7px;
    margin-top: 4px;
    border-radius: 4px;
    font-size: 0.76rem;
    font-family: inherit;
}

input:focus,
textarea:focus,
select:focus {
    outline: none;
    border-color: var(--accent);
}

button {
    width: 100%;
    margin-top: 14px;
    background: var(--btn-primary);
    color: #fff;
    border: none;
    padding: 9px;
    border-radius: 4px;
    cursor: pointer;
    font-weight: bold;
    font-family: inherit;
    font-size: 0.78rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

button:hover {
    opacity: 0.88;
}

/* ── Board ── */
.board-container {
    flex: 1;
    display: flex;
    gap: 12px;
    overflow: hidden;
    min-width: 0;
}

.kanban-col {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 200px;
    background: var(--bg-col);
    border-radius: 6px;
    border: 1px solid var(--border);
}

.kanban-header {
    padding: 7px 10px;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    font-weight: bold;
    font-size: 0.76rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 5px;
    flex-shrink: 0;
}

.col-counter {
    font-size: 0.6rem;
    color: var(--text-dim);
    font-weight: normal;
    white-space: nowrap;
}

.col-counter.filtered {
    color: var(--accent);
}

.col-filter {
    width: auto;
    padding: 2px 4px;
    font-size: 0.58rem;
    margin-top: 0;
    background: var(--bg-col);
    border-color: var(--border);
    color: var(--text-dim);
    border-radius: 3px;
    max-width: 76px;
}

.kanban-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
}

/* ── Month group ── */
.month-group {
    margin-bottom: 6px;
}

.month-group-header {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 3px 5px;
    cursor: pointer;
    border-radius: 4px;
    user-select: none;
    border: 1px solid transparent;
}

.month-group-header:hover {
    background: var(--accent-dim);
    border-color: var(--border);
}

.month-group-label {
    font-size: 0.67rem;
    color: var(--text-dim);
    font-weight: bold;
    flex: 1;
}

.month-group-count {
    font-size: 0.6rem;
    color: var(--text-dim);
    background: var(--accent-dim);
    padding: 1px 5px;
    border-radius: 8px;
}

.month-group-body {
    max-height: 9999px;
    overflow: hidden;
    transition: max-height .3s ease, opacity .2s ease;
    opacity: 1;
    padding-top: 4px;
}

.month-group.collapsed .month-group-body {
    max-height: 0;
    opacity: 0;
    padding-top: 0;
}

/* ── Bug card ── */
.bug-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    padding: 0;
    /* Changed to 0 for summary/body layout */
    margin-bottom: 7px;
    border-radius: 6px;
    font-size: 0.75rem;
    position: relative;
    border-left: 4px solid #444;
    display: flex;
    flex-direction: column;
    transition: box-shadow .15s;
    overflow: hidden;
    /* Added to contain body transition */
}

.bug-card:hover {
    box-shadow: 0 2px 8px var(--shadow);
}

.bug-card.is-child {
    margin-left: 18px;
    width: auto;
}

/* Elbow connector */
.bug-card.is-child::before {
    content: "";
    position: absolute;
    top: -12px;
    left: -12px;
    width: 10px;
    height: 30px;
    border-left: 2px solid var(--border);
    border-bottom: 2px solid var(--border);
    border-bottom-left-radius: 6px;
    pointer-events: none;
    opacity: 0.6;
}

.status-aperto {
    border-left-color: var(--status-aperto);
}

.status-assegnato {
    border-left-color: var(--status-preso);
}

.status-preso-in-carico {
    border-left-color: var(--status-preso);
}

.status-fixing {
    border-left-color: var(--status-fixing);
}

.status-testing {
    border-left-color: var(--status-testing);
}

.status-chiuso {
    border-left-color: var(--status-chiuso);
    opacity: 0.72;
}

.bug-title {
    font-weight: bold;
    color: #ffa657;
    margin-bottom: 4px;
    padding-right: 20px;
    display: flex;
    align-items: center;
    gap: 4px;
    flex-wrap: wrap;
}

[data-theme="light"] .bug-title {
    color: #953800;
}

.bug-timeline {
    font-size: 0.6rem;
    color: var(--text-dim);
    margin-bottom: 6px;
    border-bottom: 1px dashed var(--border);
    padding-bottom: 4px;
    display: flex;
    align-items: center;
    gap: 4px;
}

pre {
    background: var(--bg-col);
    padding: 7px;
    border-radius: 4px;
    white-space: pre-wrap;
    font-size: 0.7rem;
    border: 1px solid var(--border);
    margin: 6px 0;
    font-family: inherit;
}

.actions {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 7px;
}

.btn-s {
    font-size: 0.58rem;
    padding: 3px 6px;
    border-radius: 3px;
    text-decoration: none;
    border: 1px solid var(--border);
    color: var(--text);
    font-family: inherit;
    display: inline-flex;
    align-items: center;
    gap: 3px;
}

.btn-s:hover {
    border-color: var(--accent);
    background: var(--accent-dim);
}

.btn-assign {
    border-color: var(--status-preso);
    color: var(--status-preso);
}

.btn-assign:hover {
    background: #d2992220 !important;
    border-color: var(--status-preso) !important;
    color: var(--status-preso) !important;
}

.btn-assigned {
    border-color: var(--status-preso);
    color: #fff;
    background: var(--status-preso);
    cursor: default;
    pointer-events: none;
    opacity: 0.9;
}

.btn-revoke {
    border-color: #f8514955;
    background: #f8514918;
    color: #f85149;
}
.btn-revoke:hover {
    background: #f8514930 !important;
    border-color: #f85149 !important;
    color: #f85149 !important;
}

.delete-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    text-decoration: none;
    display: flex;
    align-items: center;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
    color: #f85149;
}

.bug-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    margin-top: 7px;
    padding-top: 5px;
    border-top: 1px dashed var(--border);
}

.bug-footer-right {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-left: auto;
}

.bug-id {
    font-size: 0.55rem;
    color: var(--text-dim);
    opacity: 0.65;
}

.lc-fu {
    transform: rotate(-180deg);
}

.bug-ver {
    font-size: 0.52rem;
    color: var(--accent);
    background: var(--accent-dim);
    border: 1px solid var(--border);
    padding: 1px 5px;
    border-radius: 4px;
    text-transform: uppercase;
    font-weight: bold;
}

.follow-up-badge {
    font-size: 0.54rem;
    color: var(--status-preso);
    background: #d2992215;
    border: 1px solid #d2992240;
    padding: 1px 5px;
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    gap: 3px;
    max-width: 160px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ── Card summary/body general ── */
.card-summary,
.done-summary {
    padding: 8px 10px;
    cursor: pointer;
    position: relative;
    user-select: none;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.card-summary:hover,
.done-summary:hover {
    background: var(--accent-dim);
}

.summary-row-top {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    width: 100%;
}

.summary-row-bottom {
    display: flex;
    align-items: center;
    gap: 12px;
    padding-left: 20px;
    /* Align with title */
}

.card-summary .bug-title,
.done-summary .bug-title {
    margin-bottom: 0;
    flex: 1;
    font-size: 0.76rem;
    line-height: 1.3;
    /* allow wrap as user disliked truncation */
}

.card-date {
    font-size: 0.62rem;
    color: var(--text-dim);
    display: flex;
    align-items: center;
    gap: 4px;
    white-space: nowrap;
}

.card-author {
    font-size: 0.62rem;
    color: var(--text-dim);
    display: flex;
    align-items: center;
    gap: 4px;
    white-space: nowrap;
}

.done-badges {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
    margin-left: auto;
}

.bug-card.is-open .summary-row-bottom .done-badges {
    display: none;
}

.card-chev-icon,
.done-chev-icon {
    flex-shrink: 0;
    color: var(--text-dim);
    transition: transform 0.2s;
    margin-top: 2px;
}

.bug-card.is-open .card-chev-icon,
.bug-card.is-open .done-chev-icon {
    transform: rotate(90deg);
}

/* ── Admin Projects modal ── */
.admin-proj-row {
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 10px 12px;
    margin-bottom: 10px;
    background: var(--bg-card, transparent);
}
.ap-row-head {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 6px;
}
.ap-row-title {
    flex: 1;
    display: flex;
    align-items: baseline;
    gap: 8px;
    min-width: 0;
}
.ap-root {
    font-family: 'SF Mono','Fira Code',monospace;
    font-size: 0.78rem;
    font-weight: bold;
    color: var(--accent);
    flex-shrink: 0;
}
.ap-name {
    font-size: 0.78rem;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.ap-row-stats {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 2px;
    flex-shrink: 0;
}
.ap-tot {
    font-size: 0.85rem;
    font-weight: bold;
    color: var(--text);
    line-height: 1;
}
.ap-pct {
    font-size: 0.62rem;
    color: var(--text-dim);
}
.ap-row-actions {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
}
.ap-btn {
    width: 28px;
    height: 28px;
    padding: 0;
    margin: 0;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: transparent;
    color: var(--text-dim);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.ap-btn .lucide,
.ap-btn svg {
    width: 14px;
    height: 14px;
}
.ap-btn:hover {
    background: var(--border);
    color: var(--text);
}
.ap-btn-ghost.open svg,
.ap-btn-ghost.open .lucide {
    transform: rotate(180deg);
    transition: transform 0.2s;
}
.ap-btn-danger:hover {
    color: var(--status-aperto);
    border-color: var(--status-aperto);
}
.ap-members-row {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 4px;
}
.ap-member {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.66rem;
    color: var(--text-dim);
    padding: 2px 6px;
    background: rgba(255,255,255,0.03);
    border-radius: 10px;
}
.ap-member svg,
.ap-member .lucide { width: 10px; height: 10px; }
.ap-role {
    font-size: 0.58rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--accent);
    margin-left: 2px;
}
.admin-proj-detail {
    border-top: 1px dashed var(--border);
    padding-top: 8px;
    margin-top: 6px;
}
.ap-type-row {
    margin: 6px 0;
}
.ap-type-head {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.72rem;
    font-weight: bold;
    color: var(--text);
    margin-bottom: 4px;
}
.ap-type-head svg,
.ap-type-head .lucide { width: 12px; height: 12px; color: var(--text-dim); }
.ap-type-count {
    font-size: 0.62rem;
    color: var(--text-dim);
    font-weight: normal;
}
.ap-state-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}
.ap-state-chip {
    font-size: 0.62rem;
    padding: 2px 7px;
    border-radius: 3px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

/* ── Team modal ── */
.team-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 0;
    border-bottom: 1px solid var(--border);
    font-size: 0.76rem;
    min-width: 0;
}
.team-row-icon {
    width: 12px;
    height: 12px;
    flex-shrink: 0;
    color: var(--text-dim);
}
.team-row-name {
    flex: 1;
    color: var(--text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
}
.team-row-email {
    color: var(--text-dim);
    font-size: 0.72rem;
}
.team-row-me {
    color: var(--text-dim);
    font-size: 0.62rem;
    margin-left: 4px;
}
.team-role-badge {
    font-size: 0.62rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: bold;
    flex-shrink: 0;
}
.team-row select.team-role-sel {
    width: auto;
    margin: 0;
    padding: 2px 6px;
    font-size: 0.66rem;
    flex-shrink: 0;
}
.team-invite-row {
    display: flex;
    gap: 6px;
    align-items: stretch;
}
.team-invite-row input,
.team-invite-row select {
    margin: 0;
}
.team-invite-row input { flex: 1; min-width: 0; }
.team-invite-row select { width: auto; flex-shrink: 0; }
.ap-btn-primary {
    color: var(--accent);
    border-color: var(--accent);
}
.ap-btn-primary:hover {
    background: var(--accent);
    color: #fff;
}

/* Text-button con icona, larghezza auto, niente verde */
.ap-btn-text {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 14px;
    width: auto;
    margin-top: 0;
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text);
    border-radius: 4px;
    font-size: 0.74rem;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    cursor: pointer;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.ap-btn-text:hover {
    background: var(--border);
}
.ap-btn-text svg, .ap-btn-text .lucide { width: 13px; height: 13px; }
.ap-btn-primary-text {
    color: var(--accent);
    border-color: var(--accent);
}
.ap-btn-primary-text:hover {
    background: var(--accent);
    color: #fff;
}

/* ── Project categories sub-modal ── */
.pcat-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 8px;
    border-bottom: 1px solid var(--border);
    font-size: 0.74rem;
}
.pcat-code {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    border: 1px solid var(--accent);
    color: var(--accent);
    font-family: 'SF Mono','Fira Code',monospace;
    font-weight: bold;
    font-size: 0.72rem;
    border-radius: 3px;
    flex-shrink: 0;
}
.pcat-name {
    flex: 1;
    color: var(--text);
    text-transform: capitalize;
}

/* ── User-projects sub-modal ── */
.up-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 8px;
    border-bottom: 1px solid var(--border);
    font-size: 0.74rem;
    cursor: pointer;
    transition: background 0.15s;
}
.up-row:hover { background: rgba(255,255,255,0.04); }
.up-row .up-check {
    width: auto;
    margin: 0;
    accent-color: var(--accent);
    cursor: pointer;
}
.up-row .up-root {
    font-family: 'SF Mono','Fira Code',monospace;
    color: var(--accent);
    font-weight: bold;
    flex-shrink: 0;
}
.up-row .up-name {
    flex: 1;
    color: var(--text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ── Build stepper ── */
.build-stepper {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-top: 4px;
}
.build-stepper input {
    width: 52px;
    text-align: center;
    margin-top: 0;
    -moz-appearance: textfield;
}
.build-stepper input::-webkit-inner-spin-button,
.build-stepper input::-webkit-outer-spin-button { -webkit-appearance: none; }
.stepper-btn {
    width: 28px;
    height: 28px;
    min-width: 28px;
    margin-top: 0;
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text);
    border-radius: 4px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    transition: background 0.15s;
}
.stepper-btn:hover { background: var(--bg-hover, var(--border)); }

/* Subtle delete in card summary */
.delete-btn-card {
    color: var(--text-dim);
    opacity: 0.4;
    transition: opacity 0.15s, color 0.15s;
    padding: 0 2px;
}

.delete-btn-card:hover {
    opacity: 1;
    color: #f85149;
    /* Red only on hover */
}

.card-body,
.done-body {
    max-height: 0;
    overflow: hidden;
    transition: max-height .35s cubic-bezier(.4, 0, .2, 1), opacity .25s ease;
    opacity: 0;
    padding: 0 10px;
}

.bug-card.is-open .card-body,
.bug-card.is-open .done-body,
.bug-card-done.is-open .card-body,
.bug-card-done.is-open .done-body {
    max-height: 2000px;
    opacity: 1;
    padding: 0 10px 10px;
    border-top: 1px dashed var(--border);
}

.card-body pre,
.done-body pre {
    white-space: pre-wrap;
    word-break: break-word;
    max-height: 300px;
    overflow-y: auto;
    margin-bottom: 8px;
}

.status-in-dev {
    border-left-color: var(--status-preso);
}

.status-in-review {
    border-left-color: var(--status-fixing);
}

.status-released {
    border-left-color: var(--status-chiuso);
}

/* ── Stats Sidebar Catalog (700px) ── */
.stats-sidebar {
    position: fixed;
    top: var(--bar-h);
    right: 0;
    width: var(--stats-w);
    height: calc(100vh - var(--bar-h));
    background: var(--bg-card);
    border-left: 1px solid var(--border);
    z-index: 1000;
    transform: translateX(100%);
    transition: transform .3s cubic-bezier(.4, 0, .2, 1);
    display: flex;
    flex-direction: column;
    box-shadow: -10px 0 30px rgba(0, 0, 0, 0.3);
}

.stats-sidebar.open {
    transform: translateX(0);
}

.stats-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--bg-col);
}

.stats-content {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    align-content: start;
}

.chart-container {
    background: var(--bg-main);
    border: 1px solid var(--border);
    border-radius: 12px;
    position: relative;
    cursor: pointer;
    width: 310px;
    height: 310px;
    /* Quadratini forzati */
    overflow: hidden;
    transition: all .2s;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.chart-container:hover {
    transform: translateY(-4px);
    border-color: var(--accent);
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.3);
}

.chart-title {
    position: absolute;
    top: 10px;
    left: 12px;
    font-size: 0.7rem;
    color: var(--text-dim);
    z-index: 10;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    pointer-events: none;
}

.chart-box {
    width: 100%;
    height: 100%;
}

/* Expansion Panel (Affiancato a sinistra) */
.chart-expand-panel {
    position: fixed;
    top: var(--bar-h);
    right: var(--stats-w);
    width: var(--expand-w);
    height: calc(100vh - var(--bar-h));
    background: rgba(13, 17, 23, 0.98);
    backdrop-filter: blur(15px);
    z-index: 999;
    border-left: 1px solid var(--border);
    opacity: 0;
    pointer-events: none;
    transition: opacity .3s ease;
    display: flex;
    flex-direction: column;
}

.chart-expand-panel.open {
    opacity: 1;
    pointer-events: auto;
}

.chart-expand-header {
    padding: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border);
}

.chart-expand-body {
    flex: 1;
    padding: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chart-expanded {
    flex: 1;
    width: 100%;
    height: 100%;
}

.stats-scope-selector {
    grid-column: span 2;
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 12px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border);
}

.scope-group,
.granularity-selector {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.scope-btn,
.col-btn,
.gran-btn {
    padding: 4px 10px;
    font-size: 0.68rem;
    font-family: inherit;
    font-weight: normal;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 4px;
    cursor: pointer;
    color: var(--text-dim);
    width: auto;
    margin-top: 0;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
    display: inline-flex;
    align-items: center;
}

.scope-btn:hover,
.col-btn:hover,
.gran-btn:hover {
    background: var(--border);
    color: var(--text);
}

.scope-btn.active,
.col-btn.active,
.gran-btn.active {
    background: transparent;
    color: var(--accent);
    border-color: var(--accent);
    font-weight: bold;
}

.chart-expand-header {
    padding: 10px 14px;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.85rem;
    font-weight: bold;
    color: var(--accent);
}

.chart-expand-title {
    font-size: 0.82rem;
    color: var(--accent);
}

.chart-expand-body {
    flex: 1;
    padding: 10px;
    display: flex;
    flex-direction: column;
}

.chart-expanded {
    flex: 1;
    min-height: 0;
}

/* ── Modals ── */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
}

.modal-box {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    width: 420px;
    max-width: 95vw;
    padding: 18px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    box-shadow: 0 8px 32px var(--shadow);
    max-height: 90vh;
    overflow-y: auto;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: bold;
    color: var(--accent);
    margin-bottom: 8px;
    font-size: 0.88rem;
}

.modal-close {
    color: var(--text-dim);
    background: none;
    border: none;
    cursor: pointer;
    width: auto;
    margin: 0;
    padding: 3px;
    display: flex;
    align-items: center;
    border-radius: 4px;
}

.modal-close:hover {
    color: #f85149;
}

/* ── Auth feedback ── */
.auth-error {
    background: #f851491a;
    border: 1px solid #f8514944;
    color: #f85149;
    border-radius: 4px;
    padding: 8px 10px;
    font-size: 0.73rem;
    margin-bottom: 10px;
}

.auth-ok {
    background: #23863615;
    border: 1px solid #23863644;
    color: var(--status-chiuso);
    border-radius: 4px;
    padding: 8px 10px;
    font-size: 0.73rem;
    margin-bottom: 10px;
}

/* ── Auth pages ── */
.auth-body {
    overflow: auto;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 20px;
}

.auth-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 32px 28px;
    width: 100%;
    max-width: 360px;
    box-shadow: 0 8px 32px var(--shadow);
}

.projects-card {
    max-width: 420px;
}

.auth-logo {
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--accent);
    text-align: center;
    margin-bottom: 6px;
}

.auth-title {
    font-size: 0.9rem;
    text-align: center;
    color: var(--text-dim);
    margin-bottom: 18px;
}

.auth-hint {
    font-size: 0.75rem;
    color: var(--text-dim);
    text-align: center;
    margin: -10px 0 16px;
}

.auth-hint-inline {
    font-size: 0.68rem;
    color: var(--text-dim);
    font-weight: normal;
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.auth-form input {
    margin-top: 4px;
}

.auth-form button {
    margin-top: 16px;
}

.auth-switch {
    text-align: center;
    font-size: 0.72rem;
    color: var(--text-dim);
    margin-top: 14px;
}

.auth-switch a {
    color: var(--accent);
    text-decoration: none;
}

.auth-switch a:hover {
    text-decoration: underline;
}

.projects-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 16px;
}

.project-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--bg-col);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 10px 12px;
    cursor: pointer;
    text-align: left;
    margin: 0;
    width: 100%;
    transition: border-color .15s, background .15s;
    font-family: inherit;
}

.project-btn:hover {
    border-color: var(--accent);
    background: var(--accent-dim);
}

.project-root {
    font-weight: bold;
    color: var(--accent);
    font-size: 0.8rem;
    min-width: 40px;
}

.project-name {
    flex: 1;
    font-size: 0.76rem;
    color: var(--text);
}

.project-arrow {
    color: var(--text-dim);
    font-size: 0.8rem;
}

.projects-divider {
    text-align: center;
    font-size: 0.7rem;
    color: var(--text-dim);
    margin: 14px 0 10px;
    position: relative;
}

.projects-divider::before,
.projects-divider::after {
    content: '';
    position: absolute;
    top: 50%;
    width: 28%;
    height: 1px;
    background: var(--border);
}

.projects-divider::before {
    left: 0;
}

.projects-divider::after {
    right: 0;
}

/* ── Responsive mobile ── */
@media (max-width: 1024px) {

    body,
    html {
        overflow: auto;
    }

    .global-bar {
        position: sticky;
    }

    .dashboard {
        flex-direction: column;
        height: auto;
        min-height: calc(100vh - var(--bar-h));
        margin-top: 0;
        padding: 12px;
    }

    .column-left {
        flex: none;
        width: 100%;
        max-width: 480px;
        margin: 0 auto;
        border-right: none;
        padding-right: 0;
        overflow-y: visible;
    }

    .boards-area {
        display: none !important;
    }

    .stats-sidebar {
        width: 100%;
        top: var(--bar-h);
    }

    .chart-expand-panel {
        width: 100%;
        right: auto;
        left: 0;
        top: 0;
    }
}

/* ── Settings page ── */
.settings-body {
    overflow: auto;
    background: var(--bg-main);
    color: var(--text);
    min-height: 100vh;
    margin: 0;
    height: auto;
    font-family: 'SF Mono', 'Fira Code', monospace;
}
.settings-topbar {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 0 16px;
    height: var(--bar-h);
    background: var(--bg-bar);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 10;
}
.settings-back {
    color: var(--text-dim);
    display: inline-flex;
    align-items: center;
    text-decoration: none;
    padding: 6px;
    border-radius: 4px;
}
.settings-back:hover { color: var(--accent); background: var(--accent-dim); }
.settings-proj {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.82rem;
}
.settings-proj-root {
    font-weight: bold;
    color: var(--accent);
    letter-spacing: 0.5px;
}
.settings-proj-name { color: var(--text-dim); }
.settings-topbar-right { margin-left: auto; }
.settings-user {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--text-dim);
    font-size: 0.78rem;
}

.settings-shell {
    display: flex;
    min-height: calc(100vh - var(--bar-h));
}
.settings-side {
    width: 220px;
    flex-shrink: 0;
    background: var(--bg-col);
    border-right: 1px solid var(--border);
    padding: 18px 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.settings-side-title {
    font-size: 0.7rem;
    font-weight: bold;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.6px;
    padding: 6px 10px 10px;
}
.settings-side-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: 4px;
    text-decoration: none;
    color: var(--text);
    font-size: 0.78rem;
    transition: background 0.12s, color 0.12s;
}
.settings-side-link:hover {
    background: var(--accent-dim);
    color: var(--accent);
}
.settings-side-link.is-active {
    background: var(--accent);
    color: #fff;
}

.settings-main {
    flex: 1;
    padding: 28px 32px 60px;
    max-width: 880px;
    width: 100%;
}
.settings-section {
    display: flex;
    flex-direction: column;
    gap: 16px;
}
.settings-section-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 14px;
    border-bottom: 1px solid var(--border);
    padding-bottom: 14px;
}
.settings-section-header h2 {
    margin: 0 0 4px;
    font-size: 1.05rem;
    color: var(--accent);
    letter-spacing: 0.4px;
}
.settings-section-sub {
    margin: 0;
    color: var(--text-dim);
    font-size: 0.74rem;
    line-height: 1.45;
}
.settings-section-sub code {
    background: var(--bg-card);
    padding: 1px 5px;
    border-radius: 3px;
    border: 1px solid var(--border);
    font-size: 0.72rem;
}
.settings-section-actions { flex-shrink: 0; }
.settings-section-footer { margin-top: 4px; }

.settings-warn {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--accent-dim);
    border: 1px solid var(--accent);
    color: var(--accent);
    padding: 8px 12px;
    font-size: 0.74rem;
    border-radius: 4px;
}

.settings-error {
    background: #f851491a;
    border: 1px solid #f8514944;
    color: #f85149;
    padding: 8px 12px;
    border-radius: 4px;
    font-size: 0.74rem;
}
.settings-ok {
    background: #23863615;
    border: 1px solid #23863644;
    color: var(--status-chiuso);
    padding: 8px 12px;
    border-radius: 4px;
    font-size: 0.74rem;
}

.settings-list {
    display: flex;
    flex-direction: column;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--bg-card);
    overflow: hidden;
}
.settings-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    border-bottom: 1px solid var(--border);
    font-size: 0.76rem;
}
.settings-row:last-child { border-bottom: none; }
.settings-row.is-dragging { opacity: 0.4; }
.settings-row .ap-btn {
    width: 26px; height: 26px;
    padding: 0;
    margin: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.settings-row-handle {
    color: var(--text-dim);
    cursor: grab;
    display: inline-flex;
}
.settings-row-handle:active { cursor: grabbing; }
.settings-empty {
    padding: 16px;
    color: var(--text-dim);
    font-size: 0.78rem;
    text-align: center;
}

.build-row { display: grid;
    grid-template-columns: 92px 110px 1fr 92px auto auto auto auto;
    gap: 10px;
    align-items: center;
}
.build-row.is-current { background: var(--accent-dim); }
.build-num {
    font-family: 'SF Mono','Fira Code',monospace;
    font-weight: bold;
    color: var(--accent);
}
.build-version { color: var(--text); font-weight: bold; }
.build-note { color: var(--text-dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.build-date { color: var(--text-dim); font-size: 0.72rem; text-align: right; }
.build-badge-current {
    background: var(--accent);
    color: #fff;
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 0.66rem;
    text-transform: uppercase;
    letter-spacing: 0.4px;
}
.ap-btn[disabled] { opacity: 0.4; cursor: not-allowed; }

.settings-add {
    border: 1px dashed var(--border);
    border-radius: 6px;
    padding: 12px;
    background: var(--bg-card);
}
.settings-add-title {
    font-size: 0.7rem;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}
.settings-add input {
    background: var(--input-bg);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 6px 8px;
    border-radius: 4px;
    font-size: 0.78rem;
    font-family: inherit;
}

.settings-textarea {
    width: 100%;
    min-height: 360px;
    background: var(--input-bg);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 12px;
    border-radius: 6px;
    font-family: 'SF Mono','Fira Code',monospace;
    font-size: 0.8rem;
    line-height: 1.5;
    resize: vertical;
}

@media (max-width: 720px) {
    .settings-shell { flex-direction: column; }
    .settings-side {
        width: 100%;
        flex-direction: row;
        overflow-x: auto;
        padding: 10px;
    }
    .settings-side-title { display: none; }
    .settings-main { padding: 18px; }
    .build-row {
        grid-template-columns: 1fr 1fr;
    }
}
