@import url("https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap");

:root {
  --page: #f7f7f8;
  --card: #ffffff;
  --ink: #17181c;
  --ink-soft: #4b4d56;
  --muted: #80828d;
  --line: #e7e7ea;
  --line-strong: #d4d5db;
  --navy: #0d1b2a;
  --accent: #b9915b;
  --accent-deep: #8c6a3a;
  --accent-soft: #f5eee3;
  --ok: #1b7a3d;
  --ok-soft: #e7f6ec;
  --amber: #b5650a;
  --amber-soft: #fdf1e2;
  --rose: #b0271f;
  --rose-soft: #fdeceb;
  --info: #2158b0;
  --info-soft: #eaf1fb;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow-sm: 0 1px 2px rgba(20, 20, 24, 0.04), 0 1px 1px rgba(20, 20, 24, 0.03);
  --shadow-md: 0 6px 20px rgba(20, 20, 24, 0.06), 0 2px 6px rgba(20, 20, 24, 0.04);
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { letter-spacing: -0.01em; }
button { font-family: inherit; }
::selection { background: var(--accent-soft); }

/* ---------- Login screen ---------- */
.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(ellipse 60% 50% at 15% 0%, rgba(185, 145, 91, 0.08), transparent 60%),
    radial-gradient(ellipse 50% 40% at 100% 100%, rgba(13, 27, 42, 0.05), transparent 60%),
    var(--page);
}
.login-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 44px 36px;
  max-width: 400px;
  width: 100%;
  text-align: center;
  box-shadow: var(--shadow-md);
}
.login-mark {
  width: 44px; height: 44px; border-radius: 12px;
  background: var(--navy);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 20px;
}
.login-card h1 { font-size: 22px; margin: 0 0 6px; color: var(--navy); font-weight: 800; }
.subtitle { color: var(--muted); font-size: 14px; margin: 0 0 28px; line-height: 1.5; }
.btn-google {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  background: white; border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  padding: 13px; text-decoration: none; color: var(--ink); font-weight: 600; font-size: 15px;
  transition: border-color 120ms ease, box-shadow 120ms ease;
}
.btn-google:hover { border-color: var(--ink-soft); box-shadow: var(--shadow-sm); }
.error {
  color: var(--rose); background: var(--rose-soft); border: 1px solid #f4c9c6;
  border-radius: var(--radius-sm); padding: 10px 14px; font-size: 13px; margin-top: 18px; text-align: left;
}
.footer { color: var(--muted); font-size: 12px; margin-top: 22px; }

/* ---------- Icons ---------- */
.icon { display: inline-flex; align-items: center; justify-content: center; width: 1em; height: 1em; flex-shrink: 0; }
.icon svg { width: 100%; height: 100%; }
.icon.spin svg { animation: spin 0.8s linear infinite; }

/* ---------- App shell ---------- */
.shell { min-height: 100vh; display: flex; }

.sidebar {
  width: 248px; flex-shrink: 0;
  background: var(--navy);
  color: #e8eaf0;
  display: none;
  flex-direction: column;
  padding: 22px 14px;
}
.sidebar .brand {
  display: flex; align-items: center; gap: 10px;
  font-weight: 700; font-size: 14.5px; color: #fff;
  padding: 6px 8px 26px;
  letter-spacing: -0.01em;
}
.sidebar .brand .icon { width: 20px; height: 20px; color: var(--accent); }
.sidebar nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.sidebar nav button {
  display: flex; align-items: center; gap: 11px;
  background: none; border: none; color: #9fa2b3;
  text-align: left; padding: 10px 12px; border-radius: 9px;
  font-size: 13.5px; font-weight: 500; cursor: pointer;
  transition: background 120ms ease, color 120ms ease;
}
.sidebar nav button .icon { width: 17px; height: 17px; }
.sidebar nav button:hover { background: rgba(255,255,255,0.06); color: #fff; }
.sidebar nav button.active { background: rgba(185,145,91,0.16); color: #fff; font-weight: 600; }
.sidebar .user-box {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 8px; border-top: 1px solid rgba(255,255,255,0.1); margin-top: 10px;
}
.sidebar .user-box .avatar {
  width: 30px; height: 30px; border-radius: 999px; background: var(--accent);
  color: var(--navy); display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 13px; flex-shrink: 0;
}
.sidebar .user-box .who { flex: 1; min-width: 0; }
.sidebar .user-box .name { font-size: 12.5px; font-weight: 600; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar .user-box .role { font-size: 11px; color: #9fa2b3; }
.sidebar .user-box .logout { background: none; border: none; color: #9fa2b3; cursor: pointer; padding: 4px; width: 16px; height: 16px; }
.sidebar .user-box .logout:hover { color: #fff; }

.main-col { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 20px; background: var(--card); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 5;
}
.topbar .brand.mobile-brand { display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: 14.5px; color: var(--navy); }
.topbar .brand.mobile-brand .icon { width: 18px; height: 18px; color: var(--accent-deep); }
.topbar .page-title { display: none; font-weight: 700; font-size: 16px; color: var(--navy); }
.topbar .logout-mobile { background: none; border: none; color: var(--muted); cursor: pointer; width: 20px; height: 20px; padding: 0; }

.app-body { flex: 1; padding: 18px 16px 100px; max-width: 900px; width: 100%; margin: 0 auto; }

.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0;
  background: var(--card); border-top: 1px solid var(--line);
  display: flex; z-index: 10;
  padding-bottom: env(safe-area-inset-bottom);
}
.tabbar button {
  flex: 1; background: none; border: none; padding: 10px 0 8px;
  font-size: 10.5px; color: var(--muted); cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 4px; font-weight: 600;
}
.tabbar button .icon { width: 19px; height: 19px; }
.tabbar button.active { color: var(--navy); }
.tabbar button.active .icon { color: var(--accent-deep); }

@media (min-width: 900px) {
  .sidebar { display: flex; }
  .tabbar { display: none; }
  .topbar .brand.mobile-brand { display: none; }
  .topbar .page-title { display: block; }
  .app-body { padding: 36px 44px 52px; max-width: 1120px; }
}

/* ---------- Cards & primitives ---------- */
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 22px; margin-bottom: 16px; box-shadow: var(--shadow-sm);
}
.card h2 {
  margin: 0 0 4px; font-size: 15px; color: var(--navy); font-weight: 700;
  display: flex; align-items: center; gap: 8px;
}
.card h2 .icon { width: 16px; height: 16px; color: var(--accent-deep); }
.card .card-sub { color: var(--muted); font-size: 12.5px; margin: 0 0 16px; }
.card.card-alert { border-color: #f4c9c6; background: linear-gradient(180deg, var(--rose-soft), var(--card) 40%); }
.card.card-alert h2 .icon { color: var(--rose); }
.card-grid { display: grid; grid-template-columns: 1fr; gap: 16px; }
@media (min-width: 640px) { .card-grid.cols-2 { grid-template-columns: 1fr 1fr; } }
@media (min-width: 900px) { .card-grid.cols-3 { grid-template-columns: 1fr 1fr 1fr; } }

.section-title {
  font-size: 13px; font-weight: 700; color: var(--ink-soft); text-transform: uppercase;
  letter-spacing: 0.04em; margin: 24px 0 12px;
}
.section-title:first-child { margin-top: 0; }

.big-input {
  width: 100%; font-size: 32px; padding: 16px; border-radius: var(--radius-sm);
  border: 1.5px solid var(--line-strong); text-align: center; font-weight: 800;
  color: var(--navy); font-variant-numeric: tabular-nums;
  transition: border-color 120ms ease, box-shadow 120ms ease;
}
.big-input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

.btn { font-weight: 600; border-radius: var(--radius-sm); cursor: pointer; border: 1px solid transparent; font-size: 13.5px; padding: 10px 16px; transition: all 120ms ease; }
.btn-primary { background: var(--navy); color: #fff; }
.btn-primary:hover:not(:disabled) { background: #142943; }
.btn-primary:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-block { width: 100%; padding: 14px; font-size: 15px; margin-top: 16px; }
.btn-outline { background: var(--card); border: 1px solid var(--line-strong); color: var(--ink); }
.btn-outline:hover:not(:disabled) { border-color: var(--ink-soft); background: var(--page); }
.btn-outline:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-sm { padding: 7px 12px; font-size: 12.5px; }
.btn-ghost { background: none; border: none; color: var(--muted); }

.status-pill { display: inline-flex; align-items: center; gap: 5px; padding: 4px 11px; border-radius: 999px; font-size: 12px; font-weight: 700; }
.status-pill .icon { width: 12px; height: 12px; }
.status-pending { background: var(--amber-soft); color: var(--amber); }
.status-submitted { background: var(--ok-soft); color: var(--ok); }
.status-late { background: var(--rose-soft); color: var(--rose); }
.status-neutral { background: var(--page); color: var(--muted); border: 1px solid var(--line); }
.row-muted { opacity: 0.55; }
.text-amber { color: var(--amber, #b45309); font-weight: 600; }

.badge { display: inline-flex; align-items: center; padding: 3px 9px; border-radius: 999px; font-size: 11px; font-weight: 700; background: var(--page); color: var(--ink-soft); border: 1px solid var(--line); }
.badge-accent { background: var(--accent-soft); color: var(--accent-deep); border-color: #e5d3b8; }

.empty-state { text-align: center; padding: 48px 20px; color: var(--muted); display: flex; flex-direction: column; align-items: center; gap: 10px; }
.empty-state .icon { width: 28px; height: 28px; color: var(--line-strong); }
.empty-state .msg { font-size: 13.5px; }

@keyframes spin { to { transform: rotate(360deg); } }
.btn .icon { width: 13px; height: 13px; }
.btn-primary .icon { color: #fff; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; margin: -4px; padding: 4px; }
table.history { width: 100%; border-collapse: collapse; font-size: 13px; min-width: 460px; }
table.history th, table.history td { padding: 10px 8px; text-align: right; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.history th { color: var(--muted); font-weight: 600; font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.03em; }
table.history th:first-child, table.history td:first-child { text-align: left; }
table.history tbody tr:hover { background: var(--page); }
.delta-pos { color: var(--ok); font-weight: 700; }
.delta-neg { color: var(--rose); font-weight: 700; }
.delta-zero { color: var(--muted); }

/* ---------- KPI grid (analytics) ---------- */
.kpi-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin-bottom: 16px; }
@media (min-width: 640px) { .kpi-grid { grid-template-columns: repeat(4, 1fr); } }
.kpi-card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px 18px; box-shadow: var(--shadow-sm);
}
.kpi-top { display: flex; align-items: center; gap: 7px; margin-bottom: 10px; }
.kpi-ic { width: 15px; height: 15px; color: var(--muted); }
.kpi-label { font-size: 11.5px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.03em; }
.kpi-value { font-size: 24px; font-weight: 800; color: var(--navy); font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }
.kpi-sub { font-size: 11.5px; color: var(--muted); margin-top: 4px; }
.kpi-card.tone-ok .kpi-value { color: var(--ok); }
.kpi-card.tone-amber .kpi-value { color: var(--amber); }
.kpi-card.tone-rose .kpi-value { color: var(--rose); }

/* ---------- Team table ---------- */
table.team-table th, table.team-table td { text-align: left; }
table.team-table th:not(:first-child), table.team-table td:not(:first-child) { text-align: right; }
table.team-table .who { display: flex; align-items: center; gap: 10px; min-width: 0; }
table.team-table .avatar-sm { width: 28px; height: 28px; border-radius: 999px; background: var(--accent-soft); color: var(--accent-deep); display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 11px; flex-shrink: 0; }
table.team-table .name { font-weight: 600; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 180px; }
table.team-table .meta { font-size: 11px; color: var(--muted); }
.delta-pos, .delta-neg, .delta-zero { display: inline-flex; align-items: center; gap: 3px; font-weight: 700; justify-content: flex-end; }
.delta-pos .icon, .delta-neg .icon, .delta-zero .icon { width: 12px; height: 12px; }

/* ---------- Switch (toggle) ---------- */
.switch { position: relative; display: inline-flex; align-items: center; width: 36px; height: 21px; flex-shrink: 0; cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; z-index: 1; }
.switch-track { position: absolute; inset: 0; background: var(--line-strong); border-radius: 999px; transition: background 150ms ease; }
.switch-track::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 17px; height: 17px; border-radius: 999px;
  background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,0.2); transition: transform 150ms ease;
}
.switch input:checked + .switch-track { background: var(--ok); }
.switch input:checked + .switch-track::after { transform: translateX(15px); }
.switch input:disabled + .switch-track { opacity: 0.5; cursor: not-allowed; }

/* Role badges */
.role-badge { display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 999px; font-size: 11px; font-weight: 700; }
.role-badge .icon { width: 11px; height: 11px; }
.role-badge.role-admin { background: rgba(168, 85, 247, 0.14); color: #a855f7; }
.role-badge.role-leader { background: rgba(59, 130, 246, 0.14); color: #3b82f6; }
.role-badge.role-seller { background: var(--surface-2); color: var(--muted); }
.sidebar .user-box .role .role-badge { padding: 2px 7px; }

/* Card head with actions on the right (range toggle, etc.) */
.card-head-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 4px; }
.card-head-row h2 { margin-bottom: 2px; }
.card-head-row .card-sub { margin-bottom: 0; }

.range-toggle { display: inline-flex; background: var(--surface-2); border-radius: 10px; padding: 3px; gap: 2px; flex-shrink: 0; }
.range-toggle button { border: none; background: none; padding: 5px 12px; border-radius: 8px; font-size: 12.5px; font-weight: 600; color: var(--muted); cursor: pointer; }
.range-toggle button.active { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgba(0,0,0,0.08); }

/* Filters row (search + selects) */
.filters-row { display: flex; gap: 8px; flex-wrap: wrap; margin: 14px 0 16px; }
.filters-row .input-inline { flex: 1 1 180px; min-width: 140px; }
.filters-row select.input-inline { cursor: pointer; }

/* Pagination */
.pagination { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 14px; flex-wrap: wrap; }
.pagination-info { font-size: 12px; color: var(--muted); }
.pagination-btns { display: flex; gap: 6px; }
.pagination-btns .btn { padding: 6px 10px; }
.pagination-btns .btn .icon { width: 14px; height: 14px; }

/* ---------- Cron / Automações panel ---------- */
.cron-job { display: flex; gap: 14px; border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 16px; margin-bottom: 12px; transition: opacity 150ms ease; }
.cron-job.is-disabled { opacity: 0.62; }
.cron-job.is-disabled .cron-job-ic { background: var(--page); color: var(--muted); }
.cron-job-head-right { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.cron-disabled-note { display: flex; align-items: center; gap: 6px; font-size: 11.5px; color: var(--rose); margin-top: 8px; }
.cron-disabled-note .icon { width: 13px; height: 13px; }
.cron-job-ic {
  width: 36px; height: 36px; border-radius: 10px; background: var(--accent-soft); color: var(--accent-deep);
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.cron-job-ic .icon { width: 17px; height: 17px; }
.cron-job-main { flex: 1; min-width: 0; }
.cron-job-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.cron-job-title { font-weight: 700; font-size: 14px; color: var(--navy); }
.cron-job-desc { color: var(--muted); font-size: 12.5px; margin: 4px 0 0; max-width: 520px; }
.cron-schedule { font-size: 11.5px; color: var(--ink-soft); font-weight: 600; background: var(--page); border: 1px solid var(--line); border-radius: 999px; padding: 3px 10px; flex-shrink: 0; }
.cron-job-foot { display: flex; align-items: center; justify-content: space-between; margin-top: 12px; padding-top: 12px; border-top: 1px dashed var(--line); flex-wrap: wrap; gap: 10px; }
.cron-run-status { font-size: 12px; color: var(--muted); }
.cron-run-status b { color: var(--ink); }
.btn-outline .icon { color: var(--ink-soft); }

/* ---------- Test panel ---------- */
pre.test-result {
  background: var(--page); border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 12px; font-size: 11.5px; white-space: pre-wrap; word-break: break-all;
  margin-top: 12px; max-height: 240px; overflow: auto; font-family: "SF Mono", Menlo, monospace;
  color: var(--ink-soft);
}
.test-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.test-row .info { flex: 1; min-width: 180px; }
.test-row .info .t { font-weight: 600; font-size: 13.5px; color: var(--ink); }
.test-row .info .d { font-size: 12px; color: var(--muted); margin-top: 2px; }
.input-inline {
  border: 1px solid var(--line-strong); border-radius: var(--radius-sm); padding: 9px 12px;
  font-size: 13px; min-width: 200px; font-family: inherit;
}
.input-inline:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
