:root {
    --asws-bg: #ffffff;
    --asws-surface: #f4f5f7;
    --asws-ink: #14171a;
    --asws-muted: #6b7280;
    --asws-line: #e4e6ea;
    --asws-energy: #ff4b1f;
    --asws-energy-dark: #d63c14;
    --asws-ok: #16c784;
    --asws-warn: #ffb020;
    --asws-full: #9aa0a8;
    --asws-radius: 10px;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--asws-bg);
    color: var(--asws-ink);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    -webkit-text-size-adjust: 100%;
    overflow-x: hidden;
}

.asws-display {
    font-family: 'Bebas Neue', 'Inter', sans-serif;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    margin: 0 0 4px;
}

#asws-cal-wrapper { width: 100%; padding: 10px; }

.asws-logo {
    text-align: center;
    margin: 4px 0 12px;
}

.asws-logo img {
    max-width: 260px;
    max-height: 88px;
    width: auto;
    height: auto;
    display: inline-block;
}

.asws-intro {
    margin: 0 0 12px;
    font-size: 13px;
    color: var(--asws-muted);
    text-align: center;
}

/* ---------- Griglia settimanale ---------- */
.asws-grid {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
}

.asws-grid th.asws-day {
    background: var(--asws-ink);
    color: #fff;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    padding: 8px 3px;
    border: 1px solid var(--asws-ink);
}

.asws-grid th.asws-corner {
    background: var(--asws-ink);
    border: 1px solid var(--asws-ink);
    width: 62px;
}

.asws-grid th.asws-time {
    background: var(--asws-surface);
    color: #444;
    font-size: 11px;
    font-weight: 700;
    border: 1px solid var(--asws-line);
    text-align: center;
    white-space: nowrap;
    padding: 4px 2px;
    vertical-align: middle;
}

.asws-grid td {
    border: 1px solid var(--asws-line);
    vertical-align: top;
    padding: 3px;
    background: #fff;
    height: 48px;
}

.asws-grid td.is-empty { background: #fafbfc; }

.asws-blk {
    display: block;
    width: 100%;
    text-align: left;
    border: none;
    border-radius: 5px;
    padding: 5px 6px;
    margin-bottom: 3px;
    cursor: pointer;
    font-family: inherit;
    line-height: 1.2;
    transition: transform 0.1s ease, filter 0.15s ease;
}

.asws-blk:last-child { margin-bottom: 0; }
.asws-blk:hover { filter: brightness(1.08); }
.asws-blk:active { transform: scale(0.98); }

.asws-blk-name {
    display: block;
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

.asws-blk-time {
    display: block;
    font-size: 10px;
    font-weight: 600;
    opacity: 0.88;
    margin-top: 1px;
}

.asws-blk-flag {
    display: inline-block;
    font-size: 8.5px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-top: 3px;
    padding: 1px 5px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.28);
}

.asws-blk.is-full { opacity: 0.62; }

.asws-loading, .asws-error {
    padding: 24px 10px;
    font-size: 14px;
    color: var(--asws-muted);
    text-align: center;
}

/* ---------- Legenda ---------- */
.asws-legend { margin-top: 12px; border-top: 1.5px solid var(--asws-ink); padding-top: 8px; }

.asws-legend-title {
    font-size: 10px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--asws-muted);
    margin-bottom: 6px;
}

.asws-legend-items { display: flex; flex-wrap: wrap; gap: 5px 14px; }

.asws-legend-item { display: flex; align-items: center; gap: 5px; }

.asws-legend-sw { width: 12px; height: 12px; border-radius: 3px; flex-shrink: 0; }

.asws-legend-name {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    white-space: nowrap;
}

/* ---------- Vista mobile a giorni ---------- */
.asws-days { display: none; }

.asws-day-block { margin-bottom: 14px; }

.asws-day-title {
    background: var(--asws-ink);
    color: #fff;
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    padding: 7px 10px;
    border-radius: 6px 6px 0 0;
}

.asws-day-list {
    border: 1px solid var(--asws-line);
    border-top: none;
    border-radius: 0 0 6px 6px;
    padding: 7px;
}

.asws-day-row { display: flex; gap: 8px; align-items: stretch; margin-bottom: 6px; }
.asws-day-row:last-child { margin-bottom: 0; }

.asws-day-hour {
    flex: 0 0 52px;
    font-size: 11px;
    font-weight: 700;
    color: #444;
    background: var(--asws-surface);
    border-radius: 5px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.asws-day-row .asws-blk { flex: 1; margin-bottom: 0; }

/* ---------- Modali ---------- */
.asws-modal { position: fixed; inset: 0; z-index: 9999; display: none; }
.asws-modal[aria-hidden="false"] { display: block; }

.asws-modal-overlay { position: absolute; inset: 0; background: rgba(20, 23, 26, 0.55); }

.asws-modal-box {
    position: relative;
    background: var(--asws-bg);
    max-width: 420px;
    width: calc(100% - 32px);
    margin: 6vh auto;
    border-radius: var(--asws-radius);
    padding: 24px 20px 20px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.25);
    max-height: 88vh;
    overflow-y: auto;
    border-top: 5px solid var(--asws-ink);
}

.asws-modal-close {
    position: absolute;
    top: 10px;
    right: 12px;
    background: none;
    border: none;
    font-size: 1.6rem;
    line-height: 1;
    color: var(--asws-muted);
    cursor: pointer;
    padding: 4px;
}

.asws-modal-image-wrap {
    width: 100%;
    aspect-ratio: 16 / 9;
    border-radius: 8px;
    overflow: hidden;
    background: var(--asws-surface);
    margin-bottom: 12px;
    display: none;
}

.asws-modal-image-wrap.has-image { display: block; }
.asws-modal-image { width: 100%; height: 100%; object-fit: cover; display: block; }

.asws-badge {
    display: inline-block;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    padding: 4px 10px;
    border-radius: 999px;
    margin-bottom: 8px;
    background: rgba(22, 199, 132, 0.12);
    color: #0f9d67;
}

.asws-badge.is-limited { background: rgba(255, 176, 32, 0.14); color: #b5760a; }
.asws-badge.is-full { background: rgba(154, 160, 168, 0.18); color: #5b6068; }

#m1-name { font-size: 1.7rem; color: var(--asws-ink); }

.asws-meta { margin: 0 0 4px; color: var(--asws-muted); font-size: 0.92rem; }

.asws-btn-primary {
    display: inline-block;
    width: 100%;
    margin-top: 16px;
    border: none;
    background: var(--asws-energy);
    color: #fff;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    font-size: 0.9rem;
    padding: 13px 18px;
    cursor: pointer;
    border-radius: 6px;
    font-family: inherit;
    transition: background 0.15s ease, transform 0.1s ease;
}

.asws-btn-primary:hover { background: var(--asws-energy-dark); }
.asws-btn-primary:active { transform: translateY(1px); }
.asws-btn-primary:disabled { background: var(--asws-full); cursor: not-allowed; }

.asws-field { display: block; margin-top: 12px; font-size: 0.82rem; font-weight: 600; }
.asws-field span { display: block; margin-bottom: 4px; }

.asws-field input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--asws-line);
    border-radius: 6px;
    font-size: 0.95rem;
    font-family: inherit;
    background: var(--asws-surface);
    color: var(--asws-ink);
}

.asws-field input:focus {
    outline: 2px solid var(--asws-energy);
    outline-offset: 1px;
    background: #fff;
}

.asws-field input.is-invalid { border-color: var(--asws-energy); background: #fff; }

.asws-form-message {
    margin-top: 12px;
    font-size: 0.85rem;
    font-weight: 600;
    display: none;
    padding: 10px 12px;
    border-radius: 6px;
}

.asws-form-message.is-visible { display: block; }
.asws-form-message.is-error { background: rgba(255, 75, 31, 0.1); color: var(--asws-energy-dark); }
.asws-form-message.is-success { background: rgba(22, 199, 132, 0.12); color: #0f9d67; }

/* ---------- Responsività mobile ---------- */
@media (max-width: 720px) {
    .asws-grid { display: none; }
    .asws-logo img { max-width: 190px; max-height: 68px; }
    .asws-days { display: block; }

    .asws-modal-box {
        margin: 0;
        width: 100%;
        max-width: 100%;
        min-height: 100vh;
        border-radius: 0;
        max-height: none;
        padding: 20px 16px 24px;
    }

    .asws-legend-item { width: calc(50% - 7px); }
}

@media (prefers-reduced-motion: reduce) {
    .asws-blk, .asws-btn-primary { transition: none; }
}
