body.admin { display: grid; grid-template-columns: 260px 1fr; min-height: 100vh; background: var(--bg-2); font-size: 14.5px; letter-spacing: -.01em; }

/* Barra lateral */
.side { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; background: var(--glass); backdrop-filter: saturate(180%) blur(20px); border-right: 1px solid var(--line-2); padding: 1.25rem .9rem; }
.side__brand { display: flex; align-items: center; gap: .7rem; padding: .25rem .55rem 1.4rem; }
.side__mark { width: 34px; height: 34px; border-radius: 9px; background: var(--inv-bg); color: var(--inv-fg); display: grid; place-items: center; font-weight: 600; flex-shrink: 0; }
.side__brand strong { display: block; color: var(--ink); font-size: 1rem; letter-spacing: -.02em; line-height: 1.2; }
.side__brand small { color: var(--muted); font-size: .76rem; }
.side__nav { display: grid; gap: 2px; }
.side__nav a { display: flex; align-items: center; gap: .7rem; padding: .55rem .65rem; border-radius: 8px; text-decoration: none; font-size: .9rem; color: var(--ink); transition: background .15s; }
.side__nav a > span { width: 18px; height: 18px; flex-shrink: 0; color: var(--accent); }
.side__nav a em { margin-left: auto; font-style: normal; font-size: .75rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.side__nav a em:empty { display: none; }
.side__nav a:hover { background: rgba(0, 0, 0, .045); }
.side__nav a.is-active { background: rgba(0, 0, 0, .075); font-weight: 500; }
.side__foot { margin-top: auto; display: grid; gap: .6rem; }
.side__store { color: var(--link); }
.side__store span[data-icon] { width: 14px; height: 14px; }
.side__nav a b { font-weight: inherit; }
.side__foot p { margin: 0; font-size: .72rem; color: var(--muted); text-align: center; }

/* Área principal */
.main { min-width: 0; padding: 2rem clamp(1.25rem, 3vw, 2.75rem) 4rem; }
.main__head { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; margin-bottom: 1.75rem; flex-wrap: wrap; }
.crumb { font-size: .75rem; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); font-weight: 600; }
.main__head h1 { margin: .3rem 0 0; font-size: 2.1rem; letter-spacing: -.035em; font-weight: 600; line-height: 1.1; }
.main__actions { display: flex; gap: .6rem; }
.main__body { animation: fade .35s var(--ease); }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } }

.panel { background: var(--surface); border: 0; border-radius: 18px; box-shadow: 0 1px 2px rgba(0,0,0,.03); }
.panel__head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: 1.1rem 1.35rem; border-bottom: 1px solid var(--line-2); }
.panel__head h2 { margin: 0; font-size: 1rem; font-weight: 600; letter-spacing: -.01em; }
.panel__head a { font-size: .82rem; font-weight: 600; color: var(--accent); text-decoration: none; }
.panel__body { padding: 1.35rem; }

/* Indicadores */
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; margin-bottom: 1.25rem; }
.kpi { padding: 1.25rem 1.35rem; display: grid; gap: .35rem; position: relative; overflow: hidden; }
.kpi__label { font-size: .8rem; color: var(--muted); font-weight: 500; display: flex; align-items: center; gap: .5rem; }
.kpi__label span { width: 28px; height: 28px; border-radius: 8px; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; }
.kpi__label svg { width: 15px; height: 15px; }
.kpi__value { font-size: 1.75rem; font-weight: 600; letter-spacing: -.03em; font-variant-numeric: tabular-nums; line-height: 1.15; }
.kpi__sub { font-size: .78rem; color: var(--muted); }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 1.25rem; }

.list { list-style: none; margin: 0; padding: 0; }
.list li { display: grid; grid-template-columns: 44px 1fr auto; gap: .9rem; align-items: center; padding: .8rem 1.35rem; border-bottom: 1px solid var(--line-2); }
.list li:last-child { border-bottom: 0; }
.list .thumb { width: 44px; height: 44px; }
.list strong { font-size: .9rem; font-weight: 600; display: block; letter-spacing: -.01em; }
.list small { color: var(--muted); font-size: .78rem; }
.list__empty { padding: 2.25rem 1.35rem; text-align: center; color: var(--muted); font-size: .88rem; }

/* Barra de filtros */
.filters { display: flex; gap: .6rem; margin-bottom: 1rem; flex-wrap: wrap; }
.filters .input { max-width: 300px; height: 40px; border-radius: 999px; padding-left: 2.5rem; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236E7380' stroke-width='1.8' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='6.5'/%3E%3Cpath d='m20 20-4.2-4.2'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: 14px center; background-size: 17px; }
.filters .select { width: auto; min-width: 180px; height: 40px; border-radius: 999px; }
.seg { display: inline-flex; padding: 3px; background: var(--line-2); border-radius: 999px; }
.seg button { border: 0; background: none; height: 34px; padding: 0 .9rem; border-radius: 999px; font-size: .82rem; font-weight: 600; color: var(--muted); }
.seg button.is-on { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-1); }

/* Tabela */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: .88rem; }
.table th { text-align: left; font-size: .72rem; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); font-weight: 600; padding: .85rem 1rem; border-bottom: 1px solid var(--line); white-space: nowrap; background: var(--surface-2); }
.table th:first-child { border-top-left-radius: var(--radius); }
.table th:last-child { border-top-right-radius: var(--radius); }
.table td { padding: .8rem 1rem; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr { transition: background .15s; }
.table tbody tr:hover { background: var(--row-hover); }
.table tr.is-inactive td:nth-child(-n+4) { opacity: .5; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.prod { display: flex; align-items: center; gap: .85rem; min-width: 220px; }
.thumb { width: 48px; height: 48px; border-radius: 10px; overflow: hidden; flex-shrink: 0; background: var(--bg-2); padding: 3px; }
.thumb svg { width: 100%; height: 100%; }
.prod strong { display: block; font-weight: 600; letter-spacing: -.01em; }
.prod small { color: var(--muted); font-size: .76rem; font-family: ui-monospace, 'SFMono-Regular', Consolas, monospace; }
.stock-edit { display: inline-flex; align-items: center; gap: .5rem; }
.stock-edit input { width: 64px; height: 34px; text-align: center; border: 1px solid var(--line); border-radius: 8px; font-variant-numeric: tabular-nums; font-weight: 600; background: var(--surface); }
.stock-edit input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(30, 58, 92, .12); }
.stock-edit.is-low input { border-color: var(--warn-line); background: var(--warn-soft); color: var(--warn); }
.stock-edit.is-out input { border-color: var(--danger-line); background: var(--danger-soft); color: var(--danger); }
.row-actions { display: flex; gap: .35rem; justify-content: flex-end; }
.row-actions button { width: 34px; height: 34px; border-radius: 8px; border: 1px solid transparent; background: none; color: var(--muted); display: grid; place-items: center; transition: all .15s; }
.row-actions button:hover { background: var(--line-2); color: var(--ink); }
.row-actions button.is-danger:hover { background: var(--danger-soft); color: var(--danger); }
.row-actions svg { width: 17px; height: 17px; }

.switch { position: relative; display: inline-block; width: 38px; height: 22px; flex-shrink: 0; }
.switch input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; z-index: 1; }
.switch span { position: absolute; inset: 0; border-radius: 999px; background: var(--switch-off); transition: background .2s; }
.switch span::after { content: ''; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .2); transition: transform .25s var(--ease); }
.switch input:checked + span { background: #34C759; }
.switch input:checked + span::after { transform: translateX(16px); }
.switch input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.toggle-row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .85rem 1rem; border: 1px solid var(--line); border-radius: var(--radius-sm); }
.toggle-row strong { display: block; font-size: .88rem; font-weight: 600; }
.toggle-row small { color: var(--muted); font-size: .76rem; }

/* Categorias */
.cats { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 1rem; }
.cat { padding: 1.2rem 1.25rem; display: grid; gap: .25rem; align-content: start; }
.cat__top { display: flex; justify-content: space-between; align-items: flex-start; gap: .5rem; }
.cat__thumbs { display: flex; margin-bottom: .8rem; }
.cat__thumbs .thumb { width: 40px; height: 40px; border: 2px solid var(--surface); margin-right: -10px; border-radius: 10px; }
.cat h3 { margin: 0; font-size: 1.02rem; letter-spacing: -.015em; font-weight: 600; }
.cat p { margin: 0; color: var(--muted); font-size: .84rem; min-height: 1.3em; }
.cat__meta { margin-top: .6rem; font-size: .78rem; font-weight: 600; color: var(--accent); }
.cat--new { border-style: dashed; background: transparent; display: grid; gap: .7rem; }
.cat--new h3 { font-size: .95rem; }

/* Pedidos */
.status { height: 32px; border-radius: 999px; font-size: .8rem; font-weight: 600; padding: 0 2rem 0 .85rem; min-width: 150px; }
.status[data-v="novo"] { background-color: var(--accent-soft); color: var(--accent); border-color: transparent; }
.status[data-v="preparacao"] { background-color: var(--warn-soft); color: var(--warn); border-color: transparent; }
.status[data-v="enviado"] { background-color: var(--purple-soft); color: var(--purple); border-color: transparent; }
.status[data-v="concluido"] { background-color: var(--ok-soft); color: var(--ok); border-color: transparent; }
.status[data-v="cancelado"] { background-color: var(--line-2); color: var(--muted); border-color: transparent; }
.items-cell { color: var(--ink-2); font-size: .82rem; max-width: 320px; }

/* Definições */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1.1rem 1.25rem; }
.form-grid .full { grid-column: 1 / -1; }
.settings { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 1.25rem; align-items: start; }
.danger-zone { box-shadow: inset 0 0 0 1px var(--danger-line); }
.danger-zone p { margin: 0 0 1rem; font-size: .86rem; color: var(--ink-2); }

/* Painel lateral do editor */
.sheet, .dialog { position: fixed; inset: 0; z-index: 100; }
.sheet__backdrop, .dialog__backdrop { position: absolute; inset: 0; background: rgba(15, 17, 22, .45); backdrop-filter: blur(3px); opacity: 0; transition: opacity .3s; }
.sheet.is-open .sheet__backdrop, .dialog.is-open .dialog__backdrop { opacity: 1; }
.sheet__panel { position: absolute; top: 0; right: 0; bottom: 0; width: min(920px, 100%); background: var(--bg); display: flex; flex-direction: column; box-shadow: var(--shadow-3); transform: translateX(100%); transition: transform .45s var(--ease); }
.sheet.is-open .sheet__panel { transform: none; }
.sheet__head { display: flex; justify-content: space-between; align-items: center; padding: 1.25rem 1.75rem; background: var(--surface); border-bottom: 1px solid var(--line); }
.sheet__head h2 { margin: 0; font-size: 1.2rem; letter-spacing: -.02em; font-weight: 600; }
.sheet__body { flex: 1; overflow: auto; padding: 1.5rem 1.75rem; display: grid; grid-template-columns: minmax(0, 1fr) 280px; gap: 1.5rem; align-items: start; }
.sheet__foot { display: flex; justify-content: flex-end; gap: .6rem; padding: 1rem 1.75rem; background: var(--surface); border-top: 1px solid var(--line); }
.form-section { display: grid; gap: 1rem; }
.form-section + .form-section { margin-top: 1.5rem; }
.form-section h3 { margin: 0; font-size: .75rem; text-transform: uppercase; letter-spacing: .12em; color: var(--muted); font-weight: 600; }
.money { position: relative; }
.money::before { content: '€'; position: absolute; left: .9rem; top: 50%; transform: translateY(-50%); color: var(--muted); font-size: .9rem; pointer-events: none; }
.money .input { padding-left: 2rem; font-variant-numeric: tabular-nums; }
.shapes { display: grid; grid-template-columns: repeat(6, 1fr); gap: .5rem; }
.shapes button { padding: 0; border: 2px solid transparent; border-radius: 12px; overflow: hidden; background: none; aspect-ratio: 1; transition: border-color .15s, transform .15s; }
.shapes button:hover { transform: translateY(-2px); }
.shapes button[aria-pressed="true"] { border-color: var(--ink); }
.shapes svg { width: 100%; height: 100%; }
.tones { display: flex; gap: .55rem; flex-wrap: wrap; }
.tones button { width: 34px; height: 34px; border-radius: 50%; border: 2px solid var(--surface); box-shadow: 0 0 0 1px var(--line); transition: box-shadow .15s, transform .15s; }
.tones button:hover { transform: scale(1.08); }
.tones button[aria-pressed="true"] { box-shadow: 0 0 0 2px var(--ink); }
.preview { position: sticky; top: 0; display: grid; gap: .75rem; }
.preview__label { font-size: .75rem; text-transform: uppercase; letter-spacing: .12em; color: var(--muted); font-weight: 600; }
.preview__card { background: var(--surface); border-radius: var(--radius); padding: .6rem .6rem 1rem; border: 1px solid var(--line); box-shadow: var(--shadow-1); }
.preview__media { position: relative; aspect-ratio: 1; border-radius: 14px; overflow: hidden; padding: 8%; background: radial-gradient(110% 95% at 50% 15%, var(--st1), var(--st2) 62%, var(--st3)); }
.preview__media svg { width: 100%; height: 100%; }
.preview__media .badges { position: absolute; top: 10px; left: 10px; display: flex; gap: .3rem; }
.preview__body { padding: .85rem .4rem 0; display: grid; gap: .25rem; }
.preview__cat { font-size: .68rem; text-transform: uppercase; letter-spacing: .12em; color: var(--muted); font-weight: 600; }
.preview__name { font-weight: 600; letter-spacing: -.015em; }
.preview__price { display: flex; gap: .5rem; align-items: baseline; font-variant-numeric: tabular-nums; }
.preview__price strong { font-size: 1.05rem; }
.preview__price s { color: var(--muted); font-size: .85rem; }
.preview__hint { font-size: .78rem; color: var(--muted); margin: 0; line-height: 1.45; }

/* Confirmação */
.dialog__panel { position: relative; width: min(420px, calc(100% - 32px)); margin: 18vh auto 0; background: var(--surface); border-radius: 18px; padding: 1.6rem; box-shadow: var(--shadow-3); opacity: 0; transform: scale(.97); transition: opacity .25s, transform .3s var(--ease); }
.dialog.is-open .dialog__panel { opacity: 1; transform: none; }
.dialog__panel h2 { margin: 0 0 .5rem; font-size: 1.15rem; letter-spacing: -.02em; }
.dialog__panel p { margin: 0 0 1.4rem; color: var(--ink-2); font-size: .9rem; }
.dialog__actions { display: flex; justify-content: flex-end; gap: .5rem; }

.empty-state { text-align: center; padding: 3.5rem 1rem; display: grid; justify-items: center; gap: .5rem; }
.empty-state__icon { width: 58px; height: 58px; border-radius: 50%; background: var(--line-2); display: grid; place-items: center; color: var(--muted); margin-bottom: .4rem; }
.empty-state__icon svg { width: 26px; height: 26px; }
.empty-state p { margin: 0 0 .75rem; color: var(--muted); font-size: .88rem; }

@media (max-width: 1180px) {
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .settings { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
  body.admin { grid-template-columns: 1fr; }
  .side { position: sticky; z-index: 40; height: auto; flex-direction: row; align-items: center; gap: .75rem; padding: .6rem .9rem; overflow-x: auto; }
  .side__brand { border: 0; padding: 0; margin: 0; }
  .side__brand div { display: none; }
  .side__nav { display: flex; gap: 2px; }
  .side__nav a { padding: .55rem .7rem; white-space: nowrap; font-size: .82rem; }
  .side__nav a em { display: none; }
  .side__foot { margin: 0 0 0 auto; }
  .side__foot p { display: none; }
  .two { grid-template-columns: 1fr; }
  .sheet__body { grid-template-columns: 1fr; }
  .preview { position: static; order: -1; grid-template-columns: 140px 1fr; align-items: center; }
  .preview__label, .preview__hint { display: none; }
  .form-grid { grid-template-columns: 1fr; }
  .shapes { grid-template-columns: repeat(4, 1fr); }
}
@media (max-width: 560px) {
  .kpis { grid-template-columns: 1fr 1fr; gap: .6rem; }
  .kpi__value { font-size: 1.35rem; }
  .main__head h1 { font-size: 1.5rem; }
  .filters .input { max-width: none; }
}

/* Tabela de categorias editável */
.panel__hint { font-size: .8rem; color: var(--muted); }
.cat-table td { padding-block: .6rem; }
.cat-table__n { color: var(--muted); font-variant-numeric: tabular-nums; font-weight: 500; }
.cat-input { height: 40px; border-color: transparent; background: var(--bg-2); font-weight: 500; }
.cat-input:hover { border-color: var(--line); }
.cat-table th:nth-child(2) { width: 32%; }
.cat-table th:nth-child(3) { width: 48%; }
.panel__head { flex-wrap: wrap; }
.cat-input:focus { background: var(--card); }
.cat-input[data-cat-field="description"] { font-weight: 400; color: var(--ink-2); }
.cat-add { display: grid; grid-template-columns: auto minmax(160px, 1fr) minmax(200px, 1.6fr) auto; gap: .75rem; align-items: center; padding: 1rem 1.35rem 1.25rem; border-top: 1px solid var(--line-2); background: var(--surface-2); border-radius: 0 0 18px 18px; }
.cat-add__label { display: inline-flex; align-items: center; gap: .4rem; font-weight: 600; font-size: .9rem; color: var(--accent); white-space: nowrap; }
.cat-add__label svg { width: 16px; height: 16px; }
@media (max-width: 760px) { .cat-add { grid-template-columns: 1fr; } }

/* Controlo de idioma e tema no painel */
.side__prefs { display: flex; align-items: center; justify-content: space-between; gap: .5rem; padding: .25rem .2rem; }
.side__prefs .lang__menu { top: auto; bottom: calc(100% + 8px); left: 0; right: auto; transform-origin: bottom left; }
[data-theme="dark"] .side__nav a:hover { background: rgba(255, 255, 255, .06); }
[data-theme="dark"] .side__nav a.is-active { background: rgba(255, 255, 255, .1); }
[data-theme="dark"] .side__nav a > span { color: var(--link); }
@media (max-width: 900px) {
  .side__foot { flex-direction: row; display: flex; align-items: center; gap: .5rem; }
  .side__prefs { padding: 0; }
  .side { backdrop-filter: none; -webkit-backdrop-filter: none; background: var(--surface); }
  .side__prefs .lang__menu { position: fixed; top: 64px; bottom: auto; right: 12px; left: auto; max-height: calc(100vh - 80px); overflow-y: auto; transform-origin: top right; }
  .side__store { width: auto; }
}

.side__logout { color: var(--ink-2); }
@media (max-width: 900px) { .side__logout { width: auto; } }
