/* ==========================================================================
   TimeTracker - folha de estilo unica
   Paleta e densidade inspiradas no Clockify.
   ========================================================================== */

:root {
  --sidebar: #16232e;
  --sidebar-hover: #1f313f;
  --accent: #03a9f4;
  --accent-dark: #0288d1;
  --bg: #f5f7fa;
  --surface: #ffffff;
  --border: #e4e9ee;
  --ink: #1b2733;
  --muted: #7c8a99;
  --green: #4caf50;
  --red: #e5484d;
  --amber: #f5a623;
  --radius: 8px;
  --shadow-sm: 0 1px 2px rgba(27, 39, 51, .06);
  --shadow-md: 0 6px 20px rgba(27, 39, 51, .12);
  --sidebar-width: 224px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent-dark); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -.01em; }
h1 { font-size: 22px; }
h2 { font-size: 16px; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- Layout ---------- */
.layout { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-width);
  flex: 0 0 var(--sidebar-width);
  background: var(--sidebar);
  color: #cbd6e0;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}
.sidebar__brand {
  display: flex; align-items: center; gap: 10px;
  padding: 18px 18px 14px;
  color: #fff; font-weight: 700; font-size: 16px;
}
.sidebar__brand span { width: 26px; height: 26px; border-radius: 7px; background: var(--accent);
  display: grid; place-items: center; font-size: 14px; }

.workspace-switch { padding: 0 12px 14px; }
.workspace-switch select {
  width: 100%; background: var(--sidebar-hover); color: #fff;
  border: 1px solid #2b3f4f; border-radius: var(--radius);
  padding: 9px 10px; font-size: 13px;
}
.workspace-switch label { display: block; font-size: 11px; color: #8fa3b3; margin-bottom: 5px; }

.nav { list-style: none; margin: 0; padding: 6px 8px; flex: 1; }
.nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border-radius: var(--radius);
  color: #cbd6e0; font-size: 14px; text-decoration: none;
}
.nav a:hover { background: var(--sidebar-hover); color: #fff; }
.nav a.is-active { background: var(--accent); color: #fff; font-weight: 600; }
.nav svg { width: 17px; height: 17px; flex: 0 0 17px; }

.sidebar__footer { padding: 12px; border-top: 1px solid #22333f; font-size: 13px; }
.sidebar__footer .user { color: #fff; font-weight: 600; }
.sidebar__footer .email { color: #8fa3b3; font-size: 12px; word-break: break-all; }
.sidebar__footer button {
  margin-top: 8px; width: 100%; background: transparent; color: #cbd6e0;
  border: 1px solid #2b3f4f; border-radius: var(--radius); padding: 7px; cursor: pointer;
}
.sidebar__footer button:hover { background: var(--sidebar-hover); color: #fff; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  background: var(--surface); border-bottom: 1px solid var(--border);
  padding: 14px 26px; display: flex; align-items: center; justify-content: space-between;
  gap: 16px;
}
.topbar__meta { color: var(--muted); font-size: 13px; }
.content { padding: 22px 26px 60px; }
.content--narrow { max-width: 860px; }

/* ---------- Componentes ---------- */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-sm);
}
.card__body { padding: 18px; }
.card__header {
  padding: 14px 18px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  border: 1px solid transparent; border-radius: var(--radius);
  padding: 9px 16px; font-size: 14px; font-weight: 600; cursor: pointer;
  background: var(--surface); color: var(--ink); font-family: inherit;
}
.btn:hover { text-decoration: none; }
.btn--primary { background: var(--accent); color: #fff; }
.btn--primary:hover { background: var(--accent-dark); }
.btn--danger { background: var(--red); color: #fff; }
.btn--ghost { border-color: var(--border); color: var(--ink); }
.btn--ghost:hover { background: #eef2f6; }
.btn--sm { padding: 6px 11px; font-size: 13px; }
.btn--block { width: 100%; }

.icon-btn {
  border: none; background: transparent; color: var(--muted);
  padding: 6px; border-radius: 6px; cursor: pointer; line-height: 0;
}
.icon-btn:hover { background: #eef2f6; color: var(--ink); }
.icon-btn--danger:hover { color: var(--red); }

.field { margin-bottom: 14px; }
.field > label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 5px; }
.field .hint { color: var(--muted); font-size: 12px; margin-top: 4px; }
input[type="text"], input[type="email"], input[type="password"], input[type="date"],
input[type="time"], input[type="number"], select, textarea {
  width: 100%; padding: 9px 11px; font-size: 14px; font-family: inherit; color: var(--ink);
  border: 1px solid var(--border); border-radius: var(--radius); background: #fff;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); outline: none;
  box-shadow: 0 0 0 3px rgba(3, 169, 244, .15); }
textarea { min-height: 88px; resize: vertical; }
.error { color: var(--red); font-size: 12px; margin-top: 4px; }

.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0 16px; }
.form-actions { display: flex; gap: 10px; align-items: center; margin-top: 6px; }

/* Switch cobravel */
.switch { display: inline-flex; align-items: center; gap: 9px; cursor: pointer; user-select: none; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch__track {
  width: 38px; height: 21px; border-radius: 999px; background: #cfd8e0;
  position: relative; transition: background .15s ease; flex: 0 0 38px;
}
.switch__track::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 17px; height: 17px;
  background: #fff; border-radius: 50%; box-shadow: var(--shadow-sm); transition: transform .15s ease;
}
.switch input:checked + .switch__track { background: var(--green); }
.switch input:checked + .switch__track::after { transform: translateX(17px); }
.switch input:focus-visible + .switch__track { outline: 2px solid var(--accent); outline-offset: 2px; }
.switch__label { font-size: 13px; color: var(--muted); }

/* ---------- Cronometro ---------- */
.timer {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-sm); display: flex; align-items: center; gap: 12px;
  padding: 10px 14px; margin-bottom: 18px;
}
.timer.is-running { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(3, 169, 244, .12); }
.timer__description { flex: 1; min-width: 0; }
.timer__description input { border: none; padding: 8px 4px; font-size: 15px; box-shadow: none !important; }
.timer__project { width: 220px; flex: 0 0 220px; }
.timer__project select { border: none; color: var(--accent-dark); font-weight: 600; }
.timer__clock {
  font-variant-numeric: tabular-nums; font-size: 20px; font-weight: 600;
  min-width: 96px; text-align: right;
}
.timer__divider { width: 1px; height: 30px; background: var(--border); }
.btn--timer { min-width: 92px; border-radius: 999px; }
.timer--manual .btn--timer { min-width: 104px; }

/* Seletor de modo: cronômetro x lançamento manual */
.toolbar--modes { gap: 4px; margin-bottom: 10px; }
.mode-btn {
  display: inline-flex; align-items: center; gap: 6px;
  background: none; border: 1px solid transparent; border-radius: 999px;
  color: var(--muted); font: inherit; font-size: 13px; font-weight: 600;
  padding: 5px 12px; cursor: pointer;
}
.mode-btn:hover { background: #eef2f6; color: var(--ink); }
.mode-btn.is-active {
  background: rgba(3, 169, 244, .1); border-color: rgba(3, 169, 244, .35);
  color: var(--accent-dark);
}

/* Barra de lancamento manual (mesma pegada visual do cronômetro) */
.timer--manual { flex-wrap: wrap; gap: 8px; }
.timer--manual .timer__description { flex: 1 1 140px; min-width: 120px; }
.timer--manual .timer__project { flex: 0 1 176px; width: 176px; }
.timer--manual input[type="text"], .timer--manual input[type="time"],
.timer--manual input[type="date"], .timer--manual input[type="number"] {
  border: none; box-shadow: none !important; padding: 7px 4px; background: transparent;
}
.timer--manual input:focus { box-shadow: 0 0 0 3px rgba(3, 169, 244, .15) !important;
  border-radius: 6px; }
.timer--manual select { border: none; }
.timer__range, .timer__date, .timer__rate {
  display: flex; align-items: center; gap: 2px; flex: 0 0 auto;
}
.timer__range input { width: 80px; font-variant-numeric: tabular-nums; text-align: center; }
.timer__date input { width: 122px; }
.timer__rate input { width: 78px; text-align: center; }
.timer__dash { color: var(--muted); }
.timer--manual .timer__clock { min-width: 78px; font-size: 18px; }
.timer--manual .timer__clock--zero { color: var(--muted); }

/* ---------- Lista de lancamentos ---------- */
.day-group { margin-bottom: 18px; }
.day-group__header {
  display: flex; align-items: baseline; justify-content: space-between;
  padding: 0 4px 7px;
}
.day-group__title { font-weight: 600; font-size: 14px; }
.day-group__total { color: var(--muted); font-size: 13px; }
.day-group__total strong { color: var(--ink); font-variant-numeric: tabular-nums; }

.entry {
  display: flex; align-items: center; gap: 14px;
  background: var(--surface); border: 1px solid var(--border); border-top: none;
  padding: 11px 14px;
}
.day-group .entry:first-of-type { border-top: 1px solid var(--border);
  border-radius: var(--radius) var(--radius) 0 0; }
.day-group .entry:last-of-type { border-radius: 0 0 var(--radius) var(--radius); }
.entry:hover { background: #fbfcfd; }
.entry__text { flex: 1; min-width: 0; }
.entry__desc { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.entry__desc--empty { color: var(--muted); font-style: italic; }
.entry__project { font-size: 13px; font-weight: 600; }
.entry__times { color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.entry__duration { font-variant-numeric: tabular-nums; font-weight: 600; min-width: 78px;
  text-align: right; }
.entry__amount { min-width: 92px; text-align: right; font-variant-numeric: tabular-nums;
  color: var(--muted); }
.entry__actions { display: flex; gap: 2px; }

.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; flex: 0 0 9px; }

.badge {
  display: inline-block; padding: 2px 8px; border-radius: 999px;
  font-size: 11.5px; font-weight: 600; background: #eef2f6; color: var(--muted);
}
.badge--billable { background: rgba(76, 175, 80, .12); color: #2e7d32; }
.badge--pf { background: rgba(126, 87, 194, .12); color: #5e35b1; }
.badge--pj { background: rgba(3, 169, 244, .12); color: var(--accent-dark); }
.badge--archived { background: #eceff1; color: #607d8b; }

/* ---------- Tabelas ---------- */
.table { width: 100%; border-collapse: collapse; }
.table th {
  text-align: left; font-size: 12px; color: var(--muted); font-weight: 600;
  padding: 10px 14px; border-bottom: 1px solid var(--border);
}
.table td { padding: 12px 14px; border-bottom: 1px solid var(--border); }
.table tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: #fbfcfd; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table tfoot td { font-weight: 700; background: #f7f9fb; border-top: 2px solid var(--ink); }

/* ---------- Relatorio ---------- */
.filters { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; }
.filters .field { margin-bottom: 0; min-width: 170px; }
.summary { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px;
  margin: 18px 0; }
.summary__item { background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px 16px; }
.summary__label { color: var(--muted); font-size: 12.5px; }
.summary__value { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums;
  margin-top: 2px; }
.summary__value--accent { color: var(--accent-dark); }

/* ---------- Utilidades ---------- */
.flash-stack { position: fixed; top: 16px; right: 16px; z-index: 50; width: 320px; }
.flash {
  background: var(--surface); border-left: 4px solid var(--accent);
  border-radius: var(--radius); box-shadow: var(--shadow-md);
  padding: 11px 14px; margin-bottom: 9px; font-size: 13.5px;
}
.flash--success { border-left-color: var(--green); }
.flash--danger { border-left-color: var(--red); }
.flash--warning { border-left-color: var(--amber); }

.empty { text-align: center; padding: 46px 20px; color: var(--muted); }
.empty h2 { color: var(--ink); margin-bottom: 6px; }
.page-header { display: flex; align-items: center; justify-content: space-between;
  gap: 16px; margin-bottom: 16px; }
.toolbar { display: flex; gap: 10px; align-items: center; margin-bottom: 14px; }
.muted { color: var(--muted); }
.hidden { display: none !important; }
.text-right { text-align: right; }

.auth-shell { min-height: 100vh; display: grid; place-items: center; padding: 24px;
  background: linear-gradient(160deg, #16232e 0%, #22384a 100%); }
.auth-card { width: 100%; max-width: 380px; background: var(--surface);
  border-radius: 12px; padding: 30px; box-shadow: var(--shadow-md); }
.auth-card h1 { margin-bottom: 4px; }
.auth-card p.sub { color: var(--muted); margin: 0 0 22px; }

@media (max-width: 900px) {
  .layout { flex-direction: column; }
  .sidebar { width: 100%; flex: none; height: auto; position: static; }
  .nav { display: flex; flex-wrap: wrap; }
  .timer { flex-wrap: wrap; }
  .timer__project { flex: 1 1 100%; width: auto; }
  .timer--manual { flex-wrap: wrap; }
  .timer--manual .timer__divider { display: none; }
  .timer--manual .btn--timer { flex: 1 1 100%; }
  .summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .entry__amount { display: none; }
  .content { padding: 16px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* ---------- Painel ---------- */
.period-bar { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end;
  justify-content: space-between; margin-bottom: 18px; }
.presets { display: flex; flex-wrap: wrap; gap: 6px; }
.preset {
  border: 1px solid var(--border); background: var(--surface); color: var(--ink);
  border-radius: 999px; padding: 6px 13px; font-size: 13px; text-decoration: none;
}
.preset:hover { background: #eef2f6; text-decoration: none; }
.preset.is-active { background: var(--accent); border-color: var(--accent); color: #fff;
  font-weight: 600; }
.period-form { display: flex; gap: 8px; align-items: flex-end; }
.period-form .field { margin-bottom: 0; }
.period-form input { min-width: 148px; }

.metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px;
  margin-bottom: 18px; }
.metric { background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 15px 17px; }
.metric--accent { border-left: 3px solid var(--accent); }
.metric--money { border-left: 3px solid var(--green); }
.metric__label { color: var(--muted); font-size: 12.5px; }
.metric__value { font-size: 26px; font-weight: 700; font-variant-numeric: tabular-nums;
  margin-top: 2px; letter-spacing: -.02em; }
.metric__value--money { color: #2e7d32; }
.metric__hint { color: var(--muted); font-size: 12px; margin-top: 3px; }

.chart-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.chart-grid--full { grid-template-columns: 1fr; }

/* Barras verticais: horas por semana */
.bars { display: flex; align-items: flex-end; gap: 10px; height: 190px;
  padding: 10px 4px 0; }
.bars__col { flex: 1; display: flex; flex-direction: column; justify-content: flex-end;
  align-items: center; height: 100%; min-width: 0; }
.bars__value { font-size: 11.5px; color: var(--muted); font-variant-numeric: tabular-nums;
  margin-bottom: 4px; white-space: nowrap; }
.bars__bar { width: 100%; max-width: 46px; background: var(--accent); border-radius: 4px 4px 0 0;
  min-height: 2px; }
.bars__bar--empty { background: #eceff1; }
.bars__label { font-size: 11.5px; color: var(--muted); margin-top: 7px;
  font-variant-numeric: tabular-nums; }
.bars__axis { border-top: 1px solid var(--border); margin: 0 4px; }

/* Rosca: distribuição por projeto */
.donut-wrap { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.donut { flex: 0 0 132px; }
.donut__center { font-variant-numeric: tabular-nums; }
.legend { list-style: none; margin: 0; padding: 0; flex: 1; min-width: 170px; }
.legend li { display: flex; align-items: center; gap: 9px; padding: 5px 0;
  font-size: 13px; border-bottom: 1px solid var(--border); }
.legend li:last-child { border-bottom: none; }
.legend__name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis;
  white-space: nowrap; }
.legend__value { color: var(--muted); font-variant-numeric: tabular-nums; }

/* Barras horizontais: horas por cliente */
.hbars { list-style: none; margin: 0; padding: 0; }
.hbars li { padding: 9px 0; border-bottom: 1px solid var(--border); }
.hbars li:last-child { border-bottom: none; }
.hbars__head { display: flex; justify-content: space-between; gap: 10px;
  font-size: 13px; margin-bottom: 6px; }
.hbars__name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hbars__meta { color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.hbars__track { height: 7px; background: #eef2f6; border-radius: 999px; overflow: hidden; }
.hbars__fill { height: 100%; border-radius: 999px; min-width: 3px; }

@media (max-width: 900px) {
  .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .chart-grid { grid-template-columns: 1fr; }
  .bars { height: 150px; gap: 6px; }
  .period-form { width: 100%; }
}

/* ---------- Tags ---------- */
.tag-chip {
  display: inline-flex; align-items: center; gap: 5px;
  border: 1px solid color-mix(in srgb, var(--tag) 45%, transparent);
  background: color-mix(in srgb, var(--tag) 12%, #fff);
  color: color-mix(in srgb, var(--tag) 75%, #000);
  border-radius: 999px; padding: 2px 9px; font-size: 11.5px; font-weight: 600;
  white-space: nowrap;
}
.tag-chip::before {
  content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--tag);
}
.entry__tags { display: flex; gap: 5px; flex-wrap: wrap; }

.tag-picker { position: relative; }
.tag-picker summary {
  list-style: none; cursor: pointer; display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid var(--border); border-radius: 999px; padding: 6px 12px;
  font-size: 13px; color: var(--muted); background: var(--surface); white-space: nowrap;
}
.tag-picker summary::-webkit-details-marker { display: none; }
.tag-picker summary:hover { background: #eef2f6; color: var(--ink); }
.tag-picker[open] summary { border-color: var(--accent); color: var(--accent-dark); }
.tag-picker__panel {
  position: absolute; z-index: 20; top: calc(100% + 6px); left: 0; min-width: 210px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-md); padding: 8px; max-height: 260px; overflow-y: auto;
}
.tag-options { list-style: none; margin: 0; padding: 0; }
.tag-options li { padding: 0; }
.tag-options label {
  display: flex; align-items: center; gap: 8px; padding: 6px 7px; border-radius: 6px;
  font-size: 13px; cursor: pointer;
}
.tag-options label:hover { background: #eef2f6; }
.tag-options input { width: 15px; height: 15px; accent-color: var(--accent); }

.checkbox-grid .tag-options { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
