/* JornadaFX admin — design tokens shared with the mobile app (JORNADAFX_HARNESS §7). */
:root {
  --navy: #0B1F33; --navy-2: #13304D; --blue: #2563EB; --blue-d: #1D4FD8; --blue-50: #EEF3FE;
  --green: #16B77A; --green-50: #E8F8F1; --amber: #F59E0B; --amber-50: #FEF5E6; --red: #DC2626; --red-50: #FDECEC;
  --bg: #F7F9FC; --surface: #FFFFFF; --text: #172033; --muted: #65758B; --border: #E5EAF0; --disabled: #AAB4C3;
  --r: 16px; --r-sm: 10px; --shadow: 0 1px 2px rgba(11,31,51,.04), 0 4px 16px rgba(11,31,51,.04);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: var(--font); font-size: 15px; line-height: 1.5; color: var(--text); background: var(--bg); -webkit-font-smoothing: antialiased; }
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; line-height: 1.25; font-weight: 650; letter-spacing: -.01em; }
h1 { font-size: 24px; } h2 { font-size: 18px; } h3 { font-size: 15px; }
small, .muted { color: var(--muted); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; }
.nowrap { white-space: nowrap; }

/* Shell */
.shell { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; }
.sidebar { background: var(--navy); color: #C9D4E2; padding: 20px 14px; position: sticky; top: 0; height: 100vh; overflow-y: auto; display: flex; flex-direction: column; }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 18px; color: #fff; }
.brand-mark { width: 32px; height: 32px; border-radius: 9px; background: var(--blue); display: grid; place-items: center; font-weight: 800; font-size: 14px; color: #fff; }
.brand-name { font-weight: 700; font-size: 17px; letter-spacing: -.01em; }
.brand-tag { font-size: 11.5px; color: #8EA2BA; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 10px; color: #C9D4E2; font-weight: 500; font-size: 14.5px; }
.nav a:hover { background: var(--navy-2); color: #fff; text-decoration: none; }
.nav a.active { background: var(--blue); color: #fff; }
.nav a svg { width: 18px; height: 18px; flex: none; opacity: .9; }
.nav-sep { margin: 14px 12px 6px; font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: #6F849D; }
.sidebar-foot { margin-top: auto; padding: 14px 10px 0; border-top: 1px solid var(--navy-2); font-size: 13px; }
.sidebar-foot form { margin: 8px 0 0; }
.sidebar-foot button { background: none; border: 0; color: #C9D4E2; padding: 0; cursor: pointer; font: inherit; }
.main { min-width: 0; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 18px 32px; border-bottom: 1px solid var(--border); background: var(--surface); position: sticky; top: 0; z-index: 5; }
.topbar .tenant { font-weight: 600; }
.topbar select { min-width: 220px; }
.content { padding: 28px 32px 48px; max-width: 1360px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head p { margin: 4px 0 0; color: var(--muted); }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* Cards & grids */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); box-shadow: var(--shadow); }
.card-pad { padding: 20px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.card-head h2 { font-size: 16px; }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 20px; }
.kpi { padding: 16px 18px; display: block; color: inherit; }
.kpi:hover { text-decoration: none; border-color: #C9D6EA; }
.kpi .label { color: var(--muted); font-size: 13px; font-weight: 500; }
.kpi .value { font-size: 30px; font-weight: 700; letter-spacing: -.02em; margin-top: 2px; }
.kpi.warn .value { color: #B45309; } .kpi.ok .value { color: #0E8A5B; } .kpi.alert .value { color: var(--red); }
.section-list { list-style: none; margin: 0; padding: 0; }
.section-list li { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 11px 20px; border-top: 1px solid var(--border); }
.section-list li:first-child { border-top: 0; }
.dl { display: grid; grid-template-columns: 180px 1fr; gap: 8px 16px; margin: 0; }
.dl dt { color: var(--muted); font-size: 14px; } .dl dd { margin: 0; font-weight: 500; }

/* Tables */
.table-wrap { overflow-x: auto; }
table.t { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 14.5px; }
.t th { position: sticky; top: 0; background: #FAFBFD; text-align: left; font-weight: 600; font-size: 12.5px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); padding: 10px 14px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.t td { padding: 12px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.t tr:last-child td { border-bottom: 0; }
.t tbody tr:hover td { background: #FBFCFE; }
.t .num { text-align: right; font-variant-numeric: tabular-nums; }
.empty { padding: 40px 20px; text-align: center; color: var(--muted); }
.empty strong { display: block; color: var(--text); font-size: 15px; margin-bottom: 4px; }

/* Badges (always text + color, never color alone) */
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; font-size: 12.5px; font-weight: 600; background: #EEF1F5; color: #44546A; white-space: nowrap; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .8; }
.badge.ok { background: var(--green-50); color: #0E7A51; }
.badge.warn { background: var(--amber-50); color: #A15C07; }
.badge.bad { background: var(--red-50); color: #B91C1C; }
.badge.info { background: var(--blue-50); color: var(--blue-d); }
.badge.plain::before { display: none; }

/* Forms & buttons */
label { display: block; font-weight: 600; font-size: 13.5px; margin-bottom: 6px; }
.field { margin-bottom: 16px; }
.field .hint { font-size: 12.5px; color: var(--muted); margin-top: 4px; font-weight: 400; }
.field .error { font-size: 13px; color: var(--red); margin-top: 4px; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], input[type=time], input[type=url], input[type=search], input[type=datetime-local], select, textarea {
  width: 100%; padding: 9px 12px; border: 1px solid #D5DDE7; border-radius: var(--r-sm); font: inherit; color: var(--text); background: #fff; min-height: 40px; }
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(37,99,235,.25); border-color: var(--blue); }
textarea { min-height: 96px; resize: vertical; }
input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--blue); vertical-align: middle; }
.check { display: flex; gap: 10px; align-items: flex-start; font-weight: 500; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 16px; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 40px; padding: 8px 16px; border-radius: var(--r-sm); border: 1px solid transparent; font: inherit; font-weight: 600; font-size: 14.5px; cursor: pointer; text-decoration: none !important; white-space: nowrap; }
.btn-primary { background: var(--blue); color: #fff; } .btn-primary:hover { background: var(--blue-d); }
.btn-secondary { background: #fff; color: var(--text); border-color: #D5DDE7; } .btn-secondary:hover { background: #F4F7FB; }
.btn-danger { background: #fff; color: var(--red); border-color: #F3C4C4; } .btn-danger:hover { background: var(--red-50); }
.btn-success { background: var(--green); color: #fff; }
.btn-sm { min-height: 32px; padding: 4px 12px; font-size: 13.5px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.filters .f { min-width: 160px; flex: 0 1 200px; } .filters .f-grow { flex: 1 1 260px; }
.filters label { font-size: 12px; color: var(--muted); font-weight: 600; margin-bottom: 4px; }
.inline-form { display: inline; }

/* Alerts */
.flash { padding: 12px 16px; border-radius: var(--r-sm); margin-bottom: 16px; font-weight: 500; border: 1px solid; }
.flash.ok { background: var(--green-50); border-color: #BFEBD7; color: #0B6B47; }
.flash.bad { background: var(--red-50); border-color: #F6CACA; color: #9B1C1C; }
.flash.warn { background: var(--amber-50); border-color: #F8DDB0; color: #8A4E05; }
.secret-box { background: var(--navy); color: #fff; border-radius: var(--r-sm); padding: 14px 16px; font-family: ui-monospace, monospace; word-break: break-all; }

/* Pagination */
.pager { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; border-top: 1px solid var(--border); font-size: 14px; color: var(--muted); }
.pager .links { display: flex; gap: 6px; }

/* Tabs */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 20px; overflow-x: auto; }
.tabs a { padding: 10px 14px; font-weight: 600; color: var(--muted); border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs a.active { color: var(--blue); border-color: var(--blue); }
.tabs a:hover { text-decoration: none; color: var(--text); }

/* Evidence */
.evidence-img { width: 100%; max-width: 360px; border-radius: 12px; border: 1px solid var(--border); background: #EEF1F5; }
.thumb { width: 44px; height: 44px; border-radius: 10px; object-fit: cover; background: #EEF1F5; border: 1px solid var(--border); }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { padding: 12px 20px; border-top: 1px solid var(--border); display: grid; grid-template-columns: 76px 1fr auto; gap: 12px; align-items: center; }
.timeline li:first-child { border-top: 0; }
.timeline .time { font-weight: 700; font-variant-numeric: tabular-nums; font-size: 16px; }
.strike { text-decoration: line-through; color: var(--muted); }

/* Mail delivery tracking */
.mail-diagnostics { margin-bottom: 16px; }
.mail-span-2 { grid-column: span 2; }
.break-all { overflow-wrap: anywhere; word-break: break-word; }
.dl.compact { margin-top: 12px; }
.dl.compact dt, .dl.compact dd { padding-top: 7px; padding-bottom: 7px; }
.mail-timeline { list-style: none; margin: 0; padding: 0; }
.mail-timeline li { display: grid; grid-template-columns: minmax(130px, auto) minmax(220px, 1fr) minmax(180px, 1fr); gap: 16px; align-items: start; padding: 16px 20px; border-top: 1px solid var(--border); }
.mail-timeline li:first-child { border-top: 0; }

/* QR print sheet */
.qr-sheet { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.qr-card { border: 1px dashed #C7D2E0; border-radius: 12px; padding: 14px; text-align: center; page-break-inside: avoid; background: #fff; }
.qr-card svg { width: 180px; height: 180px; }
.qr-card .code { font-family: ui-monospace, monospace; font-size: 16px; font-weight: 700; letter-spacing: .06em; }

/* Auth */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: linear-gradient(180deg, var(--navy) 0, var(--navy) 42%, var(--bg) 42%); }
.auth-card { width: 100%; max-width: 420px; padding: 32px; }
.auth-brand { color: #fff; text-align: center; margin-bottom: 24px; }
.auth-brand .brand-mark { margin: 0 auto 12px; width: 48px; height: 48px; font-size: 20px; border-radius: 14px; }

@media (max-width: 1200px) { .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 960px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; }
  .nav { flex-direction: row; flex-wrap: wrap; }
  .grid-2, .grid-3, .form-grid { grid-template-columns: 1fr; }
  .mail-span-2 { grid-column: auto; }
  .mail-timeline li { grid-template-columns: 1fr; }
  .content, .topbar { padding-left: 16px; padding-right: 16px; }
  .dl { grid-template-columns: 1fr; }
  .qr-sheet { grid-template-columns: repeat(2, 1fr); }
}
@media print {
  .sidebar, .topbar, .no-print { display: none !important; }
  .shell { display: block; } .content { padding: 0; max-width: none; }
  .card { box-shadow: none; border: 0; }
  body { background: #fff; }
}
