/* ============================================================
   Main Padel Alpha 0 — Design System
   Editorial paper warm · DECISIONS.md §1
   ============================================================ */

:root {
    --paper:      #f4efe6;
    --paper-soft: #ebe4d4;
    --paper-dark: #ddd5c3;
    --ink:        #1a1814;
    --ink-soft:   #5a5348;
    --ink-mute:   #8c8371;
    --court:      #3e5641;
    --court-light:#5a7a5e;
    --clay:       #c44b2d;
    --clay-light: #e07a62;
    --signal:     #e8a94a;
    --signal-light:#f0c97a;
    --positive:   #2d8659;
    --positive-light:#4aad76;
    --line:       #d4ccb8;
    --line-light: #e2ddd0;

    --font-display: 'Fraunces', serif;
    --font-body:    'Inter Tight', sans-serif;
    --font-mono:    'JetBrains Mono', monospace;

    --radius:     4px;
    --radius-lg:  8px;
    --shadow:     0 2px 8px rgba(26,24,20,0.08);
    --shadow-lg:  0 4px 16px rgba(26,24,20,0.12);
    --transition: 0.2s ease;

    /* Aliases usati in dado/players/grid */
    --surface:        var(--paper-soft);
    --surface-alt:    var(--paper-dark);
    --text-mute:      var(--ink-mute);
    --text-secondary: var(--ink-soft);
    --space-sm:       0.5rem;
    --space-md:       1rem;
}

/* ---- Reset & Base ---- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
    font-size: 19px;
    -webkit-font-smoothing: antialiased;
}

body {
    font-family: var(--font-body);
    color: var(--ink);
    background-color: var(--paper);
    background-image: url("data:image/svg+xml,%3Csvg width='200' height='200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.75' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.03'/%3E%3C/svg%3E");
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

a { color: var(--court); text-decoration: none; }
a:hover { color: var(--ink); }

/* ---- Typography ---- */
.h-display {
    font-family: var(--font-display);
    font-size: clamp(2rem, 4vw, 3.2rem);
    font-weight: 400;
    letter-spacing: -0.02em;
    line-height: 1.15;
    color: var(--ink);
}

.h-section {
    font-family: var(--font-display);
    font-size: clamp(1.5rem, 2.5vw, 2rem);
    font-weight: 500;
    line-height: 1.25;
    color: var(--ink);
}

.h-card {
    font-family: var(--font-display);
    font-size: 1.2rem;
    font-weight: 500;
    line-height: 1.3;
    color: var(--ink);
}

.kicker {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 2.5px;
    color: var(--clay);
    display: block;
    margin-bottom: 0.25rem;
}

.lead {
    font-family: var(--font-display);
    font-size: 1.1rem;
    font-weight: 300;
    font-style: italic;
    color: var(--ink-soft);
    border-left: 3px solid var(--court);
    padding-left: 1rem;
    margin: 0.75rem 0;
}

.mono-data {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    font-weight: 400;
    color: var(--ink-soft);
}

/* ---- Navigation ---- */
.nav-main {
    background: var(--ink);
    color: var(--paper);
    padding: 0 1.5rem;
    position: sticky;
    top: 0;
    z-index: 100;
}

.nav-inner {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    height: 3.2rem;
    gap: 2rem;
}

.nav-brand {
    font-family: var(--font-display);
    font-weight: 500;
    font-size: 1.1rem;
    color: var(--paper) !important;
    white-space: nowrap;
}

.nav-links {
    display: flex;
    gap: 0.25rem;
}

.nav-link {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--ink-mute) !important;
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius);
    transition: var(--transition);
}

.nav-link:hover {
    color: var(--paper) !important;
    background: rgba(244,239,230,0.1);
}

.nav-link.active {
    color: var(--signal) !important;
    background: rgba(232,169,74,0.12);
}

/* ---- Layout ---- */
.main-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1.5rem;
    width: 100%;
    flex: 1;
}
.main-content.wide {
    max-width: none;
    padding: 1.5rem 2rem;
}

.page-header {
    margin-bottom: 1.5rem;
}

.footer {
    text-align: center;
    padding: 1rem;
    border-top: 1px solid var(--line);
    margin-top: 2rem;
}

/* ---- Cards ---- */
.card {
    background: var(--paper);
    border: 1.5px solid var(--ink);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    transition: box-shadow var(--transition);
    /* Permette stretch verticale nel grid senza spingere il contenuto */
    box-sizing: border-box;
}

.card:hover {
    box-shadow: var(--shadow);
}

/* .card + .card solo fuori da grid (dentro grid usa gap) */
.card + .card {
    margin-top: 1rem;
}
.dashboard-grid .card + .card,
.stats-grid .card + .card {
    margin-top: 0;
}

/* ---- Dashboard Grid ---- */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
    /* NO align-items: start — default stretch = tutte le card stessa altezza */
    align-items: stretch;
}

/* ---- Badges ---- */
.badge {
    font-family: var(--font-mono);
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    padding: 0.15rem 0.5rem;
    border-radius: 3px;
    display: inline-block;
    vertical-align: middle;
}

.badge-unsent    { background: var(--paper-soft); color: var(--ink-mute); }
.badge-partial   { background: var(--signal-light); color: var(--ink); }
.badge-full      { background: var(--positive-light); color: #fff; }
.badge-locked    { background: var(--ink-mute); color: var(--paper); }
.badge-concluded { background: var(--line); color: var(--ink-soft); }
.badge-cancelled      { background: var(--clay-light); color: #fff; text-decoration: line-through; }
.badge-awaiting_close { background: var(--signal); color: var(--ink); }
.badge-manual    { border: 2px solid var(--court); background: transparent; color: var(--court); }
.badge-warn      { border: 2px solid var(--signal); background: transparent; color: var(--signal); }
.badge-banned    { background: var(--clay); color: #fff; }
.badge-active    { background: var(--positive); color: #fff; }
.badge-level     { background: var(--court); color: #fff; }
.badge-gender-m  { background: var(--ink); color: var(--paper); }
.badge-gender-f  { background: var(--clay); color: #fff; }
.badge-gender-x  { background: var(--ink-mute); color: var(--paper); }
.badge-gender-mixed { background: var(--signal); color: var(--ink); }
.badge-hot       { background: var(--clay); color: #fff; }
.badge-warm      { background: var(--signal); color: var(--ink); }
.badge-cold      { background: var(--court-light); color: #fff; }

/* ---- Buttons ---- */
.btn {
    font-family: var(--font-body);
    font-size: 0.85rem;
    font-weight: 600;
    padding: 0.5rem 1rem;
    border: 1.5px solid var(--ink);
    border-radius: var(--radius);
    cursor: pointer;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    text-decoration: none;
}

.btn-primary {
    background: var(--ink);
    color: var(--paper);
}
.btn-primary:hover {
    background: var(--ink-soft);
    color: var(--paper);
}

.btn-secondary {
    background: var(--paper);
    color: var(--ink);
}
.btn-secondary:hover {
    background: var(--paper-soft);
}

.btn-positive {
    background: var(--positive);
    color: #fff;
    border-color: var(--positive);
}
.btn-positive:hover {
    background: var(--positive-light);
}

.btn-danger {
    background: var(--clay);
    color: #fff;
    border-color: var(--clay);
}
.btn-danger:hover {
    background: var(--clay-light);
}

.btn-sm {
    font-size: 0.75rem;
    padding: 0.3rem 0.6rem;
}

.btn-ghost {
    background: transparent;
    border-color: transparent;
    color: var(--ink-soft);
}
.btn-ghost:hover {
    color: var(--ink);
    background: var(--paper-soft);
    border-color: var(--line);
}

/* ---- Forms ---- */
.form-group {
    margin-bottom: 1rem;
}

.form-label {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--ink-soft);
    display: block;
    margin-bottom: 0.3rem;
}

.form-control {
    font-family: var(--font-body);
    font-size: 0.9rem;
    padding: 0.5rem 0.75rem;
    border: 1.5px solid var(--line);
    border-radius: var(--radius);
    background: var(--paper);
    color: var(--ink);
    width: 100%;
    transition: var(--transition);
}

.form-control:focus {
    outline: none;
    border-color: var(--court);
    box-shadow: 0 0 0 3px rgba(62,86,65,0.15);
}

select.form-control {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' fill='%235a5348'%3E%3Cpath d='M6 8L0 0h12z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    padding-right: 2rem;
}

.form-row {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.form-row .form-group {
    flex: 1;
    min-width: 120px;
}

/* ---- Tables ---- */
.table-wrap {
    overflow-x: auto;
    border: 1.5px solid var(--ink);
    border-radius: var(--radius-lg);
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

thead th {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--paper);
    background: var(--ink);
    padding: 0.6rem 0.75rem;
    text-align: left;
    white-space: nowrap;
}

tbody td {
    padding: 0.55rem 0.75rem;
    border-bottom: 1px solid var(--line-light);
    vertical-align: middle;
}

tbody tr:hover {
    background: var(--paper-soft);
}

tbody tr:last-child td {
    border-bottom: none;
}

/* ---- Bordero Grid ---- */
.bordero-controls {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.bordero-nav {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.day-tabs {
    display: flex;
    gap: 0.25rem;
}

.day-tab {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    font-weight: 500;
    padding: 0.4rem 0.6rem;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--paper);
    color: var(--ink-soft);
    cursor: pointer;
    text-decoration: none;
    transition: var(--transition);
}

.day-tab:hover { background: var(--paper-soft); color: var(--ink); }
.day-tab.active {
    background: var(--ink);
    color: var(--paper);
    border-color: var(--ink);
}
.day-tab.today {
    border-color: var(--court);
    color: var(--court);
    font-weight: 700;
}
.day-tab.today.active {
    background: var(--court);
    color: #fff;
    border-color: var(--court);
}

.grid-bordero-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}
.grid-bordero {
    display: grid;
    /* columns set inline via template (dynamic hour count) */
    gap: 1px;
    background: var(--line);
    border: 1.5px solid var(--ink);
    border-radius: var(--radius-lg);
    overflow: hidden;
    min-width: 600px;
}

.grid-header {
    font-family: var(--font-mono);
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    background: var(--ink);
    color: var(--paper);
    padding: 0.35rem 0.2rem;
    text-align: center;
}
.grid-header-half {
    background: var(--ink-soft);
    font-size: 0.55rem;
    font-weight: 400;
    letter-spacing: 0;
    color: var(--paper-dark);
    opacity: 1;
}

.grid-time {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    font-weight: 500;
    background: var(--paper-soft);
    color: var(--ink-soft);
    padding: 0.4rem;
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
}

.grid-cell {
    background: var(--paper);
    padding: 0.25rem 0.3rem;
    height: 110px;
    overflow: hidden;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: flex-start;
    font-size: 0.82rem;
    text-decoration: none;
    color: var(--ink);
    position: relative;
}

.grid-cell:hover {
    background: var(--paper-soft);
    box-shadow: inset 0 0 0 2px var(--court);
}

.grid-cell.empty {
    border: 1px solid rgba(26,24,20,0.08);
    background: transparent;
    align-items: center;
    justify-content: center;
}

.grid-cell.status-unsent   { background: var(--paper-soft); }
.grid-cell.status-partial  { background: var(--signal-light); }
.grid-cell.status-full     { background: var(--positive-light); color: #fff; }
.grid-cell.status-locked   { background: var(--ink-mute); color: var(--paper); }
.grid-cell.status-concluded { background: var(--line); color: var(--ink-soft); }
.grid-cell.status-cancelled      { background: var(--paper-soft); color: var(--ink-mute); text-decoration: line-through; }
.grid-cell.status-awaiting_close { background: var(--signal-light); color: var(--ink); }

.grid-cell.flag-manual  { box-shadow: inset 3px 0 0 var(--court); }
.grid-cell.flag-warn    { box-shadow: inset 0 3px 0 var(--signal); }
.grid-cell.flag-complex { outline: 1.5px dashed var(--clay); outline-offset: -2px; }

.cell-lock-icon {
    position: absolute;
    top: 3px;
    right: 5px;
    font-size: 1.1rem;
    line-height: 1;
    pointer-events: none;
}

.grid-cell.sport-training { background: #dce8f5; color: #1a3a5c; }
.grid-cell.sport-training.status-full { background: #7aabdb; color: #fff; }
.cell-training-badge {
    display: inline-block;
    font-size: 0.6rem;
    font-weight: 700;
    letter-spacing: .03em;
    text-transform: uppercase;
    background: #1a3a5c;
    color: #fff;
    border-radius: 3px;
    padding: 1px 4px;
    margin-bottom: 2px;
}

.cell-complex {
    font-size: .75rem;
    color: var(--clay);
    font-weight: 700;
    margin-left: auto;
    line-height: 1;
}

.cell-meta {
    display: flex;
    align-items: baseline;
    gap: 4px;
    width: 100%;
}

.cell-count {
    font-family: var(--font-mono);
    font-weight: 700;
    font-size: 0.85rem;
}

.cell-level {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    opacity: 0.7;
}

.cell-players {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    width: 100%;
    gap: 0;
    margin-top: 2px;
    border-top: 1px solid rgba(26,24,20,0.1);
    padding-top: 2px;
}

.cell-player-name {
    font-family: var(--font-mono);
    font-size: 0.68rem;
    line-height: 1.3;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
    color: inherit;
    opacity: 0.9;
}

.cell-locked-name {
    font-family: var(--font-mono);
    font-size: 0.68rem;
    font-weight: 700;
    line-height: 1.3;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    color: inherit;
    opacity: 0.9;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    padding: 0.1rem 0;
}

.cell-time-range {
    font-family: var(--font-mono);
    font-size: 0.62rem;
    opacity: 0.65;
    margin-top: auto;
    padding-top: 0.2rem;
    white-space: nowrap;
}

/* ---- Slot Detail ---- */
.slot-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
    margin-bottom: 1.5rem;
}

.slot-header .badge { font-size: 0.7rem; }

.player-positions {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

.position-card {
    border: 1.5px solid var(--line);
    border-radius: var(--radius-lg);
    padding: 1rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.position-card.filled { border-color: var(--ink); }
.position-card.empty  { border-style: dashed; }

.position-number {
    font-family: var(--font-display);
    font-size: 1.5rem;
    font-weight: 500;
    color: var(--ink-mute);
    min-width: 2rem;
    text-align: center;
}

.position-info { flex: 1; }

.position-name {
    font-weight: 600;
    margin-bottom: 0.15rem;
}

.position-meta {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    color: var(--ink-soft);
}

.position-actions {
    display: flex;
    gap: 0.35rem;
}

/* ---- Matchmaking Suggestions ---- */
.suggestions-panel {
    margin-top: 1rem;
    border: 1.5px solid var(--court);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.suggestions-header {
    background: var(--court);
    color: #fff;
    padding: 0.6rem 1rem;
    font-family: var(--font-mono);
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.suggestion-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--line-light);
}

.suggestion-item:last-child { border-bottom: none; }

.suggestion-rank {
    font-family: var(--font-display);
    font-size: 1.3rem;
    font-weight: 500;
    color: var(--ink-mute);
    min-width: 1.5rem;
}

.suggestion-info { flex: 1; }

.suggestion-name { font-weight: 600; }

.suggestion-score {
    font-family: var(--font-mono);
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--court);
}

.score-bars {
    display: flex;
    gap: 3px;
    margin-top: 0.35rem;
}

.score-bar {
    height: 4px;
    border-radius: 2px;
    background: var(--line);
    flex: 1;
    position: relative;
    overflow: hidden;
}

.score-bar-fill {
    height: 100%;
    border-radius: 2px;
    position: absolute;
    left: 0;
    top: 0;
}

.score-bar-fill.affinity     { background: var(--court); }
.score-bar-fill.time_match   { background: var(--signal); }
.score-bar-fill.compatibility { background: var(--positive); }
.score-bar-fill.age_match    { background: var(--clay); }
.score-bar-fill.recency      { background: var(--ink-mute); }

/* ---- Player Detail ---- */
.affinity-display {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

.affinity-score-big {
    font-family: var(--font-display);
    font-size: 3rem;
    font-weight: 400;
    line-height: 1;
}

.affinity-score-big.high   { color: var(--positive); }
.affinity-score-big.medium { color: var(--signal); }
.affinity-score-big.low    { color: var(--clay); }

.affinity-breakdown { flex: 1; max-width: 400px; }

.affinity-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.4rem;
}

.affinity-label {
    font-family: var(--font-mono);
    font-size: 0.65rem;
    font-weight: 500;
    color: var(--ink-soft);
    min-width: 100px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.affinity-bar {
    flex: 1;
    height: 8px;
    background: var(--line);
    border-radius: 4px;
    overflow: hidden;
}

.affinity-bar-fill {
    height: 100%;
    border-radius: 4px;
    background: var(--court);
    transition: width 0.5s ease;
}

.affinity-weight {
    font-family: var(--font-mono);
    font-size: 0.6rem;
    color: var(--ink-mute);
    min-width: 32px;
    text-align: right;
}

.affinity-value {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--ink);
    min-width: 32px;
    text-align: right;
}

/* ---- Stats Grid ---- */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

.stat-card {
    text-align: center;
    padding: 1rem;
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
}

.stat-value {
    font-family: var(--font-display);
    font-size: 2rem;
    font-weight: 400;
    color: var(--ink);
    line-height: 1.1;
}

.stat-label {
    font-family: var(--font-mono);
    font-size: 0.6rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--ink-mute);
    margin-top: 0.25rem;
}

/* ---- Params Table ---- */
.params-section {
    margin-bottom: 1.5rem;
}

.params-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    padding: 0.6rem 0;
    border-bottom: 2px solid var(--ink);
    margin-bottom: 0.75rem;
}

.params-section-header .h-card { margin: 0; }

.params-section-toggle {
    font-size: 1.2rem;
    color: var(--ink-mute);
    transition: transform var(--transition);
}

.params-section.collapsed .params-section-toggle {
    transform: rotate(-90deg);
}

.params-section.collapsed .params-table-wrap {
    display: none;
}

.params-table {
    width: 100%;
    font-size: 0.8rem;
}

.params-table td {
    padding: 0.4rem 0.5rem;
    border-bottom: 1px solid var(--line-light);
    vertical-align: top;
}

.param-key {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--court);
    white-space: nowrap;
}

.param-value {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--clay);
}

.param-desc {
    font-size: 0.75rem;
    color: var(--ink-soft);
}

/* ---- Temperature Heatmap ---- */
.heatmap-grid {
    display: grid;
    grid-template-columns: 50px repeat(24, 1fr);
    gap: 1px;
    background: var(--line);
    border: 1px solid var(--ink);
    border-radius: var(--radius);
    overflow: hidden;
    font-size: 0.6rem;
}

.heatmap-cell {
    padding: 0.3rem;
    text-align: center;
    font-family: var(--font-mono);
    font-weight: 500;
}

.heatmap-label {
    background: var(--paper-soft);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
}

.heatmap-header {
    background: var(--ink);
    color: var(--paper);
    font-weight: 700;
}

/* ---- Flash Messages ---- */
.flash-messages {
    margin-bottom: 1rem;
}

.flash {
    padding: 0.6rem 1rem;
    border-radius: var(--radius);
    font-size: 0.85rem;
    margin-bottom: 0.5rem;
    transition: opacity 0.3s ease;
}

.flash-success { background: rgba(45,134,89,0.1); border: 1px solid var(--positive); color: var(--positive); }
.flash-error   { background: rgba(196,75,45,0.1); border: 1px solid var(--clay); color: var(--clay); }
.flash-warning { background: rgba(232,169,74,0.1); border: 1px solid var(--signal); color: var(--signal); }
.flash-info    { background: rgba(62,86,65,0.1); border: 1px solid var(--court); color: var(--court); }

/* ---- Modal ---- */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(26,24,20,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
}

.modal-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.modal {
    background: var(--paper);
    border: 1.5px solid var(--ink);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    max-width: 480px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
}

.modal-title {
    font-family: var(--font-display);
    font-size: 1.3rem;
    font-weight: 500;
    margin-bottom: 1rem;
}

.modal-actions {
    display: flex;
    gap: 0.5rem;
    justify-content: flex-end;
    margin-top: 1.5rem;
}

/* ---- Search / Autocomplete ---- */
.search-wrap {
    position: relative;
}

.search-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--paper);
    border: 1.5px solid var(--ink);
    border-top: none;
    border-radius: 0 0 var(--radius) var(--radius);
    max-height: 240px;
    overflow-y: auto;
    z-index: 50;
    display: none;
}

.search-results.active { display: block; }

.search-result-item {
    padding: 0.5rem 0.75rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    border-bottom: 1px solid var(--line-light);
}

.search-result-item:hover { background: var(--paper-soft); }
.search-result-item:last-child { border-bottom: none; }

/* ---- Utility ---- */
.flex { display: flex; }
.flex-wrap { flex-wrap: wrap; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-sm { gap: 0.5rem; }
.gap-md { gap: 1rem; }
.gap-lg { gap: 1.5rem; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.text-mute { color: var(--ink-mute); }
.text-court { color: var(--court); }
.text-clay { color: var(--clay); }
.text-positive { color: var(--positive); }
.text-center { text-align: center; }
.hidden { display: none !important; }

/* ---- Tooltip system ---- */
[data-tip] {
    position: relative;
}
[data-tip]::after {
    content: attr(data-tip);
    position: absolute;
    bottom: calc(100% + 6px);
    left: 50%;
    transform: translateX(-50%);
    background: var(--ink);
    color: var(--paper);
    font-family: var(--font-body);
    font-size: 0.72rem;
    font-weight: 400;
    line-height: 1.3;
    padding: 0.35rem 0.6rem;
    border-radius: var(--radius);
    white-space: nowrap;
    max-width: 240px;
    white-space: pre-wrap;
    text-align: center;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.15s ease, transform 0.15s ease;
    transform: translateX(-50%) translateY(4px);
    z-index: 999;
    box-shadow: 0 2px 8px rgba(26,24,20,0.2);
}
[data-tip]:hover::after {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* ---- Responsive ---- */
@media (max-width: 767px) {
    .nav-inner { gap: 0.75rem; }
    .nav-link { font-size: 0.6rem; padding: 0.4rem 0.5rem; letter-spacing: 0.5px; }
    .main-content { padding: 1rem; }
    .h-display { font-size: 1.8rem; }
    .dashboard-grid { grid-template-columns: 1fr !important; }
    .dashboard-grid .card[style*="span 2"] { grid-column: span 1 !important; }
    .grid-bordero { min-width: 500px; }
    .grid-header, .grid-time { font-size: 0.6rem; padding: 0.3rem; }
    .grid-cell { height: 56px; font-size: 0.6rem; }
    .player-positions { grid-template-columns: 1fr; }
    .affinity-display { flex-direction: column; align-items: flex-start; }
    .players-stats-strip { gap: 0.75rem; }
    .dash-stats { grid-template-columns: repeat(2, 1fr); }
}

/* ---- Dado / Autosaturazione ---- */
.dado-panel { padding: var(--space-md); }
.dado-controls {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    flex-wrap: wrap;
}
.dado-icon { font-size: 1.4rem; line-height: 1; }
.dado-slider-wrap { display: flex; align-items: center; gap: var(--space-sm); flex: 1; min-width: 200px; }
.dado-slider {
    flex: 1;
    max-width: 220px;
    accent-color: var(--court);
    cursor: pointer;
    height: 4px;
}
.dado-pct {
    font-size: 1rem;
    min-width: 3rem;
    font-weight: 600;
    color: var(--court);
}
.dado-result {
    margin-top: var(--space-sm);
    padding: var(--space-sm) var(--space-md);
    background: var(--surface-alt, var(--surface));
    border-radius: var(--radius);
    border-left: 3px solid var(--court);
    font-size: 0.9rem;
}
.dado-details {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-sm);
    margin-top: var(--space-sm);
}
.dado-details .mono-data {
    background: var(--surface);
    border: 1px solid var(--line);
    padding: 0.2rem 0.5rem;
    border-radius: var(--radius);
    font-size: 0.8rem;
}

/* ---- Dado preview modal ---- */
.modal-dado-preview {
    max-width: none;
    width: 98vw;
    max-height: 96vh;
    padding: 1rem 1.1rem 0.75rem;
    display: flex;
    flex-direction: column;
}
.dado-preview-meta {
    font-size: 0.75rem;
    margin-bottom: var(--space-sm);
    opacity: 0.7;
    flex-shrink: 0;
}
.dado-preview-summary-text {
    font-size: 0.95rem;
    margin: 0 0 var(--space-sm);
    padding-bottom: var(--space-sm);
    border-bottom: 1px solid var(--line);
}
.dado-preview-list {
    overflow-x: auto;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    flex: 1;
    min-height: 0;
    margin-bottom: var(--space-md);
}
.modal-dado-preview .modal-title,
.modal-dado-preview .dado-preview-summary,
.modal-dado-preview .modal-actions { flex-shrink: 0; }
.modal-dado-preview .modal-actions { margin-top: auto; padding-top: var(--space-sm); }

/* ---- Dado preview grid ---- */
.dado-pg {
    display: grid;
    gap: 1px;
    background: var(--line);
    border: 1.5px solid var(--ink);
    border-radius: var(--radius);
    overflow: hidden;
    min-width: 500px;
}
.dado-pg-hd {
    background: var(--ink);
    color: var(--paper);
    font-family: var(--font-mono);
    font-weight: 700;
    font-size: 0.72rem;
    padding: 0.25rem 0.15rem;
    text-align: center;
}
.dado-pg-court {
    background: var(--surface);
    font-family: var(--font-mono);
    font-size: 0.75rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--ink-soft);
}
.dado-pg-cell {
    height: 96px;
    overflow: hidden;
    padding: 0.15rem 0.2rem;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: flex-start;
    position: relative;
    background: var(--paper-soft);
}
.dado-pg-cell.-empty {
    background: transparent;
    border: 1px dashed rgba(26,24,20,0.1);
}
.dado-pg-cell.-new {
    background: var(--positive-light);
    box-shadow: inset 0 0 0 2px var(--positive);
}
.dado-pg-cell.-touch { background: var(--signal-light); }
.dado-pg-cell.-exist { background: var(--paper); opacity: 0.45; }
.dado-pg-badge {
    position: absolute;
    top: 2px;
    right: 2px;
    background: var(--positive);
    color: #fff;
    font-size: 0.48rem;
    font-weight: 700;
    width: 11px;
    height: 11px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}
.dado-pg-count {
    font-family: var(--font-mono);
    font-weight: 700;
    font-size: 0.72rem;
    line-height: 1;
}
.dado-pg-names {
    display: flex;
    flex-direction: column;
    margin-top: 2px;
    width: 100%;
    border-top: 1px solid rgba(26,24,20,0.1);
    padding-top: 1px;
}
.dado-pg-name {
    font-family: var(--font-mono);
    font-size: 0.62rem;
    line-height: 1.25;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--ink-soft);
}

/* ---- Multi-select candidati ---- */
.suggestion-check {
    display: flex;
    align-items: center;
    padding-right: var(--space-sm);
    cursor: pointer;
}
.suggestion-check input[type=checkbox] {
    width: 1.1rem;
    height: 1.1rem;
    accent-color: var(--positive);
    cursor: pointer;
}
.suggestion-check input[type=checkbox]:disabled { opacity: 0.35; cursor: not-allowed; }

/* ---- Dashboard stat boxes ---- */
.dash-stats {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.4rem;
}
.dash-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 0.65rem 0.25rem;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    min-width: 0;
    gap: 0.15rem;
}
.dash-stat-value {
    font-family: var(--font-display);
    font-size: 1.5rem;
    font-weight: 700;
    line-height: 1;
}
.dash-stat-label {
    font-size: 0.6rem;
    font-family: var(--font-mono);
    color: var(--text-mute);
    text-transform: uppercase;
    letter-spacing: .04em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

/* Week fill bar */
.week-bar {
    height: 8px;
    background: var(--line);
    border-radius: 4px;
    overflow: hidden;
}
.week-bar-fill {
    height: 100%;
    background: var(--positive);
    border-radius: 4px;
    transition: width .4s ease;
    min-width: 2px;
}

/* ---- Bordero grid invertito (campi = righe, ore = colonne) ---- */
.grid-court {
    background: var(--surface);
    font-family: var(--font-mono);
    font-size: 0.9rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.4rem 0.2rem;
    color: var(--text-secondary);
}

/* ---- Players anagrafica stats ---- */
.players-stats-strip {
    display: flex;
    align-items: flex-end;
    gap: 1rem;
    flex-wrap: wrap;
    padding: 1rem;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
}
.pstat {
    text-align: center;
    min-width: 50px;
}
.pstat-divider {
    border-left: 1px solid var(--line);
    padding-left: 1rem;
}
.pstat-value {
    font-family: var(--font-display);
    font-size: 1.5rem;
    font-weight: 700;
    line-height: 1.1;
}
.pstat-label {
    font-size: 0.65rem;
    font-family: var(--font-mono);
    color: var(--text-mute);
    text-transform: uppercase;
    letter-spacing: .04em;
    margin-top: .15rem;
}
.pstat-levels {
    display: flex;
    align-items: flex-end;
    gap: 3px;
    border-left: 1px solid var(--line);
    padding-left: 1rem;
    height: 56px;
}
.pstat-lvl {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    cursor: default;
}
.pstat-lvl-bar {
    width: 14px;
    background: var(--court);
    border-radius: 2px 2px 0 0;
    min-height: 3px;
    transition: background .15s;
}
.pstat-lvl:hover .pstat-lvl-bar { background: var(--positive); }
.pstat-lvl-label {
    font-family: var(--font-mono);
    font-size: 0.55rem;
    color: var(--text-mute);
}

/* ============================================================
   Statistics section (below bordero grid)
   ============================================================ */

.day-stats-section {
    margin: 1.5rem 0 2rem;
}

.day-stats-row {
    display: flex;
    gap: 1rem;
    align-items: stretch;
}

.day-stat-card {
    flex: 1;
    background: var(--paper-soft);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    padding: 1rem 1.2rem;
    min-width: 0;
}

.dsc-header {
    font-family: var(--font-body);
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--ink-mute);
    margin-bottom: 0.75rem;
}

/* Big number */
.dsc-big {
    font-family: var(--font-display);
    font-size: 2.4rem;
    font-weight: 700;
    line-height: 1;
    color: var(--ink);
}
.dsc-unit {
    font-family: var(--font-body);
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--ink-soft);
    margin-left: 2px;
}
.dsc-sub {
    font-size: 0.65rem;
    color: var(--ink-mute);
    margin-top: 0.15rem;
    margin-bottom: 0.75rem;
}

/* Court bars */
.dsc-court-bars {
    display: flex;
    flex-direction: column;
    gap: 5px;
    margin-top: 0.5rem;
}
.dsc-court-bar-row {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}
.dsc-court-label {
    font-family: var(--font-mono);
    font-size: 0.6rem;
    color: var(--ink-mute);
    width: 2rem;
    flex-shrink: 0;
}
.dsc-bar-track {
    flex: 1;
    height: 6px;
    background: var(--paper-dark);
    border-radius: 3px;
    overflow: hidden;
}
.dsc-bar-fill {
    height: 100%;
    background: var(--court);
    border-radius: 3px;
    transition: width 0.3s ease;
    min-width: 2px;
}
.dsc-bar-pct {
    font-family: var(--font-mono);
    font-size: 0.58rem;
    color: var(--ink-soft);
    width: 2.2rem;
    text-align: right;
    flex-shrink: 0;
}

/* Badges */
.dsc-badge {
    display: inline-block;
    font-size: 0.6rem;
    font-weight: 700;
    border-radius: 99px;
    padding: 2px 8px;
    margin-right: 4px;
    vertical-align: middle;
}
.dsc-badge-open {
    background: #e6f4eb;
    color: var(--positive);
    border: 1px solid var(--positive-light);
}
.dsc-badge-full {
    background: #fdecea;
    color: var(--clay);
    border: 1px solid var(--clay-light);
}

/* Player rows */
.dsc-player-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 3px 0;
    border-bottom: 1px solid var(--line-light);
    font-size: 0.65rem;
}
.dsc-player-row:last-child { border-bottom: none; }
.dsc-player-name {
    color: var(--ink-soft);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.dsc-player-n {
    font-family: var(--font-mono);
    font-size: 0.6rem;
    color: var(--ink-mute);
    flex-shrink: 0;
    margin-left: 0.5rem;
}

/* Type breakdown */
.dsc-type-row {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.5rem;
}
.dsc-type-block {
    flex: 1;
    border-radius: var(--radius);
    padding: 0.5rem 0.6rem;
    text-align: center;
}
.dsc-type-padel   { background: #e8f0e8; }
.dsc-type-training { background: #dce8f5; }
.dsc-type-planning { background: #f5f0e0; }
.dsc-type-val {
    font-family: var(--font-display);
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--ink);
    line-height: 1;
}
.dsc-type-label {
    font-size: 0.55rem;
    font-weight: 600;
    letter-spacing: .05em;
    text-transform: uppercase;
    color: var(--ink-mute);
    margin-top: 2px;
}

.mt-half { margin-top: 0.5rem; }
