/* AuRepair — interface mobile-first, orientada a botões */
:root {
    --navy: #0f2742;
    --navy-2: #173a5e;
    --primary: #1d6fd8;
    --primary-dark: #1557ad;
    --accent: #f59e0b;
    --success: #16a34a;
    --warning: #d97706;
    --danger: #dc2626;
    --info: #0891b2;
    --bg: #f1f4f8;
    --surface: #ffffff;
    --text: #15202e;
    --muted: #64748b;
    --border: #dfe5ee;
    --radius: 14px;
    --radius-sm: 10px;
    --shadow: 0 1px 2px rgba(15, 39, 66, .06), 0 4px 16px rgba(15, 39, 66, .06);
    --sidebar-w: 260px;
    --touch: 52px;
    font-size: 16px;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
    margin: 0;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.45;
}
a { color: var(--primary); text-decoration: none; }
img, video { max-width: 100%; display: block; }
h1, h2, h3 { margin: 0; line-height: 1.2; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }
p { margin: 0 0 .75rem; }
small, .muted { color: var(--muted); }
.icon { width: 20px; height: 20px; flex: 0 0 auto; }
.icon-xs { width: 14px; height: 14px; vertical-align: -2px; }

/* ---------- Estrutura ---------- */
.app { display: flex; min-height: 100vh; }
.sidebar {
    position: fixed; inset: 0 auto 0 0; width: var(--sidebar-w); z-index: 40;
    background: var(--navy); color: #cfd9e6; display: flex; flex-direction: column;
    padding: 16px 12px calc(16px + env(safe-area-inset-bottom));
    transform: translateX(-100%); transition: transform .2s ease; overflow-y: auto;
}
.nav-open .sidebar { transform: none; }
.backdrop { position: fixed; inset: 0; background: rgba(8, 20, 35, .5); z-index: 30; display: none; }
.nav-open .backdrop { display: block; }
.brand { display: flex; align-items: center; justify-content: space-between; padding: 4px 8px 16px; }
.brand-link { display: flex; align-items: center; gap: 10px; color: #fff; }
.brand-mark {
    width: 38px; height: 38px; border-radius: 10px; background: var(--accent); color: var(--navy);
    display: grid; place-items: center;
}
.brand-mark .icon { width: 22px; height: 22px; }
.brand-name { font-size: 1.3rem; letter-spacing: .2px; color: #fff; }
.brand-name strong { color: var(--accent); }
.tenant-chip {
    display: flex; align-items: center; gap: 8px; margin: 0 4px 12px; padding: 10px 12px;
    background: var(--navy-2); border-radius: var(--radius-sm); color: #fff; font-size: .9rem;
}
.tenant-chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.nav-sep { height: 1px; background: rgba(255,255,255,.1); margin: 8px 6px; }
.nav-link {
    display: flex; align-items: center; gap: 12px; min-height: 48px; padding: 0 14px;
    color: #cfd9e6; border-radius: var(--radius-sm); font-size: .98rem; width: 100%;
    background: none; border: 0; font: inherit; cursor: pointer; text-align: left;
}
.nav-link:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav-link.active { background: var(--primary); color: #fff; }
.nav-link small { display: block; color: #8fa3bb; font-size: .75rem; }
.nav-link.active small { color: #dbe8fb; }
.sidebar-foot { border-top: 1px solid rgba(255,255,255,.1); padding-top: 10px; margin-top: 10px; }
.sidebar-foot form { margin: 0; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; padding-bottom: calc(76px + env(safe-area-inset-bottom)); }
.topbar {
    position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 10px;
    background: var(--surface); border-bottom: 1px solid var(--border); padding: 10px 14px; min-height: 60px;
}
.topbar-title { font-size: 1.1rem; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar-cta span { display: none; }
.icon-btn {
    width: 44px; height: 44px; display: grid; place-items: center; border-radius: var(--radius-sm);
    background: transparent; border: 0; color: inherit; cursor: pointer;
}
.icon-btn:hover { background: rgba(0,0,0,.05); }
.sidebar .icon-btn { color: #fff; }
.acting-banner {
    display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px;
    background: #fff7e6; border-bottom: 1px solid #f6d58f; padding: 8px 14px; font-size: .9rem;
}
.acting-banner span { display: flex; align-items: center; gap: 6px; }
.acting-banner form { margin: 0; }
.content { padding: 16px 14px 24px; width: 100%; max-width: 1280px; margin: 0 auto; }

.bottom-nav {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 25; display: grid; grid-template-columns: repeat(5, 1fr);
    background: var(--surface); border-top: 1px solid var(--border); padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
}
.bottom-nav a, .bottom-nav button {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
    min-height: 54px; color: var(--muted); font-size: .72rem; background: none; border: 0; font-family: inherit; cursor: pointer;
}
.bottom-nav .icon { width: 24px; height: 24px; }
.bottom-nav .active { color: var(--primary); }
.bottom-nav .bottom-cta .icon {
    width: 46px; height: 46px; padding: 11px; border-radius: 50%; background: var(--primary); color: #fff;
    margin-top: -22px; box-shadow: 0 6px 16px rgba(29,111,216,.4);
}
.bottom-nav .bottom-cta { color: var(--text); }

@media (min-width: 1024px) {
    .sidebar { transform: none; }
    .main { margin-left: var(--sidebar-w); padding-bottom: 0; }
    .menu-btn, .sidebar-close, .bottom-nav, .backdrop { display: none !important; }
    .topbar { padding: 12px 24px; }
    .content { padding: 24px; }
    .topbar-cta span { display: inline; }
}

/* ---------- Alertas ---------- */
.alert { padding: 12px 14px; border-radius: var(--radius-sm); margin-bottom: 12px; border: 1px solid; font-size: .95rem; }
.alert-success { background: #ecfdf3; border-color: #a7e8c0; color: #11632f; }
.alert-error { background: #fef2f2; border-color: #f7b9b9; color: #8f1d1d; }
.alert-info { background: #ecfeff; border-color: #a5e3ee; color: #0e5566; }
.alert-warning { background: #fffbeb; border-color: #f6d58f; color: #7a4d06; }

/* ---------- Botões ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    min-height: var(--touch); padding: 0 20px; border-radius: var(--radius-sm); border: 1px solid transparent;
    font: inherit; font-weight: 600; font-size: 1rem; cursor: pointer; text-align: center;
    background: var(--surface); color: var(--text); border-color: var(--border);
    transition: background .15s, box-shadow .15s, transform .05s; -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: scale(.98); }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-success { background: var(--success); border-color: var(--success); color: #fff; }
.btn-warning { background: var(--accent); border-color: var(--accent); color: #1f1300; }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-light { background: #fff; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--primary); }
.btn-outline-danger { color: var(--danger); border-color: #f3c0c0; background: #fff; }
.btn-sm { min-height: 40px; padding: 0 14px; font-size: .9rem; }
.btn-lg { min-height: 64px; font-size: 1.1rem; padding: 0 26px; }
.btn-block { display: flex; width: 100%; }
.btn[disabled] { opacity: .55; pointer-events: none; }
.btn-row { display: flex; flex-wrap: wrap; gap: 10px; }
.btn-row > .btn { flex: 1 1 auto; }
.actions-bar {
    position: sticky; bottom: calc(72px + env(safe-area-inset-bottom)); z-index: 10; margin-top: 16px;
    display: flex; gap: 10px; padding: 10px; background: rgba(241,244,248,.92); backdrop-filter: blur(6px);
    border-radius: var(--radius);
}
.actions-bar > .btn { flex: 1; }
@media (min-width: 1024px) { .actions-bar { bottom: 12px; } }

/* ---------- Cartões e grelhas ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 16px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.card-head h2 { display: flex; align-items: center; gap: 8px; }
.card-body { padding: 16px; }
.card-body.flush { padding: 0; }
.grid { display: grid; gap: 16px; }
.grid > * { min-width: 0; }
@media (min-width: 768px) {
    .grid-2 { grid-template-columns: 1fr 1fr; }
    .grid-3 { grid-template-columns: repeat(3, 1fr); }
}
@media (min-width: 1100px) {
    .grid-main { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); align-items: start; }
}

.page-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.page-head h2 { font-size: 1.25rem; }
.page-head .sub { color: var(--muted); font-size: .92rem; margin-top: 2px; }

/* Estatísticas */
.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin-bottom: 16px; }
@media (min-width: 768px) { .stats { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); } }
.stat {
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px;
    box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 4px; color: var(--text); position: relative; overflow: hidden;
}
.stat::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--c, var(--primary)); }
.stat-label { font-size: .85rem; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.stat-value { font-size: 1.9rem; font-weight: 700; line-height: 1.1; }
a.stat:hover { border-color: var(--c, var(--primary)); }

/* Mosaico de botões grandes */
.tiles { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin-bottom: 16px; }
@media (min-width: 768px) { .tiles { grid-template-columns: repeat(4, 1fr); } }
.tile {
    display: flex; flex-direction: column; align-items: flex-start; justify-content: space-between; gap: 14px;
    min-height: 112px; padding: 16px; border-radius: var(--radius); background: var(--surface); color: var(--text);
    border: 1px solid var(--border); box-shadow: var(--shadow); font-weight: 600; font: inherit; cursor: pointer; text-align: left; width: 100%;
}
.tile .icon { width: 30px; height: 30px; color: var(--c, var(--primary)); }
.tile small { font-weight: 400; display: block; }
.tile:hover { border-color: var(--c, var(--primary)); }
.tile.tile-primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.tile.tile-primary .icon, .tile.tile-primary small { color: #fff; }
.tile.selected { border: 2px solid var(--primary); background: #eef5ff; }

/* ---------- Listas ---------- */
.list { list-style: none; margin: 0; padding: 0; }
.list-item {
    display: flex; align-items: center; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--border);
    color: var(--text); min-height: 64px;
}
.list-item:last-child { border-bottom: 0; }
a.list-item:hover { background: #f7f9fc; }
.list-item .li-icon {
    width: 44px; height: 44px; border-radius: 12px; background: #eef3fa; color: var(--navy-2);
    display: grid; place-items: center; flex: 0 0 auto;
}
.list-item .li-main { flex: 1; min-width: 0; }
.list-item .li-title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-item .li-sub { color: var(--muted); font-size: .88rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-item .li-end { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; font-size: .82rem; color: var(--muted); text-align: right; }
.list-item > .icon:last-child { color: #a3b1c2; }
.empty { padding: 28px 16px; text-align: center; color: var(--muted); }
.empty .icon { width: 36px; height: 36px; margin: 0 auto 8px; color: #b6c2d1; }

/* Estados */
.badge { display: inline-flex; align-items: center; padding: 3px 10px; border-radius: 999px; font-size: .78rem; font-weight: 600; white-space: nowrap; }
.badge-received { background: #e0f2fe; color: #075985; }
.badge-in_progress { background: #fef3c7; color: #92400e; }
.badge-paused { background: #ffedd5; color: #9a3412; }
.badge-completed { background: #ede9fe; color: #5b21b6; }
.badge-ready { background: #dcfce7; color: #166534; }
.badge-delivered { background: #e2e8f0; color: #334155; }
.badge-cancelled { background: #fee2e2; color: #991b1b; }
.badge-neutral { background: #eef2f7; color: #475569; }
.badge-on { background: #dcfce7; color: #166534; }
.badge-off { background: #fee2e2; color: #991b1b; }

/* ---------- Formulários ---------- */
.form-grid { display: grid; gap: 14px; }
@media (min-width: 768px) {
    .form-grid.cols-2 { grid-template-columns: 1fr 1fr; }
    .form-grid .span-2 { grid-column: 1 / -1; }
}
.field { display: flex; flex-direction: column; gap: 6px; }
.field label, .label { font-weight: 600; font-size: .92rem; }
.field .req { color: var(--danger); }
.field .hint { font-size: .82rem; color: var(--muted); }
.input, .select, .textarea {
    width: 100%; min-height: var(--touch); padding: 12px 14px; font: inherit; font-size: 16px; color: var(--text);
    background: #fff; border: 1px solid #cdd6e2; border-radius: var(--radius-sm); appearance: none;
}
.textarea { min-height: 110px; resize: vertical; }
.select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right 12px center; padding-right: 40px;
}
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(29,111,216,.18); }
.has-error .input, .has-error .select, .has-error .textarea { border-color: var(--danger); }
.field-error { color: var(--danger); font-size: .85rem; }
.search-bar { display: flex; gap: 8px; margin-bottom: 16px; }
.search-bar .input { flex: 1; }

/* Interruptores grandes (checkbox) */
.toggle {
    display: flex; align-items: center; gap: 12px; min-height: 60px; padding: 12px 14px; cursor: pointer;
    border: 1px solid var(--border); border-radius: var(--radius-sm); background: #fff; user-select: none;
}
.toggle input { position: absolute; opacity: 0; pointer-events: none; }
.toggle .t-box {
    width: 28px; height: 28px; border-radius: 8px; border: 2px solid #b8c4d3; display: grid; place-items: center; flex: 0 0 auto; color: transparent;
}
.toggle .t-box .icon { width: 18px; height: 18px; }
.toggle .t-text { flex: 1; }
.toggle .t-text small { display: block; }
.toggle input:checked ~ .t-box { background: var(--primary); border-color: var(--primary); color: #fff; }
.toggle:has(input:checked) { border-color: var(--primary); background: #f3f8ff; }
.toggle input:focus-visible ~ .t-box { box-shadow: 0 0 0 3px rgba(29,111,216,.25); }
.toggles { display: grid; gap: 10px; }
@media (min-width: 768px) { .toggles.cols-3 { grid-template-columns: repeat(3, 1fr); } }

/* Seletor de fotos/vídeos */
.upload-zone {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; text-align: center;
    min-height: 130px; padding: 18px; border: 2px dashed #b9c6d6; border-radius: var(--radius); background: #f8fafd; cursor: pointer; color: var(--muted);
}
.upload-zone .icon { width: 36px; height: 36px; color: var(--primary); }
.upload-zone strong { color: var(--text); }
.upload-zone input { display: none; }
.upload-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.upload-buttons input { display: none; }
.previews { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; margin-top: 10px; }
.previews figure { margin: 0; position: relative; border-radius: 10px; overflow: hidden; background: #e5eaf1; aspect-ratio: 1; }
.previews img, .previews video { width: 100%; height: 100%; object-fit: cover; }
.previews figcaption { position: absolute; left: 0; right: 0; bottom: 0; font-size: .7rem; padding: 2px 6px; background: rgba(0,0,0,.55); color: #fff; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.previews .rm {
    position: absolute; top: 4px; right: 4px; width: 28px; height: 28px; border-radius: 50%; border: 0;
    background: rgba(0,0,0,.6); color: #fff; display: grid; place-items: center; cursor: pointer;
}
.previews .rm .icon { width: 16px; height: 16px; }

/* Galeria */
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; }
.gallery .g-item { position: relative; border-radius: 10px; overflow: hidden; background: #dfe6ef; aspect-ratio: 1; }
.gallery .g-item img, .gallery .g-item video { width: 100%; height: 100%; object-fit: cover; }
.gallery .g-tag { position: absolute; left: 6px; top: 6px; font-size: .7rem; padding: 2px 8px; border-radius: 999px; background: rgba(15,39,66,.8); color: #fff; }
.gallery .g-play { position: absolute; inset: 0; display: grid; place-items: center; color: #fff; pointer-events: none; }
.gallery .g-play .icon { width: 36px; height: 36px; filter: drop-shadow(0 1px 3px rgba(0,0,0,.6)); }
.gallery form { position: absolute; right: 6px; top: 6px; margin: 0; }
.gallery .g-del { width: 30px; height: 30px; border-radius: 50%; border: 0; background: rgba(220,38,38,.9); color: #fff; display: grid; place-items: center; cursor: pointer; }
.gallery .g-del .icon { width: 16px; height: 16px; }

.lightbox { position: fixed; inset: 0; z-index: 100; background: rgba(0,0,0,.92); display: none; align-items: center; justify-content: center; padding: 16px; }
.lightbox.open { display: flex; }
.lightbox img, .lightbox video { max-height: 90vh; max-width: 100%; border-radius: 8px; }
.lightbox .lb-close { position: absolute; top: 12px; right: 12px; color: #fff; background: rgba(255,255,255,.15); }

/* Janela (pop-up) */
.modal {
    width: min(520px, calc(100vw - 24px)); max-height: calc(100vh - 32px); padding: 0; border: 0;
    border-radius: var(--radius); box-shadow: 0 20px 60px rgba(8,20,35,.35); color: var(--text);
}
.modal::backdrop { background: rgba(8, 20, 35, .55); }
.modal form { display: flex; flex-direction: column; max-height: calc(100vh - 32px); margin: 0; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.modal-head h2 { display: flex; align-items: center; gap: 8px; }
.modal-body { padding: 16px; overflow-y: auto; }
.modal-foot { display: flex; gap: 10px; padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); border-top: 1px solid var(--border); }
.modal-foot .btn { flex: 1; }
@media (max-width: 767px) {
    .modal { width: 100vw; max-width: 100vw; margin: auto 0 0; border-radius: var(--radius) var(--radius) 0 0; }
}
.choice-list { display: grid; gap: 10px; }
.choice {
    display: flex; align-items: center; gap: 12px; min-height: 58px; padding: 12px 14px; cursor: pointer;
    border: 1px solid var(--border); border-radius: var(--radius-sm); font-weight: 600;
}
.choice input { width: 22px; height: 22px; accent-color: var(--accent); flex: 0 0 auto; }
.choice:has(input:checked) { border-color: var(--accent); background: #fff8eb; }

.pause-box {
    display: flex; align-items: center; gap: 12px; padding: 14px; margin-bottom: 12px;
    border-radius: var(--radius-sm); background: #fff7ed; border: 1px solid #fed7aa; color: #7c2d12;
}
.pause-box > .icon { width: 28px; height: 28px; color: #ea580c; }

/* Assinatura */
.declaration { background: #f8fafc; border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px 14px; }
.signature-pad { position: relative; border: 2px dashed #b9c6d6; border-radius: var(--radius); background: #fff; }
.signature-pad canvas { display: block; width: 100%; height: 220px; touch-action: none; cursor: crosshair; }
.signature-pad .sig-hint { position: absolute; left: 0; right: 0; bottom: 14px; text-align: center; color: #a3b1c2; pointer-events: none; font-size: .95rem; }
.signature-pad::after { content: ""; position: absolute; left: 24px; right: 24px; bottom: 44px; border-bottom: 1px solid #d5dde8; pointer-events: none; }
.signature-pad.signed { border-style: solid; border-color: var(--success); }
.signature-pad.signed .sig-hint { display: none; }
.signature-img { max-width: 320px; width: 100%; background: #fff; border: 1px solid var(--border); border-radius: 10px; padding: 6px; }

.public-link { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.public-link code { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; background: #f1f5f9; padding: 10px 12px; border-radius: 8px; font-size: .82rem; }

/* Logótipo da oficina */
.tenant-logo { max-height: 56px; max-width: 100%; object-fit: contain; background: #fff; border-radius: 8px; padding: 6px; }
.tenant-chip.has-logo { flex-direction: column; align-items: flex-start; }
.logo-preview { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.logo-empty { display: flex; align-items: center; gap: 8px; padding: 18px 22px; border: 2px dashed #c9d3e0; border-radius: 10px; color: var(--muted); }
.sr-file { position: absolute; width: 1px; height: 1px; opacity: 0; overflow: hidden; pointer-events: none; }
label.btn { position: relative; }
.logo-preview img { max-height: 80px; max-width: 220px; object-fit: contain; border: 1px solid var(--border); border-radius: 10px; padding: 8px; background: #fff; }

/* Pares chave/valor */
.kv { display: grid; grid-template-columns: minmax(110px, 40%) 1fr; gap: 8px 12px; margin: 0; font-size: .95rem; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 500; word-break: break-word; }

/* Linha temporal do trabalho */
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { position: relative; padding: 0 0 14px 26px; font-size: .92rem; }
.timeline li::before { content: ""; position: absolute; left: 6px; top: 6px; width: 10px; height: 10px; border-radius: 50%; background: var(--primary); }
.timeline li::after { content: ""; position: absolute; left: 10px; top: 18px; bottom: 0; width: 2px; background: var(--border); }
.timeline li:last-child::after { display: none; }
.timeline .tl-meta { color: var(--muted); font-size: .8rem; }

/* Etapas do fluxo */
.flow { display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px; margin-bottom: 16px; }
.flow-step { text-align: center; font-size: .75rem; color: var(--muted); min-width: 0; }
.flow-step .dot {
    width: 38px; height: 38px; margin: 0 auto 6px; border-radius: 50%; display: grid; place-items: center;
    background: #e3e9f1; color: #8a9ab0;
}
.flow-step .dot .icon { width: 18px; height: 18px; }
.flow-step.done .dot { background: var(--success); color: #fff; }
.flow-step.current .dot { background: var(--primary); color: #fff; box-shadow: 0 0 0 4px rgba(29,111,216,.2); }
.flow-step.done, .flow-step.current { color: var(--text); font-weight: 600; }
.flow-step .who { display: block; font-weight: 400; color: var(--muted); font-size: .72rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.wizard-steps { display: flex; gap: 6px; margin-bottom: 16px; }
.wizard-steps span { flex: 1; height: 6px; border-radius: 3px; background: #dbe3ee; }
.wizard-steps span.on { background: var(--primary); }
.wizard-label { font-size: .85rem; color: var(--muted); margin-bottom: 4px; }

/* Tabelas (viram cartões em ecrãs pequenos) */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: .93rem; }
.table th, .table td { padding: 12px 14px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: top; }
.table th { font-size: .78rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); background: #f8fafc; white-space: nowrap; }
.table .num { text-align: right; white-space: nowrap; }
.table tfoot td { font-weight: 700; border-bottom: 0; }
@media (max-width: 767px) {
    .table.responsive thead { display: none; }
    .table.responsive tr { display: block; border-bottom: 1px solid var(--border); padding: 8px 0; }
    .table.responsive td { display: flex; justify-content: space-between; gap: 12px; border: 0; padding: 6px 16px; }
    .table.responsive td::before { content: attr(data-label); color: var(--muted); font-size: .82rem; }
    .table.responsive td.num { text-align: right; }
    .table.responsive tfoot tr { display: flex; justify-content: space-between; }
}

.filters { display: grid; gap: 10px; grid-template-columns: 1fr 1fr; margin-bottom: 16px; }
.filters .span-all { grid-column: 1 / -1; }
@media (min-width: 900px) { .filters { grid-template-columns: 2fr 1fr 1fr 1fr 1fr auto; align-items: end; } .filters .span-all { grid-column: auto; } }

.seg { display: inline-flex; background: #e6ebf2; border-radius: 12px; padding: 4px; gap: 4px; }
.seg a { padding: 8px 14px; border-radius: 9px; color: var(--muted); font-weight: 600; font-size: .9rem; min-height: 40px; display: flex; align-items: center; }
.seg a.active { background: #fff; color: var(--text); box-shadow: var(--shadow); }

.pagination { display: flex; justify-content: center; gap: 6px; margin-top: 16px; flex-wrap: wrap; }
.pagination a, .pagination span { min-width: 44px; min-height: 44px; display: grid; place-items: center; border-radius: 10px; background: #fff; border: 1px solid var(--border); color: var(--text); padding: 0 10px; }
.pagination .current { background: var(--primary); color: #fff; border-color: var(--primary); }

.pill-list { display: flex; flex-wrap: wrap; gap: 6px; }
.pill { font-size: .78rem; background: #eef2f7; color: #334155; border-radius: 999px; padding: 3px 10px; }

.product-picker { position: relative; }
.picker-results { position: absolute; left: 0; right: 0; top: 100%; z-index: 15; background: #fff; border: 1px solid var(--border); border-radius: var(--radius-sm); box-shadow: var(--shadow); max-height: 320px; overflow-y: auto; margin-top: 4px; }
.picker-results button { display: flex; justify-content: space-between; gap: 10px; width: 100%; min-height: 52px; padding: 10px 14px; border: 0; border-bottom: 1px solid var(--border); background: #fff; font: inherit; text-align: left; cursor: pointer; }
.picker-results button:hover { background: #f3f8ff; }
.picker-chosen { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 14px; border-radius: var(--radius-sm); background: #f3f8ff; border: 1px solid #c7dcfa; }

details.more { border-top: 1px solid var(--border); }
details.more summary { cursor: pointer; padding: 14px 16px; font-weight: 600; color: var(--primary); list-style: none; }
details.more summary::-webkit-details-marker { display: none; }

.text-right { text-align: right; }
.mt-0 { margin-top: 0; } .mt-1 { margin-top: 8px; } .mt-2 { margin-top: 16px; }
.mb-0 { margin-bottom: 0; } .mb-2 { margin-bottom: 16px; }
.nowrap { white-space: nowrap; }
.pre { white-space: pre-line; }
.inline-form { display: inline; margin: 0; }
.hide-mobile { display: none; }
@media (min-width: 768px) { .hide-mobile { display: initial; } .hide-desktop { display: none; } }

/* ---------- Página pública (front-office) ---------- */
body.public { background: var(--bg); min-height: 100vh; display: flex; flex-direction: column; }
.public-head { background: var(--navy); padding: 14px 16px; }
.public-brand { display: flex; align-items: center; justify-content: center; gap: 12px; color: #fff; font-size: 1.15rem; font-weight: 700; max-width: 640px; margin: 0 auto; }
.public-brand img { max-height: 48px; max-width: 160px; object-fit: contain; background: #fff; border-radius: 8px; padding: 4px 6px; }
.public-wrap { width: 100%; max-width: 640px; margin: 0 auto; padding: 20px 16px; flex: 1; }
.public-title { font-size: 1.35rem; margin-bottom: 6px; }
.text-center { text-align: center; }
.status-hero .card-body { display: flex; gap: 16px; align-items: center; }
.status-icon { width: 60px; height: 60px; border-radius: 16px; display: grid; place-items: center; flex: 0 0 auto; background: #e0f2fe; color: #0369a1; }
.status-icon .icon { width: 30px; height: 30px; }
.status-ref { font-size: .85rem; color: var(--muted); font-weight: 600; margin-bottom: 4px; }
.status-in_progress .status-icon { background: #fef3c7; color: #b45309; }
.status-paused .status-icon { background: #ffedd5; color: #c2410c; }
.status-completed .status-icon { background: #ede9fe; color: #6d28d9; }
.status-ready .status-icon { background: #dcfce7; color: #15803d; }
.status-ready { border-color: #86efac; }
.status-delivered .status-icon { background: #e2e8f0; color: #334155; }
.status-cancelled .status-icon { background: #fee2e2; color: #b91c1c; }
.public-steps { list-style: none; margin: 0; padding: 0; }
.public-steps li { position: relative; display: flex; gap: 14px; align-items: center; padding: 0 0 18px; color: var(--muted); }
.public-steps li:last-child { padding-bottom: 0; }
.public-steps li::after { content: ""; position: absolute; left: 18px; top: 38px; bottom: 0; width: 2px; background: var(--border); }
.public-steps li:last-child::after { display: none; }
.public-steps .dot { width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; background: #e3e9f1; color: #8a9ab0; flex: 0 0 auto; position: relative; z-index: 1; }
.public-steps .dot .icon { width: 18px; height: 18px; }
.public-steps .step-text { display: flex; flex-direction: column; }
.public-steps li.done { color: var(--text); }
.public-steps li.done .dot { background: var(--success); color: #fff; }
.public-steps li.done::after { background: var(--success); }
.public-steps li.current { color: var(--text); }
.public-steps li.current .dot { background: var(--primary); color: #fff; box-shadow: 0 0 0 4px rgba(29,111,216,.2); }
.public-foot { text-align: center; padding: 20px 16px calc(24px + env(safe-area-inset-bottom)); color: var(--muted); font-size: .9rem; display: grid; gap: 6px; }
.public-contacts { display: flex; justify-content: center; gap: 16px; flex-wrap: wrap; }
.public-contacts a { display: inline-flex; align-items: center; gap: 6px; min-height: 40px; }
.public-contacts .icon { width: 16px; height: 16px; }
.powered { font-size: .75rem; margin-top: 6px; }

/* ---------- Login ---------- */
body.guest { background: linear-gradient(160deg, var(--navy) 0%, var(--navy-2) 60%, #1f4f80 100%); min-height: 100vh; }
.guest-wrap { max-width: 420px; margin: 0 auto; padding: 48px 18px; }
.guest-brand { display: flex; align-items: center; justify-content: center; gap: 12px; margin-bottom: 24px; }
.guest-brand .brand-mark { width: 48px; height: 48px; border-radius: 14px; }
.guest-brand .brand-name { font-size: 1.8rem; }
.guest .card { padding: 8px; }
.demo-login { width: 100%; background: none; border: 0; border-bottom: 1px solid var(--border); font: inherit; text-align: left; cursor: pointer; }
.demo-login:hover { background: #f3f8ff; }
.demo-login > .icon { color: var(--primary); }
