:root {
    --bs-font-sans-serif: 'Poppins', sans-serif;
    --bs-body-font-family: 'Poppins', sans-serif;
    --bs-primary: #1a1a2e;
    --bs-primary-rgb: 26, 26, 46;
    --bs-danger: #c0392b;
    --bs-danger-rgb: 192, 57, 43;

    --panel-bg: #eef1f6;
    --panel-surface: #ffffff;
    --panel-sidebar: #1a1a2e;
    --panel-sidebar-hover: rgba(255, 255, 255, 0.08);
    --panel-sidebar-active: rgba(255, 255, 255, 0.12);
    --panel-accent: #4a6cf7;
    --panel-text: #2c2c2c;
    --panel-text-muted: #6c757d;
    --panel-border: #e2e8f0;
    --panel-border-strong: #cbd5e1;
    --panel-radius: 10px;
    --panel-radius-sm: 6px;
    --panel-shadow: 0 1px 3px rgba(15, 23, 42, 0.06), 0 4px 16px rgba(15, 23, 42, 0.04);
    --panel-shadow-lg: 0 8px 32px rgba(15, 23, 42, 0.12);
    --panel-header-gap: 2.75rem;
}

* {
    box-sizing: border-box;
}

body.panel-body {
    font-family: 'Poppins', sans-serif;
    background: var(--panel-bg);
    color: var(--panel-text);
    min-height: 100vh;
    font-size: 0.9375rem;
    line-height: 1.5;
}

.panel-layout {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.panel-sidebar {
    width: 260px;
    background: var(--panel-sidebar);
    color: #fff;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    position: sticky;
    top: 0;
    align-self: flex-start;
    height: 100vh;
    overflow-y: auto;
    font-family: 'Poppins', sans-serif;
    box-shadow: 2px 0 12px rgba(0, 0, 0, 0.08);
}

.panel-sidebar-header {
    padding: 28px 22px 22px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.panel-sidebar-header h1 {
    font-size: 1.15rem;
    font-weight: 700;
    line-height: 1.3;
    letter-spacing: -0.01em;
}

.panel-sidebar-header p {
    font-size: 0.8125rem;
    color: rgba(255, 255, 255, 0.55);
    margin-top: 6px;
    margin-bottom: 0;
}

.panel-sidebar-nav {
    flex: 1;
    padding: 12px 0;
}

.panel-sidebar-nav ul {
    list-style: none;
    margin: 0;
    padding: 0 10px;
}

.panel-sidebar-nav li {
    margin-bottom: 4px;
}

.panel-sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 14px;
    color: rgba(255, 255, 255, 0.78);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    border-radius: var(--panel-radius-sm);
    transition: background 0.15s ease, color 0.15s ease;
}

.panel-sidebar-nav a:hover {
    background: var(--panel-sidebar-hover);
    color: #fff;
}

.panel-sidebar-nav a.active {
    background: var(--panel-sidebar-active);
    color: #fff;
    box-shadow: inset 3px 0 0 var(--panel-accent);
}

.panel-nav-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.35rem;
    height: 1.35rem;
    flex-shrink: 0;
    opacity: 0.85;
    font-size: 0.95rem;
    line-height: 1;
}

.panel-sidebar-nav a.active .panel-nav-icon {
    opacity: 1;
}

.panel-sidebar-footer {
    padding: 16px 10px 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.panel-sidebar-footer a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 11px 14px;
    color: #f1948a;
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 600;
    border-radius: var(--panel-radius-sm);
    transition: background 0.15s ease;
}

.panel-sidebar-footer a:hover {
    background: rgba(231, 76, 60, 0.15);
    color: #ffaba3;
}

/* Contenuto principale */
.panel-main {
    flex: 1;
    padding: 28px 36px 40px;
    overflow-x: auto;
    min-width: 0;
}

.panel-main-header {
    margin-bottom: 22px;
}

.panel-main-header h2 {
    font-size: 1.625rem;
    font-weight: 700;
    color: #111827;
    letter-spacing: -0.02em;
    margin: 0;
}

.panel-content {
    background: var(--panel-surface);
    padding: 28px 32px 32px;
    border-radius: var(--panel-radius);
    box-shadow: var(--panel-shadow);
    border: 1px solid var(--panel-border);
}

.panel-content + .panel-content {
    margin-top: 24px;
}

.panel-content--danger {
    border-color: #f5c2c7;
}

.panel-content--danger > h3 {
    color: #842029;
}

.panel-content h3 {
    font-size: 1.125rem;
    font-weight: 600;
    color: #111827;
    margin: 0 0 8px;
    letter-spacing: -0.01em;
}

.panel-page-lead {
    color: var(--panel-text-muted);
    font-size: 0.9rem;
    line-height: 1.6;
    margin-bottom: var(--panel-header-gap);
}

.panel-page-lead:last-child {
    margin-bottom: 0;
}

.panel-content > .panel-path {
    margin-bottom: var(--panel-header-gap);
}

.panel-content > .panel-callout {
    margin-bottom: var(--panel-header-gap);
}

.panel-path {
    font-size: 0.8125rem;
    color: var(--panel-text-muted);
    margin-bottom: 18px;
    padding: 8px 12px;
    background: #f8fafc;
    border-radius: var(--panel-radius-sm);
    border: 1px solid var(--panel-border);
    word-break: break-all;
}

.panel-path code,
.panel-content code {
    font-size: 0.8125rem;
    color: #475569;
    background: #f1f5f9;
    padding: 0.15em 0.45em;
    border-radius: 4px;
}

.panel-callout {
    display: flex;
    gap: 12px;
    padding: 14px 16px;
    border-radius: var(--panel-radius-sm);
    font-size: 0.875rem;
    line-height: 1.55;
    margin-bottom: 20px;
}

.panel-callout--warning {
    background: #fff8e6;
    border: 1px solid #ffe08a;
    color: #664d03;
}

.panel-callout--info {
    background: #eef4ff;
    border: 1px solid #c7d9ff;
    color: #1e3a6e;
}

.panel-callout strong {
    font-weight: 600;
}

.panel-alert {
    border-radius: var(--panel-radius-sm);
    font-size: 0.9rem;
}

/* Toolbar e tabelle */
.panel-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 14px 18px;
    background: #f8fafc;
    border: 1px solid var(--panel-border);
    border-bottom: none;
    border-radius: var(--panel-radius-sm) var(--panel-radius-sm) 0 0;
    flex-wrap: wrap;
}

.panel-toolbar-group {
    display: flex;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
}

.panel-toolbar .form-check-label {
    font-size: 0.875rem;
    font-weight: 500;
    color: #475569;
    user-select: none;
}

.panel-table-wrap {
    border: 1px solid var(--panel-border);
    border-radius: var(--panel-radius-sm);
    overflow: hidden;
    margin-bottom: 8px;
}

.panel-table-wrap .panel-toolbar {
    border: none;
    border-bottom: 1px solid var(--panel-border);
    border-radius: 0;
}

.panel-table-scroll {
    overflow-x: auto;
}

.panel-table {
    font-size: 0.875rem;
    margin-bottom: 0;
}

.panel-table > :not(caption) > * > * {
    padding: 0.72rem 1rem;
    vertical-align: middle;
}

.panel-table thead th {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #64748b;
    background: #f8fafc;
    border-bottom-width: 1px;
    white-space: nowrap;
}

.panel-table tbody tr {
    transition: background 0.12s ease;
}

.panel-table tbody tr:hover {
    background: #f8fafc;
}

.panel-table tbody td {
    color: #334155;
}

.panel-table-check {
    width: 44px;
    text-align: center;
}

.panel-table-check .form-check {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 1.25rem;
    padding-left: 0;
    margin-bottom: 0;
}

.panel-table-check .form-check-input {
    float: none;
    margin: 0;
    width: 1.05em;
    height: 1.05em;
    cursor: pointer;
}

.panel-table .form-check-input {
    cursor: pointer;
}

.panel-table-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.panel-section {
    margin-top: 28px;
}

.panel-section:first-of-type {
    margin-top: 0;
}

.panel-section-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
}

.panel-section-title {
    font-size: 0.9375rem;
    font-weight: 600;
    color: #1e293b;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.panel-section-title::before {
    content: '';
    display: inline-block;
    width: 4px;
    height: 1em;
    background: var(--panel-accent);
    border-radius: 2px;
}

.panel-section-count {
    font-size: 0.75rem;
    font-weight: 600;
    color: #64748b;
    background: #f1f5f9;
    padding: 0.2em 0.65em;
    border-radius: 999px;
}

.panel-empty-state {
    text-align: center;
    padding: 40px 24px;
    color: var(--panel-text-muted);
    font-size: 0.9rem;
    background: #f8fafc;
    border: 1px dashed var(--panel-border-strong);
    border-radius: var(--panel-radius-sm);
}

/* Badge stato */
.panel-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.22em 0.65em;
    font-size: 0.75rem;
    font-weight: 600;
    line-height: 1.4;
    border-radius: 999px;
    white-space: nowrap;
}

.panel-badge--neutral {
    background: #f1f5f9;
    color: #475569;
}

.panel-badge--success {
    background: #dcfce7;
    color: #166534;
}

.panel-badge--warning {
    background: #fef3c7;
    color: #92400e;
}

.panel-badge--danger {
    background: #fee2e2;
    color: #991b1b;
}

.panel-badge--info {
    background: #dbeafe;
    color: #1e40af;
}

.panel-badge--export {
    background: #ede9fe;
    color: #5b21b6;
}

.panel-badge--task {
    background: #ffedd5;
    color: #9a3412;
}

.panel-col-script {
    font-weight: 500;
    color: #1e293b;
}

.panel-col-muted {
    color: #64748b;
    font-size: 0.8125rem;
}

.panel-col-numeric {
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

/* Bottoni */
.btn {
    font-weight: 500;
    font-size: 0.875rem;
    border-radius: var(--panel-radius-sm);
    padding: 0.45rem 1rem;
}

.btn-sm {
    font-size: 0.8125rem;
    padding: 0.3rem 0.75rem;
}

.btn-primary {
    --bs-btn-bg: #1a1a2e;
    --bs-btn-border-color: #1a1a2e;
    --bs-btn-hover-bg: #2d2d44;
    --bs-btn-hover-border-color: #2d2d44;
    --bs-btn-active-bg: #2d2d44;
    --bs-btn-active-border-color: #2d2d44;
    --bs-btn-disabled-bg: #1a1a2e;
    --bs-btn-disabled-border-color: #1a1a2e;
}

.btn-secondary {
    --bs-btn-bg: #fff;
    --bs-btn-border-color: var(--panel-border-strong);
    --bs-btn-color: #475569;
    --bs-btn-hover-bg: #f8fafc;
    --bs-btn-hover-border-color: #94a3b8;
    --bs-btn-hover-color: #1e293b;
}

.btn-danger {
    --bs-btn-bg: #c0392b;
    --bs-btn-border-color: #c0392b;
    --bs-btn-hover-bg: #a93226;
    --bs-btn-hover-border-color: #a93226;
    --bs-btn-active-bg: #a93226;
    --bs-btn-active-border-color: #a93226;
}

.btn-outline-view {
    --bs-btn-color: #475569;
    --bs-btn-border-color: var(--panel-border-strong);
    --bs-btn-hover-bg: #f1f5f9;
    --bs-btn-hover-border-color: #94a3b8;
    --bs-btn-hover-color: #1e293b;
}

/* Importazione manuale */
.manual-import-section-title {
    font-size: 1rem;
    color: #1a1a1a;
    margin: 24px 0 12px;
}

.manual-import-actions-left {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}

.manual-import-toolbar-divider {
    width: 1px;
    height: 24px;
    background: var(--panel-border-strong);
    flex-shrink: 0;
}

.manual-import-run-btn {
    min-width: 200px;
    font-weight: 600;
}

.manual-import-progress-wrap {
    margin-bottom: 20px;
}

.manual-import-progress-track {
    width: 100%;
    height: 12px;
    background: #e9ecef;
    border-radius: 999px;
    overflow: hidden;
}

.manual-import-progress-bar {
    width: 0;
    height: 100%;
    background: linear-gradient(90deg, #1a1a2e, #4a6cf7);
    border-radius: 999px;
    transition: width 0.3s ease;
}

.manual-import-progress-status {
    margin-top: 12px;
    font-size: 0.9375rem;
    color: #1e293b;
    font-weight: 600;
}

.manual-import-progress-meta {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    margin-top: 6px;
    font-size: 0.8125rem;
    color: #64748b;
}

.manual-import-log {
    max-height: 320px;
    overflow-y: auto;
    background: #1a1d23;
    color: #d4d4d4;
    border-radius: var(--panel-radius-sm);
    padding: 14px 16px;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 0.8125rem;
    line-height: 1.5;
    border: 1px solid #2d333b;
}

.manual-import-log-line {
    padding: 2px 0;
    word-break: break-word;
}

.manual-import-log-info { color: #9cdcfe; }
.manual-import-log-progress { color: #ce9178; }
.manual-import-log-detail { color: #b5b5b5; }
.manual-import-log-success { color: #4ec9b0; }
.manual-import-log-error { color: #f48771; }

.manual-import-modal-dialog {
    max-height: calc(100vh - 40px);
    display: flex;
    flex-direction: column;
}

.manual-import-modal .panel-modal-body {
    overflow-y: auto;
    flex: 1;
}

.manual-import-log-title {
    margin-top: 0;
}

.manual-import-modal.is-running .panel-modal-backdrop {
    cursor: default;
}

/* Log importazioni */
.import-logs-modal-dialog {
    max-height: calc(100vh - 40px);
    display: flex;
    flex-direction: column;
}

.import-logs-modal .panel-modal-body {
    overflow-y: auto;
    flex: 1;
}

.import-logs-modal-filename {
    margin-top: 6px;
    margin-bottom: 0;
}

.import-logs-modal .import-logs-viewer {
    max-height: none;
    min-height: 200px;
}

.import-logs-viewer-header {
    margin-bottom: 12px;
}

.import-logs-viewer {
    max-height: 480px;
    white-space: pre-wrap;
    word-break: break-word;
}

.import-logs-row-active {
    background: #eff6ff !important;
}

.import-logs-status-col {
    width: 40px;
    text-align: center;
}

.import-logs-issue-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: #c0392b;
    color: #fff;
    font-size: 0.8rem;
    font-weight: 700;
    line-height: 1;
    cursor: help;
    box-shadow: 0 0 0 2px rgba(192, 57, 43, 0.2);
}

.import-logs-actions-col {
    width: 110px;
    text-align: right;
}

/* Schedulazione */
.import-schedule-intro {
    margin-bottom: 0.75rem;
}

.import-schedule-now {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.35rem 0.5rem;
    margin-bottom: var(--panel-header-gap);
    padding: 10px 14px;
    font-size: 0.875rem;
    color: #475569;
    background: #f8fafc;
    border: 1px solid var(--panel-border);
    border-radius: var(--panel-radius-sm);
}

.import-schedule-now-label {
    color: #64748b;
}

.import-schedule-now strong {
    font-variant-numeric: tabular-nums;
    font-weight: 600;
    color: #1e293b;
}

.import-schedule-now-tz {
    font-size: 0.8125rem;
    color: #94a3b8;
}

.import-schedule-section-title {
    margin: 0 0 12px;
    font-size: 0.9375rem;
    font-weight: 600;
    color: #1e293b;
}

.import-schedule-table {
    font-size: 0.875rem;
}

.import-schedule-table thead th {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #64748b;
    background: #f8fafc;
    white-space: nowrap;
    padding: 0.65rem 0.85rem;
}

.import-schedule-table tbody td {
    padding: 0.75rem 0.85rem;
    vertical-align: middle;
}

.import-schedule-table tbody tr {
    transition: background 0.12s ease;
}

.import-schedule-table tbody tr:has(input[type="checkbox"][name*="[enabled]"]:checked) {
    background: rgba(74, 108, 247, 0.04);
}

.import-schedule-table tbody tr:has(input[type="checkbox"][name*="[enabled]"]:checked) .panel-col-script {
    color: #1a1a2e;
}

.import-schedule-col-active {
    width: 56px;
    text-align: center;
}

.import-schedule-col-time {
    width: 120px;
}

.import-schedule-col-mode {
    width: 130px;
    min-width: 120px;
}

.import-schedule-col-timing {
    width: 130px;
    min-width: 115px;
}

.import-schedule-minute-wrap {
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.import-schedule-minute-prefix {
    font-weight: 600;
    color: #64748b;
    font-variant-numeric: tabular-nums;
}

.import-schedule-minute {
    min-width: 4.5rem;
    font-variant-numeric: tabular-nums;
}

.import-schedule-col-status {
    width: 80px;
}

.import-schedule-col-datetime {
    width: 130px;
    font-variant-numeric: tabular-nums;
    font-size: 0.8125rem;
    color: #64748b;
    white-space: nowrap;
}

.import-schedule-time {
    min-width: 105px;
    font-variant-numeric: tabular-nums;
}

.import-schedule-weekdays {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    min-width: 220px;
}

.import-schedule-weekday {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 2.15rem;
    padding: 0.25rem 0.4rem;
    font-size: 0.72rem;
    font-weight: 600;
    margin: 0;
    border: 1px solid var(--panel-border);
    border-radius: 999px;
    background: #fff;
    color: #64748b;
    cursor: pointer;
    transition: background 0.12s ease, border-color 0.12s ease, color 0.12s ease;
    user-select: none;
}

.import-schedule-weekday:hover {
    border-color: #94a3b8;
    color: #334155;
}

.import-schedule-weekday:has(input:checked) {
    background: #1a1a2e;
    border-color: #1a1a2e;
    color: #fff;
}

.import-schedule-weekday input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
    pointer-events: none;
}

.import-schedule-status {
    display: inline-flex;
    align-items: center;
    padding: 0.2em 0.55em;
    font-size: 0.75rem;
    font-weight: 600;
    border-radius: 999px;
}

.import-schedule-status--success {
    background: #dcfce7;
    color: #166534;
}

.import-schedule-status--error {
    background: #fee2e2;
    color: #991b1b;
}

.import-schedule-status--skipped {
    background: #fef3c7;
    color: #92400e;
}

.import-schedule-status--none {
    background: #f1f5f9;
    color: #94a3b8;
}

.import-schedule-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid var(--panel-border);
}

.import-schedule-cron-help {
    margin-top: 28px;
    padding: 18px 20px;
    background: #f8fafc;
    border: 1px solid var(--panel-border);
    border-radius: var(--panel-radius-sm);
}

.import-schedule-cron-help h4 {
    font-size: 0.9375rem;
    font-weight: 600;
    margin: 0 0 8px;
    color: #1e293b;
}

.import-schedule-cron-help p {
    font-size: 0.875rem;
    color: #64748b;
    margin-bottom: 10px;
}

.import-schedule-cron-line {
    background: #1a1a2e;
    color: #e2e8f0;
    padding: 12px 16px;
    border-radius: var(--panel-radius-sm);
    overflow-x: auto;
    font-size: 0.8125rem;
    font-family: 'Consolas', 'Monaco', monospace;
    margin: 0;
}

/* Modale */
body.panel-modal-open {
    overflow: hidden;
}

.panel-modal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.panel-modal.is-open {
    display: flex;
}

.panel-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.5);
    backdrop-filter: blur(2px);
}

.panel-modal-dialog {
    position: relative;
    width: 100%;
    max-width: 480px;
    background: #fff;
    border-radius: var(--panel-radius);
    box-shadow: var(--panel-shadow-lg);
    overflow: hidden;
}

.panel-modal-dialog.manual-import-modal-dialog,
.panel-modal-dialog.import-logs-modal-dialog {
    max-width: 80%;
}

.panel-modal-header {
    padding: 20px 24px 0;
}

.panel-modal-header h4 {
    font-size: 1.125rem;
    font-weight: 600;
    color: #111827;
    margin: 0;
}

.panel-modal-body {
    padding: 14px 24px 22px;
}

.panel-modal-body p {
    color: #64748b;
    line-height: 1.55;
    font-size: 0.9375rem;
}

.panel-modal-password-wrap {
    margin-top: 16px;
}

.panel-modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 0 24px 20px;
    background: #f8fafc;
    border-top: 1px solid var(--panel-border);
    padding-top: 16px;
}

/* Login */
body.panel-login-body {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.panel-login-card {
    width: 100%;
    max-width: 400px;
    border-radius: var(--panel-radius);
}

.panel-login-subtitle {
    font-size: 0.9rem;
}

@media (max-width: 992px) {
    .panel-main {
        padding: 22px 20px 32px;
    }

    .panel-content {
        padding: 22px 20px 24px;
    }

    .import-schedule-weekdays {
        min-width: 0;
    }
}

@media (max-width: 768px) {
    .panel-layout {
        flex-direction: column;
    }

    .panel-sidebar {
        width: 100%;
        position: static;
        height: auto;
        overflow-y: visible;
    }

    .panel-sidebar-nav ul {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 4px;
    }

    .panel-main-header h2 {
        font-size: 1.35rem;
    }

    .manual-import-run-btn {
        width: 100%;
        min-width: 0;
    }

    .panel-toolbar {
        flex-direction: column;
        align-items: stretch;
    }

    .panel-toolbar .btn {
        width: 100%;
    }
}
