/* =============================================================================
   Assist — bacheca issue. Stesso foglio di stile del Pannello Deploy
   (/opt/monitor/public/style.css): stessi colori, chiaro/scuro automatico,
   stesse card, pillole e bottoni. Nessuna risorsa esterna.
   ============================================================================= */

:root {
    color-scheme: light dark;

    --bg: #f4f5f7;
    --bg-card: #ffffff;
    --bg-sunken: #eceef1;
    --border: #d8dbe0;
    --text: #1b1f24;
    --text-muted: #6b7280;

    --accent: #2563eb;
    --accent-hover: #1d4ed8;
    --accent-bg: #dbeafe;
    --ok: #15803d;
    --ok-bg: #dcfce7;
    --warn: #a16207;
    --warn-bg: #fef3c7;
    --error: #b91c1c;
    --error-bg: #fee2e2;

    --log-bg: #10151c;
    --log-text: #d6deeb;

    --radius: 10px;
    --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #14171c;
        --bg-card: #1c2027;
        --bg-sunken: #23282f;
        --border: #333a44;
        --text: #e6e9ee;
        --text-muted: #9aa3af;

        --accent: #3b82f6;
        --accent-hover: #60a5fa;
        --accent-bg: #1e2f4d;
        --ok: #4ade80;
        --ok-bg: #14321f;
        --warn: #fbbf24;
        --warn-bg: #3a2e0c;
        --error: #f87171;
        --error-bg: #3d1616;
    }
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

a { color: var(--accent); }
.muted { color: var(--text-muted); }
.small { font-size: 13px; }
.error { color: var(--error); }
code, .mono { font-family: var(--mono); font-size: 12.5px; }

/* ─── Barra superiore ─────────────────────────────────────────────────────── */

.topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    flex-wrap: wrap;
    gap: 10px 18px;
    align-items: center;
    padding: 12px 20px;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
}

.topbar-title { display: flex; align-items: center; gap: 10px; font-weight: 700; }
.topbar-title .pill { margin-left: 2px; }

.topbar nav { display: flex; flex-wrap: wrap; gap: 4px; }
.topbar nav a {
    padding: 5px 10px;
    border-radius: 8px;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 13px;
    font-weight: 600;
}
.topbar nav a:hover { background: var(--bg-sunken); color: var(--text); }
.topbar nav a.on { background: var(--bg-sunken); color: var(--text); }

.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 12px; font-size: 13px; color: var(--text-muted); }
.topbar-actions form { display: inline; }

main {
    max-width: 1180px;
    margin: 0 auto;
    padding: 20px 20px 60px;
}

h1 { margin: 0; font-size: 20px; }
h1 small { font-weight: 400; }
.page-head { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between; margin: 6px 0 16px; }
.lead { margin: -8px 0 16px; font-size: 13.5px; color: var(--text-muted); }

.section-title {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 22px 0 10px;
    font-size: 13px;
    font-weight: 700;
    letter-spacing: .04em;
    text-transform: uppercase;
    color: var(--text-muted);
}
.section-title:first-child { margin-top: 0; }
.section-title small { font-weight: 400; text-transform: none; letter-spacing: 0; }

/* ─── Bottoni ─────────────────────────────────────────────────────────────── */

button { font: inherit; }

.btn-ghost, .btn-primary, .btn-danger {
    display: inline-block;
    padding: 7px 13px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    font-size: 13px;
    border: 1px solid var(--border);
    background: var(--bg-card);
    color: var(--text);
    text-decoration: none;
    line-height: 1.4;
}
.btn-ghost:hover { background: var(--bg-sunken); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); }
.btn-danger { background: var(--error-bg); border-color: var(--error); color: var(--error); }
button:disabled { opacity: .55; cursor: not-allowed; }

button:focus-visible, select:focus-visible, input:focus-visible, textarea:focus-visible, a:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 1px;
}

/* ─── Campi ───────────────────────────────────────────────────────────────── */

select, input[type=text], input[type=password], input[type=url], textarea {
    font: inherit;
    font-size: 14px;
    color: var(--text);
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 8px 10px;
}
textarea { width: 100%; min-height: 84px; resize: vertical; }
select:focus-visible, input:focus-visible, textarea:focus-visible { border-color: var(--accent); }

label.field { display: flex; flex-direction: column; gap: 4px; font-size: 12.5px; font-weight: 600; color: var(--text-muted); }
label.field input, label.field select { width: 100%; font-weight: 400; }
.fields { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.inline-label { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text-muted); }

/* ─── Pillole ─────────────────────────────────────────────────────────────── */

.pill {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 2px 9px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
}
.pill-ok    { background: var(--ok-bg);    color: var(--ok); }
.pill-warn  { background: var(--warn-bg);  color: var(--warn); }
.pill-error { background: var(--error-bg); color: var(--error); }
.pill-info  { background: var(--accent-bg); color: var(--accent); }
.pill-muted { background: var(--bg-sunken); color: var(--text-muted); }
.pill-strike { text-decoration: line-through; }
.dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; flex: none; }

/* Stati delle issue: rosso = da guardare, ambra = in mano a qualcuno, blu =
   ci si lavora / in test, verde = in prod, grigio = chiusa. */
.st-new             { background: var(--error-bg);  color: var(--error); }
.st-triaged         { background: var(--warn-bg);   color: var(--warn); }
.st-in_progress,
.st-fixed_on_branch,
.st-released_test   { background: var(--accent-bg); color: var(--accent); }
.st-deployed_prod   { background: var(--ok-bg);     color: var(--ok); }
.st-closed, .st-rejected, .st-duplicate { background: var(--bg-sunken); color: var(--text-muted); }
.st-rejected { text-decoration: line-through; }

.sev-low    { background: var(--bg-sunken); color: var(--text-muted); }
.sev-medium { background: var(--warn-bg);   color: var(--warn); }
.sev-high   { background: var(--error-bg);  color: var(--error); }

.app { font-weight: 600; }

/* ─── Card ────────────────────────────────────────────────────────────────── */

.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px 18px 18px;
    margin-bottom: 16px;
}
.card p:last-child { margin-bottom: 0; }
.card.flash-ok  { border-color: var(--ok);    background: var(--ok-bg);    color: var(--ok);    padding: 10px 14px; }
.card.flash-err { border-color: var(--error); background: var(--error-bg); color: var(--error); padding: 10px 14px; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 820px) { .two { grid-template-columns: 1fr; } }

.counts { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.counts a { text-decoration: none; }
.counts a .pill b { margin-left: 3px; }

.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 14px; }

/* ─── Tabelle ─────────────────────────────────────────────────────────────── */

.table-wrap { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); overflow: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 9px 12px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: top; }
th { font-size: 12px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--text-muted); background: var(--bg-sunken); }
tr:last-child td { border-bottom: 0; }
tr:hover td { background: color-mix(in srgb, var(--bg-sunken) 50%, transparent); }
td.t a { font-weight: 600; text-decoration: none; color: var(--text); }
td.t a:hover { color: var(--accent); }
td.t small { display: block; color: var(--text-muted); font-family: var(--mono); font-size: 12px; }
td small { color: var(--text-muted); }

/* ─── Dettaglio ───────────────────────────────────────────────────────────── */

.meta { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 8px 18px; margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--border); font-size: 14px; }
.meta div small { display: block; color: var(--text-muted); font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em; }
.summary { white-space: pre-wrap; margin: 10px 0 0; }
.links { display: flex; gap: 12px; margin: 10px 0 0; font-size: 13px; font-weight: 600; }
.links a { text-decoration: none; }
.links a:hover { text-decoration: underline; }

pre.log {
    margin: 0;
    padding: 12px 14px;
    background: var(--log-bg);
    color: var(--log-text);
    border-radius: 8px;
    font: 12.5px/1.55 var(--mono);
    white-space: pre-wrap;
    word-break: break-word;
    overflow: auto;
    max-height: 440px;
}
pre.log .e { color: #f87171; }
pre.log .w { color: #fbbf24; }
pre.log .f { color: #60a5fa; }
pre.log .r { color: #4ade80; }
pre.log .t { color: #6b7280; }

.chat { display: flex; flex-direction: column; gap: 6px; }
.chat div { max-width: 85%; padding: 7px 11px; border-radius: 10px; white-space: pre-wrap; font-size: 14px; }
.chat .u { align-self: flex-end; background: var(--accent); color: #fff; border-bottom-right-radius: 3px; }
.chat .a { align-self: flex-start; background: var(--bg-sunken); border-bottom-left-radius: 3px; }

.hist { list-style: none; padding: 0; margin: 0; }
.hist li { padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 14px; }
.hist li:last-child { border-bottom: 0; }
.hist li small { color: var(--text-muted); margin-right: 8px; font-family: var(--mono); font-size: 12px; }
.hist li .n { white-space: pre-wrap; display: block; margin-top: 3px; }
.hint { margin: 6px 0 0; font-size: 12.5px; color: var(--text-muted); }

/* ─── Login ───────────────────────────────────────────────────────────────── */

.login-wrap { min-height: calc(100vh - 57px); display: grid; place-items: center; padding: 24px; }
.login-card { width: 100%; max-width: 360px; background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 28px; box-shadow: 0 4px 24px rgb(0 0 0 / 8%); }
.login-card h1 { margin: 0 0 4px; font-size: 20px; }
.login-card p { margin: 0 0 12px; font-size: 14px; }
.login-card label { display: block; margin: 14px 0 6px; font-size: 13px; font-weight: 600; }
.login-card input { width: 100%; padding: 10px 12px; }
.login-card button { width: 100%; margin-top: 22px; padding: 11px; }

/* ─── Lista / Kanban ──────────────────────────────────────────────────────── */

.seg { display: inline-flex; margin-left: auto; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.seg a { padding: 6px 12px; font-size: 13px; font-weight: 600; color: var(--text-muted); text-decoration: none; background: var(--bg-card); }
.seg a.on { background: var(--accent); color: #fff; }
.seg a:not(.on):hover { background: var(--bg-sunken); color: var(--text); }

.kanban { display: flex; gap: 12px; align-items: flex-start; overflow-x: auto; padding-bottom: 8px; }
.kcol { flex: 0 0 250px; background: var(--bg-sunken); border: 1px solid var(--border); border-radius: var(--radius); min-height: 160px; }
.kcol.over { border-color: var(--accent); background: var(--accent-bg); }
.kcol header { display: flex; align-items: center; justify-content: space-between; padding: 9px 11px; border-bottom: 1px solid var(--border); }
.kcol header b { font-size: 12px; color: var(--text-muted); }
.kbody { padding: 8px; display: flex; flex-direction: column; gap: 8px; min-height: 60px; }
.kempty { margin: 8px 0; text-align: center; color: var(--text-muted); font-size: 13px; }
.kcard { background: var(--bg-card); border: 1px solid var(--border); border-radius: 8px; padding: 9px 10px; cursor: grab; font-size: 13.5px; }
.kcard.dragging { opacity: .5; }
.kcard > a { display: block; font-weight: 600; color: var(--text); text-decoration: none; margin-bottom: 6px; }
.kcard > a:hover { color: var(--accent); }
.kmeta { display: flex; flex-wrap: wrap; gap: 5px; align-items: center; font-size: 12px; }
.kfoot { display: flex; justify-content: space-between; gap: 6px; margin-top: 7px; font-size: 11.5px; color: var(--text-muted); }
.kfoot .mono { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.karchive { opacity: .8; }
