:root {
  --brand: #ff6a1a;
  --brand-dark: #e2550a;
  --brand-soft: #fff1e8;
  --bg: #f5f6f8;
  --surface: #ffffff;
  --border: #e4e7ec;
  --text: #1d2330;
  --muted: #6b7385;
  --side: #161a22;
  --side-text: #c4cad6;
  --danger: #d93838;
  --success: #1f9d55;
  --info: #2f6fdf;
  --warn-bg: #fff7e0;
  --warn-border: #f3d27a;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  font-family: Inter, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  color: var(--text);
  font-size: 15px;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); }
a { color: var(--brand-dark); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.5rem; margin: 0; }
h2 { font-size: 1.02rem; margin: 0; }
h3.sub { font-size: .9rem; margin: 1.2rem 0 .4rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.text-danger { color: var(--danger) !important; }
.text-success { color: var(--success); }
.text-info { color: var(--info); }
.boot, .loading-page { padding: 3rem; text-align: center; color: var(--muted); }

/* ---------- marca ---------- */
.brand { display: flex; align-items: center; gap: .55rem; color: inherit; font-weight: 800; font-size: 1.15rem; letter-spacing: .02em; }
.brand:hover { text-decoration: none; }
.brand img { width: 30px; height: 30px; }
.brand b { color: var(--brand); }
.brand-lg { font-size: 1.6rem; justify-content: center; }
.brand-lg img { width: 42px; height: 42px; }

/* ---------- login ---------- */
.login-page { min-height: 100vh; display: grid; place-items: center; padding: 1rem;
  background: radial-gradient(circle at 20% 10%, #2a2f3b, var(--side) 60%); }
.login-card { width: 100%; max-width: 360px; background: var(--surface); border-radius: 16px; padding: 2rem; box-shadow: 0 20px 50px rgba(0, 0, 0, .35); display: grid; gap: .9rem; }
.login-card .muted { text-align: center; margin: -.4rem 0 .4rem; }
.form-error { color: var(--danger); margin: 0; font-size: .9rem; }

/* ---------- layout ---------- */
.shell { display: flex; min-height: 100vh; }
.sidebar { width: 236px; flex-shrink: 0; background: var(--side); color: var(--side-text); display: flex; flex-direction: column; padding: 1.1rem .8rem; position: sticky; top: 0; height: 100vh; }
.sidebar .brand { color: #fff; padding: .2rem .5rem 1.2rem; }
.sidebar nav { display: grid; gap: 2px; }
.sidebar nav a { display: flex; align-items: center; gap: .7rem; padding: .6rem .7rem; border-radius: 8px; color: var(--side-text); font-weight: 500; }
.sidebar nav a:hover { background: rgba(255, 255, 255, .06); text-decoration: none; color: #fff; }
.sidebar nav a.active { background: rgba(255, 106, 26, .16); color: #fff; }
.sidebar nav a.active .nav-icon { fill: var(--brand); }
.nav-icon { width: 20px; height: 20px; fill: currentColor; flex-shrink: 0; }
.sidebar-foot { margin-top: auto; display: flex; align-items: center; justify-content: space-between; padding: .6rem .5rem 0; border-top: 1px solid rgba(255, 255, 255, .08); }
.sidebar-foot .btn-ghost { color: var(--side-text); }
.content { flex: 1; min-width: 0; }
.topbar { display: none; }
main { padding: 1.6rem 2rem 3rem; max-width: 1400px; }
.sidebar-scrim { display: none; }

.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; margin-bottom: 1.2rem; flex-wrap: wrap; }
.page-head p { margin: .25rem 0 0; }
.page-actions { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.page-actions input[type=search] { min-width: 260px; width: auto; }
.back { font-size: .85rem; display: inline-block; margin-bottom: .2rem; }

/* ---------- cards ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.1rem 1.2rem; margin-bottom: 1rem; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: .5rem; margin-bottom: .9rem; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(380px, 1fr)); gap: 1rem; align-items: start; }
.grid-2 > .card { margin: 0; }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: .8rem; margin-bottom: 1rem; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: .9rem 1rem; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: .15rem; }
.kpi span { color: var(--muted); font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; }
.kpi b { font-size: 1.45rem; }
.kpi small { color: var(--muted); }
.kpi-accent { background: linear-gradient(135deg, var(--brand), #ff8a3d); border: 0; color: #fff; }
.kpi-accent span, .kpi-accent small { color: rgba(255, 255, 255, .85); }
.kpi-accent b { font-size: 1.15rem; }
.kpi-accent b::first-letter { text-transform: uppercase; }

.alert { padding: .75rem 1rem; border-radius: var(--radius); margin-bottom: 1rem; border: 1px solid; }
.alert-warn { background: var(--warn-bg); border-color: var(--warn-border); }

.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; justify-content: space-between; align-items: center; gap: .6rem; padding: .55rem 0; border-bottom: 1px solid var(--border); }
.list li:last-child { border-bottom: 0; }
.empty { text-align: center; padding: 3rem 1rem; color: var(--muted); background: var(--surface); border: 1px dashed var(--border); border-radius: var(--radius); }
.inactive { opacity: .55; }

/* ---------- botões ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .35rem; border: 1px solid var(--border); background: var(--surface); color: var(--text);
  padding: .55rem .95rem; border-radius: 8px; font: inherit; font-weight: 600; font-size: .9rem; cursor: pointer; white-space: nowrap; line-height: 1.1; }
.btn:hover { background: #f0f2f5; text-decoration: none; }
.btn:disabled { opacity: .6; cursor: default; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-dark); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-danger-ghost { background: transparent; border-color: transparent; color: var(--danger); }
.btn-danger-ghost:hover { background: #fdecec; }
.btn-sm { padding: .35rem .65rem; font-size: .82rem; }
.btn-block { width: 100%; padding: .75rem; }
.btn.loading { position: relative; color: transparent !important; }
.btn.loading::after { content: ''; position: absolute; width: 16px; height: 16px; border: 2px solid currentColor; border-color: #fff #fff transparent transparent; border-radius: 50%; animation: spin .7s linear infinite; }
.btn:not(.btn-primary).loading::after { border-color: var(--muted) var(--muted) transparent transparent; }
@keyframes spin { to { transform: rotate(360deg); } }
.btn-row { display: flex; gap: .4rem; flex-wrap: wrap; align-items: center; }
.btn-row.quick { margin-bottom: .8rem; }
.icon-btn { border: 0; background: transparent; cursor: pointer; font-size: 1rem; padding: .3rem .45rem; border-radius: 6px; color: var(--muted); line-height: 1; }
.icon-btn:hover:not(:disabled) { background: #eef0f3; color: var(--text); }
.icon-btn:disabled { opacity: .3; cursor: default; }

/* ---------- formulários ---------- */
label, .field { display: flex; flex-direction: column; gap: .3rem; font-size: .86rem; font-weight: 600; color: #3a4252; }
.field > span { font-weight: 600; }
input, select, textarea { font: inherit; font-weight: 400; color: var(--text); padding: .55rem .7rem; border: 1px solid #cfd4dc; border-radius: 8px; background: #fff; width: 100%; }
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(255, 106, 26, .35); border-color: var(--brand); }
input[type=color] { padding: .2rem; height: 40px; }
input[type=checkbox] { width: auto; }
label.check { flex-direction: row; align-items: center; gap: .5rem; font-weight: 500; }
label small { font-weight: 400; }
textarea { resize: vertical; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .9rem 1rem; }
.form-grid-4 { grid-template-columns: repeat(4, 1fr); }
.span-2 { grid-column: span 2; }
.form-actions { display: flex; justify-content: flex-end; gap: .5rem; margin-top: .4rem; }
.form-layout { display: grid; grid-template-columns: minmax(0, 1fr) 330px; gap: 1rem; align-items: start; }
.form-side .sticky { position: sticky; top: 1rem; }
.duration { display: flex; gap: .5rem; }
.duration label, .input-suffix { flex-direction: row; align-items: center; gap: .35rem; font-weight: 500; }
.duration input { width: 80px; }
.input-suffix input { width: 100px; }

.fil-row { display: grid; grid-template-columns: minmax(0, 1fr) auto 80px auto; gap: .6rem; align-items: center; margin-bottom: .55rem; }
.fil-cost { text-align: right; font-size: .85rem; }

.cost-list { display: grid; grid-template-columns: 1fr auto; gap: .45rem .8rem; margin: 0; font-size: .9rem; }
.cost-list dt { color: var(--muted); }
.cost-list dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; }
.cost-list .total { font-weight: 700; color: var(--text); border-top: 1px solid var(--border); padding-top: .45rem; }

.stock-big { display: flex; align-items: baseline; gap: .4rem; }
.stock-big b { font-size: 2.2rem; }

/* ---------- fotos ---------- */
.photos { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: .8rem; }
.photo { position: relative; margin: 0; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; background: #fafbfc; aspect-ratio: 1; display: flex; flex-direction: column; }
.photo a { flex: 1; min-height: 0; }
.photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo figcaption { display: flex; justify-content: center; gap: .2rem; padding: .2rem; background: #fff; border-top: 1px solid var(--border); }
.photo-cover { position: absolute; top: 6px; left: 6px; }
.photo-add { cursor: pointer; align-items: center; justify-content: center; border-style: dashed; text-align: center; padding: .5rem; color: var(--brand-dark); font-weight: 600; gap: .3rem; }
.photo-add:hover { background: var(--brand-soft); }

/* ---------- tabelas ---------- */
.table-wrap { padding: 0; overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.table th { text-align: left; font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; padding: .7rem .8rem; border-bottom: 1px solid var(--border); background: #fafbfc; white-space: nowrap; }
.table td { padding: .65rem .8rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table .actions { text-align: right; white-space: nowrap; }
.table tr.clickable { cursor: pointer; }
.table tr.clickable:hover td { background: #fafbfc; }
.table-compact td, .table-compact th { padding: .4rem .5rem; }
.modal .table th { background: transparent; }
.thumb-cell { width: 64px; }
.thumb-cell img, .thumb-ph { width: 52px; height: 52px; border-radius: 8px; object-fit: cover; display: block; background: #eef0f3; }
.bar-cell { width: 110px; }

.swatch { display: inline-block; width: 14px; height: 14px; border-radius: 50%; border: 1px solid rgba(0, 0, 0, .18); vertical-align: -2px; }
.swatches { display: flex; gap: 3px; margin-top: 4px; }
.swatches .swatch { width: 11px; height: 11px; }

.badge { display: inline-block; padding: .18rem .55rem; border-radius: 999px; font-size: .75rem; font-weight: 600; white-space: nowrap; }
.badge-gray { background: #eef0f3; color: #4a5263; }
.badge-blue { background: #e6efff; color: var(--info); }
.badge-green { background: #e3f6ec; color: var(--success); }
.badge-red { background: #fdecec; color: var(--danger); }
.badge-accent { background: var(--brand); color: #fff; }

.progress { height: 8px; background: #eef0f3; border-radius: 99px; overflow: hidden; min-width: 80px; }
.progress > div { height: 100%; background: var(--brand); border-radius: 99px; }
.progress-danger > div { background: var(--danger); }
.job-row { display: grid; grid-template-columns: 1fr 140px; align-items: center; gap: 1rem; padding: .5rem 0; border-bottom: 1px solid var(--border); }

.tabs { display: flex; gap: .3rem; margin-bottom: 1rem; border-bottom: 1px solid var(--border); }
.tab { border: 0; background: none; font: inherit; font-weight: 600; color: var(--muted); padding: .6rem .9rem; cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tab.active { color: var(--brand-dark); border-bottom-color: var(--brand); }

/* ---------- agenda (gantt) ---------- */
.gantt { display: flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.gantt-labels { width: 170px; flex-shrink: 0; border-right: 1px solid var(--border); background: #fafbfc; }
.gantt-label { height: 54px; padding: .45rem .7rem; display: flex; flex-direction: column; justify-content: center; border-bottom: 1px solid var(--border); font-size: .85rem; }
.gantt-label.gantt-axis-label { height: 32px; }
.gantt-scroll { overflow-x: auto; flex: 1; }
.gantt-canvas { position: relative; }
.gantt-axis { height: 32px; position: relative; border-bottom: 1px solid var(--border); background: #fafbfc; }
.tick { position: absolute; top: 9px; font-size: .72rem; color: var(--muted); transform: translateX(-50%); white-space: nowrap; }
.tick-day { font-weight: 700; color: var(--text); transform: none; padding-left: 4px; text-transform: capitalize; }
.gantt-dayline { position: absolute; top: 0; bottom: 0; border-left: 1px dashed #cfd4dc; }
.gantt-row { height: 54px; position: relative; border-bottom: 1px solid var(--border); }
.gantt-bar { position: absolute; top: 10px; height: 34px; border-radius: 6px; background: var(--c); color: #fff; font-size: .75rem; font-weight: 600; display: flex; align-items: center; padding: 0 .5rem; overflow: hidden; box-shadow: var(--shadow); cursor: default; }
.gantt-bar span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-shadow: 0 1px 1px rgba(0, 0, 0, .25); }
.gantt-bar.pending { opacity: .82; }
.gantt-bar.printing { outline: 2px solid #1d2330; outline-offset: 1px; }
.gantt-bar.short { background: repeating-linear-gradient(45deg, var(--c), var(--c) 8px, #d93838 8px, #d93838 14px); }
.gantt-bar.overdue { outline-color: var(--danger); }
.gantt-now { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--danger); z-index: 2; }
.gantt-now::before { content: 'agora'; position: absolute; top: 2px; left: 4px; font-size: .68rem; color: var(--danger); font-weight: 700; }
.day-card h2::first-letter { text-transform: uppercase; }

/* ---------- modal e toast ---------- */
.modal-backdrop { position: fixed; inset: 0; background: rgba(16, 20, 28, .55); display: grid; place-items: center; padding: 1rem; z-index: 50; animation: fade .12s; }
.modal { background: var(--surface); border-radius: 14px; width: 100%; max-width: 560px; max-height: calc(100vh - 2rem); display: flex; flex-direction: column; box-shadow: 0 20px 60px rgba(0, 0, 0, .3); }
.modal-wide { max-width: 760px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 1rem 1.2rem; border-bottom: 1px solid var(--border); }
.modal-head h2 { font-size: 1.1rem; }
.modal-body { padding: 1.1rem 1.2rem 1.2rem; overflow-y: auto; }
.modal-body p { margin-top: 0; }
@keyframes fade { from { opacity: 0; } }
#toasts { position: fixed; bottom: 1rem; right: 1rem; display: grid; gap: .5rem; z-index: 60; }
.toast { background: #1d2330; color: #fff; padding: .7rem 1rem; border-radius: 8px; box-shadow: 0 8px 24px rgba(0, 0, 0, .2); font-size: .9rem; max-width: 380px; transition: opacity .4s, transform .4s; }
.toast-error { background: var(--danger); }
.toast.out { opacity: 0; transform: translateY(8px); }

/* ---------- responsivo ---------- */
@media (max-width: 1000px) {
  .form-layout { grid-template-columns: 1fr; }
  .form-side .sticky { position: static; }
}
@media (max-width: 800px) {
  .sidebar { position: fixed; left: 0; top: 0; z-index: 40; transform: translateX(-100%); transition: transform .2s; }
  .sidebar.open { transform: none; }
  .sidebar.open + .sidebar-scrim { display: block; position: fixed; inset: 0; background: rgba(0, 0, 0, .4); z-index: 30; }
  .topbar { display: flex; align-items: center; gap: .6rem; padding: .7rem 1rem; background: var(--side); color: #fff; position: sticky; top: 0; z-index: 20; }
  .topbar .icon-btn { color: #fff; font-size: 1.3rem; }
  .topbar .brand { color: #fff; }
  main { padding: 1rem; }
  .grid-2 { grid-template-columns: 1fr; }
  .form-grid, .form-grid-4 { grid-template-columns: 1fr 1fr; }
  .page-actions input[type=search] { min-width: 0; flex: 1; }
  .gantt-labels { width: 110px; }
}
@media (max-width: 520px) {
  .form-grid, .form-grid-4 { grid-template-columns: 1fr; }
  .span-2 { grid-column: span 1; }
  .fil-row { grid-template-columns: 1fr auto auto; }
  .fil-row .fil-cost { display: none; }
}
