/* MeriLav — SaaS / standalone pages stylesheet.
   Loaded ONLY by the pages that live outside the main dashboard (public/index.php) and have
   their own <head>: account/, admin/, team/, register/, demo/, billing/, loyalty/ and the
   legal pages (src/Support/privacy.php). These load only Bootstrap + this file, so it is
   self-contained (reset, body, btn-primary). The dashboard uses merilav-modern.css. */

/* ---- Teal palette ---- */
:root {
	--ml-bg: #f4f6f8;
	--ml-border: #dce3ea;
	--ml-text: #202934;
	--ml-muted: #6b7785;
	--ml-primary: #0f6b7a;
	--ml-primary-dark: #0a5160;
}
* { 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.ml-standalone-page { background: var(--ml-bg); color: var(--ml-text); }
@media (max-width: 1199.98px) { body.ml-standalone-page { overflow-x: hidden; } }
/* Demo and billing centre a single card in the viewport. */
body.ml-center-page { display: grid; place-items: center; padding: 24px; }

.btn-primary {
	--bs-btn-bg: var(--ml-primary); --bs-btn-border-color: var(--ml-primary);
	--bs-btn-hover-bg: var(--ml-primary-dark); --bs-btn-hover-border-color: var(--ml-primary-dark);
	--bs-btn-active-bg: var(--ml-primary-dark); --bs-btn-active-border-color: var(--ml-primary-dark);
	--bs-btn-disabled-bg: var(--ml-primary); --bs-btn-disabled-border-color: var(--ml-primary);
	color: #fff;
}
.btn-primary:hover { color: #fff; }
.logout-form { margin: 0; }

/* ---- Utilities for the standalone pages ---- */
.ml-fs-72  { font-size: .72rem; }
.ml-fs-82  { font-size: .82rem; }
.ml-fs-85  { font-size: .85rem; }
.ml-fs-88  { font-size: .88rem; }
.ml-fs-90  { font-size: .9rem; }
.ml-fs-92  { font-size: .92rem; }
.ml-fs-95  { font-size: .95rem; }
.ml-fs-100 { font-size: 1rem; }
.ml-text-cancel { color: #7f1d1d; }
.ml-vat-row { gap: 6px; }
.perm-badge { font-weight: 500; }

/* ---- 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; }
/* Field labels inside account panels are uppercase; form-check labels are not. */
.account-panel label { display: grid; gap: 6px; color: var(--ml-muted); font-size: .78rem; font-weight: 800; text-transform: uppercase; }
.account-panel label.form-check { display: flex; align-items: flex-start; gap: 8px; text-transform: none; font-size: .92rem; font-weight: 600; }
.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: #0a5160; background: #e8f3f5; border: 1px solid #0f6b7a; }
.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; }
@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; }
}

/* ---- Loyalty page (loyalty/index.php) ---- */
.loy-shell { max-width: 1100px; margin: 0 auto; padding: 24px; }
.loy-topbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 24px; flex-wrap: wrap; }
.loy-brand { display: flex; align-items: center; gap: 12px; }
.loy-brand img { height: 36px; }
.loy-brand strong { font-size: 1.15rem; color: var(--ml-primary); }
.loy-panel { background: #fff; border: 1px solid var(--ml-border); border-radius: 12px; padding: 24px; margin-bottom: 20px; }
.loy-panel h2 { margin: 0 0 16px; font-size: 1.1rem; font-weight: 700; color: var(--ml-primary); }
.loy-panel .table th, .loy-panel .table td { vertical-align: middle; }
.points-badge { font-size: 1rem; font-weight: 700; }
.loy-info-box { background: #f8fafc; border: 1px solid var(--ml-border); border-radius: 8px; padding: 14px; height: 100%; }
@media (max-width: 576px) {
	.loy-panel .table thead { display: none; }
	.loy-panel .table tr { display: block; border-bottom: 2px solid var(--ml-border); padding: 8px 0; }
	.loy-panel .table td { display: block; text-align: left; padding: 4px 0; }
	.loy-panel .table td::before { content: attr(data-label); font-weight: 700; margin-right: 6px; color: #607080; }
}

/* ---- Register + Demo + Billing (shared card container) ---- */
.page { max-width: 980px; margin: 0 auto; padding: 24px 16px; }
.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 a card (the dashboard sidebar brand is not loaded here). */
.card-form .brand, .billing-card .brand { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.card-form .brand img { width: 150px; max-height: 110px; object-fit: contain; }
.billing-card .brand img { width: 140px; max-height: 92px; object-fit: contain; }
.card-form label { display: grid; gap: 6px; color: #5e6d7d; font-size: .78rem; font-weight: 800; text-transform: 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; }
.card-form .grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
/* 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; }
.card-form .grid .full, .card-form .full { grid-column: 1 / -1; }
.demo-card { width: min(100%, 520px); display: grid; gap: 14px; }
/* Billing summary card (billing/index.php). */
.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); }
.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: #0a5160; 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 #0f6b7a; border-radius: 8px; background: #e8f3f5; color: #0a3d47; }
.founder-reg-note i { font-size: 1.3rem; line-height: 1.2; color: #0f6b7a; 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: #0f6b7a; 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: #0f6b7a; 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: #0f6b7a; text-decoration: underline; }
@media (max-width: 760px) { .card-form .grid, .billing-options, .card-form .credentials-grid { grid-template-columns: 1fr; } }

/* ---- Legal pages (privacy / cookie / refund — src/Support/privacy.php) ---- */
.legal-wrap { max-width: 820px; margin: 0 auto; padding: 32px 20px 64px; line-height: 1.6; }
.legal-back { display: inline-flex; align-items: center; gap: 6px; color: var(--ml-primary); font-weight: 650; text-decoration: none; margin-bottom: 18px; }
.legal-back:hover { color: var(--ml-primary-dark); }
.legal-version { display: inline-block; padding: 3px 10px; border-radius: 999px; background: #e8f3f5; color: var(--ml-primary-dark); font-size: .74rem; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; }
.legal-wrap h1 { margin: 12px 0 8px; font-size: 2rem; font-weight: 800; }
.legal-lead { color: var(--ml-muted); font-size: 1.05rem; margin: 0 0 28px; }
.legal-block { background: #fff; border: 1px solid var(--ml-border); border-radius: 10px; padding: 20px 22px; margin-bottom: 16px; box-shadow: 0 6px 18px rgba(31,43,57,.04); }
.legal-block h2 { margin: 0 0 10px; font-size: 1.2rem; font-weight: 800; }
.legal-block p { margin: 0 0 10px; }
.legal-block p:last-child { margin-bottom: 0; }
.legal-block code { background: #f1f5f9; padding: 1px 6px; border-radius: 5px; font-size: .9em; }
.legal-footer { margin-top: 28px; padding-top: 18px; border-top: 1px solid var(--ml-border); color: var(--ml-muted); font-size: .9rem; display: flex; flex-wrap: wrap; gap: 14px; justify-content: space-between; }
.legal-footer a { color: var(--ml-primary); }
