:root {
  /* paleta Maraca Hub */
  --brand: #890909;
  --brand-dark: #440000;
  --brand-vivid: #bf0000;
  --brand-mid: #9a0101;
  --gray: #b6b6b6;

  --bg: #f7f7f7;
  --surface: #ffffff;
  --border: #e6e6e6;
  --text: #000000;
  --muted: #666666;
  --accent: var(--brand-mid);
  --accent-soft: #f6e3e3;
  --slot: var(--brand-vivid);
  --slot-hover: #f2c9c9;
  --on-brand: #ffffff;
  --ok: #1e8a4c;
  --warn: #b26a00;
  --caution: #8a7000;
  --danger: var(--brand-vivid);
  --radius: 10px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000000;
    --surface: #121212;
    --border: #2b2b2b;
    --text: #ffffff;
    --muted: var(--gray);
    --accent: #e25555;
    --accent-soft: #2a0a0a;
    --slot: var(--brand-vivid);
    --slot-hover: #4a1010;
    --ok: #4cc27f;
    --warn: #e0a040;
    --caution: #e0cb40;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
a { color: var(--accent); }

.topbar {
  display: flex; align-items: center; gap: 16px;
  padding: 10px 20px; background: var(--brand); color: var(--on-brand);
  border-bottom: 3px solid var(--brand-dark);
}
.topbar .brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 15px; color: inherit; text-decoration: none; }
.topbar .brand img { height: 26px; width: auto; display: block; }
.topbar nav { display: flex; gap: 4px; margin-left: 8px; }
.topbar nav a { color: rgba(255,255,255,.75); text-decoration: none; padding: 5px 10px; border-radius: 6px; }
.topbar nav a:hover { color: #fff; background: rgba(255,255,255,.1); }
.topbar nav a.active { color: #fff; font-weight: 600; background: var(--brand-dark); }
.topbar .user { margin-left: auto; color: rgba(255,255,255,.85); display: flex; gap: 12px; align-items: center; }
.topbar .user a { color: #fff; }

.user-switch { position: relative; }
.user-switch-btn {
  font: inherit; cursor: pointer; border: 0; background: transparent; color: inherit;
  padding: 0; display: inline-flex; align-items: center; gap: 4px;
}
.user-switch-btn:hover { text-decoration: underline; }
.user-switch-menu {
  position: absolute; top: calc(100% + 8px); right: 0; z-index: 10; min-width: 220px;
  background: var(--surface); color: var(--text); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: 0 8px 24px rgba(0,0,0,.18); overflow: hidden;
}
.user-switch-item { padding: 9px 14px; font-size: 13px; cursor: pointer; }
.user-switch-item:hover { background: var(--bg); }
.user-switch-item.current { font-weight: 600; color: var(--accent); }
.user-switch-item.muted { color: var(--muted); cursor: default; }
.user-switch-item.muted:hover { background: transparent; }

.open-periods-warning {
  padding: 8px 20px; font-size: 13px; text-align: center;
  background: color-mix(in srgb, var(--warn) 18%, var(--surface));
  color: var(--text); border-bottom: 1px solid var(--border);
}

.impersonate-banner {
  padding: 8px 20px; font-size: 13px; text-align: center;
  background: color-mix(in srgb, var(--accent) 16%, var(--surface));
  color: var(--text); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center; gap: 10px; flex-wrap: wrap;
}
.impersonate-banner button {
  padding: 4px 10px; font-size: 12px;
}

main { max-width: 1100px; margin: 0 auto; padding: 20px 16px 48px; }

.page-title { font-size: 20px; margin: 0 0 2px; }
.page-subtitle { color: var(--muted); font-size: 13px; margin: 0 0 16px; }

.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 14px; }
.toolbar.sticky {
  display: flex; flex-direction: column; flex-wrap: nowrap; gap: 10px;
  position: sticky; top: 0; z-index: 3;
  background: var(--bg); padding: 10px 0; margin: 0 0 10px;
  border-bottom: 1px solid var(--border);
}
/* variante de linha única (sem .toolbar-row empilhadas dentro) — fixa sem forçar quebra em coluna.
   .toolbar-center é a de admin.html (centraliza tudo); esta é a de devops.html (mantém o layout
   normal com .spacer empurrando pra direita, só evitando o empilhamento vertical do .sticky). */
.toolbar.sticky.toolbar-center,
.toolbar.sticky.toolbar-row-single {
  flex-direction: row; flex-wrap: wrap;
}
.toolbar-row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.toolbar-actions { gap: 8px; }
.toolbar .spacer { flex: 1; }
.toolbar-center { justify-content: center; }
.toolbar-center button, .toolbar-center .btn { padding: 5px 10px; font-size: 13px; }
.toolbar-center .seg button { padding: 5px 10px; }
.toolbar-center .week-nav strong { min-width: 120px; font-size: 14px; }
.week-nav { display: flex; align-items: center; gap: 6px; }
.week-nav strong { min-width: 150px; text-align: center; font-size: 15px; }
[hidden] { display: none !important; }

button, .btn {
  font: inherit; cursor: pointer; border-radius: 8px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  padding: 7px 12px; text-decoration: none; display: inline-flex; align-items: center; gap: 6px;
}
button:hover, .btn:hover { border-color: var(--accent); }
button.primary, .btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
button.primary:hover, .btn.primary:hover { background: var(--brand-dark); border-color: var(--brand-dark); }
button.icon { padding: 7px 10px; }
button:disabled, .btn:disabled {
  background: var(--bg); border-color: var(--border); color: var(--muted);
  cursor: not-allowed; opacity: .7;
}
button:disabled:hover, .btn:disabled:hover { border-color: var(--border); }

.status { color: var(--muted); font-size: 13px; }
.status.ok { color: var(--ok); }
.status.err { color: var(--danger); }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.hint { color: var(--muted); font-size: 13px; margin: 0 0 12px; }

/* ---------- calendário */
.grid-wrap { overflow-x: auto; overflow-y: visible; }
.grid {
  display: grid;
  grid-template-columns: 44px repeat(7, minmax(36px, 1fr));
  user-select: none; -webkit-user-select: none;
}
.grid-head-sticky {
  position: sticky; top: var(--toolbar-h, 49px); z-index: 2;
  background: var(--surface);
  border-bottom: 0; border-radius: var(--radius) var(--radius) 0 0;
  overflow-x: auto; overflow-y: visible;
}
.grid-wrap { border-top: 0; border-radius: 0 0 var(--radius) var(--radius); }
.grid .head {
  background: var(--surface); border-bottom: 1px solid var(--border);
  padding: 8px 4px; text-align: center; font-size: 12px; color: var(--muted);
}
.grid .head b { display: block; color: var(--text); font-size: 13px; }
.grid .head .hours { color: var(--accent); font-weight: 600; }
.grid .head.today b { color: var(--accent); }

.grid.unavailable { opacity: .55; }
.grid.locked { opacity: .55; pointer-events: none; }
.banner {
  margin-bottom: 12px; padding: 10px 14px; border-radius: var(--radius);
  background: var(--bg); border: 1px solid var(--border); color: var(--muted);
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
}
.banner.unavailable { background: color-mix(in srgb, var(--gray) 20%, transparent); }
.banner button { margin-left: auto; }
.grid .time {
  font-size: 11px; color: var(--muted); text-align: right; padding-right: 6px;
  height: 20px; line-height: 1; padding-top: 2px;
}
.grid .cell {
  height: 20px; border-left: 1px solid var(--border); cursor: pointer;
  touch-action: pan-y;
}
.grid .cell.hour { border-top: 1px solid var(--border); }
.grid .cell:hover { background: var(--slot-hover); }
.grid .cell.on { background: var(--slot); border-top-color: var(--slot); }
.grid .cell.on.top { border-top-left-radius: 4px; border-top-right-radius: 4px; }

.summary { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 12px; }
.pill { background: var(--accent-soft); color: var(--accent); border-radius: 999px; padding: 4px 10px; font-weight: 600; }

/* ---------- login */
.login {
  min-height: 100vh; display: grid; place-items: center; padding: 16px;
  background: var(--brand);
}
.login .card { padding: 36px 32px 32px; max-width: 380px; width: 100%; text-align: center; border: 0; box-shadow: 0 12px 40px rgba(68,0,0,.35); }
.login .logo { height: 96px; width: auto; margin: 0 auto 20px; display: block; }
.login h1 { font-size: 22px; margin: 0 0 6px; }
.login p { color: var(--muted); margin: 0 0 24px; }
.ms-btn { width: 100%; justify-content: center; padding: 11px; font-weight: 600; }
.ms-btn svg { background: #fff; padding: 2px; border-radius: 2px; box-sizing: content-box; }

/* ---------- gestão */
.seg { display: inline-flex; flex: none; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; background: var(--surface); }
.seg button { flex: none; border: 0; border-radius: 0; padding: 7px 12px; background: transparent; }
.seg button + button { border-left: 1px solid var(--border); }
.seg button[aria-selected="true"] { background: var(--brand); color: #fff; font-weight: 600; }
.section-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.section-head h2 { margin: 0; }
.section-head button { margin-left: auto; }
.kpis.compact { margin-bottom: 12px; }
.kpis.compact .kpi { padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius); }
.kpis.compact .value { font-size: 22px; }
.badge.over { background: color-mix(in srgb, var(--danger) 15%, transparent); color: var(--danger); font-weight: 600; }
.badge.muted { background: var(--bg); color: var(--muted); border: 1px solid var(--border); }
td.unavailable { background: var(--bg); color: var(--muted); font-style: italic; }
td.err { color: var(--danger); white-space: normal; }
.alloc-col { min-width: 150px; }
.alloc { display: inline-flex; align-items: center; gap: 8px; justify-content: flex-end; width: 100%; }
.meter { flex: 1; min-width: 50px; max-width: 90px; height: 6px; background: var(--border); border-radius: 3px; overflow: hidden; }
.meter i { display: block; height: 100%; background: var(--gray); }
.meter i.over { background: var(--danger); }
.kpi .sub { color: var(--muted); font-size: 12px; margin-top: 2px; }
b.over { color: var(--danger); }
b.under { color: var(--ok); }

.budget-input {
  width: 100px; font: inherit; text-align: right; font-variant-numeric: tabular-nums;
  border: 1px solid var(--border); border-radius: 6px; padding: 4px 8px; background: var(--surface); color: var(--text);
}
.budget-input:focus { outline: none; border-color: var(--accent); }
.budget-input:disabled { opacity: .5; }
.help-list { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 10px; }
.help-list li { line-height: 1.5; }

.add-client { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; align-items: center; }
.add-client input[type="text"] { flex: 1; min-width: 180px; }
.add-client input[type="number"] { width: 140px; }
.add-client input[type="month"] { width: 150px; }
.add-client input { font: inherit; border: 1px solid var(--border); border-radius: 8px; padding: 7px 10px; background: var(--surface); color: var(--text); }
.add-client input:focus { outline: none; border-color: var(--accent); }

#filters-bar input[type="text"] { font: inherit; border: 1px solid var(--border); border-radius: 8px; padding: 6px 10px; background: var(--surface); color: var(--text); min-width: 200px; }
#filters-bar input[type="text"]:focus { outline: none; border-color: var(--accent); }

.contract-trend-block { margin-bottom: 20px; }
.contract-trend-block:last-child { margin-bottom: 0; }
.contract-trend-block h3 { margin: 0 0 8px; font-size: 14px; }
.additional-input { font: inherit; border: 1px solid var(--border); border-radius: 6px; padding: 4px 6px; background: var(--surface); color: var(--text); }
.additional-input:focus { outline: none; border-color: var(--accent); }

.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; }
.cal-head { text-align: center; font-size: 12px; color: var(--muted); padding-bottom: 2px; }
.cal-day {
  min-height: 74px; border: 1px solid var(--border); border-radius: 8px; padding: 6px 8px;
  display: flex; flex-direction: column; gap: 2px; font-variant-numeric: tabular-nums;
}
.cal-day.empty { border: 0; background: transparent; }
.cal-day .n { font-size: 12px; color: var(--muted); }
.cal-day b { font-size: 15px; }
.cal-day small { font-size: 11px; color: var(--muted); }
.cal-day.today { outline: 2px solid var(--brand); outline-offset: -1px; }
@media (max-width: 640px) {
  .cal { gap: 3px; }
  .cal-day { min-height: 54px; padding: 4px; }
  .cal-day b { font-size: 12px; }
  .cal-day small { display: none; }
}
.month-layout { display: grid; grid-template-columns: 260px 1fr; gap: 16px; align-items: start; }
#month-calendar-box { position: sticky; top: calc(var(--toolbar-h, 49px) + 12px); }
#month-calendar-box h2 { font-size: 14px; margin: 0 0 10px; }
#month-calendar { grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 3px; }
#month-calendar .cal-day { min-height: 34px; padding: 3px 4px; }
#month-calendar .cal-day .n { font-size: 10px; }
#month-calendar .cal-day.has-hours { background: color-mix(in srgb, var(--slot, #c0392b) 35%, var(--surface)); }
#monthly-estimate-box { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border); }
#monthly-estimate-box .hint { margin: 0 0 8px; }
#monthly-estimate-box .add-client { margin-top: 0; }
#monthly-estimate-box input[type="number"] { width: 100%; }
.main-col { min-width: 0; }
@media (max-width: 900px) {
  .month-layout { grid-template-columns: 1fr; }
  #month-calendar-box { position: static; }
}

.link-btn { background: none; border: 0; padding: 0; font: inherit; color: var(--accent); text-decoration: underline; cursor: pointer; }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi { padding: 14px 16px; }
.kpi .label { color: var(--muted); font-size: 12px; }
.kpi .value { font-size: 26px; font-weight: 700; font-variant-numeric: tabular-nums; }
.section { padding: 16px; margin-bottom: 16px; }
.section h2 { font-size: 15px; margin: 0 0 12px; }
.section h3 { font-size: 13px; margin: 20px 0 4px; }
.section h3:first-of-type { margin-top: 4px; }
.section h4 { font-size: 12px; color: var(--muted); margin: 0 0 6px; font-weight: 600; }
#deviation td:first-child, #no-dates td:first-child {
  white-space: normal; min-width: 260px;
}
#deviation td:first-child a, #no-dates td:first-child a { color: inherit; text-decoration: none; }
#deviation td:first-child a:hover, #no-dates td:first-child a:hover { text-decoration: underline; }

table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
th, td { padding: 8px 6px; text-align: right; border-bottom: 1px solid var(--border); white-space: nowrap; }
th:first-child, td:first-child { text-align: left; }
th.center, td.center { text-align: center; }

.checkbox-label { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); margin-bottom: 10px; cursor: pointer; }
th { color: var(--muted); font-weight: 500; font-size: 12px; }
td.zero { color: var(--muted); }
tfoot td { font-weight: 700; border-bottom: 0; }
.badge { font-size: 12px; border-radius: 999px; padding: 2px 8px; }
.badge.yes { background: color-mix(in srgb, var(--ok) 15%, transparent); color: var(--ok); }
.badge.no { background: color-mix(in srgb, var(--warn) 15%, transparent); color: var(--warn); }
.badge.caution { background: color-mix(in srgb, var(--caution) 20%, transparent); color: var(--caution); }
.table-wrap { overflow-x: auto; }

.heat { display: grid; grid-template-columns: 44px repeat(7, minmax(32px, 1fr)); gap: 1px; }
.heat .head { text-align: center; font-size: 12px; color: var(--muted); padding-bottom: 6px; }
.heat .time { font-size: 11px; color: var(--muted); text-align: right; padding-right: 6px; line-height: 14px; }
.heat .h { height: 14px; border-radius: 2px; }
.legend { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 12px; margin-top: 10px; }
.legend span { width: 18px; height: 10px; border-radius: 2px; display: inline-block; }

.trend { display: flex; align-items: flex-end; gap: 8px; height: 140px; }
.trend .bar { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; gap: 4px; }
.trend .bar div { width: 100%; max-width: 42px; background: var(--gray); border-radius: 4px 4px 0 0; min-height: 2px; }
.trend .bar.current div { background: var(--slot); }
.trend .bar small { color: var(--muted); font-size: 11px; }
.trend .bar b { font-size: 12px; font-variant-numeric: tabular-nums; }

#burndown-chart { width: 100%; height: 240px; display: block; }

@media (max-width: 640px) {
  .topbar { flex-wrap: wrap; padding: 10px 16px; }
  .topbar .user span { display: none; }
  .week-nav strong { min-width: 0; font-size: 14px; }
  .toolbar .spacer { display: none; }
  .toolbar button, .toolbar .btn { padding: 6px 9px; font-size: 13px; }
  main { padding: 14px 16px 40px; }
}
