/* MeriTeach — SaaS / standalone pages stylesheet.
   Loaded ONLY by the pages that live outside the app shell and do not use layout.php:
   account/, admin/, team/, register/, demo/ and the legal pages (meripac_render_legal_page).
   These pages use the teal palette (--ml-*) and load only Bootstrap + this file, so this
   file is self-contained (reset, body, btn-primary). The main app uses meriteach.css. */

/* ---- Teal palette + shared aliases ---- */
:root {
	--ml-bg: #f4f6f8;
	--ml-border: #dce3ea;
	--ml-text: #202934;
	--ml-muted: #6b7785;
	--ml-primary: #6d28d9;
	--ml-primary-dark: #57219f;
}
* { box-sizing: border-box; }
body { min-height: 100vh; margin: 0; background: var(--ml-bg); color: var(--ml-text); font-family: system-ui, -apple-system, "Segoe UI", sans-serif; }
body.mw-standalone-page { background: #f4f6f8; color: #202934; }
@media (max-width: 1199.98px) { body.mw-standalone-page { overflow-x: hidden; } }

/* Teal primary button (Bootstrap default would be blue; the app's gold .btn-primary is not loaded here). */
.btn-primary {
	--bs-btn-bg: #6d28d9;
	--bs-btn-border-color: #6d28d9;
	--bs-btn-hover-bg: #57219f;
	--bs-btn-hover-border-color: #57219f;
	--bs-btn-active-bg: #57219f;
	--bs-btn-active-border-color: #57219f;
	--bs-btn-disabled-bg: #6d28d9;
	--bs-btn-disabled-border-color: #6d28d9;
	color: #fff;
}
.btn-primary:hover { color: #fff; }
.logout-form { margin: 0; }

/* ---- Utilities used only by the standalone pages ---- */
.mw-text-cancel { color: #7f1d1d; }
.mw-text-xs     { font-size: .82rem; }
.mw-vat-row     { gap: 6px; }
.perm-badge     { font-weight: 500; }

/* ---- Legal pages (privacy, cookie, refund — meripac_render_legal_page) ---- */
/* The dynamic brand colour is injected inline as --mw-legal-primary; teal is the fallback. */
.legal-wrap { max-width: 820px; margin: 0 auto; padding: 32px 20px; }
.legal-head { color: var(--mw-legal-primary, var(--ml-primary)); }

/* ---- Account page (account/index.php) ---- */
.account-shell { width: min(1180px, 100%); margin: 0 auto; padding: 24px; }
.account-topbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
.account-brand { display: flex; align-items: center; gap: 14px; }
.account-brand img { width: 140px; max-height: 90px; object-fit: contain; background: #fff; border: 1px solid var(--ml-border); border-radius: 8px; padding: 8px; }
.account-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.account-grid { display: grid; grid-template-columns: minmax(0, .95fr) minmax(0, 1.05fr); gap: 18px; align-items: start; }
.account-panel { min-width: 0; border: 1px solid var(--ml-border); border-radius: 8px; padding: 18px; background: #fff; box-shadow: 0 8px 20px rgba(31,43,57,.05); }
.account-panel h2 { margin: 0 0 14px; font-size: 1.12rem; font-weight: 800; }
/* Labels inside account panels are uppercase form-field labels. */
.account-panel label { display: grid; gap: 6px; color: var(--ml-muted); font-size: .78rem; font-weight: 800; text-transform: uppercase; }
/* form-check labels (inline checkbox) must NOT be uppercase. */
.account-panel label.form-check { display: flex; align-items: flex-start; gap: 8px; text-transform: none; font-size: .92rem; font-weight: 600; }
/* Direct-child forms get grid layout; nested forms (inside alerts) are excluded. */
.account-panel > form { display: grid; gap: 12px; }
.account-stack { display: grid; gap: 18px; }
.logo-preview { width: min(100%, 320px); min-height: 128px; display: grid; place-items: center; border: 1px solid var(--ml-border); border-radius: 8px; padding: 14px; background: #fff; }
.logo-preview img { max-width: 100%; max-height: 150px; object-fit: contain; }
.readonly-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.readonly-item { border: 1px solid var(--ml-border); border-radius: 8px; padding: 10px 12px; background: #fbfcfd; overflow-wrap: anywhere; }
.readonly-item span { display: block; color: var(--ml-muted); font-size: .72rem; font-weight: 800; text-transform: uppercase; }
.readonly-item strong { display: block; margin-top: 3px; font-size: .95rem; }
.account-note { margin: 0; padding-bottom: 12px; color: var(--ml-muted); line-height: 1.5; }
.twofa-status { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.twofa-method { border-top: 1px solid var(--ml-border); padding-top: 14px; margin-top: 14px; }
.twofa-method h3 { margin: 0 0 8px; font-size: 1rem; font-weight: 800; }
.totp-qr { display: flex; justify-content: center; margin: 6px 0 10px; }
.totp-qr svg { width: 180px; height: 180px; background: #fff; border: 1px solid var(--ml-border); border-radius: 8px; padding: 8px; }
.totp-manual { margin: 0 0 10px; }
.totp-manual summary { cursor: pointer; color: var(--ml-primary); font-size: .86rem; font-weight: 650; }
.totp-secret { margin: 8px 0 0; font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace; letter-spacing: .04em; word-break: break-all; }
.billing-status-row { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.billing-status-badge { display: inline-flex; align-items: center; padding: 4px 10px; border-radius: 999px; font-size: .78rem; font-weight: 800; text-transform: uppercase; }
/* Founding-members badge (launch_promo=1): marks a locked-in-for-life founder account. */
.billing-founder-badge { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; font-size: .78rem; font-weight: 800; text-transform: uppercase; color: var(--ml-primary-dark); background: #ede9fe; border: 1px solid var(--ml-primary); }
.billing-status-info { background: #dbeafe; color: #1e40af; }
.billing-status-success { background: #dcfce7; color: #166534; }
.billing-status-warning { background: #fef9c3; color: #713f12; }
.billing-status-danger { background: #fee2e2; color: #7f1d1d; }
.billing-status-secondary { background: #f1f5f9; color: #475569; }
.billing-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.billing-actions form { margin: 0; }
.backup-grid { display: grid; gap: 8px; }
.backup-description { margin: 0 0 12px; color: var(--ml-muted); font-size: .9rem; line-height: 1.5; }
.account-cards { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; align-items: start; margin-top: 18px; }
.masonry-col { display: flex; flex-direction: column; gap: 18px; min-width: 0; }
.account-profile > summary { cursor: pointer; font-size: 1.12rem; font-weight: 800; list-style: none; display: flex; align-items: center; gap: 8px; }
.account-profile > summary::-webkit-details-marker { display: none; }
.account-profile-caret { display: inline-block; transition: transform .15s; font-size: .9rem; }
.account-profile[open] .account-profile-caret { transform: rotate(90deg); }
.account-profile > summary + * { margin-top: 14px; }
.notif-table { width: 100%; border-collapse: collapse; }
.notif-table th, .notif-table td { padding: 8px 6px; border-bottom: 1px solid var(--ml-border); font-size: .9rem; text-align: left; vertical-align: middle; }
.notif-table th { color: var(--ml-muted); font-size: .72rem; font-weight: 800; text-transform: uppercase; }
.notif-table td.notif-center, .notif-table th.notif-center { text-align: center; width: 52px; }
.notif-group-row td { background: #fbfcfd; font-weight: 800; font-size: .74rem; text-transform: uppercase; color: var(--ml-muted); }
.notif-event-label { font-weight: 700; }
.notif-event-desc { color: var(--ml-muted); font-size: .78rem; }
.notif-device-status { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; flex-wrap: wrap; }
.notif-actions { display: flex; gap: 8px; flex-wrap: wrap; margin: 10px 0; }
.notif-test-result { margin: 8px 0 0; font-size: .85rem; white-space: pre-line; }
.notif-mode-select { min-width: 110px; }
@media (max-width: 900px) {
	.account-shell { padding: 16px; }
	.account-topbar { align-items: stretch; flex-direction: column; }
	.account-grid, .account-cards, .readonly-grid { grid-template-columns: 1fr; }
	.account-actions .btn { flex: 1 1 auto; }
}
@media (max-width: 575.98px) {
	.account-shell { padding: 10px; }
	.account-brand { align-items: flex-start; flex-direction: column; }
	.account-brand img { width: 128px; }
	.account-actions, .account-actions .btn { width: 100%; }
}

/* ---- Admin page (admin/index.php) ---- */
.admin-shell { max-width: 1500px; margin: 0 auto; padding: 24px; }
.admin-topbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
.admin-actions { display: flex; align-items: center; gap: 8px; }
.admin-brand { display: flex; align-items: center; gap: 12px; }
.admin-brand img { width: 150px; max-height: 110px; object-fit: contain; border: 0; border-radius: 0; padding: 0; background: transparent; }
.admin-grid { display: grid; gap: 18px; min-width: 0; }
.admin-panel { min-width: 0; border: 1px solid var(--ml-border); border-radius: 8px; padding: 16px; background: #fff; box-shadow: 0 8px 20px rgba(31,43,57,.05); }
.admin-panel h2 { margin: 0 0 12px; font-size: 1.12rem; font-weight: 800; }
.admin-panel--danger { border-color: #dc3545; }
.admin-panel--danger h2 { color: #dc3545; }
.admin-shell .table { --bs-table-bg: transparent; }
.admin-shell .table th { color: var(--ml-muted); font-size: .75rem; text-transform: uppercase; }
.admin-shell .inline-actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; }
.admin-shell .inline-actions form { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 0; }
.reason-input { width: 170px; }
.list-form { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.price-form { display: grid; gap: 14px; }
.price-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.price-copy-grid { display: grid; grid-template-columns: minmax(0, .95fr) minmax(0, 1.05fr); gap: 12px; }
.settings-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.settings-copy-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.settings-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.settings-actions form { margin: 0; }
.admin-field { display: grid; gap: 6px; color: #5e6d7d; font-size: .78rem; font-weight: 800; text-transform: uppercase; }
.admin-field textarea { min-height: 92px; resize: vertical; }
.admin-field .form-check { color: var(--ml-text); font-size: .92rem; font-weight: 600; text-transform: none; }
.admin-help { margin: 0; color: var(--ml-muted); font-size: .86rem; font-weight: 500; text-transform: none; }
.price-summary { display: flex; flex-wrap: wrap; gap: 8px; margin: 0; padding: 0; list-style: none; }
.price-summary li { border: 1px solid var(--ml-border); border-radius: 8px; padding: 9px 12px; background: #f8fafc; color: var(--ml-text); font-weight: 700; }
.price-summary span { color: var(--ml-muted); font-weight: 800; text-transform: uppercase; font-size: .72rem; }
.tenant-edit-row td { padding: 14px 0 4px; }
.tenant-edit-form { background: #f8fafc; border: 1px solid var(--ml-border); border-radius: 8px; padding: 16px; }
.tenant-edit-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin-bottom: 12px; }
.tenant-inline-row { display: flex; gap: 8px; align-items: center; }
.tenant-grant-row { display: flex; gap: 8px; align-items: flex-end; flex-wrap: wrap; }
.tenant-grant-label { flex: 0 0 auto; }
.tenant-grant-note { flex: 1 1 180px; }
.tenant-feature-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.tenant-feature-label { font-size: .9rem; font-weight: 600; }
@media (max-width: 1199.98px) {
	.tenant-edit-grid { grid-template-columns: 1fr; }
	.admin-shell { width: 100%; max-width: 100%; padding: 16px; }
	.admin-topbar { align-items: stretch; flex-direction: column; }
	.admin-actions { justify-content: flex-start; flex-wrap: wrap; }
	.admin-actions .btn, .admin-actions form { flex: 1 1 auto; }
	.admin-actions .btn { width: 100%; }
	.admin-panel { padding: 14px; }
	.admin-shell .table-responsive { overflow: visible; }
	.admin-shell .table { display: block; margin: 0; }
	.admin-shell .table thead { display: none; }
	.admin-shell .table tbody, .admin-shell .table tr, .admin-shell .table td { display: block; width: 100%; }
	.admin-shell .table tr { border-top: 1px solid var(--ml-border); padding: 12px 0; }
	.admin-shell .table tr:first-child { border-top: 0; }
	.admin-shell .table td { min-width: 0; border: 0; display: grid; grid-template-columns: minmax(96px, 30%) minmax(0, 1fr); gap: 12px; padding: 7px 0; overflow-wrap: anywhere; text-align: left !important; }
	.admin-shell .table td::before { content: attr(data-label); color: var(--ml-muted); font-size: .72rem; font-weight: 800; line-height: 1.2; text-transform: uppercase; }
	.admin-shell .table td.admin-empty-row { display: block; padding: 18px 0; }
	.admin-shell .table td.admin-empty-row::before { content: none; }
	.admin-shell .table td[data-label="Azioni"] { grid-template-columns: 1fr; }
	.admin-shell .table td[data-label="Azioni"]::before { margin-bottom: 4px; }
	.admin-shell .inline-actions, .admin-shell .inline-actions form, .list-form { width: 100%; justify-content: flex-start; }
	.price-grid, .price-copy-grid, .settings-grid, .settings-copy-grid { grid-template-columns: 1fr; }
	.admin-shell .inline-actions .form-select { width: auto; min-width: 150px; }
	.reason-input { width: min(100%, 240px); }
}
@media (max-width: 575.98px) {
	.admin-shell { padding: 10px; }
	.admin-brand { align-items: flex-start; flex-direction: column; }
	.admin-brand img { width: 128px; max-height: 92px; }
	.admin-actions, .admin-actions form, .admin-actions .btn { width: 100%; }
	.admin-shell .table td { grid-template-columns: 1fr; gap: 4px; }
	.admin-shell .inline-actions form, .list-form { align-items: stretch; flex-direction: column; }
	.admin-shell .inline-actions .btn, .admin-shell .inline-actions .form-select, .list-form .btn { width: 100%; }
	.reason-input { width: 100%; }
}

/* ---- Team page (team/index.php) ---- */
.team-shell { max-width: 1100px; margin: 0 auto; padding: 24px; }
.team-topbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 24px; flex-wrap: wrap; }
.team-brand { display: flex; align-items: center; gap: 12px; }
.team-brand img { height: 36px; }
.team-brand strong { font-size: 1.15rem; color: var(--ml-primary); }
.team-actions { display: flex; gap: 8px; }
.team-panel { background: #fff; border: 1px solid var(--ml-border); border-radius: 12px; padding: 24px; margin-bottom: 20px; }
.team-panel h2 { margin: 0 0 16px; font-size: 1.1rem; font-weight: 700; color: var(--ml-primary); }
.team-panel .table th, .team-panel .table td { vertical-align: middle; }
.perm-list { display: flex; flex-wrap: wrap; gap: 4px; }
.form-section { border-top: 1px solid var(--ml-border); padding-top: 18px; margin-top: 18px; }
.form-section h3 { font-size: 1rem; font-weight: 700; margin-bottom: 14px; }
.perm-grid { display: flex; flex-wrap: wrap; gap: 10px 20px; }
.perm-grid .form-check { min-width: 180px; }
.team-shell .inline-actions { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.perm-editor-box { background: #f8fafc; border: 1px solid var(--ml-border); border-radius: 8px; padding: 14px; }
@media (max-width: 576px) {
	.team-panel .table thead { display: none; }
	.team-panel .table tr { display: block; border-bottom: 2px solid var(--ml-border); padding: 8px 0; }
	.team-panel .table td { display: block; text-align: left; padding: 4px 0; }
	.team-panel .table td::before { content: attr(data-label); font-weight: 700; margin-right: 6px; color: #607080; }
}

/* ---- Register + Demo pages (shared card container) ---- */
/* Outer wrapper: these pages have no app shell, so the wrapper supplies the page padding/width. */
.page { max-width: 980px; margin: 0 auto; padding: 24px 16px; }
/* Base card shell (border, padding, shadow) used by both register and demo forms. */
.card-form { border: 1px solid #dce3ea; border-radius: 8px; padding: 22px; background: #fff; box-shadow: 0 10px 26px rgba(31,43,57,.08); }
/* Brand block inside the card (the app sidebar .brand is not loaded on these pages). */
.card-form .brand { display: flex; align-items: center; justify-content: flex-start; gap: 12px; margin-bottom: 18px; }
.card-form .brand img { width: 150px; max-height: 110px; object-fit: contain; }
/* Field labels inside card forms are uppercase grid labels. */
.card-form label { display: grid; gap: 6px; color: #5e6d7d; font-size: .78rem; font-weight: 800; text-transform: uppercase; }
/* Form-check and billing-option labels are NOT uppercase. */
.card-form .form-check,
.card-form label.billing-option,
.card-form label.consent-check { text-transform: none; font-size: .92rem; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.card-form label.billing-option { display: grid; }
/* Two-column grid for register form fields; .full spans both columns. */
.card-form .grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.card-form .grid .full { grid-column: 1 / -1; }
/* Credentials row (username + password + confirm) on a 3-column responsive grid. */
.card-form .credentials-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; align-items: start; }
/* Demo card: width-constrained + grid layout (the form IS the card). */
.demo-card { width: min(100%, 520px); display: grid; gap: 14px; }
/* Demo page centres the single card in the viewport. */
body.mw-demo-page { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
/* Billing result page (billing/index.php) centres a single card. */
body.mw-billing-page { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.billing-card { width: min(100%, 720px); border: 1px solid #dce3ea; border-radius: 8px; padding: 24px; background: #fff; box-shadow: 0 10px 26px rgba(31,43,57,.08); }
.billing-card .brand { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.billing-card .brand img { width: 140px; max-height: 92px; object-fit: contain; }
.summary { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin: 18px 0; }
.summary div { border: 1px solid #dce3ea; border-radius: 8px; padding: 12px; background: #f8fafc; }
.summary span { display: block; color: #6b7785; font-size: .75rem; font-weight: 800; text-transform: uppercase; }
.summary strong { display: block; margin-top: 3px; font-size: 1rem; }
@media (max-width: 640px) { .summary { grid-template-columns: 1fr; } }
/* Listino / billing option components (register page). */
.listino-section { display: grid; gap: 12px; }
.listino-title { margin: 0; color: #202934; font-size: 1rem; font-weight: 800; line-height: 1.35; }
.listino-copy { max-width: 760px; margin: 0; color: #5e6d7d; font-size: .94rem; line-height: 1.45; }
.listino-options { display: flex; flex-wrap: wrap; gap: 14px 20px; }
.price-badge { display: inline-flex; align-items: center; min-height: 26px; border-radius: 999px; padding: 3px 10px; background: #e8f3f5; color: #57219f; font-size: .78rem; font-weight: 800; white-space: nowrap; }
.price-badge-list { display: inline-flex; flex-wrap: wrap; gap: 6px; }
.billing-section { display: grid; gap: 12px; }
/* Founding-members notice on the registration form (shown while launch promo seats remain). */
.founder-reg-note { display: flex; align-items: flex-start; gap: 12px; padding: 14px 16px; border: 1px solid var(--ml-primary); border-radius: 8px; background: #f5f3ff; color: #4c1d95; }
.founder-reg-note i { font-size: 1.3rem; line-height: 1.2; color: var(--ml-primary); flex: 0 0 auto; }
.founder-reg-note strong { display: block; font-size: 1rem; font-weight: 800; }
.founder-reg-note span { font-size: .9rem; font-weight: 600; line-height: 1.4; }
.billing-options { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.billing-option { position: relative; display: grid; gap: 8px; min-height: 118px; border: 1px solid #dce3ea; border-radius: 8px; padding: 14px; background: #f8fafc; color: #202934; text-transform: none; cursor: pointer; }
.billing-option input { position: absolute; opacity: 0; pointer-events: none; }
.billing-option:has(input:checked) { border-color: #6d28d9; box-shadow: 0 0 0 3px rgba(15,107,122,.12); background: #fff; }
.billing-option strong { font-size: 1rem; }
.billing-option span { color: #5e6d7d; font-size: .9rem; font-weight: 600; line-height: 1.35; }
.billing-option em { color: #6d28d9; font-style: normal; font-size: .9rem; font-weight: 800; }
.consent-box { display: grid; gap: 10px; margin-top: 18px; padding: 14px 16px; background: #f8fafc; border: 1px solid #dce3ea; border-radius: 8px; }
.consent-check { display: flex; align-items: flex-start; gap: 10px; color: #202934; font-size: .9rem; font-weight: 500; text-transform: none; line-height: 1.45; cursor: pointer; }
.consent-check input { margin-top: 3px; flex: 0 0 auto; width: 17px; height: 17px; }
.consent-check a { color: #6d28d9; text-decoration: underline; }
@media (max-width: 760px) { .card-form .grid, .billing-options, .card-form .credentials-grid { grid-template-columns: 1fr; } }
