/* Aquardens Operations CMS — stile dell'interfaccia admin.
   Palette dal Brand Book 1.2: Deep Indigo #232F47 (#34466A, #B7C3DC), Silver Mist #9EB5BD
   (#A2C1CE, #B6D3DD), Pure Aqua #98D0D0 (#A7DAD8, #BBEAE9); secondaria: Amber Seam #E5A74C,
   Warm Haze #EBD8BF, Cedar Wood #B88665, Deep Earth #483222, Quiet Green #779D75. */
:root {
  --indigo: #232f47;
  --indigo-2: #34466a;
  --indigo-3: #b7c3dc;
  --mist: #9eb5bd;
  --mist-2: #a2c1ce;
  --mist-3: #b6d3dd;
  --aqua: #98d0d0;
  --aqua-2: #a7dad8;
  --aqua-3: #bbeae9;
  --amber: #e5a74c;
  --haze: #ebd8bf;
  --cedar: #b88665;
  --earth: #483222;
  --green: #779d75;

  --bg: #f3f6f8;
  --panel: #ffffff;
  --text: #1f2a3d;
  --muted: #5d6b80;
  --line: #d8e0e8;
  --brand: var(--indigo);
  --brand-dark: #182238;
  --accent: var(--aqua);
  --ok: #4f7f4d;
  --ok-bg: #e6f0e5;
  --warn: #b07a1f;
  --warn-bg: #fbf1df;
  --error: #b3261e;
  --error-bg: #fcebe9;
  --info: var(--indigo-2);
  --info-bg: #e9eef8;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(35, 47, 71, 0.06), 0 4px 16px rgba(35, 47, 71, 0.06);
  --font: "Degular Sans", "Segoe UI", system-ui, -apple-system, Roboto, Helvetica, Arial, sans-serif;
  --topbar-h: 64px;
}

* { box-sizing: border-box; }
html, body, #root { height: 100%; margin: 0; }
body { font: 14px/1.45 var(--font); color: var(--text); background: var(--bg); }
a { color: var(--indigo-2); }
h1 { font-size: 24px; margin: 0 0 4px; color: var(--indigo); font-weight: 700; letter-spacing: -0.01em; }
h2 { font-size: 17px; margin: 0 0 6px; color: var(--indigo); font-weight: 700; }
code, pre { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12.5px; }
pre { background: #f6f8fa; border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 12px; overflow: auto; max-height: 60vh; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.text-error { color: var(--error); }
.text-ok { color: var(--ok); }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
@media (max-width: 700px) { .grid-2 { grid-template-columns: 1fr; } }

/* Struttura: barra alta blu, menu bianco a sinistra, contenuto */
.shell { min-height: 100%; display: flex; flex-direction: column; }
.shell-bare { align-items: center; justify-content: center; padding: 24px; background: linear-gradient(160deg, var(--indigo) 0%, var(--indigo-2) 60%, #4a5f8a 100%); }
.shell-bare .card { box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25); }
.topbar { height: var(--topbar-h); background: var(--indigo); color: #fff; display: flex; align-items: center; justify-content: space-between; padding: 0 20px; position: sticky; top: 0; z-index: 50; box-shadow: 0 2px 10px rgba(0, 0, 0, 0.15); }
.brand { display: flex; align-items: center; gap: 10px; color: #fff; text-decoration: none; font-weight: 700; font-size: 18px; letter-spacing: 0.02em; }
.brand-logo { height: 38px; width: auto; display: block; }
.brand-text { font-family: Georgia, "Times New Roman", serif; font-size: 22px; letter-spacing: 0.08em; text-transform: uppercase; }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.topbar-user { display: flex; align-items: center; gap: 10px; color: #fff; text-decoration: none; padding: 6px 10px; border-radius: 30px; }
.topbar-user:hover, .topbar-user.active { background: rgba(255, 255, 255, 0.12); }
.topbar-user-text { display: flex; flex-direction: column; line-height: 1.15; font-size: 12px; }
.topbar-user-text strong { font-size: 13px; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--aqua); color: var(--indigo); display: inline-flex; align-items: center; justify-content: center; font-weight: 700; }
.btn-ghost { background: transparent; border-color: rgba(255, 255, 255, 0.35); color: #fff; }
.btn-ghost:hover:not(:disabled) { background: rgba(255, 255, 255, 0.12); border-color: #fff; }
.badge { display: inline-block; background: var(--amber); color: var(--earth); border-radius: 10px; padding: 1px 8px; font-size: 11px; text-transform: uppercase; font-weight: 700; }
.body { display: flex; flex: 1; min-height: 0; }
.sidebar { width: 232px; flex: 0 0 232px; background: #fff; border-right: 1px solid var(--line); padding: 18px 12px; position: sticky; top: var(--topbar-h); height: calc(100vh - var(--topbar-h)); overflow: auto; }
.sidebar-title { font-weight: 800; color: var(--indigo); font-size: 15px; padding: 4px 12px 14px; letter-spacing: 0.01em; }
.sidebar-title span { display: block; font-size: 11px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; }
.nav-group { margin-bottom: 14px; }
.nav-group-title { font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); padding: 6px 12px 4px; font-weight: 700; }
.sidebar nav a { display: block; color: var(--indigo); text-decoration: none; padding: 9px 12px; border-radius: 10px; font-weight: 600; margin: 1px 0; }
.sidebar nav a:hover { background: #eef3f7; }
.sidebar nav a.active { background: var(--indigo); color: #fff; box-shadow: var(--shadow); }
.content { flex: 1; min-width: 0; padding: 22px 26px; display: flex; flex-direction: column; gap: 12px; }

.page { display: flex; flex-direction: column; gap: 12px; min-height: 0; flex: 1; }
.page-grid { height: calc(100vh - var(--topbar-h) - 44px); }
.page-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }
.card.narrow { width: 100%; max-width: 420px; }
.login h1 { margin: 16px 0 12px; }
.login .brand { color: var(--indigo); }
.login .brand-text { display: inline !important; }
.steps { padding-left: 20px; }
.steps li { margin-bottom: 6px; }
.qr-box { display: flex; gap: 16px; align-items: flex-start; margin: 12px 0; }
.qr-box img { border: 1px solid var(--line); border-radius: var(--radius-sm); background: #fff; }
.secret { display: block; margin-top: 6px; word-break: break-all; background: #f6f8fa; padding: 6px; border-radius: 4px; }

/* Controlli */
.btn { font: inherit; font-weight: 600; padding: 7px 13px; border-radius: 9px; border: 1px solid var(--line); background: #fff; color: var(--indigo); cursor: pointer; white-space: nowrap; }
.btn:hover:not(:disabled) { border-color: var(--mist); background: #f6f9fb; }
.btn:disabled { opacity: 0.5; cursor: default; }
.btn-primary { background: var(--indigo); border-color: var(--indigo); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--brand-dark); border-color: var(--brand-dark); }
.btn-danger { color: var(--error); border-color: #e7b9b5; }
.btn-sm { padding: 4px 10px; font-size: 13px; }
.btn-block { width: 100%; margin-top: 8px; }
.btn-link { border: none; background: none; color: var(--indigo-2); padding: 4px 6px; text-decoration: underline; font-weight: 500; }
.btn-icon { border: none; background: none; font-size: 20px; line-height: 1; padding: 2px 8px; }
input, select, textarea { font: inherit; padding: 7px 10px; border: 1px solid var(--line); border-radius: 9px; background: #fff; color: var(--text); }
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(152, 208, 208, 0.6); border-color: var(--indigo-2); }
textarea { width: 100%; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12.5px; }
input[type="date"] { padding: 5px 8px; }
.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px; }
.field-label { font-weight: 700; font-size: 12px; color: var(--indigo); text-transform: uppercase; letter-spacing: 0.04em; }
.field-hint { color: var(--muted); font-size: 12px; text-transform: none; letter-spacing: 0; font-weight: 400; }
.check { display: inline-flex; align-items: center; gap: 6px; }
.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 8px 12px; box-shadow: var(--shadow); }
.toolbar .sep { width: 1px; height: 22px; background: var(--line); margin: 0 4px; }
.daterange { display: flex; gap: 6px; align-items: center; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.tabs a, .tabs button { padding: 8px 12px; border: none; background: none; color: var(--muted); text-decoration: none; border-bottom: 2px solid transparent; cursor: pointer; font: inherit; font-weight: 600; }
.tabs .active { color: var(--indigo); border-bottom-color: var(--indigo); }

/* Messaggi */
.box { padding: 10px 12px; border-radius: var(--radius-sm); border: 1px solid; }
.box-error { background: var(--error-bg); border-color: #efc1bd; color: #7a1a15; }
.box-warn { background: var(--warn-bg); border-color: #efd39b; color: #6b4400; }
.box-info { background: var(--info-bg); border-color: var(--indigo-3); color: var(--indigo); }
.box-ok { background: var(--ok-bg); border-color: #bfd7bd; color: #2f4f2e; }
.issues ul { margin: 6px 0 0; padding-left: 18px; }
.spinner { display: flex; align-items: center; gap: 10px; color: var(--muted); padding: 20px; }
.spinner-dot { width: 14px; height: 14px; border: 2px solid var(--line); border-top-color: var(--indigo); border-radius: 50%; animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.toasts { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 1000; max-width: 420px; }
.toast { padding: 10px 14px; border-radius: var(--radius-sm); color: #fff; box-shadow: 0 6px 20px rgba(0, 0, 0, 0.18); cursor: pointer; font-weight: 500; }
.toast-ok { background: var(--green); }
.toast-error { background: var(--error); }
.toast-info { background: var(--indigo-2); }

/* Finestre */
.modal-backdrop { position: fixed; inset: 0; background: rgba(35, 47, 71, 0.5); display: flex; align-items: center; justify-content: center; z-index: 900; padding: 16px; }
.modal { background: #fff; border-radius: 14px; width: 100%; max-width: 520px; max-height: 92vh; display: flex; flex-direction: column; box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3); }
.modal-wide { max-width: 860px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.modal-body { padding: 16px 18px; overflow: auto; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 18px; border-top: 1px solid var(--line); }

/* Tabelle semplici */
.etable { overflow: auto; }
td.nowrap, th.nowrap { white-space: nowrap; }
table.data { width: 100%; border-collapse: separate; border-spacing: 0; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
table.data th, table.data td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.data th { background: #eef2f6; font-weight: 700; font-size: 12px; color: var(--indigo); text-transform: uppercase; letter-spacing: 0.04em; }
table.data tr:last-child td { border-bottom: none; }
table.data td.num, table.data th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.data tr.row-dirty td { background: #fffbe8; }
table.data tr.row-error td { background: var(--error-bg); }
.pill { display: inline-block; padding: 1px 8px; border-radius: 10px; font-size: 12px; background: #e6ebef; font-weight: 600; }
.pill-PUBLISHED, .pill-APPLIED, .pill-APPROVED { background: #dcebdb; color: #2f4f2e; }
.pill-DRAFT, .pill-SUBMITTED { background: var(--haze); color: #6b4400; }
.pill-ARCHIVED, .pill-CANCELLED, .pill-FAILED { background: #f2d7d5; color: #7a1a15; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); }
.stat .muted { text-transform: uppercase; font-size: 11px; letter-spacing: 0.08em; font-weight: 700; }
.stat .big { font-size: 30px; font-weight: 800; color: var(--indigo); line-height: 1.1; margin: 6px 0 2px; }
.usage { display: flex; align-items: center; gap: 10px; font-size: 12.5px; color: var(--muted); }
.usage-bar { flex: 1; height: 8px; background: #e6ebef; border-radius: 4px; overflow: hidden; min-width: 120px; }
.usage-bar > span { display: block; height: 100%; background: var(--aqua); }
.usage-bar.warn > span { background: var(--amber); }
.usage-bar.full > span { background: var(--error); }
.thumb { width: 56px; height: 42px; object-fit: cover; border-radius: 6px; border: 1px solid var(--line); background: #f6f8fa; }
.thumb-lg { width: 160px; height: 110px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { display: grid; grid-template-columns: 130px 1fr; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.timeline .when { color: var(--muted); font-size: 12.5px; font-variant-numeric: tabular-nums; }
.timeline .who { font-weight: 700; color: var(--indigo); }
.diff { margin: 4px 0 0; padding: 0; list-style: none; font-size: 12.5px; }
.diff li { padding: 1px 0; }
.diff .before { color: var(--error); text-decoration: line-through; }
.diff .after { color: var(--ok); font-weight: 600; }
.tree { display: flex; flex-direction: column; gap: 4px; }
.tree button { text-align: left; border: 1px solid var(--line); background: #fff; border-radius: 9px; padding: 8px 10px; cursor: pointer; font: inherit; }
.tree button.active { background: var(--indigo); color: #fff; border-color: var(--indigo); }
.tree .sub { padding-left: 14px; }

/* Griglia RevoGrid */
.grid-wrap { flex: 1; min-height: 320px; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: #fff; box-shadow: var(--shadow); }
.grid-wrap revo-grid { height: 100%; }
revo-grid .row-dirty .rgCell { background: #fffbe8; }
revo-grid .row-error .rgCell { background: #fff1f0; }
revo-grid .row-warn .rgCell { background: #fff8ec; }
revo-grid .row-published .rgCell:first-child { box-shadow: inset 3px 0 0 var(--green); }
revo-grid .row-archived .rgCell { color: #8a949c; text-decoration: line-through; }
revo-grid .rgCell.cell-error { background: #ffd6d3 !important; outline: 1px solid var(--error); outline-offset: -1px; }
revo-grid .rgCell.cell-locked { color: #8a949c; font-style: italic; }
revo-grid .rgCell.cell-readonly { background: #f5f7f9; }
revo-grid .rgCell.cell-closed { color: var(--error); font-weight: 600; }
revo-grid .rgCell.cell-rule { color: #5f6b76; }
revo-grid .list-editor { width: 100%; height: 100%; border: none; padding: 0 6px; font: inherit; outline: none; }
