/* FBR · Gestão do site */
:root {
  --ink: #1B1A17; --ink-2: #2a2925; --paper: #F5F2EB; --paper-2: #EDE8DD; --white: #fff;
  --body: #4A473F; --muted: #6B675E; --faint: #9a968c;
  --line: #E4DED2; --line-strong: #CFC8BA; --line-light: rgba(255,255,255,.1);
  --forest: #2F4A2C; --forest-2: #3d5f39; --forest-deep: #1D2A1C; --lime: #B5D334; --lime-2: #c6e24a;
  --red: #B8402C; --red-bright: #e0624b; --ok: #2F6B3A; --warn: #A76A00;
  --st-novo: #B8402C; --st-contactado: #A76A00; --st-visita: #2563B0; --st-orcamento: #9A3B86; --st-adjudicado: #2F6B3A; --st-perdido: #8A857B;
  --sans: 'Outfit', system-ui, sans-serif; --serif: 'Newsreader', Georgia, serif; --mono: 'JetBrains Mono', ui-monospace, monospace;
  --side-w: 248px; --head-h: 74px; --pad: clamp(16px, 2.6vw, 36px);
  --radius: 10px; --ease: cubic-bezier(.16,1,.3,1);
  --shadow: 0 1px 0 rgba(27,26,23,.03), 0 10px 30px rgba(27,26,23,.07);
}
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body { background: var(--paper); color: var(--ink); font: 400 15px/1.5 var(--sans); -webkit-font-smoothing: antialiased; }
a { color: inherit; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
button:disabled { cursor: not-allowed; }
input, textarea, select { font: inherit; color: inherit; }
img { display: block; max-width: 100%; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--forest); outline-offset: 2px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.muted { color: var(--muted); }
.ico { width: 20px; height: 20px; flex: none; }
.ico-sm { width: 16px; height: 16px; flex: none; }

/* ── boot ── */
.boot { position: fixed; inset: 0; display: grid; place-items: center; }
.boot svg { animation: pulse 1.4s var(--ease) infinite; }
@keyframes pulse { 0%,100% { opacity: .3 } 50% { opacity: 1 } }

/* ── buttons ── */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 40px; padding: 0 18px; border-radius: 999px;
  background: var(--forest); color: #fff; font-weight: 600; font-size: 14.5px; white-space: nowrap; text-decoration: none; border: 1px solid var(--forest);
  transition: background .15s, border-color .15s, color .15s, transform .15s; }
.btn:hover:not(:disabled) { background: var(--forest-2); border-color: var(--forest-2); }
.btn:active:not(:disabled) { transform: scale(.98); }
.btn:disabled { opacity: .5; }
.btn--lime { background: var(--lime); border-color: var(--lime); color: var(--ink); }
.btn--lime:hover:not(:disabled) { background: var(--lime-2); border-color: var(--lime-2); }
.btn--ghost { background: var(--white); color: var(--ink); border-color: var(--line-strong); }
.btn--ghost:hover:not(:disabled) { background: var(--paper); border-color: var(--ink); }
.btn--danger { background: var(--white); color: var(--red); border-color: #e7c3bb; }
.btn--danger:hover:not(:disabled) { background: #fbefec; border-color: var(--red); }
.btn--sm { min-height: 34px; padding: 0 14px; font-size: 13.5px; }
.btn--block { width: 100%; }
.btn .spin { width: 15px; height: 15px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg) } }
.icon-btn { display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: 8px; color: var(--muted); flex: none; transition: background .15s, color .15s; }
.icon-btn:hover:not(:disabled) { background: var(--paper-2); color: var(--ink); }
.icon-btn:disabled { opacity: .3; }
.icon-btn--danger:hover:not(:disabled) { background: #fbefec; color: var(--red); }
.link-btn { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; font-weight: 600; color: var(--forest); padding: 4px 0; text-decoration: none; }
.link-btn:hover { text-decoration: underline; text-underline-offset: 3px; }

/* ── forms ── */
.field { display: grid; gap: 6px; min-width: 0; }
.field > span, .field > label { font-size: 13.5px; font-weight: 500; color: var(--body); }
.field small { font-size: 12.5px; color: var(--muted); line-height: 1.4; }
.input, .field input:not([type=checkbox]):not([type=radio]):not([type=file]), .field textarea, .field select {
  width: 100%; font-size: 15px; padding: 10px 12px; border: 1px solid var(--line-strong); border-radius: 8px; background: var(--white); color: var(--ink);
  transition: border-color .15s, box-shadow .15s; }
.field textarea { resize: vertical; min-height: 84px; line-height: 1.5; }
.input:focus, .field input:focus, .field textarea:focus, .field select:focus { outline: 0; border-color: var(--forest); box-shadow: 0 0 0 3px rgba(47,74,44,.14); }
.field .count { justify-self: end; font: 500 11.5px var(--mono); color: var(--faint); }
.field .count[data-over] { color: var(--warn); }
.toggle { display: flex; align-items: center; gap: 12px; cursor: pointer; font-size: 14.5px; }
.toggle input { position: absolute; opacity: 0; pointer-events: none; }
.toggle i { position: relative; width: 40px; height: 24px; border-radius: 12px; background: var(--line-strong); flex: none; transition: background .2s; }
.toggle i::after { content: ''; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.2); transition: transform .2s var(--ease); }
.toggle input:checked + i { background: var(--forest); }
.toggle input:checked + i::after { transform: translateX(16px); }
.toggle input:focus-visible + i { outline: 2px solid var(--forest); outline-offset: 2px; }
.pass { position: relative; }
.pass input { padding-right: 46px !important; }
.pass input::-ms-reveal { display: none; }
.pass button { position: absolute; top: 1px; right: 1px; bottom: 1px; width: 44px; display: grid; place-items: center; color: var(--muted); border-radius: 0 8px 8px 0; }
.pass button:hover { color: var(--ink); }
.img-field { display: flex; gap: 12px; align-items: center; }
.img-field .thumb { width: 84px; height: 64px; border-radius: 8px; background: var(--paper-2) center/cover no-repeat; border: 1px solid var(--line); flex: none; }
.img-field .thumb:empty::after { content: ''; }
.seg { display: inline-flex; padding: 3px; background: var(--paper-2); border-radius: 999px; gap: 2px; flex-wrap: wrap; }
.seg button { padding: 6px 12px; border-radius: 999px; font-size: 13.5px; color: var(--body); }
.seg button[aria-pressed=true] { background: var(--white); color: var(--ink); font-weight: 600; box-shadow: 0 1px 3px rgba(27,26,23,.12); }
.err { color: var(--red); font-size: 14px; }
.ok-msg { color: var(--ok); font-size: 14px; }

/* ── auth screens ── */
.auth { min-height: 100vh; display: grid; place-content: center; justify-items: center; gap: 28px; padding: 40px 16px; }
.auth-logo { display: flex; align-items: center; gap: 12px; }
.auth-logo b { font: 500 22px/1 var(--serif); letter-spacing: .16em; }
.auth-logo small { display: block; font: 600 8.5px/1 var(--sans); letter-spacing: .32em; color: var(--muted); margin-top: 6px; }
.card { background: var(--white); border: 1px solid var(--line); border-radius: 14px; padding: 32px; box-shadow: var(--shadow); width: min(400px, calc(100vw - 32px)); }
.auth form { display: grid; gap: 18px; }
.auth h1 { font: 500 30px/1.1 var(--serif); }
.auth p { color: var(--muted); font-size: 14.5px; }
.auth .btn { min-height: 46px; }

/* ── shell: sidebar + content ── */
.app { display: grid; grid-template-columns: var(--side-w) minmax(0, 1fr); min-height: 100vh; }
.side { position: sticky; top: 0; height: 100vh; height: 100svh; display: flex; flex-direction: column; padding: 22px 14px 14px; overflow-y: auto; background: var(--ink); color: rgba(255,255,255,.74); z-index: 40; }
.side-brand { display: grid; gap: 14px; padding: 2px 10px 20px; border-bottom: 1px solid var(--line-light); text-decoration: none; }
.side-brand .row { display: flex; align-items: center; gap: 12px; }
.side-brand b { font: 500 21px/1 var(--serif); letter-spacing: .16em; color: #fff; }
.side-brand small { display: block; font: 600 7.5px/1 var(--sans); letter-spacing: .32em; color: rgba(255,255,255,.55); margin-top: 6px; }
.side-brand > span { font: 500 10.5px/1 var(--mono); letter-spacing: .18em; text-transform: uppercase; color: rgba(255,255,255,.45); }
.side-nav { display: grid; gap: 2px; padding: 10px 0; }
.side-group { padding: 18px 10px 8px; font: 500 10.5px/1 var(--mono); letter-spacing: .16em; text-transform: uppercase; color: rgba(255,255,255,.4); }
.nav { position: relative; display: flex; align-items: center; gap: 12px; min-height: 42px; padding: 0 10px; border-radius: 8px; color: rgba(255,255,255,.74); font-size: 14.5px; text-decoration: none; transition: background .15s, color .15s; }
.nav > span:not([class]) { flex: 1; min-width: 0; }
.nav:hover { color: #fff; background: rgba(255,255,255,.06); }
.nav[aria-current=page] { color: #fff; background: rgba(255,255,255,.1); font-weight: 600; }
.nav[aria-current=page]::before { content: ''; position: absolute; left: -14px; top: 9px; bottom: 9px; width: 3px; border-radius: 0 3px 3px 0; background: var(--lime); }
.nav:focus-visible { outline: 2px solid #fff; outline-offset: -2px; }
.badge { min-width: 22px; height: 22px; padding: 0 7px; display: grid; place-items: center; border-radius: 11px; background: var(--red-bright); color: #fff; font: 600 12px/1 var(--sans); flex: none; }
.dot-badge { width: 8px; height: 8px; border-radius: 50%; background: var(--lime); flex: none; }
.side-foot { margin-top: auto; display: grid; grid-template-columns: minmax(0, 1fr); gap: 4px; padding-top: 14px; border-top: 1px solid var(--line-light); }
.side-user { min-width: 0; display: flex; align-items: center; gap: 10px; padding: 8px 2px 2px 10px; }
.avatar { width: 30px; height: 30px; display: grid; place-items: center; flex: none; border-radius: 50%; background: rgba(255,255,255,.12); color: #fff; font-weight: 600; font-size: 13px; }
.side-user > span:not(.avatar) { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; color: rgba(255,255,255,.62); }
.side .icon-btn { color: rgba(255,255,255,.6); }
.side .icon-btn:hover { background: rgba(255,255,255,.1); color: #fff; }

.body { min-width: 0; display: flex; flex-direction: column; }
.head { position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 14px; min-height: var(--head-h); padding: 12px var(--pad);
  background: rgba(255,255,255,.94); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.head-titles { display: grid; gap: 5px; min-width: 0; }
.eyebrow { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font: 600 10.5px/1 var(--mono); letter-spacing: .18em; text-transform: uppercase; color: var(--forest); }
.head h1 { font: 500 28px/1.05 var(--serif); letter-spacing: -.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.head-actions { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.menu-toggle { display: none !important; }
.side-scrim { display: none; }
.pubstate { display: inline-flex; align-items: center; gap: 8px; font-size: 13.5px; color: var(--muted); white-space: nowrap; }
.pubstate i { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); flex: none; }
.pubstate[data-dirty] { color: var(--ink); font-weight: 600; }
.pubstate[data-dirty] i { background: var(--warn); box-shadow: 0 0 0 4px rgba(167,106,0,.14); }
.main { width: 100%; max-width: 1400px; padding: 26px var(--pad) 80px; display: grid; gap: 22px; align-content: start; }
.intro { color: var(--muted); max-width: 76ch; }

/* ── panels & dashboard ── */
.grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 20px; }
.span-3 { grid-column: span 3; } .span-4 { grid-column: span 4; } .span-5 { grid-column: span 5; } .span-6 { grid-column: span 6; } .span-7 { grid-column: span 7; } .span-8 { grid-column: span 8; } .span-12 { grid-column: span 12; }
.panel { background: var(--white); border: 1px solid var(--line); border-radius: 14px; min-width: 0; }
.panel-head { display: flex; align-items: baseline; justify-content: space-between; gap: 6px 16px; flex-wrap: wrap; padding: 20px 22px 0; font-size: 13.5px; color: var(--muted); }
.panel-head h2 { font: 600 16px/1.3 var(--sans); color: var(--ink); }
.panel-body { padding: 16px 22px 22px; }
.kpi { position: relative; display: grid; gap: 4px; align-content: start; padding: 20px 22px; text-align: left; border: 1px solid var(--line); border-radius: 14px; background: var(--white); text-decoration: none; transition: border-color .15s, box-shadow .15s; }
.kpi:hover { border-color: var(--line-strong); box-shadow: var(--shadow); }
.kpi[data-accent] { box-shadow: inset 0 3px 0 var(--red); }
.kpi[data-accent]:hover { box-shadow: inset 0 3px 0 var(--red), var(--shadow); }
.kpi-label { font-size: 14px; font-weight: 600; color: var(--body); }
.kpi-value { font: 600 42px/1.1 var(--sans); letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.kpi[data-accent] .kpi-value { color: var(--red); }
.kpi-sub { font-size: 13.5px; color: var(--muted); min-height: 1.5em; }
.kpi-go { position: absolute; top: 18px; right: 18px; color: var(--faint); transition: color .15s, transform .15s; }
.kpi:hover .kpi-go { color: var(--ink); transform: translateX(2px); }
.delta[data-dir=up] { color: var(--ok); font-weight: 600; }
.delta[data-dir=down] { color: var(--red); font-weight: 600; }

.sitecard { display: flex; align-items: center; gap: 18px 28px; flex-wrap: wrap; padding: 20px 22px; }
.sitecard .thumb { width: 120px; aspect-ratio: 16/10; border-radius: 8px; background: var(--paper-2) center/cover no-repeat; border: 1px solid var(--line); flex: none; }
.sitecard .txt { flex: 1; min-width: 220px; display: grid; gap: 4px; }
.sitecard .txt b { font-size: 16px; }
.sitecard .txt span { color: var(--muted); font-size: 14px; }
.sitecard .actions { display: flex; gap: 10px; flex-wrap: wrap; }
.notice { display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; border-radius: 10px; background: #FBF4E4; border: 1px solid #EED9A8; color: #5c4508; font-size: 14px; }
.notice.info { background: #EEF3EC; border-color: #CFDDC9; color: #24401f; }
.notice.danger { background: #fbefec; border-color: #ecc8bf; color: #7b2a1c; }
.notice .ico { margin-top: 1px; }
.notice b { font-weight: 600; }

/* column chart */
.chart { position: relative; display: grid; grid-template-columns: auto minmax(0,1fr); grid-template-rows: 220px auto; column-gap: 10px; }
.chart-y { position: relative; min-width: 16px; font: 400 11px/1 var(--mono); color: var(--muted); font-variant-numeric: tabular-nums; }
.chart-y span { position: absolute; right: 0; transform: translateY(50%); }
.chart-plot { position: relative; border-bottom: 1px solid var(--line-strong); }
.chart-grid { position: absolute; left: 0; right: 0; height: 1px; background: var(--line); }
.chart-cols { position: absolute; inset: 0; display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0,1fr); }
.chart-col { position: relative; display: flex; align-items: flex-end; justify-content: center; cursor: default; }
.chart-col i { display: block; width: min(24px, 60%); border-radius: 4px 4px 0 0; background: var(--forest); min-height: 0; transition: filter .15s; }
.chart-col[data-zero] i { background: transparent; }
.chart-col:hover i, .chart-col:focus-visible i { filter: brightness(1.35); }
.chart-col b { position: absolute; font: 600 12px/1 var(--sans); color: var(--ink); transform: translateY(-6px); }
.chart-x { grid-column: 2; display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0,1fr); padding-top: 8px; font: 400 11px/1.2 var(--mono); color: var(--muted); text-align: center; }
.chart-x span:nth-child(odd) { visibility: hidden; }
.tip { position: absolute; z-index: 5; pointer-events: none; background: var(--ink); color: #fff; padding: 8px 10px; border-radius: 8px; font-size: 12.5px; line-height: 1.35; white-space: nowrap; transform: translate(-50%, calc(-100% - 10px)); box-shadow: 0 6px 20px rgba(0,0,0,.2); }
.tip strong { display: block; font-size: 15px; }
/* status bars */
.bars { display: grid; gap: 14px; }
.bar-row { display: grid; gap: 7px; text-decoration: none; }
.bar-row .top { display: flex; align-items: center; gap: 10px; font-size: 14.5px; }
.bar-row .top b { margin-left: auto; font-variant-numeric: tabular-nums; }
.bar-row .track { height: 6px; border-radius: 3px; background: var(--paper-2); overflow: hidden; }
.bar-row .track i { display: block; height: 100%; border-radius: 3px; background: var(--st, var(--forest)); }
.sdot { width: 9px; height: 9px; border-radius: 50%; background: var(--st); flex: none; }
[data-status=novo] { --st: var(--st-novo); } [data-status=contactado] { --st: var(--st-contactado); } [data-status=visita] { --st: var(--st-visita); }
[data-status=orcamento] { --st: var(--st-orcamento); } [data-status=adjudicado] { --st: var(--st-adjudicado); } [data-status=perdido] { --st: var(--st-perdido); }

/* lists */
.list { display: grid; }
.list-row { display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 4px 16px; align-items: center; padding: 14px 22px; border-top: 1px solid var(--line); text-decoration: none; color: inherit; text-align: left; width: 100%; }
.list-row:hover { background: #FBFAF6; }
.list-row b { font-weight: 600; }
.list-row small { color: var(--muted); font-size: 13px; }
.chip { display: inline-flex; align-items: center; gap: 7px; padding: 4px 10px; border-radius: 999px; background: color-mix(in srgb, var(--st, var(--muted)) 11%, white); color: var(--ink); font-size: 12.5px; font-weight: 500; white-space: nowrap; }
.empty { padding: 28px 22px; color: var(--muted); text-align: center; }

/* ── leads ── */
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.toolbar .search { flex: 1; min-width: 200px; max-width: 360px; }
.filterbar { display: flex; gap: 6px; flex-wrap: wrap; }
.fchip { display: inline-flex; align-items: center; gap: 7px; padding: 7px 13px; border-radius: 999px; border: 1px solid var(--line-strong); background: var(--white); font-size: 13.5px; color: var(--body); }
.fchip:hover { border-color: var(--ink); color: var(--ink); }
.fchip[aria-pressed=true] { background: var(--ink); border-color: var(--ink); color: #fff; }
.fchip sup { font: 500 10px var(--mono); opacity: .7; }
.table { width: 100%; border-collapse: collapse; font-size: 14.5px; }
.table th { text-align: left; font: 600 11px/1 var(--mono); letter-spacing: .12em; text-transform: uppercase; color: var(--muted); padding: 14px 16px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { padding: 14px 16px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table tbody tr { cursor: pointer; }
.table tbody tr:hover td { background: #FBFAF6; }
.table td small { display: block; color: var(--muted); font-size: 13px; }
.table .nowrap { white-space: nowrap; }
.unread b::after { content: ''; display: inline-block; width: 7px; height: 7px; margin-left: 8px; border-radius: 50%; background: var(--red); vertical-align: 2px; }

/* drawer (lead detail, forms) */
.scrim { position: fixed; inset: 0; z-index: 90; background: rgba(27,26,23,.38); opacity: 0; transition: opacity .25s; }
.scrim.show { opacity: 1; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; z-index: 91; width: min(520px, 100vw); background: var(--white); box-shadow: -20px 0 60px rgba(0,0,0,.15);
  display: flex; flex-direction: column; transform: translateX(100%); transition: transform .35s var(--ease); }
.drawer.show { transform: none; }
.drawer-head { display: flex; align-items: center; gap: 12px; padding: 18px 22px; border-bottom: 1px solid var(--line); }
.drawer-head h2 { font: 500 24px/1.15 var(--serif); flex: 1; min-width: 0; }
.drawer-body { padding: 22px; overflow-y: auto; display: grid; gap: 20px; align-content: start; flex: 1; }
.drawer-foot { padding: 16px 22px; border-top: 1px solid var(--line); display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; }
.dl { display: grid; grid-template-columns: 130px minmax(0,1fr); gap: 10px 16px; font-size: 14.5px; }
.dl dt { color: var(--muted); }
.dl dd { overflow-wrap: anywhere; white-space: pre-wrap; }
.quick { display: flex; gap: 8px; flex-wrap: wrap; }

/* modal */
.modal { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 16px; }
.modal-box { position: relative; background: var(--white); border-radius: 16px; box-shadow: 0 30px 90px rgba(0,0,0,.25); width: min(560px, 100%); max-height: calc(100vh - 32px); display: flex; flex-direction: column;
  transform: translateY(12px) scale(.98); opacity: 0; transition: transform .3s var(--ease), opacity .2s; }
.modal-box.wide { width: min(1080px, 100%); height: min(780px, calc(100vh - 32px)); }
.modal.show .modal-box { transform: none; opacity: 1; }
.modal-head { display: flex; align-items: center; gap: 12px; padding: 18px 22px; border-bottom: 1px solid var(--line); }
.modal-head h2 { font: 500 24px/1.15 var(--serif); flex: 1; }
.modal-body { padding: 22px; overflow-y: auto; display: grid; gap: 16px; align-content: start; }
.modal-foot { padding: 16px 22px; border-top: 1px solid var(--line); display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; }

/* toasts */
.toasts { position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%); z-index: 200; display: grid; gap: 8px; justify-items: center; pointer-events: none; }
.toast { display: flex; align-items: center; gap: 10px; padding: 11px 16px; border-radius: 12px; background: var(--ink); color: #fff; font-size: 14px; box-shadow: 0 12px 34px rgba(0,0,0,.25); pointer-events: auto;
  animation: toastIn .35s var(--ease); max-width: min(560px, calc(100vw - 32px)); }
.toast.err { background: #7b2a1c; }
.toast.ok .ico { color: var(--lime); }
.toast button { color: var(--lime); font-weight: 600; margin-left: 6px; }
@keyframes toastIn { from { transform: translateY(14px); opacity: 0 } }

/* ── media library ── */
.dropzone { display: grid; place-items: center; gap: 8px; padding: 26px; border: 1.5px dashed var(--line-strong); border-radius: 12px; text-align: center; color: var(--muted); background: #FBFAF6; transition: border-color .15s, background .15s; cursor: pointer; }
.dropzone:hover, .dropzone.over { border-color: var(--forest); background: #F1F4EE; color: var(--ink); }
.dropzone b { color: var(--ink); font-weight: 600; }
.lib-tabs { display: flex; gap: 6px; flex-wrap: wrap; }
.lib-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(132px, 1fr)); gap: 10px; }
.lib-item { position: relative; aspect-ratio: 1; border-radius: 10px; overflow: hidden; background: var(--paper-2); border: 2px solid transparent; transition: border-color .15s, transform .15s; }
.lib-item img { width: 100%; height: 100%; object-fit: cover; }
.lib-item:hover { border-color: var(--line-strong); }
.lib-item[aria-pressed=true] { border-color: var(--forest); box-shadow: 0 0 0 3px rgba(47,74,44,.2); }
.lib-item .del { position: absolute; top: 6px; right: 6px; width: 28px; height: 28px; border-radius: 50%; background: rgba(255,255,255,.92); display: none; place-items: center; color: var(--red); }
.lib-item:hover .del { display: grid; }
.uploading { display: grid; gap: 8px; }
.up-row { display: flex; align-items: center; gap: 10px; font-size: 13.5px; }
.up-row .bar { flex: 1; height: 4px; background: var(--paper-2); border-radius: 2px; overflow: hidden; }
.up-row .bar i { display: block; height: 100%; width: 0; background: var(--forest); transition: width .2s; }
.up-row.err { color: var(--red); }

/* icon picker */
.icon-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }
.icon-grid button { display: grid; justify-items: center; gap: 8px; padding: 14px 6px; border-radius: 10px; border: 1px solid var(--line); font-size: 12.5px; color: var(--body); }
.icon-grid button:hover { border-color: var(--ink); }
.icon-grid button[aria-pressed=true] { border-color: var(--forest); background: #F1F4EE; }
.icon-grid svg { width: 36px; height: 36px; color: var(--forest); }

/* ── obras (gallery manager) ── */
.obras-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 14px; }
.obra { position: relative; background: var(--white); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; display: grid; transition: box-shadow .15s, opacity .15s; }
.obra.dragging { opacity: .4; }
.obra.drop-before { box-shadow: -4px 0 0 var(--forest); }
.obra.drop-after { box-shadow: 4px 0 0 var(--forest); }
.obra-img { position: relative; aspect-ratio: 4/5; background: var(--paper-2); cursor: grab; }
.obra-img img { width: 100%; height: 100%; object-fit: cover; object-position: 50% 72%; pointer-events: none; }
.obra-img .n { position: absolute; top: 8px; left: 8px; font: 600 11px var(--mono); background: rgba(27,26,23,.75); color: #fff; padding: 3px 7px; border-radius: 6px; }
.obra-img .tools { position: absolute; top: 6px; right: 6px; display: flex; gap: 4px; opacity: 0; transition: opacity .15s; }
.obra:hover .obra-img .tools, .obra:focus-within .obra-img .tools { opacity: 1; }
.obra-img .tools button { width: 30px; height: 30px; border-radius: 50%; background: rgba(255,255,255,.94); display: grid; place-items: center; color: var(--ink); }
.obra-img .tools button.del { color: var(--red); }
.obra-meta { display: grid; gap: 8px; padding: 10px; }
.obra-meta select, .obra-meta input { width: 100%; font-size: 13.5px; padding: 7px 9px; border: 1px solid var(--line); border-radius: 7px; background: var(--white); }
.obra-meta select:focus, .obra-meta input:focus { outline: 0; border-color: var(--forest); }
.cats { display: grid; gap: 8px; }
.cat-row { display: flex; align-items: center; gap: 8px; }
.cat-row input { flex: 1; }
.cat-row sup { font: 500 11px var(--mono); color: var(--muted); min-width: 22px; text-align: right; }

/* settings page */
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 18px 20px; }
.form-grid .full { grid-column: 1 / -1; }
.savebar { position: sticky; bottom: 0; z-index: 20; display: flex; align-items: center; gap: 12px; padding: 14px var(--pad); background: rgba(255,255,255,.96); border-top: 1px solid var(--line); backdrop-filter: blur(8px); }
.savebar span { color: var(--muted); font-size: 14px; flex: 1; }
.google { border: 1px solid var(--line); border-radius: 10px; padding: 16px; font-family: Arial, sans-serif; background: #fff; }
.google .u { font-size: 12.5px; color: #4d5156; }
.google .t { font-size: 19px; color: #1a0dab; margin: 4px 0; line-height: 1.3; }
.google .d { font-size: 13.5px; color: #4d5156; line-height: 1.5; }

/* history */
.rev { display: grid; grid-template-columns: auto minmax(0,1fr) auto; gap: 4px 16px; align-items: center; padding: 14px 22px; border-top: 1px solid var(--line); }
.rev .state { width: 10px; height: 10px; border-radius: 50%; background: var(--ok); }
.rev .state[data-s=error] { background: var(--red); }
.rev .state[data-s=pending], .rev .state[data-s=deploying] { background: var(--warn); }
.rev .state[data-s=local] { background: var(--faint); }
.rev small { color: var(--muted); font-size: 13px; display: block; }
.rev .acts { display: flex; gap: 6px; }

/* ── publish dialog progress ── */
.steps-list { display: grid; gap: 10px; }
.steps-list li { list-style: none; display: flex; gap: 10px; align-items: center; color: var(--muted); font-size: 14.5px; }
.steps-list li[data-on] { color: var(--ink); font-weight: 500; }
.steps-list li[data-done] { color: var(--ok); }

/* ── responsive shell ── */
@media (max-width: 1100px) {
  .span-3 { grid-column: span 6; } .span-4, .span-5, .span-7, .span-8 { grid-column: span 12; }
}
@media (max-width: 900px) {
  .app { grid-template-columns: minmax(0,1fr); }
  .side { position: fixed; left: 0; top: 0; bottom: 0; width: min(290px, 84vw); transform: translateX(-100%); transition: transform .3s var(--ease); }
  .app.nav-open .side { transform: none; box-shadow: 20px 0 60px rgba(0,0,0,.3); }
  .app.nav-open .side-scrim { display: block; position: fixed; inset: 0; z-index: 35; background: rgba(27,26,23,.38); }
  .menu-toggle { display: inline-grid !important; }
  .head h1 { font-size: 23px; }
  .head .pubstate span { display: none; }
  .form-grid { grid-template-columns: minmax(0,1fr); }
  .table thead { display: none; }
  .table, .table tbody, .table tr, .table td { display: block; }
  .table tr { padding: 12px 16px; border-bottom: 1px solid var(--line); }
  .table td { padding: 2px 0; border: 0; }
}
@media (max-width: 560px) {
  .span-3, .span-6 { grid-column: span 12; }
  .kpi-value { font-size: 34px; }
  .head-actions .btn span.long { display: none; }
  .dl { grid-template-columns: minmax(0,1fr); gap: 2px; }
  .dl dd { margin-bottom: 8px; }
  .obras-grid { grid-template-columns: repeat(2, minmax(0,1fr)); gap: 10px; }
}

/* ── editor (full screen) ── */
.ed-app { position: fixed; inset: 0; display: grid; grid-template-rows: 60px minmax(0,1fr); background: #DCD7CC; }
.ed-top { display: flex; align-items: center; gap: 10px; padding: 0 12px; background: var(--ink); color: #fff; min-width: 0; }
.ed-top .icon-btn { color: rgba(255,255,255,.7); }
.ed-top .icon-btn:hover:not(:disabled) { background: rgba(255,255,255,.1); color: #fff; }
.ed-top .sep { width: 1px; height: 26px; background: rgba(255,255,255,.14); margin: 0 4px; }
.ed-title { display: grid; gap: 3px; min-width: 0; padding-left: 4px; }
.ed-title b { font: 500 17px/1 var(--serif); white-space: nowrap; }
.ed-title span { font: 500 10px/1 var(--mono); letter-spacing: .16em; text-transform: uppercase; color: rgba(255,255,255,.5); }
.ed-devices { display: inline-flex; gap: 2px; padding: 3px; border-radius: 10px; background: rgba(255,255,255,.08); margin: 0 auto; }
.ed-devices button { width: 38px; height: 32px; display: grid; place-items: center; border-radius: 8px; color: rgba(255,255,255,.62); }
.ed-devices button[aria-pressed=true] { background: rgba(255,255,255,.16); color: #fff; }
.ed-save { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: rgba(255,255,255,.62); white-space: nowrap; min-width: 0; }
.ed-save i { width: 7px; height: 7px; border-radius: 50%; background: var(--lime); flex: none; }
.ed-save[data-s=saving] i { background: #f3c14b; animation: pulse 1s infinite; }
.ed-save[data-s=error] { color: #ffb3a3; }
.ed-save[data-s=error] i { background: var(--red-bright); }
.ed-top .btn--ghost { background: transparent; color: #fff; border-color: rgba(255,255,255,.28); }
.ed-top .btn--ghost:hover:not(:disabled) { background: rgba(255,255,255,.08); border-color: #fff; }
.ed-main { display: grid; grid-template-columns: 300px minmax(0,1fr); min-height: 0; }
.ed-side { background: var(--white); border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.ed-side-head { display: flex; align-items: center; gap: 8px; padding: 14px 16px; border-bottom: 1px solid var(--line); min-height: 58px; }
.ed-side-head h2 { font: 600 15px/1.2 var(--sans); flex: 1; min-width: 0; }
.ed-side-head small { display: block; font: 500 10.5px/1.2 var(--mono); letter-spacing: .12em; text-transform: uppercase; color: var(--muted); margin-bottom: 3px; }
.ed-side-body { overflow-y: auto; padding: 14px 16px 24px; display: grid; gap: 16px; align-content: start; flex: 1; }
.ed-side-foot { padding: 12px 16px; border-top: 1px solid var(--line); display: grid; gap: 8px; }
.sec-list { display: grid; gap: 4px; }
.sec-row { display: flex; align-items: center; gap: 6px; padding: 6px 6px 6px 4px; border-radius: 9px; border: 1px solid transparent; background: var(--white); transition: background .15s, border-color .15s; }
.sec-row:hover { background: var(--paper); }
.sec-row[data-current] { border-color: var(--forest); background: #F1F4EE; }
.sec-row[data-hidden] .sec-name { opacity: .45; text-decoration: line-through; }
.sec-row.dragging { opacity: .4; }
.sec-row.drop-before { box-shadow: 0 -2px 0 var(--forest); }
.sec-row.drop-after { box-shadow: 0 2px 0 var(--forest); }
.sec-grip { width: 22px; height: 30px; display: grid; place-items: center; color: var(--faint); cursor: grab; flex: none; }
.sec-grip[aria-disabled=true] { cursor: default; opacity: .3; }
.sec-name { flex: 1; min-width: 0; text-align: left; display: grid; gap: 1px; padding: 2px 0; }
.sec-name b { font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sec-name small { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sec-row .icon-btn { width: 30px; height: 30px; }
.hint { font-size: 13px; color: var(--muted); line-height: 1.5; padding: 12px 14px; background: var(--paper); border-radius: 10px; }
.hint b { color: var(--ink); font-weight: 600; }
.items-list { display: grid; gap: 4px; }
.item-row { display: flex; align-items: center; gap: 4px; padding: 4px 4px 4px 10px; border: 1px solid var(--line); border-radius: 8px; font-size: 13.5px; }
.item-row span { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item-row .icon-btn { width: 28px; height: 28px; }
.ed-stage { position: relative; min-width: 0; min-height: 0; display: grid; place-items: stretch; overflow: auto; }
.ed-frame-wrap { position: relative; margin: 0 auto; width: 100%; height: 100%; transition: width .35s var(--ease); background: var(--white); }
.ed-stage[data-device=tablet] .ed-frame-wrap { width: 820px; height: calc(100% - 32px); margin: 16px auto; border-radius: 14px; overflow: hidden; box-shadow: 0 20px 60px rgba(0,0,0,.18); }
.ed-stage[data-device=mobile] .ed-frame-wrap { width: 390px; height: min(844px, calc(100% - 32px)); margin: 16px auto; border-radius: 28px; overflow: hidden; box-shadow: 0 0 0 10px var(--ink), 0 20px 60px rgba(0,0,0,.25); }
.ed-frame-wrap iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; background: var(--paper); }
.ed-frame-wrap iframe { z-index: 1; }
.ed-frame-wrap iframe[data-back] { z-index: 0; opacity: 0; pointer-events: none; }
.ed-loading { position: absolute; inset: 0; display: grid; place-items: center; background: var(--paper); z-index: 2; font-size: 14px; color: var(--muted); }
.lib-sec { display: grid; gap: 8px; }
.lib-sec h3 { font: 600 10.5px/1 var(--mono); letter-spacing: .14em; text-transform: uppercase; color: var(--muted); padding-top: 6px; }
.lib-card { display: grid; grid-template-columns: 56px minmax(0,1fr); gap: 12px; align-items: center; padding: 10px; border: 1px solid var(--line); border-radius: 10px; text-align: left; transition: border-color .15s, background .15s; }
.lib-card:hover { border-color: var(--forest); background: #F7F9F5; }
.lib-card b { display: block; font-size: 14px; }
.lib-card small { display: block; font-size: 12.5px; color: var(--muted); line-height: 1.35; }
.lib-thumb { width: 56px; height: 44px; border-radius: 6px; background: var(--paper-2); display: grid; place-items: center; color: var(--forest); }
@media (max-width: 1000px) {
  .ed-main { grid-template-columns: minmax(0,1fr); }
  .ed-side { position: absolute; left: 0; top: 60px; bottom: 0; width: min(320px, 90vw); z-index: 20; transform: translateX(-100%); transition: transform .3s var(--ease); box-shadow: 20px 0 60px rgba(0,0,0,.2); }
  .ed-app.side-open .ed-side { transform: none; }
  .ed-save span, .ed-title span { display: none; }
}
@media (max-width: 640px) {
  .ed-devices, .ed-top .hide-sm { display: none; }
}

/* rich text box in the side panel */
.rich-box { border: 1px solid var(--line-strong); border-radius: 8px; background: var(--white); overflow: hidden; }
.rich-box:focus-within { border-color: var(--forest); box-shadow: 0 0 0 3px rgba(47,74,44,.14); }
.rich-tools { display: flex; gap: 2px; padding: 4px; border-bottom: 1px solid var(--line); background: #FBFAF6; }
.rich-tools button { width: 30px; height: 28px; display: grid; place-items: center; border-radius: 6px; color: var(--body); }
.rich-tools button:hover { background: var(--paper-2); color: var(--ink); }
.rich-input { min-height: 64px; padding: 10px 12px; font-size: 15px; line-height: 1.5; outline: none; }
.rich-input em { font-style: italic; color: var(--forest); }
.rich-input b { font-weight: 600; }
details.field > summary::marker { color: var(--muted); }

/* small editable lists (other emails, social networks) */
.srows { display: grid; gap: 8px; }
.srow { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.srow .input { flex: 1 1 160px; min-width: 0; width: auto; }
.srow select.input { flex: 0 1 220px; }
