:root {
    --bg: #080d1f;
    --surface: #11192f;
    --surface-strong: #ffffff;
    --text: #e5e7ff;
    --text-muted: #9aa6cc;
    --primary: #4068ff;
    --primary-strong: #2b4dd5;
    --secondary: rgba(255,255,255,0.12);
    --border: #2c3b68;
    --accent: #ffb84d;
    --success: #22c55e;
    --warning: #f59e0b;
    --danger: #ef4444;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #1e2a4d 0%, #101623 100%);
    color: var(--text);
    min-height: 100vh;
    padding: 10px 10px 40px;
}

.table-section,
.form-panel {
    background: var(--surface);
    color: var(--text);
    box-shadow: 0 18px 60px rgba(0, 0, 0, 0.4);
}

#practicesTable th,
#practicesTable td {
    color: var(--surface-strong);
}

.search-box input,
input,
select,
textarea {
    background: #0f1631;
    border-color: #24345f;
    color: var(--text);
}

.field-hint {
    color: var(--text-muted);
}

.filter-button,
.secondary,
.header-actions .nav-link.secondary {
    background-color: var(--secondary);
    color: var(--surface-strong);
    border-color: var(--border);
}

.filter-button:hover,
.secondary:hover,
.header-actions .nav-link.secondary:hover {
    background-color: #d8e0ff;
    color: #101623;
    border-color: #c7d3ff;
}

.filter-button.active {
    background-color: #d8e0ff;
    color: #101623;
    border-color: #d8e0ff;
}

.filter-button:disabled,
.secondary:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.filter-button:disabled:hover,
.secondary:disabled:hover {
    transform: none;
    background-color: var(--secondary);
    color: var(--surface-strong);
    border-color: var(--border);
}

.status-Aperta { background-color: rgba(255, 216, 135, 0.18); }
.status-Chiusa { background-color: rgba(180, 241, 187, 0.18); }
.status-Alla-firma { background-color: rgba(181, 217, 255, 0.18); }
.status-In-attesa-integrazione { background-color: rgba(255, 214, 182, 0.18); }

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

.app-shell {
    max-width: none;
    width: 100%;
    margin: 0 auto;
}

body.practice-page-view .app-shell {
    max-width: none;
    width: 100%;
}

body.practice-page-view .practice-page-stack .settings-page-panel,
body.practice-page-view .settings-page-panel.practice-page-panel {
    max-width: none;
    width: 100%;
    margin-left: 0;
    margin-right: 0;
}

body.practice-page-view .app-header {
    align-items: flex-start;
}

body.practice-page-view .practice-header-actions {
    display: flex;
    flex-direction: row;
    align-items: flex-start;
    justify-content: flex-end;
    gap: 10px;
    margin-left: auto;
    grid-template-columns: unset;
    flex-shrink: 0;
}

body.practice-page-view .practice-header-actions .header-action-btn {
    width: auto;
    min-width: 148px;
}

.app-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 20px;
    margin-bottom: 20px;
}

.app-header h1 {
    font-size: 32px;
    color: var(--surface-strong);
}

.subtitle {
    margin-top: 6px;
    color: var(--text-muted);
    font-size: 14px;
}

.header-actions {
    display: grid;
    grid-template-columns: repeat(4, 172px);
    gap: 10px;
    flex-shrink: 0;
}

.header-action-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-height: 44px;
    padding: 11px 14px;
    font-size: 14px;
    white-space: nowrap;
    text-align: center;
}

.header-history-btn {
    padding: 11px 12px;
}

.header-history-btn svg {
    width: 18px;
    height: 18px;
    display: block;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.header-history-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.header-history-btn:disabled:hover {
    transform: none;
}

.header-actions-single {
    grid-template-columns: auto;
}

.header-actions .nav-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    border: 1px solid var(--border);
    border-radius: 10px;
    text-decoration: none;
    white-space: nowrap;
    cursor: pointer;
    transition: transform 0.2s ease, background-color 0.2s ease, border-color 0.2s ease;
}

.header-actions .nav-link:hover {
    transform: translateY(-1px);
}

button,
input,
select,
textarea {
    font: inherit;
}

button,
input,
select,
textarea {
    border: 1px solid var(--border);
}

button {
    border-radius: 10px;
    padding: 12px 18px;
    cursor: pointer;
    transition: transform 0.2s ease, background-color 0.2s ease, border-color 0.2s ease;
}

button:hover {
    transform: translateY(-1px);
}

#practicesTable .icon-button:hover,
#practicesTable .icon-open:hover {
    transform: none !important;
}

.primary {
    background-color: var(--primary);
    color: white;
}

.primary:hover {
    background-color: var(--primary-strong);
}

.controls {
    display: flex;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 16px;
    margin-bottom: 20px;
}

.filters {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.search-box input {
    min-width: 240px;
    width: 320px;
    padding: 12px 14px;
    border-radius: 12px;
    border: 1px solid var(--border);
    background-color: rgba(255,255,255,0.08);
    color: var(--surface-strong);
}

.search-box input::placeholder {
    color: var(--text-muted);
}

.dashboard-bar {
    width: 100%;
    margin-bottom: 18px;
}

.dashboard-bar-inner {
    width: 100%;
}

.dashboard-toggle {
    width: 100%;
    min-height: 0;
    padding: 9px 16px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 600;
    border-radius: 12px;
}

.dashboard-chevron {
    width: 16px;
    height: 16px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2.5;
    stroke-linecap: round;
    stroke-linejoin: round;
    transition: transform 0.2s ease;
}

.dashboard-toggle[aria-expanded="true"] .dashboard-chevron {
    transform: rotate(180deg);
}

.dashboard-dropdown {
    margin-bottom: 20px;
    padding: 18px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 18px;
    box-shadow: 0 18px 60px rgba(0, 0, 0, 0.4);
}

.dashboard-dropdown.hidden {
    display: none;
}

.dashboard-dropdown .reports {
    margin-bottom: 0;
}

.reports {
    display: grid;
    grid-template-columns: repeat(4, minmax(180px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.report-card {
    background: rgba(255,255,255,0.08);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 18px;
    padding: 18px;
}

.report-card strong {
    display: block;
    font-size: 24px;
    margin-bottom: 8px;
    color: var(--surface-strong);
}

.report-card span {
    color: rgba(255,255,255,0.8);
    font-size: 14px;
}

.report-card-clickable {
    cursor: pointer;
    transition: transform 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.report-card-clickable:hover {
    transform: translateY(-2px);
    border-color: rgba(255, 255, 255, 0.28);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
}

.report-card-clickable:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

a.report-card {
    text-decoration: none;
    color: inherit;
    display: block;
}

.report-card-link {
    cursor: pointer;
    transition: transform 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.report-card-link:hover {
    transform: translateY(-2px);
    border-color: rgba(255, 255, 255, 0.28);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
}

.report-card-link:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.table-section {
    border-radius: 18px;
    padding: 14px 10px;
}

.table-pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px 20px;
    margin-top: 16px;
    padding-top: 14px;
    border-top: 1px solid var(--border);
}

.table-pagination.hidden {
    display: none;
}

.table-pagination-size {
    display: flex;
    align-items: center;
    gap: 10px;
}

.table-pagination-size label {
    font-size: 14px;
    color: var(--text-muted);
}

.table-pagination-size select {
    padding: 8px 12px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background-color: rgba(255, 255, 255, 0.08);
    color: var(--surface-strong);
    font-size: 14px;
}

.table-pagination-info {
    margin: 0;
    font-size: 14px;
    color: var(--text-muted);
    flex: 1 1 200px;
    text-align: center;
}

.table-pagination-nav {
    display: flex;
    gap: 8px;
}

.table-wrapper {
    overflow-x: hidden;
    position: relative;
    padding-bottom: 4px;
}

.table-wrapper::-webkit-scrollbar {
    height: 10px;
}

.table-wrapper::-webkit-scrollbar-track {
    background: #e8ecff;
    border-radius: 10px;
}

.table-wrapper::-webkit-scrollbar-thumb {
    background: rgba(64, 104, 255, 0.45);
    border-radius: 10px;
}

#horizontalScrollbar.hidden {
    display: none;
}

#tableScrollContent {
    height: 1px;
}

#practicesTable {
    width: 100%;
    max-width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
    min-width: 0;
}

#practicesTable col.col-open { width: 4%; }
#practicesTable col.col-practice { width: 5%; }
#practicesTable col.col-company { width: 12%; }
#practicesTable col.col-activity { width: 6%; }
#practicesTable col.col-type { width: 5%; }
#practicesTable col.col-amount { width: 5%; }
#practicesTable col.col-status { width: 9%; }
#practicesTable col.col-result { width: 12%; }
#practicesTable col.col-response { width: 8%; }
#practicesTable col.col-due { width: 7%; }
#practicesTable col.col-payment { width: 8%; }
#practicesTable col.col-notes { width: 14%; }
#practicesTable col.col-actions { width: 5%; }

#practicesTable th,
#practicesTable td {
    padding: 8px 6px;
    border-bottom: 1px solid #d1d9ff;
    vertical-align: top;
    color: var(--text);
    word-wrap: break-word;
    overflow-wrap: break-word;
    white-space: normal;
    min-width: 0;
}

#practicesTable td {
    background: transparent;
}

#practicesTable select:not(.status-select),
#practicesTable input,
#practicesTable textarea {
    width: 100%;
    min-width: 0;
    box-sizing: border-box;
    padding: 6px 8px;
    border-radius: 8px;
    border: 1px solid #c7d2fe;
    background: #ffffff;
    color: #1f2937;
}

#practicesTable select {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-image: none;
}

#practicesTable .icon-button,
#practicesTable .icon-open {
    width: 28px;
    height: 28px;
    padding: 0;
    border-radius: 8px;
    font-size: 13px;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 28px;
}

#practicesTable .icon-open {
    padding: 0;
}

#practicesTable td.action-buttons {
    vertical-align: top;
}

#practicesTable .action-buttons {
    /* deprecated - kept for backward compatibility */
}

#practicesTable .action-buttons-inner {
    display: flex;
    gap: 4px;
    align-items: center;
    justify-content: center;
    height: 100%;
    min-height: 28px;
}

#practicesTable textarea {
    resize: vertical;
    min-height: 40px;
}

#practicesTable td {
    font-size: 12px;
}

#practicesTable .status-select,
#practicesTable .result-select,
#practicesTable .type-select,
#practicesTable .date-input,
#practicesTable .month-input,
#practicesTable .note-input {
    font-size: 12px;
}

#practicesTable .status-select {
    min-width: 0;
    width: 100%;
    max-width: 100%;
    padding: 6px 8px;
    font-size: 12px;
    font-weight: 400;
    border-radius: 8px;
    color: var(--surface-strong);
    border: 1px solid rgba(255, 255, 255, 0.22);
    -webkit-text-fill-color: currentColor;
}

#practicesTable .result-select {
    min-width: 0;
    width: 100%;
    padding: 5px 6px;
}

.type-cell {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}

#practicesTable .type-select {
    min-width: 0;
    width: 100%;
    padding: 5px 6px;
    font-size: 11px;
}

#practicesTable .type-other-input {
    min-width: 0;
    width: 100%;
    padding: 5px 5px;
    font-size: 11px;
    border: 1px solid #c7d2fe;
    background: #ffffff;
    color: #1f2937;
}

.type-other-input {
    width: 100%;
    min-width: 0;
    box-sizing: border-box;
    padding: 6px 8px;
    border-radius: 8px;
    border: 1px solid #24345f;
    background: #0f1631;
    color: var(--text);
    font-size: 13px;
}

.type-other-field {
    margin-top: 8px;
}

#practicesTable th {
    text-align: left;
    background: linear-gradient(180deg, rgba(255,255,255,0.08) 0%, rgba(255,255,255,0.04) 100%);
    color: var(--surface-strong);
    border-bottom-color: rgba(255,255,255,0.1);
    position: sticky;
    top: 0;
    z-index: 10;
    font-weight: 700;
    font-size: 11px;
    line-height: 1.15;
    vertical-align: top;
}

.th-line {
    display: block;
    grid-column: 1;
}

.th-static {
    vertical-align: top;
}

.sort-button {
    all: unset;
    box-sizing: border-box;
    display: inline-grid;
    grid-template-columns: auto auto;
    column-gap: 3px;
    align-items: center;
    width: max-content;
    max-width: 100%;
    cursor: pointer;
    font: inherit;
    font-weight: 700;
    font-size: 11px;
    line-height: 1.15;
    color: inherit;
    text-align: left;
}

.sort-button::after {
    content: '↕';
    opacity: 0.35;
    font-size: 10px;
    line-height: 1;
    grid-column: 2;
    grid-row: 1 / -1;
    align-self: center;
}

.sort-button.sort-asc::after {
    content: '↑';
    opacity: 1;
}

.sort-button.sort-desc::after {
    content: '↓';
    opacity: 1;
}

.sort-button:hover,
.sort-button:focus-visible {
    color: var(--primary);
    outline: none;
}

#practicesTable tr:hover {
    background: rgba(64, 104, 255, 0.08);
}

#practicesTable .date-input,
#practicesTable .month-input {
    padding: 5px 4px;
}

#practicesTable textarea.note-input {
    min-height: 36px;
    max-height: none;
    padding: 5px 4px;
    overflow: visible;
    field-sizing: content;
}

.activity-cell {
    font-size: 11px;
    line-height: 1.25;
}

.amount-cell {
    white-space: nowrap;
}

#practicesTable .status-select,
#practicesTable .result-select,
#practicesTable .type-select {
    overflow: visible;
    text-overflow: clip;
    white-space: normal;
}

.amount-stack {
    display: flex;
    flex-direction: column;
    gap: 3px;
    line-height: 1.25;
}

.activity-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.activity-list li,
.activity-item {
    display: block;
    white-space: nowrap;
}

.status-select {
    min-width: 170px;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    width: auto;
    padding: 10px 14px;
    border-radius: 999px;
    border: 2px solid var(--border);
    background-color: #0f1631;
    color: #f3f6ff;
    background-image: none;
    cursor: pointer;
    transition: background-color 0.15s ease, border-color 0.15s ease;
    font-weight: 400;
}

.status-select option,
#status option {
    padding: 10px 12px;
    font-weight: 400;
}

/* Colori stato nel form modifica (#status) */
#status.status-Aperta { background: rgba(94, 127, 221, 0.45); border-color: rgba(94, 127, 221, 1); color: #e4ecff; }
#status.status-Chiusa { background: rgba(128, 224, 149, 0.45); border-color: rgba(110, 198, 111, 1); color: #eaffef; }
#status.status-Alla-firma { background: rgba(136, 180, 255, 0.45); border-color: rgba(95, 141, 255, 1); color: #eaf4ff; }
#status.status-In-attesa-integrazione { background: rgba(255, 158, 76, 0.55); border-color: rgba(255, 137, 47, 1); color: #fff4e8; }

#status option[value="Aperta"] { background: rgba(94, 127, 221, 0.28); color: #e4ecff; }
#status option[value="Chiusa"] { background: rgba(128, 224, 149, 0.28); color: #0f3a14; }
#status option[value="Alla firma"] { background: rgba(136, 180, 255, 0.28); color: #072f6d; }
#status option[value="In attesa integrazione"] { background: rgba(255, 158, 76, 0.28); color: #5d2f00; }

#status.status-Aperta:hover { background: rgba(94, 127, 221, 0.55); border-color: #8fb5ff; }
#status.status-Chiusa:hover { background: rgba(128, 224, 149, 0.55); border-color: #4ade80; }
#status.status-Alla-firma:hover { background: rgba(136, 180, 255, 0.55); border-color: #93c5fd; }
#status.status-In-attesa-integrazione:hover { background: rgba(255, 158, 76, 0.65); border-color: #fb923c; }

#status.status-Aperta:focus { outline: none; box-shadow: 0 0 0 2px rgba(94, 127, 221, 0.45); }
#status.status-Chiusa:focus { outline: none; box-shadow: 0 0 0 2px rgba(70, 160, 100, 0.4); }
#status.status-Alla-firma:focus { outline: none; box-shadow: 0 0 0 2px rgba(80, 130, 200, 0.4); }
#status.status-In-attesa-integrazione:focus { outline: none; box-shadow: 0 0 0 2px rgba(200, 120, 50, 0.4); }

/* Tabella: sfondo stato = stesso colore della riga */
#practicesTable tr.status-Aperta .status-select {
    background-color: rgba(94, 127, 221, 0.18);
}

#practicesTable tr.status-Chiusa .status-select {
    background-color: rgba(128, 224, 149, 0.18);
}

#practicesTable tr.status-Alla-firma .status-select {
    background-color: rgba(136, 180, 255, 0.18);
}

#practicesTable tr.status-In-attesa-integrazione .status-select {
    background-color: rgba(255, 158, 76, 0.25);
}

#practicesTable tr.status-Aperta .status-select:hover,
#practicesTable tr.status-Aperta .status-select:focus {
    background-color: rgba(94, 127, 221, 0.3);
    border-color: rgba(143, 181, 255, 0.55);
    outline: none;
    box-shadow: none;
}

#practicesTable tr.status-Chiusa .status-select:hover,
#practicesTable tr.status-Chiusa .status-select:focus {
    background-color: rgba(128, 224, 149, 0.3);
    border-color: rgba(160, 240, 180, 0.55);
    outline: none;
    box-shadow: none;
}

#practicesTable tr.status-Alla-firma .status-select:hover,
#practicesTable tr.status-Alla-firma .status-select:focus {
    background-color: rgba(136, 180, 255, 0.3);
    border-color: rgba(170, 205, 255, 0.55);
    outline: none;
    box-shadow: none;
}

#practicesTable tr.status-In-attesa-integrazione .status-select:hover,
#practicesTable tr.status-In-attesa-integrazione .status-select:focus {
    background-color: rgba(255, 158, 76, 0.38);
    border-color: rgba(255, 190, 120, 0.55);
    outline: none;
    box-shadow: none;
}

#practicesTable .status-select option {
    background-color: #11192f;
    color: var(--surface-strong);
}

#horizontalScrollbar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    height: 14px;
    overflow-x: auto;
    overflow-y: hidden;
    background: rgba(255,255,255,0.98);
    z-index: 60;
    border-top: 2px solid rgba(64, 104, 255, 0.2);
    box-shadow: 0 -2px 8px rgba(0,0,0,0.05);
}

#horizontalScrollbar::-webkit-scrollbar {
    height: 12px;
}

#horizontalScrollbar::-webkit-scrollbar-track {
    background: transparent;
}

#horizontalScrollbar::-webkit-scrollbar-thumb {
    background: linear-gradient(135deg, rgba(64, 104, 255, 0.4), rgba(64, 104, 255, 0.5));
    border-radius: 10px;
    border: 2px solid rgba(255,255,255,0.98);
}

#horizontalScrollbar::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(135deg, rgba(64, 104, 255, 0.6), rgba(64, 104, 255, 0.7));
}

#horizontalScrollbar.hidden {
    display: none;
}

#tableScrollContent {
    width: 100%;
    height: 1px;
}

#horizontalScrollbar {
    background: rgba(17,25,47,0.98);
    border-top-color: rgba(64, 104, 255, 0.3);
}

#horizontalScrollbar::-webkit-scrollbar-thumb {
    background: linear-gradient(135deg, rgba(64, 104, 255, 0.5), rgba(64, 104, 255, 0.6));
    border-color: rgba(17,25,47,0.98);
}

#horizontalScrollbar::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(135deg, rgba(64, 104, 255, 0.7), rgba(64, 104, 255, 0.8));
}

#practicesTable tr.status-Aperta td {
    background-color: rgba(94, 127, 221, 0.18);
}

#practicesTable tr.status-Chiusa td {
    background-color: rgba(128, 224, 149, 0.18);
}

#practicesTable tr.status-Alla-firma td {
    background-color: rgba(136, 180, 255, 0.18);
}

#practicesTable tr.status-In-attesa-integrazione td {
    background-color: rgba(255, 158, 76, 0.25);
}

.row-overdue {
    border-left: 4px solid var(--danger);
}

/* Scaduta (oggi > scadenza): evidenzia la riga in rosso */
.row-overdue td {
    background-color: rgba(239, 68, 68, 0.28) !important;
}

#practicesTable tr.row-overdue .status-select {
    background-color: rgba(239, 68, 68, 0.28) !important;
    border-color: rgba(239, 68, 68, 0.9) !important;
    box-shadow: none;
}

#practicesTable tr.row-overdue .status-select:hover,
#practicesTable tr.row-overdue .status-select:focus {
    background-color: rgba(239, 68, 68, 0.38) !important;
}

.badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
}

.badge.Aperta { background: #ffd867; color: #6f5100; }
.badge.Chiusa { background: #b4f1bb; color: #1f530d; }
.badge.Alla-firma { background: #b5d9ff; color: #103f7a; }
.badge.In-attesa-integrazione { background: #ffd6b6; color: #6b3f06; }

.empty-message {
    margin-top: 18px;
    color: var(--text-muted);
}

.form-panel {
    position: fixed;
    right: 24px;
    top: 24px;
    width: min(560px, calc(100vw - 48px));
    max-height: calc(100vh - 48px);
    overflow-y: auto;
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 20px;
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.45);
    padding: 24px;
    z-index: 20;
}

.form-panel .form-header h2 {
    color: var(--surface-strong);
}

.form-panel .field-hint {
    color: var(--text-muted);
    font-size: 12px;
}

.practice-link {
    color: var(--surface-strong);
    text-decoration: none;
    font-weight: 600;
}

.practice-link:hover {
    color: #d8e0ff;
    text-decoration: underline;
}

.practice-detail-panel,
.practice-drive-panel,
.practice-page-panel {
    margin-bottom: 0;
}

.practice-page-content {
    display: flex;
    flex-direction: column;
    gap: 0;
    max-width: 100%;
    margin: 0;
    width: 100%;
}

.practice-page-stack {
    display: flex;
    flex-direction: column;
    gap: 16px;
    width: 100%;
}

.practice-page-stack .practice-page-panel {
    width: 100%;
    margin-bottom: 0;
}

.practice-summary-panel {
    margin-bottom: 0;
}

.practice-summary-panel .practice-section-title {
    margin-bottom: 16px;
}

.practice-drive-panel {
    display: flex;
    flex-direction: column;
    min-height: 320px;
}

.practice-drive-panel .drive-explorer-table-wrap {
    flex: 1;
    overflow: auto;
    max-height: min(65vh, 760px);
    width: 100%;
}

.practice-page-grid {
    display: grid;
    grid-template-columns: minmax(300px, 34%) minmax(0, 1fr);
    gap: 16px;
    align-items: stretch;
}

.practice-page-grid .practice-page-panel {
    margin-bottom: 0;
    height: 100%;
    min-height: 0;
}

.practice-drive-panel {
    display: flex;
    flex-direction: column;
    min-height: 420px;
}

.practice-drive-panel .drive-explorer-list {
    flex: 1;
    overflow: auto;
    max-height: min(70vh, 720px);
}

.practice-page-layout {
    display: block;
}

.practice-header-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin-right: 14px;
    font-size: 14px;
    color: var(--text-muted);
}

.practice-header-chip strong {
    color: var(--surface-strong);
    font-weight: 600;
}

.practice-header-chip-label {
    color: var(--text-muted);
}

#practiceSubtitle {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 0;
    align-items: center;
}

.practice-detail-fields {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0 18px;
}

.practice-field {
    display: grid;
    grid-template-columns: 110px minmax(0, 1fr);
    align-items: baseline;
    gap: 10px;
    padding: 7px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.practice-field-notes {
    grid-column: 1 / -1;
    grid-template-columns: 110px minmax(0, 1fr);
}

.practice-field-label {
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 600;
}

.practice-field-value {
    color: var(--surface-strong);
    text-align: left;
    word-break: break-word;
}

.practice-field-editable {
    display: grid;
    grid-template-columns: 1fr;
    gap: 6px;
    align-items: stretch;
    padding: 10px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.practice-field-editable:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.practice-field-editable .practice-field-label {
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--text-muted);
}

.practice-field-editable .practice-field-control {
    min-width: 0;
}

.practice-field-full {
    grid-column: 1 / -1;
}

.practice-field-overdue .practice-field-control .date-input {
    border-color: rgba(248, 113, 113, 0.65);
    background: rgba(248, 113, 113, 0.1);
}

.practice-overdue-value {
    color: #fca5a5;
    font-weight: 600;
}

.practice-detail-group .practice-field-control select:not(.status-select),
.practice-detail-group .practice-field-control .result-select,
.practice-detail-group .practice-field-control input,
.practice-detail-group .practice-field-control textarea,
.practice-notes-editor .note-input {
    width: 100%;
    min-width: 0;
    box-sizing: border-box;
    padding: 8px 10px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: rgba(12, 18, 38, 0.92);
    color: var(--text);
    font-size: 13px;
    font-family: inherit;
    color-scheme: dark;
    transition: border-color 0.15s ease, background-color 0.15s ease, box-shadow 0.15s ease;
}

.practice-detail-group .practice-field-control select:not(.status-select):hover,
.practice-detail-group .practice-field-control .result-select:hover,
.practice-detail-group .practice-field-control input:hover,
.practice-detail-group .practice-field-control textarea:hover,
.practice-notes-editor .note-input:hover {
    border-color: #3d5190;
    background: rgba(15, 22, 49, 0.98);
}

.practice-detail-group .practice-field-control select:not(.status-select):focus,
.practice-detail-group .practice-field-control .result-select:focus,
.practice-detail-group .practice-field-control input:focus,
.practice-detail-group .practice-field-control textarea:focus,
.practice-notes-editor .note-input:focus {
    outline: none;
    border-color: var(--primary);
    background: rgba(15, 22, 49, 1);
    box-shadow: 0 0 0 2px rgba(64, 104, 255, 0.22);
}

.practice-detail-group .practice-field-control select:not(.status-select) option {
    background: #11192f;
    color: var(--text);
}

.practice-detail-group .practice-field-control select {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-image: none;
}

.practice-detail-group .practice-type-cell {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.practice-detail-group .practice-type-cell .type-other-input.hidden {
    display: none;
}

.practice-notes-editor .note-input {
    flex: 1 1 auto;
    width: 100%;
    height: 100%;
    min-height: 0;
    resize: vertical;
    line-height: 1.45;
}

.practice-detail-group-notes {
    display: flex;
    flex-direction: column;
    min-height: 100%;
}

.practice-detail-group-notes .practice-group-title {
    flex: 0 0 auto;
}

.practice-detail-group-notes .practice-notes-editor {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.practice-summary-strip {
    display: grid;
    grid-template-columns: 1.35fr repeat(6, minmax(0, 1fr));
    gap: 12px;
    margin-bottom: 12px;
    align-items: stretch;
}

.practice-summary-strip-secondary {
    grid-template-columns: 1fr;
    margin-bottom: 16px;
}

.practice-summary-card-multiline .practice-summary-value {
    white-space: pre-line;
    font-size: 14px;
    line-height: 1.45;
}

.drive-explorer-table-wrap {
    width: 100%;
    overflow-x: auto;
}

.drive-explorer-table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
}

.drive-explorer-table thead th {
    position: sticky;
    top: 0;
    z-index: 1;
    background: rgba(20, 24, 36, 0.98);
    color: var(--text-muted);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    text-align: left;
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
}

.drive-explorer-row td {
    padding: 10px 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    vertical-align: middle;
}

.drive-explorer-row.is-folder {
    background: rgba(64, 104, 255, 0.06);
}

.drive-explorer-row:hover {
    background: rgba(255, 255, 255, 0.04);
}

.drive-col-icon {
    width: 52px;
}

.drive-col-name {
    width: 44%;
}

.drive-col-size {
    width: 12%;
    color: var(--text-muted);
    font-size: 13px;
}

.drive-col-date {
    width: 18%;
    color: var(--text-muted);
    font-size: 13px;
}

.drive-col-actions {
    width: 180px;
    text-align: right;
}

.drive-explorer-open-folder {
    background: none;
    border: none;
    color: var(--surface-strong);
    font-weight: 600;
    cursor: pointer;
    padding: 0;
    text-align: left;
    font: inherit;
    word-break: break-word;
}

.drive-explorer-open-folder:hover {
    color: #d8e0ff;
}

.drive-file-type-icon.tone-folder { color: #fbbf24; background: rgba(251, 191, 36, 0.12); }
.drive-file-type-icon.tone-pdf { color: #f87171; background: rgba(248, 113, 113, 0.12); }
.drive-file-type-icon.tone-word { color: #60a5fa; background: rgba(96, 165, 250, 0.12); }
.drive-file-type-icon.tone-excel { color: #4ade80; background: rgba(74, 222, 128, 0.12); }
.drive-file-type-icon.tone-image { color: #c084fc; background: rgba(192, 132, 252, 0.12); }
.drive-file-type-icon.tone-slides { color: #fb923c; background: rgba(251, 146, 60, 0.12); }
.drive-file-type-icon.tone-file { color: #94a3b8; background: rgba(148, 163, 184, 0.12); }

.drive-file-type-icon svg text {
    font-family: inherit;
}

.practice-summary-card {
    display: flex;
    flex-direction: column;
    height: 100%;
    box-sizing: border-box;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 12px 14px;
    min-width: 0;
}

.practice-summary-card-wide {
    grid-column: auto;
}

.practice-drive-toolbar .practice-drive-tool-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 38px;
    padding: 10px 14px;
    font-size: 13px;
    border-radius: 10px;
    text-decoration: none;
    box-sizing: border-box;
    white-space: nowrap;
    cursor: pointer;
}

.practice-summary-label {
    display: block;
    flex: 0 0 auto;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.practice-summary-value {
    display: block;
    flex: 1 1 auto;
    color: var(--surface-strong);
    font-size: 15px;
    line-height: 1.35;
    word-break: break-word;
}

.practice-detail-groups {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
    align-items: stretch;
}

.practice-detail-group {
    display: flex;
    flex-direction: column;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 14px 16px;
    min-height: 100%;
}

.practice-group-title {
    margin: 0 0 12px;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--text-muted);
}

.practice-detail-group .practice-field {
    display: grid;
    grid-template-columns: minmax(100px, 38%) 1fr;
    align-items: baseline;
    gap: 10px 12px;
    padding: 10px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.practice-detail-group .practice-field-editable {
    grid-template-columns: 1fr;
    align-items: stretch;
    gap: 6px;
}

.practice-detail-group .practice-field:last-child,
.practice-detail-group .practice-field-editable:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.practice-detail-group .practice-field-label {
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 600;
}

.practice-detail-group .practice-field-value {
    color: var(--surface-strong);
    text-align: right;
    word-break: break-word;
}

.practice-detail-group .practice-field-value-multiline {
    white-space: pre-line;
    text-align: right;
    line-height: 1.45;
}

.practice-field {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    padding: 8px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.practice-field:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.practice-field-label {
    flex: 0 0 42%;
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 600;
}

.practice-field-value {
    flex: 1;
    color: var(--surface-strong);
    text-align: right;
    word-break: break-word;
}

.practice-notes-text,
.practice-notes-empty {
    margin: 0;
    color: var(--surface-strong);
    line-height: 1.5;
    white-space: pre-wrap;
}

.practice-notes-empty {
    color: var(--text-muted);
    font-style: italic;
}

.practice-section-title {
    color: var(--surface-strong);
    font-size: 20px;
    margin: 0;
}

.practice-drive-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 12px;
}

.practice-drive-toolbar {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    align-items: center;
}

.status-pill {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 13px;
    font-weight: 600;
    border: 1px solid transparent;
}

.drive-breadcrumb {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px;
    margin-bottom: 12px;
    font-size: 13px;
}

.drive-crumb-link {
    background: none;
    border: none;
    color: #b8c7ff;
    cursor: pointer;
    padding: 2px 4px;
    border-radius: 6px;
    font: inherit;
}

.drive-crumb-link:hover {
    background: rgba(255, 255, 255, 0.08);
    color: #e4ecff;
}

.drive-crumb-current {
    color: var(--surface-strong);
    font-weight: 600;
}

.drive-crumb-sep {
    color: var(--text-muted);
}

.drive-contents-status {
    margin-bottom: 12px;
}

.drive-explorer-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.drive-explorer-item {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid var(--border);
}

.drive-explorer-item.is-folder {
    background: rgba(64, 104, 255, 0.08);
}

.drive-explorer-main,
.drive-explorer-open-folder {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.drive-explorer-open-folder {
    width: 100%;
    color: var(--surface-strong);
    text-decoration: none;
    font-weight: 600;
    background: none;
    border: none;
    cursor: pointer;
    font: inherit;
    text-align: left;
    padding: 0;
}

.drive-file-type-icon {
    flex: 0 0 28px;
    width: 28px;
    height: 28px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.08);
    color: #d8e0ff;
}

.drive-file-type-icon svg {
    width: 18px;
    height: 18px;
    display: block;
    flex-shrink: 0;
}

.drive-file-type-icon svg path[fill="currentColor"] {
    fill: currentColor;
}

.drive-file-type-icon svg text {
    fill: currentColor;
}

.drive-file-type-icon svg text[fill="#fff"] {
    fill: #fff;
}

.drive-file-type-icon svg path[fill="none"],
.drive-file-type-icon svg rect[fill="none"] {
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.drive-file-type-icon svg circle[fill="currentColor"] {
    fill: currentColor;
    stroke: none;
}

.drive-file-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.drive-item-name {
    color: var(--surface-strong);
    font-weight: 600;
    word-break: break-word;
}

.drive-explorer-open-folder:hover,
.drive-explorer-open-folder:hover .drive-item-name {
    color: #d8e0ff;
}

.drive-file-actions {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
}

.drive-action-btn {
    width: 32px;
    height: 32px;
    min-width: 32px;
    padding: 0;
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    flex-shrink: 0;
    color: #d8e0ff;
    background-color: var(--secondary);
    border: 1px solid var(--border);
    text-decoration: none;
}

.drive-action-btn svg {
    width: 18px;
    height: 18px;
    display: block;
    flex-shrink: 0;
    pointer-events: none;
}

.drive-action-btn svg path {
    fill: currentColor;
}

.drive-action-btn:hover {
    color: #101623;
    background-color: #d8e0ff;
    border-color: #c7d3ff;
}

.drive-explorer-link {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    color: var(--surface-strong);
    text-decoration: none;
    font-weight: 600;
}

.drive-explorer-link:hover {
    color: #d8e0ff;
}

.practice-linked-title {
    color: var(--surface-strong);
    font-size: 16px;
    margin: 18px 0 10px;
}

.practice-detail-panel,
.practice-drive-panel {
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 18px;
    padding: 24px 28px;
    box-shadow: 0 18px 60px rgba(0, 0, 0, 0.4);
    margin-bottom: 20px;
}

.practice-detail-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px 24px;
    margin-bottom: 20px;
}

.practice-detail-row {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.practice-detail-label {
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 600;
}

.practice-detail-value {
    color: var(--surface-strong);
    white-space: pre-wrap;
}

.practice-detail-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.status-pill.status-Aperta { background: rgba(94, 127, 221, 0.35); color: #e4ecff; }
.status-pill.status-Chiusa { background: rgba(34, 197, 94, 0.2); color: #bbf7d0; }
.status-pill.status-Alla-firma { background: rgba(255, 184, 77, 0.2); color: #ffe8c2; }
.status-pill.status-In-attesa-integrazione { background: rgba(239, 68, 68, 0.2); color: #fecaca; }

.practice-drive-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 12px;
}

.practice-drive-header h2 {
    color: var(--surface-strong);
    font-size: 20px;
}

.drive-contents-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.drive-contents-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 14px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid var(--border);
}

.drive-contents-link {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    color: var(--surface-strong);
    text-decoration: none;
    font-weight: 600;
}

.drive-contents-link:hover {
    color: #d8e0ff;
}

.drive-item-meta {
    font-size: 12px;
    color: var(--text-muted);
    white-space: nowrap;
}

.practice-linked-docs {
    margin-top: 18px;
}

.practice-linked-docs h3 {
    color: var(--surface-strong);
    font-size: 16px;
    margin-bottom: 10px;
}

.settings-page-panel {
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 18px;
    padding: 28px 32px;
    box-shadow: 0 18px 60px rgba(0, 0, 0, 0.4);
    max-width: 920px;
    margin: 0 auto;
}

.settings-page-panel .field-hint {
    color: var(--text-muted);
    font-size: 12px;
}

.settings-page-panel .field-label {
    color: var(--surface-strong);
}

.drive-config-diagnostics {
    margin: 0 auto 18px;
    padding: 14px 16px;
    border-radius: 12px;
    background: rgba(239, 68, 68, 0.12);
    border: 1px solid rgba(239, 68, 68, 0.35);
    color: #fecaca;
    font-size: 14px;
    line-height: 1.5;
    max-width: 920px;
}

.drive-config-diagnostics.hidden {
    display: none;
}

.drive-setup-banner {
    margin: 0 auto 18px;
    padding: 14px 16px;
    border-radius: 12px;
    background: rgba(64, 104, 255, 0.12);
    border: 1px solid rgba(64, 104, 255, 0.28);
    color: var(--text);
    font-size: 14px;
    line-height: 1.45;
    max-width: 920px;
}

.drive-setup-banner.hidden {
    display: none;
}

.settings-drive-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    margin-top: 12px;
}

.settings-drive-actions button {
    width: 100%;
}

.settings-section-title {
    color: var(--surface-strong);
    font-size: 18px;
    margin: 0 0 12px;
}

.local-installer-panel {
    margin-bottom: 16px;
}

.local-installer-status {
    margin: 0 0 10px;
    padding: 10px 12px;
    border-radius: 10px;
    border: 1px solid var(--border);
    font-size: 14px;
}

.local-installer-status.is-ok {
    background: rgba(46, 160, 67, 0.12);
    border-color: rgba(46, 160, 67, 0.35);
    color: #8fd19e;
}

.local-installer-status.is-missing {
    background: rgba(210, 153, 34, 0.12);
    border-color: rgba(210, 153, 34, 0.35);
    color: #f0cf7b;
}

.local-installer-status.is-unknown {
    background: rgba(255, 255, 255, 0.04);
    color: var(--text-muted);
}

.local-installer-actions {
    margin-bottom: 12px;
}

.local-installer-steps {
    margin: 0;
    padding-left: 1.2rem;
    color: var(--text-muted);
    font-size: 13px;
    line-height: 1.5;
}

.local-installer-steps li + li {
    margin-top: 6px;
}

.local-installer-form-actions {
    margin-top: 10px;
}

.inline-link {
    color: #8eb4ff;
    text-decoration: underline;
}

.inline-link:hover {
    color: #b8d0ff;
}

.form-cancel-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    padding: 12px 18px;
    text-decoration: none;
}

.settings-overlay {
    position: fixed;
    inset: 0;
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 28px;
}

.settings-overlay.hidden {
    display: none;
}

.settings-overlay-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(8, 13, 31, 0.72);
    backdrop-filter: blur(4px);
}

.settings-panel {
    position: relative;
    z-index: 1;
    width: min(920px, 100%);
    max-height: calc(100vh - 56px);
    overflow-y: auto;
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 20px;
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.45);
    padding: 28px 32px;
}

.settings-panel .form-header {
    margin-bottom: 22px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border);
}

.settings-panel .form-header h2 {
    color: var(--surface-strong);
    font-size: 26px;
}

.settings-panel .close-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    padding: 0;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--secondary);
    color: var(--surface-strong);
    font-size: 24px;
}

.settings-panel .close-button:hover {
    background: #d8e0ff;
    color: #101623;
    border-color: #c7d3ff;
}

.settings-panel .field-hint {
    color: var(--text-muted);
    font-size: 12px;
}

.settings-panel .field-label {
    color: var(--surface-strong);
}

.settings-panel .checkbox-row {
    color: var(--text);
}

body.settings-open {
    overflow: hidden;
}

#importFile.hidden,
#restoreFile.hidden {
    display: block;
    position: absolute;
    left: -9999px;
    width: 1px;
    height: 1px;
    opacity: 0;
    overflow: hidden;
}

.hidden {
    display: none;
}

.form-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 18px;
}

.close-button {
    background: transparent;
    color: var(--primary);
    font-size: 26px;
    line-height: 1;
}

.field-hint {
    margin-top: 6px;
    font-size: 12px;
    color: var(--text-muted);
    line-height: 1.4;
}

.app-modal {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.app-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(8, 13, 31, 0.55);
    backdrop-filter: blur(2px);
}

.app-modal-content {
    position: relative;
    z-index: 1;
    max-width: 420px;
    width: 100%;
    background: var(--surface);
    color: var(--text);
    border-radius: 18px;
    padding: 22px 24px;
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.45);
}

.app-modal-content h3 {
    font-size: 18px;
    margin-bottom: 10px;
    color: var(--surface-strong);
}

.app-modal-content p {
    font-size: 14px;
    line-height: 1.5;
    margin-bottom: 18px;
    color: var(--text-muted);
}

.modal-extra {
    margin-bottom: 14px;
}

.modal-extra.hidden {
    display: none;
}

.modal-text-input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #334155;
    border-radius: 8px;
    font-size: 14px;
    box-sizing: border-box;
    background: #0f172a;
    color: var(--text);
}

.modal-folder-setup {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.modal-field-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
}

.modal-field-hint {
    font-size: 12px;
    color: var(--text-muted);
    margin: 0;
}

.modal-browse-row {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.modal-file-list {
    list-style: none;
    margin: 0;
    padding: 8px 10px;
    max-height: 140px;
    overflow-y: auto;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    background: #f9fafb;
}

.modal-file-list li {
    font-size: 13px;
    padding: 4px 0;
    word-break: break-all;
}

.modal-file-item {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 8px;
}

.modal-file-name {
    flex: 1;
    min-width: 0;
    word-break: break-all;
}

.modal-file-remove {
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    padding: 0;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: #6b7280;
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
}

.modal-file-remove:hover {
    background: #fee2e2;
    color: #b91c1c;
}

.modal-file-remove:hover {
    background: #450a0a;
    color: #fca5a5;
}

.modal-file-empty {
    color: #9ca3af;
    font-style: italic;
}

.modal-field-label {
    color: var(--text);
}

.modal-field-hint {
    color: var(--text-muted);
}

.modal-file-list {
    background: #0f172a;
    border-color: #334155;
}

.modal-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    flex-wrap: wrap;
}

.form-row {
    margin-bottom: 14px;
}

.form-row.split {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
}

.activities-field {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.activities-container {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.activity-row {
    display: flex;
    align-items: flex-start;
    gap: 8px;
}

.activity-combobox {
    position: relative;
    flex: 1;
}

.activity-input {
    width: 100%;
}

.activity-suggestions {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    z-index: 30;
    max-height: 240px;
    overflow-y: auto;
    margin: 0;
    padding: 6px 0;
    list-style: none;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: #1a1f3d;
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.35);
}

.activity-suggestions li {
    padding: 10px 12px;
    cursor: pointer;
    color: #e8ebff;
    line-height: 1.35;
}

.activity-suggestions li strong {
    display: inline-block;
    min-width: 58px;
    margin-right: 8px;
}

.activity-suggestions li span {
    color: #a9b0d9;
    font-size: 0.92rem;
}

.activity-suggestions li:hover,
.activity-suggestions li.active {
    background: rgba(255, 255, 255, 0.1);
}

.activity-remove {
    flex: 0 0 auto;
    min-width: 40px;
    padding-inline: 10px;
}

.add-activity-btn {
    align-self: flex-start;
    min-width: 44px;
    font-size: 1.25rem;
    line-height: 1;
    padding: 8px 14px;
}

.field-hint {
    margin: 6px 0 0;
    font-size: 0.82rem;
    color: #b45309;
}

.field-hint {
    color: #fbbf24;
}

.label-group {
    display: flex;
    flex-direction: column;
}

label {
    display: block;
    margin-bottom: 6px;
    color: var(--text-muted);
    font-weight: 600;
}

input,
select,
textarea {
    width: 100%;
    padding: 12px 14px;
    border-radius: 12px;
    border: 1px solid var(--border);
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

select:not(.status-select) {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-image: none;
    cursor: pointer;
    transition: background-color 0.15s ease, border-color 0.15s ease;
}

select:not(.status-select):hover {
    background-color: #141d3a;
    border-color: #3d5288;
}

select:not(.status-select):focus {
    outline: none;
    background-color: #18244a;
    border-color: #4a6199;
    box-shadow: 0 0 0 2px rgba(74, 97, 153, 0.35);
}

textarea {
    resize: vertical;
}

.notes-preview {
    white-space: pre-wrap;
}

.form-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 10px;
}

.settings-data-actions {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
}

.settings-data-actions button {
    width: 100%;
}

.field-label {
    display: block;
    font-weight: 600;
    margin-bottom: 8px;
}

.checkbox-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
    font-weight: normal;
}

.checkbox-row input {
    width: auto;
}

.sync-status {
    margin-top: 8px;
    font-size: 13px;
    color: var(--text-muted);
}

.sync-status-synced {
    color: #22c55e;
}

.sync-status-saving {
    color: #ffb84d;
}

.sync-status-error,
.sync-status-offline {
    color: #ef4444;
}

.folder-server-banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 16px;
    padding: 12px 16px;
    border-radius: 12px;
    background: rgba(255, 184, 77, 0.15);
    border: 1px solid rgba(255, 184, 77, 0.35);
    color: #ffe8c4;
    font-size: 14px;
}

.folder-server-banner.hidden {
    display: none;
}

.action-link {
    color: var(--primary);
    text-decoration: none;
}

.documents-list {
    display: grid;
    gap: 10px;
    margin-bottom: 10px;
}

.document-item {
    display: grid;
    grid-template-columns: 1fr 1fr auto;
    gap: 10px;
    align-items: center;
}

.document-item input {
    border-radius: 10px;
}

.document-item button {
    min-width: 120px;
}

.small {
    padding: 10px 14px;
    font-size: 13px;
}

.hidden {
    display: none;
}

.stats-panel {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 18px;
    padding: 20px;
    margin-bottom: 24px;
}

.stats-panel h2 {
    color: var(--surface-strong);
    font-size: 20px;
    margin-bottom: 16px;
}

.stats-filters {
    display: grid;
    grid-template-columns: repeat(5, minmax(140px, 1fr));
    gap: 14px;
    align-items: end;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.filter-group label {
    color: var(--text-muted);
    font-size: 13px;
    font-weight: 600;
}

.filter-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.period-summary {
    margin-top: 14px;
    color: var(--text-muted);
    font-size: 14px;
}

.charts-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(280px, 1fr));
    gap: 18px;
    margin-bottom: 24px;
}

.chart-card {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 18px;
    padding: 18px;
}

.chart-card h3 {
    color: var(--surface-strong);
    font-size: 18px;
    margin-bottom: 6px;
}

.chart-caption {
    color: var(--text-muted);
    font-size: 13px;
    margin-bottom: 14px;
    line-height: 1.4;
}

.chart-wrap {
    position: relative;
    height: 280px;
}

.stats-table-section {
    margin-top: 0;
}

#activityTable {
    width: 100%;
    border-collapse: collapse;
}

#activityTable th,
#activityTable td {
    padding: 12px 10px;
    border-bottom: 1px solid var(--border);
    text-align: left;
    color: var(--text);
}

#activityTable th {
    background: rgba(255, 255, 255, 0.06);
    color: var(--surface-strong);
}

@media (max-width: 1100px) {
    .practice-page-grid {
        grid-template-columns: 1fr;
    }

    .practice-summary-strip {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .practice-summary-card-wide {
        grid-column: auto;
    }

    .practice-detail-groups {
        grid-template-columns: 1fr 1fr;
    }

    .practice-detail-group-notes {
        grid-column: span 2;
    }

    .drive-col-date {
        display: none;
    }

    .drive-explorer-table thead .drive-col-date {
        display: none;
    }
}

@media (max-width: 960px) {
    .practice-summary-strip {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .practice-detail-groups {
        grid-template-columns: 1fr;
    }

    .practice-detail-group-notes {
        grid-column: span 1;
    }

    .drive-explorer-item {
        grid-template-columns: 1fr;
        gap: 8px;
    }

    .drive-file-actions {
        justify-content: flex-end;
        flex-wrap: wrap;
    }

    .practice-detail-grid {
        grid-template-columns: 1fr;
    }

    .drive-contents-item {
        flex-direction: column;
        align-items: flex-start;
    }

    .settings-drive-actions {
        grid-template-columns: 1fr;
    }

    .settings-page-panel {
        padding: 20px 18px;
    }

    .settings-overlay {
        padding: 12px;
    }

    .settings-panel {
        padding: 20px 18px;
        max-height: calc(100vh - 24px);
    }

    .settings-data-actions {
        grid-template-columns: 1fr 1fr;
    }

    .table-pagination {
        flex-direction: column;
        align-items: stretch;
    }

    .table-pagination-info {
        text-align: left;
    }

    .table-pagination-nav {
        justify-content: stretch;
    }

    .table-pagination-nav button {
        flex: 1;
    }

    .controls,
    .form-row.split,
    .filters,
    .dashboard-dropdown .reports,
    .reports,
    .document-item,
    .stats-filters,
    .charts-grid {
        flex-direction: column;
        display: flex;
    }

    .header-actions {
        grid-template-columns: repeat(2, 1fr);
        width: 100%;
    }

    body.practice-page-view .practice-header-actions {
        width: auto;
        margin-left: auto;
    }

    .header-actions-single {
        grid-template-columns: 1fr;
        width: 100%;
    }

    .header-history-btn {
        width: 100%;
    }

    .stats-filters {
        display: flex;
    }

    .charts-grid {
        grid-template-columns: 1fr;
    }

    .form-panel {
        position: static;
        width: 100%;
        max-height: none;
    }

    .document-item {
        grid-template-columns: 1fr;
    }
}

/* --- Telefono e tablet stretti --- */
@media (max-width: 768px) {
    body {
        padding: 0 0 max(24px, env(safe-area-inset-bottom));
        overflow-x: hidden;
    }

    .app-shell {
        width: 100%;
        max-width: 100%;
        margin: 0;
        padding:
            max(8px, env(safe-area-inset-top))
            max(6px, env(safe-area-inset-right))
            12px
            max(6px, env(safe-area-inset-left));
    }

    .app-header {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
        margin-bottom: 14px;
    }

    .app-header h1 {
        font-size: clamp(20px, 5.5vw, 28px);
        line-height: 1.2;
    }

    .subtitle {
        font-size: 13px;
    }

    .header-actions {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        width: 100%;
    }

    .header-action-btn {
        min-height: 42px;
        font-size: 13px;
        padding: 10px 12px;
    }

    .dashboard-bar,
    .controls,
    .table-section,
    .dashboard-dropdown,
    .folder-server-banner {
        width: 100%;
        max-width: 100%;
    }

    .dashboard-dropdown {
        padding: 14px 10px;
        border-radius: 12px;
    }

    .controls {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
        margin-bottom: 14px;
    }

    .filters {
        flex-direction: row;
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        padding-bottom: 4px;
        gap: 8px;
        width: 100%;
    }

    .filters::-webkit-scrollbar {
        display: none;
    }

    .filter-button {
        flex: 0 0 auto;
        white-space: nowrap;
        padding: 10px 14px;
        font-size: 13px;
    }

    .search-box {
        width: 100%;
    }

    .search-box input {
        width: 100%;
        min-width: 0;
        box-sizing: border-box;
    }

    .table-section {
        padding: 10px 8px 12px;
        border-radius: 12px;
    }

    .table-wrapper {
        width: 100%;
        overflow-x: hidden;
        margin: 0;
        padding: 0;
    }

    #practicesTable .practice-link {
        display: inline-block;
        padding: 4px 2px;
        font-size: 14px;
        font-weight: 700;
    }

    #practicesTable .icon-button,
    #practicesTable .icon-open {
        width: 34px;
        height: 34px;
        min-width: 34px;
    }

    #practicesTable select,
    #practicesTable input,
    #practicesTable textarea {
        font-size: 14px;
        padding: 8px 6px;
    }

    .table-pagination {
        gap: 10px;
    }

    .reports {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 8px;
    }

    .report-card {
        padding: 12px 10px;
    }

    .report-card strong {
        font-size: 20px;
    }

    /* Pagina pratica */
    body.practice-page-view {
        padding: 0 0 max(20px, env(safe-area-inset-bottom));
    }

    body.practice-page-view .app-shell {
        padding:
            max(8px, env(safe-area-inset-top))
            max(4px, env(safe-area-inset-right))
            10px
            max(4px, env(safe-area-inset-left));
    }

    body.practice-page-view .practice-page-content,
    body.practice-page-view .practice-page-stack {
        width: 100%;
        max-width: 100%;
    }

    body.practice-page-view .app-header {
        flex-direction: row;
        flex-wrap: wrap;
        align-items: flex-start;
        gap: 8px;
        margin-bottom: 12px;
    }

    body.practice-page-view .app-header > div:first-child {
        flex: 1 1 140px;
        min-width: 0;
    }

    body.practice-page-view .app-header h1 {
        font-size: clamp(18px, 5vw, 26px);
    }

    body.practice-page-view .practice-header-actions {
        flex: 0 0 auto;
        margin-left: auto;
        gap: 6px;
    }

    body.practice-page-view .practice-header-actions .header-action-btn {
        min-width: 0;
        width: auto;
        padding: 9px 10px;
        font-size: 12px;
        min-height: 38px;
    }

    body.practice-page-view .settings-page-panel {
        width: 100%;
        max-width: 100%;
        padding: 12px 8px;
        border-radius: 12px;
        margin-left: 0;
        margin-right: 0;
    }

    .practice-section-title {
        font-size: 17px;
    }

    .practice-summary-strip {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 8px;
    }

    .practice-summary-card {
        padding: 10px 8px;
    }

    .practice-summary-label {
        font-size: 10px;
        margin-bottom: 4px;
    }

    .practice-summary-value {
        font-size: 14px;
    }

    .practice-detail-groups {
        gap: 8px;
    }

    .practice-detail-group {
        padding: 10px 8px;
    }

    .practice-drive-header {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
    }

    .practice-drive-toolbar {
        justify-content: flex-end;
        width: 100%;
    }

    .practice-drive-panel .drive-explorer-table-wrap {
        width: 100%;
        max-height: min(55vh, 520px);
        margin: 0;
    }

    .drive-explorer-table {
        width: 100%;
        min-width: 0;
        table-layout: auto;
    }

    .drive-col-size,
    .drive-explorer-table thead .drive-col-size,
    .drive-explorer-table tbody .drive-col-size {
        display: none;
    }

    .drive-col-name {
        width: auto;
    }

    .drive-col-actions {
        width: 132px;
    }

    .drive-action-btn {
        width: 30px;
        height: 30px;
        min-width: 30px;
    }

    .drive-explorer-row td {
        padding: 8px 4px;
        font-size: 13px;
    }

    .drive-item-name,
    .drive-explorer-open-folder {
        font-size: 13px;
    }
}

@media (max-width: 420px) {
    body.practice-page-view .app-header {
        flex-direction: column;
    }

    body.practice-page-view .practice-header-actions {
        width: 100%;
        margin-left: 0;
        justify-content: stretch;
    }

    body.practice-page-view .practice-header-actions .header-action-btn {
        flex: 1;
    }

    .practice-summary-strip {
        grid-template-columns: 1fr;
    }

    .reports {
        grid-template-columns: 1fr;
    }
}
