:root {
  --ink: #1d1d1b;
  --muted: #75716b;
  --line: #dedbd5;
  --surface: #f4f3f0;
  --paper: #fff;
  --dark: #191917;
  --gold: #b88a42;
  --blue: #49709b;
  --green: #377657;
  --red: #9d4141;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
body { min-height: 100vh; margin: 0; color: var(--ink); background: var(--surface); }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }

.app-header {
  min-height: 86px;
  padding: 18px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  color: white;
  background: var(--dark);
}
.brand { display: flex; align-items: center; gap: 13px; }
.header-chevron {
  width: 18px;
  height: 18px;
  display: grid;
  place-items: center;
  color: var(--gold);
  font-size: 18px;
  font-weight: 800;
  line-height: 1;
}
.brand div { display: grid; gap: 2px; }
.brand strong { font-size: 17px; }
.brand span { color: #aaa69f; font-size: 11px; }
.brand .header-chevron { color: var(--gold); font-size: 18px; }
.header-actions { display: flex; align-items: center; gap: 8px; }
.cloud-status { color: #aaa69f; font-size: 11px; font-weight: 700; }
.cloud-status.online { color: #91c9a6; }

.button {
  min-height: 38px;
  padding: 9px 14px;
  border: 1px solid transparent;
  border-radius: 8px;
  font-weight: 800;
  font-size: 12px;
}
.button.primary { color: white; background: var(--gold); }
.button.vehicle-button { border-color: #c9d7cc; color: #345c40; background: #edf5ef; }
.button.secondary { border-color: var(--line); color: var(--ink); background: white; }
.app-header .button.secondary { border-color: #ffffff38; color: white; background: transparent; }
.button:disabled { cursor: not-allowed; opacity: .5; }
.button.compact { min-height: 34px; padding: 7px 11px; }

.workspace { min-height: calc(100vh - 86px); display: grid; grid-template-columns: 310px minmax(0, 1fr); }
.archive { padding: 24px 18px; border-right: 1px solid var(--line); background: white; }
.archive-heading, .panel-heading, .dialog-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
h1, h2, h3, p { margin: 0; }
h1 { margin-top: 3px; font-size: 25px; letter-spacing: -.04em; }
.eyebrow { color: var(--muted); font-size: 9px; font-weight: 900; letter-spacing: .13em; text-transform: uppercase; }
.counter { min-width: 28px; padding: 5px 8px; border-radius: 99px; color: var(--blue); background: #e3ebf4; font-size: 11px; font-weight: 850; text-align: center; }
.archive > input {
  width: 100%;
  margin: 17px 0 10px;
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #faf9f7;
}
.filter-row { display: flex; gap: 5px; margin-bottom: 12px; }
.filter { padding: 6px 9px; border: 0; border-radius: 99px; color: var(--muted); background: transparent; font-size: 10px; font-weight: 800; }
.filter.active { color: #31577f; background: #e3ebf4; }
.site-list { display: grid; gap: 7px; }
.site-row {
  width: 100%;
  padding: 12px;
  display: grid;
  gap: 5px;
  border: 1px solid transparent;
  border-radius: 10px;
  color: var(--ink);
  background: transparent;
  text-align: left;
}
.site-row:hover, .site-row.active { border-color: #cbd9e7; background: #f3f7fb; }
.site-row-top { display: flex; justify-content: space-between; gap: 8px; }
.site-row strong { overflow: hidden; font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.site-row span, .site-row small { color: var(--muted); font-size: 10px; }
.site-row .row-cost { color: var(--ink); font-weight: 800; }
.empty { padding: 28px 8px; color: var(--muted); font-size: 12px; line-height: 1.55; text-align: center; }

.content { min-width: 0; padding: 28px; }
.welcome-state {
  max-width: 520px;
  min-height: 470px;
  margin: 0 auto;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 12px;
  text-align: center;
}
.welcome-icon { width: 68px; height: 68px; display: grid; place-items: center; border-radius: 20px; color: var(--blue); background: #e3ebf4; font-size: 34px; }
.welcome-state h2 { font-size: 28px; letter-spacing: -.04em; }
.welcome-state p { color: var(--muted); font-size: 13px; }

#site-detail { max-width: 1120px; margin: 0 auto; }
.site-hero {
  min-height: 150px;
  padding: 26px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  border-radius: 14px;
  color: white;
  background: linear-gradient(125deg, #1c1f22, #263647);
}
.hero-meta { display: flex; align-items: center; gap: 9px; color: #c0c8d0; font-size: 11px; }
.status { padding: 5px 8px; border-radius: 99px; color: #31577f; background: #e3ebf4; font-size: 9px; font-weight: 900; text-transform: uppercase; }
.status.concluso { color: #4d6655; background: #dfe9e2; }
.status.sospeso { color: #8b6327; background: #f2e5cd; }
.site-hero h2 { margin: 9px 0 6px; font-size: clamp(27px, 4vw, 42px); letter-spacing: -.05em; }
.site-hero p { color: #b9c0c7; font-size: 12px; }
.hero-actions { display: flex; gap: 8px; }
.panel-actions { display: flex; gap: 7px; }

.metrics { margin: 15px 0; display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.metrics article, .panel { padding: 18px; border: 1px solid var(--line); border-radius: 12px; background: white; box-shadow: 0 5px 18px rgb(30 28 24 / 4%); }
.metrics article { display: grid; gap: 7px; }
.metrics span { color: var(--muted); font-size: 10px; font-weight: 750; }
.metrics strong { font-size: 20px; letter-spacing: -.035em; }
.positive { color: var(--green); }
.negative { color: var(--red); }
.panel-heading h3 { margin-top: 3px; font-size: 17px; }
.progress-panel { margin-bottom: 15px; }
.progress-track { height: 9px; margin: 17px 0 12px; overflow: hidden; border-radius: 99px; background: #ebe9e5; }
.progress-track span { display: block; width: 0; height: 100%; border-radius: inherit; background: var(--gold); transition: width .25s ease; }
.progress-data { display: flex; justify-content: space-between; gap: 15px; color: var(--muted); font-size: 11px; }
.progress-data strong { margin-left: 4px; color: var(--ink); }
.detail-grid { margin-bottom: 15px; display: grid; grid-template-columns: 1.2fr .8fr; gap: 15px; }
.category-list { margin-top: 14px; display: grid; gap: 11px; }
.category-row { display: grid; grid-template-columns: minmax(100px, .9fr) 1.8fr auto; align-items: center; gap: 10px; }
.category-row span { font-size: 11px; font-weight: 750; }
.category-bar { height: 7px; overflow: hidden; border-radius: 99px; background: #efede9; }
.category-bar i { display: block; height: 100%; border-radius: inherit; background: var(--blue); }
.category-row strong { font-size: 11px; }
.site-info dl { margin: 13px 0 0; display: grid; grid-template-columns: auto 1fr; gap: 9px 14px; font-size: 11px; }
.site-info dt { color: var(--muted); }
.site-info dd { margin: 0; font-weight: 750; text-align: right; }
.expenses-panel { margin-bottom: 12px; }
.expense-list { margin-top: 10px; }
.expense-row {
  padding: 12px 0;
  display: grid;
  grid-template-columns: 74px 1fr auto auto;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid #ebe9e5;
}
.expense-row:last-child { border: 0; }
.expense-date { color: var(--muted); font-size: 10px; }
.expense-copy { min-width: 0; display: grid; gap: 3px; }
.expense-copy strong { font-size: 12px; }
.expense-copy span { overflow: hidden; color: var(--muted); font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.expense-amount { font-size: 12px; }
.row-actions { display: flex; gap: 3px; }
.icon-button { width: 31px; height: 31px; border: 0; border-radius: 7px; color: var(--muted); background: #f2f0ec; }
.delete-link { margin: 5px 0 30px; padding: 8px 0; border: 0; color: var(--red); background: transparent; font-size: 10px; font-weight: 800; }

dialog { width: min(720px, calc(100% - 28px)); max-height: calc(100vh - 30px); padding: 0; overflow: auto; border: 0; border-radius: 14px; box-shadow: 0 25px 80px rgb(0 0 0 / 30%); }
dialog::backdrop { background: rgb(20 19 17 / 62%); }
dialog form { padding: 24px; display: grid; gap: 18px; }
dialog h3 { margin-top: 4px; font-size: 23px; letter-spacing: -.035em; }
#auth-dialog { width: min(410px, calc(100% - 28px)); }
.close-button { width: 34px; height: 34px; border: 0; border-radius: 8px; color: var(--muted); background: #f2f0ec; font-size: 22px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 13px; }
label { display: grid; gap: 6px; color: #4e4b47; font-size: 10px; font-weight: 850; }
label.wide, .calculated-total { grid-column: 1 / -1; }
input, select, textarea { width: 100%; padding: 10px 11px; border: 1px solid var(--line); border-radius: 8px; color: var(--ink); background: white; }
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid #adc2d8; border-color: var(--blue); }
.calculated-total { padding: 13px; display: flex; justify-content: space-between; border-radius: 9px; background: #f3f7fb; }
.calculated-total span { color: var(--muted); font-size: 11px; }
.calculated-total strong { color: var(--blue); font-size: 16px; }
.vehicle-cost-note { margin: -2px 0 0; color: #52705a; font-size: 10px; line-height: 1.4; }
.dialog-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.feedback { min-height: 15px; color: var(--red); font-size: 11px; }
.toast { position: fixed; right: 20px; bottom: 20px; z-index: 50; max-width: 330px; padding: 12px 14px; border-radius: 9px; color: white; background: var(--dark); font-size: 11px; opacity: 0; transform: translateY(8px); pointer-events: none; transition: .2s; }
.toast.show { opacity: 1; transform: translateY(0); }

@media (max-width: 850px) {
  .workspace { grid-template-columns: 260px minmax(0, 1fr); }
  .metrics { grid-template-columns: 1fr 1fr; }
  .detail-grid { grid-template-columns: 1fr; }
}

@media (max-width: 650px) {
  .app-header { min-height: 72px; padding: 12px 14px; }
  .brand span, .cloud-status, #logout-button { display: none; }
  .brand .header-chevron { display: grid; }
  .header-actions .button { min-height: 34px; padding: 7px 9px; font-size: 10px; }
  .workspace { display: block; }
  .archive { padding: 16px 14px 8px; border: 0; }
  .archive-heading h1 { font-size: 20px; }
  .site-list { max-height: 205px; overflow: auto; }
  .content { padding: 12px 14px 30px; }
  .welcome-state { min-height: 330px; }
  .site-hero { padding: 20px; display: grid; }
  .hero-actions { display: grid; grid-template-columns: 1fr 1fr; }
  .hero-actions .primary { grid-column: 1 / -1; }
  .panel-actions { display: grid; grid-template-columns: 1fr 1fr; }
  .metrics { gap: 7px; }
  .metrics article { padding: 13px; }
  .metrics strong { font-size: 16px; }
  .progress-data { display: grid; gap: 7px; }
  .expense-row { grid-template-columns: 58px minmax(0, 1fr) auto; gap: 8px; }
  .row-actions { grid-column: 2 / -1; justify-content: flex-end; }
  .form-grid { grid-template-columns: 1fr; }
  label.wide, .calculated-total { grid-column: auto; }
  dialog form { padding: 19px; }
}
