/* ------------------------------------------------------------------ *
 * Dashboard — identidade Grings Café Corporativo
 * ------------------------------------------------------------------ */
:root {
  --navy: #001C2C;
  --navy-deep: #00131e;
  --blue: #023353;
  --cream: #f6f1e8;
  --bg: #f2f4f6;
  --surface: #ffffff;
  --ink: #001c2c;
  --ink-soft: #4a5a68;
  --ink-faint: #8a97a2;
  --line: #e2e6ea;
  --danger: #c0392b;
  --font: "Montserrat", "Roboto", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1, h2 { margin: 0; letter-spacing: -.02em; }

/* ---------------- topbar ---------------- */
.dash-top {
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 16px;
  padding: 14px 26px;
  background: var(--navy); color: #fff;
}
.dash-title { display: flex; align-items: center; gap: 15px; }
.dash-title img { display: block; height: 44px; width: auto; }
.dash-title h1 { font-size: 19px; font-weight: 800; }
.dash-title p { margin: 1px 0 0; font-size: 12.5px; color: #8fa3b1; }

.dash-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.auto-refresh { display: flex; align-items: center; gap: 6px; font-size: 13px; color: #b6c6d0; cursor: pointer; }
.auto-refresh input { accent-color: #8fd0f5; }

.btn {
  font: inherit; font-size: 13.5px; font-weight: 700;
  padding: 9px 15px; border-radius: 9px; cursor: pointer;
  text-decoration: none; border: 1px solid transparent; white-space: nowrap;
  transition: background .15s ease, border-color .15s ease;
}
.btn-ghost { background: rgba(255, 255, 255, .07); border-color: rgba(255, 255, 255, .22); color: #fff; }
.btn-ghost:hover { background: rgba(255, 255, 255, .16); }
.btn-primary { background: var(--cream); color: var(--navy); }
.btn-primary:hover { background: #fff; }

/* ---------------- layout ---------------- */
.dash-main { max-width: 1180px; margin: 0 auto; padding: 26px 22px 60px; display: grid; gap: 20px; }

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 16px; }
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: 13px;
  padding: 17px 19px; display: flex; flex-direction: column; gap: 4px;
}
.card-label { font-size: 13px; color: var(--ink-soft); }
.card strong { font-size: 30px; font-weight: 800; letter-spacing: -.03em; color: var(--navy); }

.panels { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(0, 1fr); gap: 20px; }

.panel {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 13px; padding: 20px;
}
.panel > h2 { font-size: 15.5px; font-weight: 800; margin-bottom: 16px; }
.panel > h2 small { font-weight: 400; color: var(--ink-faint); font-size: 12.5px; }

/* ---------------- grafico de barras ---------------- */
.chart {
  display: flex; align-items: flex-end; gap: 8px;
  height: 168px; padding-top: 20px;
}
.bar-wrap { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; justify-content: flex-end; min-width: 0; }
.bar {
  width: 100%; max-width: 34px; border-radius: 6px 6px 3px 3px;
  background: linear-gradient(180deg, #0a4a75, var(--navy));
  position: relative; min-height: 3px;
  transition: filter .15s ease;
}
.bar:hover { filter: brightness(1.25); }
.bar-value {
  position: absolute; top: -19px; left: 50%; transform: translateX(-50%);
  font-size: 11.5px; font-weight: 700; color: var(--ink-soft);
}
.bar-label { font-size: 10.5px; color: var(--ink-faint); white-space: nowrap; }
.chart-empty { color: var(--ink-faint); font-size: 14px; align-self: center; margin: auto; }

/* ---------------- top empresas ---------------- */
.top-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.top-list li {
  display: flex; align-items: center; gap: 10px;
  font-size: 14px; padding-bottom: 10px; border-bottom: 1px dashed var(--line);
}
.top-list li:last-child { border-bottom: 0; padding-bottom: 0; }
.top-list .rank {
  flex: 0 0 22px; height: 22px; border-radius: 50%; display: grid; place-items: center;
  background: var(--navy); color: #fff; font-size: 11.5px; font-weight: 700;
}
.top-list .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.top-list .qtd { font-weight: 700; color: var(--ink-soft); font-size: 13px; }

/* ---------------- tabela ---------------- */
.table-panel { padding-bottom: 12px; }
.table-head { display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; margin-bottom: 14px; }
#search {
  font: inherit; font-size: 14px; padding: 9px 13px; width: 340px; max-width: 100%;
  border: 1.5px solid var(--line); border-radius: 9px; background: #fbfcfd;
}
#search:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px rgba(2, 51, 83, .12); }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
thead th {
  text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .04em;
  color: var(--ink-faint); padding: 0 12px 10px; border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
thead th[data-sort] { cursor: pointer; user-select: none; }
thead th[data-sort]:hover { color: var(--blue); }
thead th.sorted::after { content: " ▾"; color: var(--blue); }
thead th.sorted.asc::after { content: " ▴"; }
.col-id { width: 92px; }
.col-actions { width: 44px; }

tbody td { padding: 12px; border-bottom: 1px solid #f0f2f4; vertical-align: middle; }
tbody tr:hover { background: #fafbfc; }
tbody tr:last-child td { border-bottom: 0; }
.cell-code {
  font-weight: 800; color: var(--blue); font-variant-numeric: tabular-nums;
  letter-spacing: .02em;
}
.cell-name { font-weight: 600; }
.cell-phone a { color: var(--blue); text-decoration: none; font-variant-numeric: tabular-nums; white-space: nowrap; }
.cell-phone a:hover { text-decoration: underline; }
.cell-date { color: var(--ink-soft); white-space: nowrap; font-size: 13px; }
.del {
  border: 0; background: transparent; cursor: pointer; color: var(--ink-faint);
  font-size: 16px; line-height: 1; padding: 4px 7px; border-radius: 7px;
}
.del:hover { background: #fbeae8; color: var(--danger); }

.table-foot { margin: 12px 0 0; font-size: 12.5px; color: var(--ink-faint); }
.muted { color: var(--ink-faint); }
.center { text-align: center; padding: 28px 12px; }

@media (max-width: 900px) {
  .panels { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
  .dash-top { padding: 14px 18px; }
  .dash-title img { height: 36px; }
  .dash-actions { width: 100%; }
  #search { width: 100%; }
  .card strong { font-size: 25px; }
}
