/* Portale progetti - Stile coerente con domenicocaiazza.com */

:root {
    --app-sidebar-width: 17rem;
    --app-sidebar-pad-x: 0.875rem;
    --app-sidebar-brand-inline: 0.35rem;
    --app-shell-header-height: 4.25rem;
    --app-shell-header-pad-x: max(
        calc(var(--app-sidebar-pad-x) + var(--app-sidebar-brand-inline)),
        env(safe-area-inset-left, 0px)
    );
    --font-sans: 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --color-bg: #FFFFFF;
    --color-bg-alt: #F8F9FA;
    --color-text: #202124;
    --color-text-muted: #5F6368;
    --color-accent: #264b6e;
    --color-accent-soft: rgba(38, 75, 110, 0.12);
    --color-border: #E8EAED;
    --cta-gradient: linear-gradient(45deg, #495057, #264b6e, #5fa15a);
    --cta-gradient-hover: linear-gradient(45deg, #3d4550, #1e3a52, #4d8a47);
    --green: #2a9d6e;
    --amber: #d4800a;
    --red: #c0392b;
    --slate: #4a5568;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
html { scroll-behavior: smooth; }
@supports (padding: env(safe-area-inset-top)) {
    .site-header {
        height: calc(var(--app-shell-header-height) + env(safe-area-inset-top, 0px));
        padding-top: env(safe-area-inset-top, 0px);
        padding-left: env(safe-area-inset-left);
        padding-right: env(safe-area-inset-right);
    }
    .main-content {
        padding-left: max(1.5rem, env(safe-area-inset-left));
        padding-right: max(1.5rem, env(safe-area-inset-right));
    }
}
body {
    font-family: var(--font-sans);
    font-size: 1rem;
    line-height: 1.6;
    color: var(--color-text);
    background: var(--color-bg-alt);
    -webkit-font-smoothing: antialiased;
}

/* Header - fixed top nav like domenicocaiazza.com */
.site-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    height: var(--app-shell-header-height);
    padding: 0;
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border-bottom: 1px solid transparent;
    transition: border-color 0.2s, box-shadow 0.2s;
}
.site-header.scrolled {
    border-color: var(--color-border);
    box-shadow: 0 1px 0 rgba(0,0,0,0.04);
}
/* Con sidebar: barra solo sulla colonna destra (come i dashboard moderni), non sopra la sidebar */
.site-header.site-header--with-sidebar {
    border-bottom-color: var(--color-border);
    box-shadow: 0 1px 0 rgba(0, 0, 0, 0.04);
}
@media (max-width: 767px) {
    .site-header.scrolled,
    .site-header.site-header--with-sidebar {
        box-shadow: none;
    }
}
@media (min-width: 768px) {
    .site-header.site-header--with-sidebar {
        left: var(--app-sidebar-width);
        right: 0;
        width: auto;
    }
}
.site-header .container {
    max-width: 1140px;
    height: 100%;
    margin: 0 auto;
    padding: 0 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}
.site-header.site-header--with-sidebar .container {
    padding-left: var(--app-shell-header-pad-x);
    padding-right: 1.25rem;
}
@media (min-width: 768px) {
    .site-header.site-header--with-sidebar .container {
        max-width: none;
        width: 100%;
        margin: 0;
        padding-left: 2rem;
        padding-right: 2rem;
    }
}
.site-header__start {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    min-width: 0;
}
.sidebar-menu-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.75rem;
    height: 2.75rem;
    min-width: 2.75rem;
    min-height: 2.75rem;
    padding: 0;
    margin: 0;
    border: none;
    border-radius: 0.75rem;
    background: transparent;
    color: var(--color-text);
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    transition: background 0.15s, color 0.15s;
}
@media (hover: hover) {
    .sidebar-menu-toggle:hover {
        background: var(--color-bg-alt);
        color: var(--color-accent);
    }
}
.sidebar-menu-toggle:active {
    background: var(--color-bg-alt);
    color: var(--color-accent);
}
.sidebar-menu-toggle:focus-visible {
    outline: 2px solid var(--color-accent);
    outline-offset: 2px;
}
@media (min-width: 768px) {
    .sidebar-menu-toggle {
        display: none;
    }
}
.navbar-brand {
    font-weight: 600;
    font-size: 1.1rem;
    color: var(--color-text);
    text-decoration: none;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}
@media (max-width: 767px) {
    .logout-btn {
        -webkit-tap-highlight-color: transparent;
        touch-action: manipulation;
    }
}
.navbar-nav {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    list-style: none;
    margin: 0;
    padding: 0;
}
.nav-link {
    display: block;
    padding: 0.5rem 1rem;
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--color-text-muted);
    text-decoration: none;
    border-radius: 2rem;
    transition: color 0.2s, background 0.2s;
}
.nav-link:hover {
    color: var(--color-text);
    background: var(--color-bg-alt);
}
.nav-link.active {
    color: var(--color-accent);
    font-weight: 600;
}
.user-area {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.user-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.625rem;
    padding: 0.3rem 0.85rem 0.3rem 0.95rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--color-text);
    background: var(--color-bg-alt);
    border: 1px solid var(--color-border);
    border-radius: 999px;
    transition: border-color 0.2s, background 0.2s;
}
.user-badge:hover {
    border-color: rgba(38, 75, 110, 0.25);
    background: #fff;
}
.user-area::before {
    content: "";
    align-self: center;
    width: 1px;
    height: 1.5rem;
    background: var(--color-border);
    margin: 0 0.25rem;
}
.logout-form {
    display: inline-flex;
    margin: 0;
}
.logout-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.5rem;
    height: 2.5rem;
    padding: 0;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 999px;
    color: var(--color-text-muted);
    cursor: pointer;
    transition: color 0.2s, background 0.2s, border-color 0.2s;
    line-height: 0;
}
.logout-btn:hover {
    color: var(--red);
    background: rgba(192, 57, 43, 0.08);
    border-color: rgba(192, 57, 43, 0.18);
}
.logout-btn:focus-visible {
    outline: 2px solid var(--color-accent);
    outline-offset: 2px;
}
.avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: var(--cta-gradient);
    background-size: 180% 180%;
    background-position: 30% 30%;
    border: 1px solid rgba(255, 255, 255, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    color: #fff;
    box-shadow: 0 2px 6px rgba(15, 36, 52, 0.25), 0 1px 0 rgba(255, 255, 255, 0.18) inset;
}

/* Main content */
.main-content {
    padding: calc(var(--app-shell-header-height) + 1.75rem) 1.5rem 4rem;
    min-height: 100vh;
}
.main-content--with-sidebar {
    padding-top: calc(var(--app-shell-header-height) + 1.5rem);
    padding-left: var(--app-shell-header-pad-x);
    padding-right: 1.25rem;
}
@media (min-width: 768px) {
    .main-content--with-sidebar {
        margin-left: var(--app-sidebar-width);
        padding-left: 2rem;
        padding-right: 2rem;
    }
}
.main-inner {
    max-width: 720px;
    margin: 0 auto;
}
.main-inner--wide { max-width: 1140px; }

/* App sidebar — colonna sinistra a tutta altezza (allineata alla shell, non sotto la navbar) */
.app-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 50;
    width: var(--app-sidebar-width);
    height: 100vh;
    height: 100dvh;
    display: flex;
    flex-direction: column;
    padding: 0 var(--app-sidebar-pad-x) max(1.5rem, env(safe-area-inset-bottom, 0px)) max(var(--app-sidebar-pad-x), env(safe-area-inset-left, 0px));
    background: linear-gradient(165deg, #1a3349 0%, #132a3d 48%, #0f2434 100%);
    border-right: 1px solid rgba(255, 255, 255, 0.06);
    box-shadow: 4px 0 24px rgba(15, 36, 52, 0.12);
    transform: translateX(-100%);
    transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}
@media (min-width: 768px) {
    .app-sidebar {
        transform: translateX(0);
    }
}
@media (max-width: 767px) {
    .app-sidebar.app-sidebar--open {
        z-index: 1050;
    }
}
.app-sidebar.app-sidebar--open {
    transform: translateX(0);
}
.app-sidebar__brand {
    flex-shrink: 0;
    height: var(--app-shell-header-height);
    padding: 0 var(--app-sidebar-brand-inline);
    margin: 0 calc(var(--app-sidebar-brand-inline) * -1) 0.75rem;
    padding-left: calc(var(--app-sidebar-brand-inline) * 2);
    padding-right: calc(var(--app-sidebar-brand-inline) * 2);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    display: flex;
    align-items: center;
}
@supports (padding-top: env(safe-area-inset-top)) {
    .app-sidebar__brand {
        height: calc(var(--app-shell-header-height) + env(safe-area-inset-top, 0px));
        padding-top: env(safe-area-inset-top, 0px);
    }
}
.app-sidebar__brand-link {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 0.75rem;
    width: 100%;
    font-size: 1rem;
    font-weight: 600;
    letter-spacing: -0.02em;
    color: #fff;
    text-decoration: none;
    line-height: 1.25;
    transition: color 0.2s, opacity 0.2s;
}
.app-sidebar__brand-logo {
    flex-shrink: 0;
    width: 2.25rem;
    height: 2.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 0.6rem;
    color: #fff;
    background: var(--cta-gradient);
    background-size: 180% 180%;
    background-position: 30% 30%;
    border: 1px solid rgba(255, 255, 255, 0.18);
    box-shadow: 0 4px 12px rgba(15, 36, 52, 0.35), 0 1px 0 rgba(255, 255, 255, 0.18) inset;
    transition: transform 0.2s, box-shadow 0.2s, background-position 0.4s;
}
.app-sidebar__brand-logo svg {
    display: block;
    flex-shrink: 0;
}
.app-sidebar__brand-text {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    min-width: 0;
}
.app-sidebar__brand-title {
    display: block;
    font-size: 1.0625rem;
    font-weight: 600;
    letter-spacing: -0.02em;
}
.app-sidebar__brand-subtitle {
    display: block;
    font-size: 0.8125rem;
    font-weight: 500;
    letter-spacing: 0.06em;
    color: rgba(255, 255, 255, 0.62);
    text-transform: uppercase;
}
.app-sidebar__brand-link:hover {
    color: rgba(255, 255, 255, 0.92);
}
.app-sidebar__brand-link:hover .app-sidebar__brand-logo {
    transform: translateY(-1px);
    background-position: 70% 70%;
    box-shadow: 0 6px 16px rgba(15, 36, 52, 0.45), 0 1px 0 rgba(255, 255, 255, 0.22) inset;
}
.app-sidebar__brand-link:hover .app-sidebar__brand-subtitle {
    color: rgba(255, 255, 255, 0.78);
}
.app-sidebar__brand-link:focus-visible {
    outline: 2px solid rgba(255, 255, 255, 0.45);
    outline-offset: 3px;
    border-radius: 0.35rem;
}
.app-sidebar__nav {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    padding: 0.5rem var(--app-sidebar-brand-inline) 0;
}
.app-sidebar__nav-title {
    display: block;
    padding: 0 0.85rem;
    margin-bottom: 0.4rem;
    font-size: 0.6875rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.42);
}
.app-sidebar__nav-title + .app-sidebar__section {
    margin-top: 0.35rem;
}
.app-sidebar__divider {
    height: 1px;
    margin: 0.85rem 0.85rem 0.6rem;
    background: rgba(255, 255, 255, 0.12);
}
.app-sidebar__section {
    margin-top: 0.85rem;
}
.app-sidebar__section:first-child {
    margin-top: 0.35rem;
}
.app-sidebar__section-title {
    display: block;
    padding: 0 0.85rem;
    margin: 0.35rem 0 0.35rem;
    font-size: 0.6875rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.42);
}
.app-sidebar__link {
    position: relative;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.55rem 1rem;
    border-radius: 999px;
    font-size: 0.9375rem;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.7);
    text-decoration: none;
    transition: background 0.2s, color 0.2s, box-shadow 0.2s;
}
.app-sidebar__link:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.06);
}
.app-sidebar__link--active {
    color: #fff;
    font-weight: 600;
    background: rgba(255, 255, 255, 0.1);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.1);
}
.app-sidebar__link--active .app-sidebar__link-icon {
    color: #fff;
}
.app-sidebar__link-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    color: rgba(255, 255, 255, 0.55);
    transition: color 0.2s;
}
.app-sidebar__link:hover .app-sidebar__link-icon {
    color: rgba(255, 255, 255, 0.9);
}
.app-sidebar__link-text {
    flex: 1;
    min-width: 0;
}
.app-sidebar__link--active::after {
    content: "";
    flex-shrink: 0;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--cta-gradient);
    box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.06);
}

@media (max-width: 767px) {
    body.sidebar-open {
        overflow: hidden;
        touch-action: none;
    }
}

/* Page header */
.page-header { margin-bottom: 2rem; }
.page-title {
    font-size: clamp(1.75rem, 4vw, 2.25rem);
    font-weight: 600;
    color: var(--color-text);
    margin: 0 0 0.25rem;
}
.page-subtitle {
    font-size: 1rem;
    color: var(--color-text-muted);
    margin: 0;
}

/* Buttons - domenicocaiazza style */
.btn-cta {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
    font-weight: 600;
    color: #fff;
    text-decoration: none;
    border: none;
    border-radius: 2rem;
    cursor: pointer;
    font-family: inherit;
    background: var(--cta-gradient);
    background-size: 200% 200%;
    transition: transform 0.2s, filter 0.2s;
}
.btn-cta:hover {
    color: #fff;
    transform: scale(1.02);
    filter: brightness(1.08);
}
.btn-ghost {
    display: inline-flex;
    align-items: center;
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
    font-weight: 500;
    color: var(--color-text);
    text-decoration: none;
    border: 1px solid var(--color-border);
    border-radius: 2rem;
    background: #fff;
    cursor: pointer;
    font-family: inherit;
    transition: border-color 0.2s, background 0.2s;
}
.btn-ghost:hover {
    border-color: var(--color-accent);
    background: var(--color-accent-soft);
}

/* Cards */
.card {
    background: var(--color-bg);
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: 16px;
    padding: 1.5rem 1.75rem;
    margin-bottom: 1.5rem;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.04);
}

/* Form elements */
.section-title {
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--color-text-muted);
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--color-border);
}
.field-label {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--color-text-muted);
    margin-bottom: 0.5rem;
}
.text-input, .select-input, .textarea-input {
    width: 100%;
    padding: 0.75rem 1rem;
    font-size: 1rem;
    font-family: inherit;
    color: var(--color-text);
    border: 1px solid var(--color-border);
    border-radius: 2rem;
    background: #fff;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}
.text-input::placeholder, .textarea-input::placeholder { color: var(--color-text-muted); }
.text-input:focus, .select-input:focus, .textarea-input:focus {
    border-color: var(--color-accent);
    box-shadow: 0 0 0 3px var(--color-accent-soft);
}
.select-input {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%235F6368'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 16px;
    padding-right: 2.5rem;
}
.textarea-input { min-height: 100px; resize: vertical; }
input[type="range"] {
    -webkit-appearance: none;
    width: 100%;
    height: 6px;
    background: var(--color-border);
    border-radius: 3px;
    cursor: pointer;
    accent-color: var(--color-accent);
}
input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--color-accent);
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(38, 75, 110, 0.3);
}

/* Checkbox, Radio */
.checkbox-row, .radio-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 1rem;
    font-weight: 500;
    color: var(--color-text);
    cursor: pointer;
}
.checkbox-custom, .radio-custom {
    width: 20px;
    height: 20px;
    border: 2px solid var(--color-border);
    border-radius: 4px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}
.radio-custom { border-radius: 50%; }
input[type="checkbox"]:checked + .checkbox-custom {
    background: var(--color-accent);
    border-color: var(--color-accent);
}
input[type="checkbox"]:checked + .checkbox-custom::after {
    content: '';
    display: block;
    width: 6px;
    height: 10px;
    border: solid #fff;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
    margin-bottom: 2px;
}
input[type="radio"]:checked + .radio-custom {
    border-color: var(--color-accent);
    background: #fff;
    box-shadow: inset 0 0 0 5px var(--color-accent);
}
input[type="checkbox"], input[type="radio"] { position: absolute; opacity: 0; pointer-events: none; }

/* Switch */
.switch-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    font-size: 1rem;
    font-weight: 500;
    color: var(--color-text);
    cursor: pointer;
}
.switch-track {
    width: 48px;
    height: 26px;
    border-radius: 13px;
    background: var(--color-border);
    position: relative;
    flex-shrink: 0;
    transition: background 0.2s;
}
.switch-thumb {
    position: absolute;
    top: 2px;
    left: 2px;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
    transition: transform 0.2s;
}
input[type="checkbox"].switch-input { position: absolute; opacity: 0; pointer-events: none; }
input[type="checkbox"].switch-input:checked + .switch-track { background: var(--color-accent); }
input[type="checkbox"].switch-input:checked + .switch-track .switch-thumb { transform: translateX(22px); }

/* File input */
.file-input-wrap { position: relative; }
.file-input-wrap input[type="file"] { position: absolute; opacity: 0; width: 100%; height: 100%; cursor: pointer; }
.file-input-display {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem 1.25rem;
    border: 1px dashed var(--color-border);
    border-radius: 8px;
    background: var(--color-bg-alt);
    font-size: 0.95rem;
    color: var(--color-text-muted);
}
.file-input-display svg { width: 20px; height: 20px; color: var(--color-text-muted); }
.file-input-wrap:hover .file-input-display { border-color: var(--color-accent); background: var(--color-accent-soft); }

/* Tabs */
.tabs-bar {
    display: flex;
    gap: 0.25rem;
    border-bottom: 1px solid var(--color-border);
}
.tabs-bar--customer-context {
    margin-top: -1.25rem;
    margin-bottom: 1rem;
}
.tab-btn {
    padding: 0.75rem 1.25rem;
    font-size: 0.95rem;
    font-weight: 600;
    border: none;
    background: none;
    cursor: pointer;
    color: var(--color-text-muted);
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    font-family: inherit;
    transition: color 0.2s, border-color 0.2s;
}
.tab-btn:hover { color: var(--color-text); }
.tab-btn.active { color: var(--color-accent); border-bottom-color: var(--color-accent); }

/* Badges */
.badge {
    display: inline-block;
    padding: 0.25rem 0.6rem;
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    border-radius: 1rem;
}
.badge-green { background: rgba(42, 157, 110, 0.15); color: var(--green); }
.badge-amber { background: rgba(212, 128, 10, 0.15); color: var(--amber); }
.badge-red { background: rgba(192, 57, 43, 0.15); color: var(--red); }
.badge-slate { background: var(--color-accent-soft); color: var(--color-accent); }

/* Stat grid - responsive */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
}

/* Tables */
.table-wrap {
    background: #fff;
    border: 1px solid var(--color-border);
    border-radius: 12px;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.04);
}
table {
    width: 100%;
    min-width: 500px;
    border-collapse: collapse;
}
thead { background: var(--color-bg-alt); }
thead th {
    padding: 0.875rem 1.25rem;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--color-text-muted);
    text-align: left;
}
tbody tr { transition: background 0.1s; }
tbody tr:hover { background: var(--color-bg-alt); }
tbody td { padding: 1rem 1.25rem; font-size: 0.95rem; }
.row-name { font-weight: 600; color: var(--color-accent); cursor: pointer; }
.row-name:hover { text-decoration: underline; }
.row-mono { font-family: 'DM Mono', monospace; font-weight: 500; color: var(--color-text-muted); }
.kebab-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.35rem;
    border-radius: 8px;
    color: var(--color-text-muted);
    transition: all 0.2s;
}
.kebab-btn:hover { color: var(--color-accent); background: var(--color-accent-soft); }
.table-section-title {
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--color-text-muted);
    margin-bottom: 0.75rem;
}
.table-wrap { margin-bottom: 2rem; }
.text-right { text-align: right; }
.table-compact thead th { padding: 0.65rem 1rem; font-size: 0.7rem; }
.table-compact tbody td { padding: 0.75rem 1rem; font-size: 0.875rem; }
.table-striped tbody tr:nth-child(even) { background: var(--color-bg-alt); }
.table-striped tbody tr:nth-child(even):hover { background: rgba(248,249,250,0.9); }
.table-bordered th, .table-bordered td { border: 1px solid var(--color-border); }
.table-bordered thead th { border-bottom-width: 2px; }

/* Stat cards */
.stat-card {
    background: #fff;
    border: 1px solid var(--color-border);
    border-radius: 12px;
    padding: 1.25rem 1.5rem;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.04);
}
.stat-label { font-size: 0.75rem; font-weight: 600; color: var(--color-text-muted); margin-bottom: 0.5rem; }
.stat-value { font-size: 1.75rem; font-weight: 700; color: var(--color-text); font-family: 'DM Mono', monospace; }
.stat-delta { font-size: 0.8rem; font-weight: 600; margin-top: 0.25rem; }
.stat-delta.up { color: var(--green); }
.stat-delta.down { color: var(--red); }

/* Typography page */
.typo-card {
    background: #fff;
    border: 1px solid var(--color-border);
    border-radius: 12px;
    padding: 1.5rem 1.75rem;
    margin-bottom: 1.25rem;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.04);
}
.typo-section { margin-bottom: 2rem; }
h1, h2, h3, h4, h5, h6 { margin: 0 0 0.5em; font-weight: 600; color: var(--color-text); }
h1 { font-size: 1.75rem; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.25rem; }
h4 { font-size: 1.1rem; }
h5 { font-size: 1rem; }
h6 { font-size: 0.9rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--color-text-muted); }
.typo-card p { margin: 0 0 1em; }
.typo-card ul, .typo-card ol { margin: 0 0 1em; padding-left: 1.5em; }
.typo-card blockquote {
    margin: 0 0 1em;
    padding: 1rem 1.25rem;
    border-left: 4px solid var(--color-accent);
    background: var(--color-bg-alt);
    border-radius: 0 8px 8px 0;
    font-style: italic;
    color: var(--color-text-muted);
}
.typo-card code {
    padding: 0.2rem 0.5rem;
    background: var(--color-bg-alt);
    border-radius: 6px;
    font-family: 'DM Mono', monospace;
    font-size: 0.9rem;
    color: var(--color-accent);
}
.typo-card pre {
    margin: 0 0 1em;
    padding: 1rem 1.25rem;
    background: #1a1f2e;
    color: #e2e5ea;
    border-radius: 8px;
    overflow-x: auto;
}
.typo-card pre code { padding: 0; background: none; color: inherit; }
.typo-card hr { border: none; border-top: 1px solid var(--color-border); margin: 1.5rem 0; }
.typo-card a { color: var(--color-accent); }

/* Form grid */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1.25rem 1.5rem; }
.form-grid-full { grid-column: 1 / -1; }
.form-actions { display: flex; gap: 0.75rem; margin-top: 1.5rem; padding-top: 1.25rem; border-top: 1px solid var(--color-border); }
.field-hint { font-size: 0.8rem; color: var(--color-text-muted); margin-top: 0.35rem; }

/* Comp section (componenti) */
.comp-section { margin-bottom: 2rem; }
.comp-section-title {
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--color-text-muted);
    margin-bottom: 0.75rem;
}
.comp-row { display: flex; flex-wrap: wrap; gap: 0.75rem; align-items: center; }

/* ========== Features Board (hierarchical inline editor) ========== */
.features-board {
    background: #fff;
    border: 1px solid var(--color-border);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.04);
}
.board-row {
    display: grid;
    grid-template-columns: 36px minmax(220px, 1fr) 140px 110px 110px 140px 96px;
    align-items: center;
    column-gap: 0.5rem;
    padding: 0.4rem 0.75rem;
    border-bottom: 1px solid var(--color-border);
    transition: background 0.1s;
}
.board-row:last-child { border-bottom: none; }
.board-row .cell { display: flex; align-items: center; min-width: 0; }
.board-row .cell-title { gap: 0.5rem; }
.board-row .cell-actions { justify-content: flex-end; gap: 0.35rem; }
.board-row--header {
    background: var(--color-bg-alt);
    padding: 0.65rem 0.75rem;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--color-text-muted);
}
.board-row--feature { background: var(--color-bg-alt); font-weight: 600; }
.board-row--feature:hover { background: rgba(248, 249, 250, 0.95); }
.board-row--task { padding-left: 1.25rem; }
.board-row--task:hover { background: var(--color-bg-alt); }
.board-row--task .cell-title { padding-left: 1.5rem; }
.board-row--new { color: var(--color-text-muted); padding: 0.4rem 0.75rem 0.4rem 1.25rem; }
.board-row--new .cell-title { padding-left: 1.5rem; }
.board-row--new-feature .cell-title { padding-left: 0; }
.board-row--empty { padding: 1.25rem; color: var(--color-text-muted); }

.board-toggle {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.25rem;
    border-radius: 6px;
    color: var(--color-text-muted);
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.board-toggle:hover { color: var(--color-accent); background: var(--color-accent-soft); }
.board-toggle-icon { display: inline-block; transition: transform 0.15s ease; font-size: 0.9rem; }
.feature-group.is-collapsed .board-toggle-icon { transform: rotate(-90deg); }

.board-add-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    color: var(--color-text-muted);
    font-weight: 600;
}

.board-input {
    width: 100%;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 6px;
    padding: 0.35rem 0.5rem;
    font-size: 0.95rem;
    color: var(--color-text);
    transition: border-color 0.15s, background 0.15s;
}
.board-input:hover { border-color: var(--color-border); background: #fff; }
.board-input:focus { outline: none; border-color: var(--color-accent); background: #fff; }
.board-input--title { font-weight: 600; }
.board-input--number { max-width: 100%; }
.board-input--select { appearance: none; padding-right: 1.5rem; cursor: pointer; }

.board-chip {
    flex: 0 0 auto;
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--color-text-muted);
    background: rgba(0, 0, 0, 0.04);
    padding: 0.15rem 0.5rem;
    border-radius: 999px;
    white-space: nowrap;
}

.board-action-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 6px;
    color: var(--color-text-muted);
    text-decoration: none;
    transition: background 0.15s, color 0.15s;
    font-size: 0.95rem;
}
.board-action-link:hover { background: var(--color-bg-alt); color: var(--color-accent); }
.board-action-link--danger:hover { color: var(--red); background: rgba(192, 57, 43, 0.08); }

.board-error {
    display: block;
    margin-top: 0.25rem;
    color: var(--red);
    font-size: 0.85rem;
}

.feature-body { background: #fff; }
.feature-group.is-collapsed .feature-body { display: none; }

.task-title-stack {
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
    width: 100%;
    min-width: 0;
}
.board-row-description {
    display: block;
    font-size: 0.8rem;
    color: var(--color-text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    padding-left: 0.5rem;
}

/* Modal (HTML5 dialog) */
.modal-dialog {
    margin: auto;
    border: none;
    border-radius: 14px;
    padding: 0;
    width: min(640px, 92vw);
    max-height: 90vh;
    background: #fff;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.18);
    color: var(--color-text);
}
.modal-dialog::backdrop {
    background: rgba(15, 23, 42, 0.45);
    backdrop-filter: blur(2px);
}
.modal-dialog[open] {
    animation: modal-fade-in 0.15s ease-out;
}
@keyframes modal-fade-in {
    from { opacity: 0; transform: translateY(-6px); }
    to { opacity: 1; transform: translateY(0); }
}
.modal-content {
    display: flex;
    flex-direction: column;
    max-height: 90vh;
}
.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--color-border);
}
.modal-title {
    margin: 0;
    font-size: 1.05rem;
    font-weight: 700;
}
.modal-close {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.4rem;
    line-height: 1;
    padding: 0.25rem 0.5rem;
    border-radius: 8px;
    color: var(--color-text-muted);
    transition: background 0.15s, color 0.15s;
}
.modal-close:hover { background: var(--color-bg-alt); color: var(--color-accent); }
.modal-body {
    padding: 1.25rem;
    overflow-y: auto;
    flex: 1;
}
.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    padding: 1rem 1.25rem;
    border-top: 1px solid var(--color-border);
    background: var(--color-bg-alt);
    margin: 1.25rem -1.25rem -1.25rem;
}
.modal-errors {
    margin-bottom: 1rem;
    padding: 0.75rem 1rem;
    border: 1px solid rgba(192, 57, 43, 0.35);
    background: rgba(192, 57, 43, 0.06);
    border-radius: 8px;
    color: var(--red);
    font-size: 0.9rem;
}
.modal-errors ul { margin: 0.35rem 0 0; padding-left: 1.25rem; }

@media (max-width: 1024px) {
    .board-row {
        grid-template-columns: 32px minmax(160px, 1fr) 110px 80px 80px 110px 72px;
        column-gap: 0.35rem;
    }
}
@media (max-width: 768px) {
    .board-row { grid-template-columns: 32px 1fr 90px 70px 70px 90px 64px; }
    .board-row .cell-priority,
    .board-row .cell-time { font-size: 0.85rem; }
}

/* ========== RESPONSIVE ========== */

/* Tablet e mobile */
@media (max-width: 1024px) {
    .main-inner--wide { max-width: 100%; padding: 0 0.5rem; }
    .stat-grid { grid-template-columns: repeat(2, 1fr); }
}

/* Tablet portrait e mobile */
@media (max-width: 768px) {
    .site-header .container {
        flex-wrap: wrap;
        gap: 0.75rem;
    }
    .navbar-nav {
        order: 3;
        flex-basis: 100%;
        justify-content: flex-start;
    }
    .form-grid { grid-template-columns: 1fr; }
    .main-content { padding: calc(var(--app-shell-header-height) + 1rem) 1rem 3rem; }
    .main-inner, .main-inner--wide { padding: 0; }
    .card, .typo-card { padding: 1.25rem 1.25rem; }
    .page-title { font-size: clamp(1.5rem, 5vw, 1.85rem); }
    .comp-row { gap: 0.5rem; }
    .tabs-bar { flex-wrap: wrap; gap: 0; }
    .tabs-bar--customer-context { margin-top: -0.75rem; margin-bottom: 0.75rem; }
    .tab-btn { padding: 0.6rem 1rem; font-size: 0.9rem; }
}

/* Smartphone */
@media (max-width: 480px) {
    :root { --app-shell-header-height: 3.75rem; }
    .site-header .container { padding: 0 1rem; }
    .navbar-brand { font-size: 1rem; }
    .user-badge {
        padding: 0.25rem 0.35rem 0.25rem 0.65rem;
        gap: 0.4rem;
    }
    .user-badge > span:first-child { display: none; }
    .user-area::before { display: none; }
    .main-content { padding: calc(var(--app-shell-header-height) + 0.75rem) 1rem 2.5rem; }
    .card, .typo-card { padding: 1rem 1.25rem; }
    .page-header { margin-bottom: 1.5rem; }
    .page-subtitle { font-size: 0.95rem; }
    .stat-grid { grid-template-columns: 1fr; }
    .stat-value { font-size: 1.5rem; }
    .btn-cta, .btn-ghost { padding: 0.65rem 1.25rem; font-size: 0.95rem; }
    .form-actions { flex-direction: column; margin-top: 1.25rem; }
    .form-actions .btn-cta, .form-actions .btn-ghost { width: 100%; justify-content: center; }
    table { min-width: 320px; }
    .typo-card pre { padding: 0.75rem 1rem; font-size: 0.85rem; overflow-x: auto; }
    .file-input-display { flex-direction: column; text-align: center; padding: 1.25rem 1rem; }
    .switch-row { flex-direction: column; align-items: flex-start; gap: 0.5rem; }
}
