:root {
    --bg: #f4f6fb;
    --surface: #ffffff;
    --surface-soft: #f8fafc;
    --ink: #172033;
    --muted: #64748b;
    --line: #e2e8f0;
    --navy: #0f172a;
    --navy-soft: #1e293b;
    --orange: #f97316;
    --orange-dark: #ea580c;
    --green: #16a34a;
    --red: #dc2626;
    --shadow: 0 16px 40px rgba(15, 23, 42, .08);
    --radius: 16px;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--bg); }
body { margin: 0; color: var(--ink); font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; font-size: 15px; line-height: 1.5; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; }
button, select { cursor: pointer; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 6px; font-size: clamp(1.65rem, 3vw, 2.2rem); line-height: 1.15; letter-spacing: -.035em; }
h2 { margin-bottom: 4px; font-size: 1.08rem; letter-spacing: -.015em; }
h3 { font-size: .98rem; }
p { color: var(--muted); }
small { display: block; color: var(--muted); }

.app-shell { display: grid; grid-template-columns: 258px minmax(0, 1fr); min-height: 100vh; }
.sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; padding: 22px 16px; color: #cbd5e1; background: var(--navy); z-index: 20; }
.brand { display: flex; align-items: center; gap: 12px; padding: 0 8px 22px; color: #fff; }
.brand strong, .brand small { display: block; }
.brand strong { font-size: 1.02rem; }
.brand small { color: #94a3b8; font-size: .76rem; }
.brand-mark { display: inline-grid; flex: 0 0 auto; width: 42px; height: 42px; place-items: center; color: #fff; font-weight: 900; letter-spacing: -.06em; border-radius: 13px; background: linear-gradient(135deg, var(--orange), #fb923c); box-shadow: 0 8px 22px rgba(249, 115, 22, .3); }
.nav-list { display: flex; flex-direction: column; gap: 5px; }
.nav-list > a { display: flex; align-items: center; gap: 11px; min-height: 43px; padding: 10px 12px; border-radius: 11px; transition: .15s ease; }
.nav-list > a:hover { color: #fff; background: var(--navy-soft); }
.nav-list > a span { width: 20px; color: #94a3b8; text-align: center; }
.nav-list > a.disabled { opacity: .45; pointer-events: none; }
.nav-section { padding: 22px 12px 6px; color: #64748b; font-size: .7rem; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
.sidebar-footer { margin-top: auto; padding-top: 18px; border-top: 1px solid #24324a; }
.user-card { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; padding: 0 6px; }
.user-card strong { display: block; color: #fff; font-size: .88rem; }
.user-card small { max-width: 150px; overflow: hidden; color: #94a3b8; font-size: .7rem; text-overflow: ellipsis; white-space: nowrap; }
.avatar { display: grid; width: 36px; height: 36px; place-items: center; border-radius: 50%; color: #fff; font-weight: 800; background: #334155; }

.main-content { min-width: 0; }
.topbar { position: sticky; top: 0; z-index: 15; display: flex; align-items: center; gap: 14px; min-height: 72px; padding: 12px 28px; border-bottom: 1px solid rgba(226, 232, 240, .8); background: rgba(255, 255, 255, .9); backdrop-filter: blur(14px); }
.topbar > div { margin-right: auto; }
.topbar strong { display: block; }
.topbar small { font-size: .74rem; }
.menu-button { display: none; width: 40px; height: 40px; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
.page-content { padding: 28px; }
.page-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 18px; margin-bottom: 24px; }
.page-heading p { margin-bottom: 0; }
.eyebrow { margin-bottom: 6px !important; color: var(--orange-dark) !important; font-size: .72rem; font-weight: 900; letter-spacing: .12em; text-transform: uppercase; }
.heading-actions { display: flex; align-items: center; gap: 10px; }

.btn { display: inline-flex; align-items: center; justify-content: center; min-height: 42px; padding: 9px 15px; border: 1px solid transparent; border-radius: 10px; font-weight: 750; transition: .15s ease; }
.btn:hover { transform: translateY(-1px); }
.btn-primary { color: #fff; background: var(--orange); box-shadow: 0 8px 18px rgba(249, 115, 22, .18); }
.btn-primary:hover { background: var(--orange-dark); }
.btn-secondary { color: #334155; border-color: var(--line); background: #fff; }
.btn-ghost { color: #475569; border-color: transparent; background: transparent; }
.btn-block { width: 100%; }
.btn-sm { min-height: 34px; padding: 6px 11px; font-size: .82rem; }

.alert { margin-bottom: 20px; padding: 13px 16px; border: 1px solid; border-radius: 11px; font-weight: 650; }
.alert-success { color: #166534; border-color: #bbf7d0; background: #f0fdf4; }
.alert-error { color: #991b1b; border-color: #fecaca; background: #fef2f2; }

.metric-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 14px; margin-bottom: 20px; }
.metric-card, .panel { border: 1px solid rgba(226, 232, 240, .95); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
.metric-card { min-height: 132px; padding: 19px; }
.metric-card > span { color: var(--muted); font-size: .8rem; font-weight: 700; }
.metric-card strong { display: block; margin: 10px 0 4px; font-size: clamp(1.35rem, 2vw, 1.8rem); line-height: 1.1; letter-spacing: -.04em; }
.metric-card small { font-size: .72rem; }
.metric-danger strong { color: var(--red); }
.panel { min-width: 0; padding: 20px; }
.panel-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
.panel-header p { margin-bottom: 0; font-size: .84rem; }
.panel-header > a { color: var(--orange-dark); font-size: .82rem; font-weight: 750; }
.content-grid { display: grid; gap: 20px; }
.content-grid-main { grid-template-columns: minmax(0, 1fr) 320px; }
.stack { display: flex; flex-direction: column; gap: 20px; min-width: 0; }

.table-wrap { width: 100%; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { padding: 11px 12px; color: #64748b; font-size: .7rem; font-weight: 850; letter-spacing: .07em; text-align: left; text-transform: uppercase; background: var(--surface-soft); }
th:first-child { border-radius: 10px 0 0 10px; }
th:last-child { border-radius: 0 10px 10px 0; }
td { padding: 13px 12px; border-bottom: 1px solid #eef2f7; vertical-align: middle; }
td small { margin-top: 2px; font-size: .72rem; }
tr:last-child td { border-bottom: 0; }
.table-link { color: #0f172a; font-weight: 800; }
.table-link:hover { color: var(--orange-dark); }
.text-right { text-align: right; }
.empty-cell { padding: 30px; color: var(--muted); text-align: center; }

.badge { --badge-color: #64748b; display: inline-flex; align-items: center; gap: 6px; padding: 5px 9px; color: var(--badge-color); border: 1px solid color-mix(in srgb, var(--badge-color) 30%, white); border-radius: 999px; font-size: .72rem; font-weight: 800; background: color-mix(in srgb, var(--badge-color) 10%, white); white-space: nowrap; }
.badge-neutral { --badge-color: #64748b; text-transform: capitalize; }
.badge-lg { padding: 8px 12px; font-size: .78rem; }
.status-summary { display: flex; flex-direction: column; }
.status-summary > div { display: grid; grid-template-columns: 12px minmax(0,1fr) auto; align-items: center; gap: 9px; padding: 11px 0; border-bottom: 1px solid #eef2f7; }
.status-summary > div:last-child { border-bottom: 0; }
.status-summary span:not(.status-dot) { color: #475569; font-size: .84rem; }
.status-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; }

.filter-bar { display: flex; gap: 10px; margin-bottom: 18px; }
.filter-bar input { flex: 1; }
.filter-multiple select { min-width: 210px; }
label { display: flex; flex-direction: column; gap: 7px; color: #334155; font-size: .78rem; font-weight: 750; }
input, select, textarea { width: 100%; min-height: 43px; padding: 9px 11px; color: var(--ink); border: 1px solid #cbd5e1; border-radius: 9px; outline: none; background: #fff; transition: border .15s, box-shadow .15s; }
textarea { min-height: 90px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: #fb923c; box-shadow: 0 0 0 3px rgba(249, 115, 22, .12); }
.form-panel { padding: 24px; }
.form-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 17px; }
.span-2 { grid-column: span 2; }
.span-full { grid-column: 1 / -1; }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 24px; padding-top: 20px; border-top: 1px solid var(--line); }
.form-stack { display: flex; flex-direction: column; gap: 15px; }
.form-layout { display: flex; flex-direction: column; gap: 20px; }
.form-panel hr { height: 1px; margin: 20px 0; border: 0; background: var(--line); }
.check-label { align-items: center; flex-direction: row; align-self: end; min-height: 43px; }
.check-label input, .role-option input { width: 18px; min-height: 18px; accent-color: var(--orange); }
.role-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 0; padding: 16px; border: 1px solid var(--line); border-radius: 11px; }
.role-grid legend { padding: 0 7px; color: #334155; font-size: .78rem; font-weight: 800; }
.role-option { align-items: center; flex-direction: row; padding: 11px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface-soft); }
.role-option strong, .role-option small { display: block; }

.order-item-row { position: relative; display: grid; grid-template-columns: 1.2fr 1.8fr .65fr .6fr .85fr; gap: 12px; margin-bottom: 14px; padding: 16px 40px 16px 16px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-soft); }
.item-specifications { grid-column: 1 / -1; }
.remove-item { position: absolute; top: 12px; right: 10px; display: grid; width: 26px; height: 26px; place-items: center; color: #94a3b8; border: 0; border-radius: 7px; background: transparent; font-size: 1.25rem; }
.remove-item:hover { color: var(--red); background: #fee2e2; }

.totals { display: flex; justify-content: flex-end; gap: 24px; padding: 18px 10px 0; }
.totals span { color: var(--muted); font-size: .8rem; }
.totals strong { display: block; margin-top: 2px; color: var(--ink); font-size: 1rem; }
.detail-list > div { display: flex; justify-content: space-between; gap: 15px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.detail-list > div:last-child { border-bottom: 0; }
.detail-list span { color: var(--muted); }
.detail-list strong { text-align: right; text-transform: capitalize; }
.timeline { display: flex; flex-direction: column; }
.timeline > div { position: relative; display: grid; grid-template-columns: 18px minmax(0, 1fr); gap: 10px; padding-bottom: 18px; }
.timeline > div:not(:last-child)::before { position: absolute; top: 13px; bottom: 0; left: 4px; width: 1px; content: ''; background: #cbd5e1; }
.timeline-dot { position: relative; z-index: 1; width: 9px; height: 9px; margin-top: 5px; border: 2px solid #fff; border-radius: 50%; outline: 2px solid var(--orange); background: var(--orange); }
.timeline p { margin: 2px 0; font-size: .82rem; }
.timeline small { font-size: .7rem; }
.copy-field { display: flex; gap: 8px; }
.copy-field input { min-width: 0; font-size: .72rem; }
.muted { color: var(--muted); }

.kanban-board { display: flex; gap: 14px; padding-bottom: 14px; overflow-x: auto; scroll-snap-type: x proximity; }
.kanban-column { flex: 0 0 300px; min-height: 450px; padding: 12px; border: 1px solid var(--line); border-radius: 15px; background: #eef2f7; scroll-snap-align: start; }
.kanban-column > header { display: flex; align-items: center; justify-content: space-between; padding: 5px 4px 14px; }
.kanban-column > header > div { display: flex; align-items: center; gap: 8px; }
.kanban-column > header .status-dot { background: var(--status-color); }
.kanban-column > header > span { display: grid; width: 26px; height: 26px; place-items: center; color: #475569; border-radius: 8px; background: #fff; font-size: .76rem; font-weight: 800; }
.kanban-cards { display: flex; flex-direction: column; gap: 10px; }
.kanban-card { padding: 14px; border: 1px solid #e2e8f0; border-radius: 12px; background: #fff; box-shadow: 0 7px 18px rgba(15, 23, 42, .06); }
.kanban-card.is-blocked { border-color: #fca5a5; }
.kanban-card-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.kanban-card-top a { color: var(--orange-dark); font-size: .73rem; font-weight: 850; }
.kanban-card h3 { margin: 10px 0 2px; }
.kanban-card > p { margin-bottom: 12px; font-size: .8rem; }
.kanban-card select { min-height: 36px; margin-top: 12px; padding: 6px 8px; font-size: .72rem; }
.kanban-meta { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.kanban-meta span { color: var(--muted); font-size: .66rem; }
.kanban-meta strong { display: block; margin-top: 1px; overflow: hidden; color: #334155; font-size: .7rem; text-overflow: ellipsis; text-transform: capitalize; white-space: nowrap; }
.priority { padding: 3px 6px; border-radius: 6px; font-size: .62rem; font-weight: 850; text-transform: uppercase; }
.priority-urgente { color: #991b1b; background: #fee2e2; }
.priority-alta { color: #9a3412; background: #ffedd5; }
.priority-normal { color: #1e40af; background: #dbeafe; }
.priority-baixa { color: #475569; background: #e2e8f0; }
.block-note { margin-top: 10px; padding: 7px 9px; color: #991b1b; border-radius: 7px; background: #fef2f2; font-size: .7rem; }
.kanban-empty { padding: 26px 10px; color: #94a3b8; text-align: center; font-size: .75rem; }

.empty-state { max-width: 560px; margin: 10vh auto; padding: 40px; color: var(--muted); text-align: center; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; box-shadow: var(--shadow); }
.empty-state.compact { margin: 20px auto; padding: 25px; border: 0; box-shadow: none; }
.empty-icon { display: block; margin-bottom: 10px; color: var(--orange); font-size: 2.7rem; font-weight: 900; }

.guest-body { display: grid; min-height: 100vh; padding: 24px; place-items: center; background: radial-gradient(circle at 10% 10%, #263854, transparent 32%), radial-gradient(circle at 90% 90%, rgba(249, 115, 22, .22), transparent 28%), var(--navy); }
.guest-shell { width: 100%; max-width: 680px; }
.auth-card, .portal-card { padding: clamp(25px, 5vw, 44px); border: 1px solid rgba(255,255,255,.1); border-radius: 22px; background: #fff; box-shadow: 0 30px 90px rgba(0,0,0,.28); }
.auth-card { max-width: 480px; margin: auto; }
.auth-brand { margin-bottom: 24px; }
.auth-card > p { margin-bottom: 24px; }
.auth-card .muted { margin-top: 18px; text-align: center; }
.portal-card { max-width: 680px; margin: auto; }
.portal-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 32px; }
.portal-brand strong, .portal-brand small { display: block; }
.portal-status { display: flex; align-items: center; gap: 13px; margin: 25px 0; padding: 18px; border: 1px solid color-mix(in srgb, var(--status-color) 28%, white); border-radius: 13px; background: color-mix(in srgb, var(--status-color) 8%, white); }
.portal-status > span { width: 14px; height: 14px; border-radius: 50%; background: var(--status-color); box-shadow: 0 0 0 5px color-mix(in srgb, var(--status-color) 16%, white); }
.portal-status small { font-size: .72rem; }
.portal-status strong { display: block; color: var(--status-color); font-size: 1.08rem; }
.portal-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 20px; }
.portal-grid > div { padding: 14px; border-radius: 11px; background: var(--surface-soft); }
.portal-grid span { display: block; color: var(--muted); font-size: .72rem; }
.portal-grid strong { display: block; margin-top: 4px; text-transform: capitalize; }
.portal-update { margin: 20px 0; font-size: .76rem; text-align: center; }

@media (max-width: 1180px) {
    .metric-grid { grid-template-columns: repeat(3, 1fr); }
    .form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .order-item-row { grid-template-columns: repeat(3, 1fr); }
    .item-description { grid-column: span 2; }
}

@media (max-width: 900px) {
    .app-shell { display: block; }
    .sidebar { position: fixed; left: -280px; width: 258px; transition: left .2s ease; box-shadow: 20px 0 50px rgba(15,23,42,.25); }
    .sidebar.is-open { left: 0; }
    .menu-button { display: grid; place-items: center; }
    .content-grid-main { grid-template-columns: 1fr; }
    .status-panel { order: -1; }
}

@media (max-width: 680px) {
    .topbar { min-height: 64px; padding: 10px 14px; }
    .topbar .btn { padding: 8px 10px; font-size: .76rem; }
    .page-content { padding: 18px 14px; }
    .page-heading { align-items: stretch; flex-direction: column; }
    .heading-actions { align-items: stretch; flex-direction: column; }
    .metric-grid { grid-template-columns: 1fr 1fr; }
    .metric-card { min-height: 112px; padding: 15px; }
    .metric-card:last-child { grid-column: 1 / -1; }
    .panel { padding: 15px; border-radius: 13px; }
    .filter-bar, .filter-multiple { align-items: stretch; flex-direction: column; }
    .filter-multiple select { min-width: 0; }
    .form-grid { grid-template-columns: 1fr; }
    .span-2, .span-full { grid-column: auto; }
    .order-item-row { grid-template-columns: 1fr 1fr; padding: 14px 36px 14px 14px; }
    .order-item-row label, .item-description, .item-specifications { grid-column: 1 / -1; }
    .totals { align-items: flex-end; flex-direction: column; gap: 8px; }
    .totals span { text-align: right; }
    .portal-grid { grid-template-columns: 1fr; }
    .role-grid { grid-template-columns: 1fr; }
    .guest-body { padding: 14px; }
    .auth-card, .portal-card { border-radius: 16px; }
}

@media (max-width: 420px) {
    .metric-grid { grid-template-columns: 1fr; }
    .metric-card:last-child { grid-column: auto; }
    .topbar small { display: none; }
}
