/*
 * Diaria Parada — Dash Web Design System
 * Segue REGRA 25 (padrao visual do Studio Hub) + design-system.md do produto.
 * Accent do produto: #E8541E. Dark/light via prefers-color-scheme.
 * Sem dependencias externas (os modules do Hub sao acoplados ao axiomstudiofinal).
 */

:root {
  /* Accent (assinatura da marca — igual nos dois temas) */
  --accent: #E8541E;
  --accent-dark: #C23E0E;
  --accent-soft: #FCE9E0;
  --on-accent: #1A1208;

  /* Status */
  --success: #1E8E5A;
  --success-soft: #E3F4EC;
  --warning: #B8860B;
  --warning-soft: #FBF1D8;
  --danger: #C0392B;
  --danger-soft: #FBE7E4;

  /* Light theme */
  --bg: #F7F5F2;
  --surface: #FFFFFF;
  --surface-2: #F1EEEA;
  --border: #E2DDD6;
  --text: #1A1208;
  --text-secondary: #5C544A;
  --text-muted: #8A8076;
  --shadow: 0 1px 3px rgba(26,18,8,.06), 0 8px 24px rgba(26,18,8,.05);

  /* Tokens */
  --radius-sm: 8px;
  --radius: 14px;
  --radius-lg: 20px;
  --radius-xl: 24px;
  --sidebar-w: 248px;
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --accent-soft: rgba(232,84,30,.18);
    --bg: #14110D;
    --surface: #1E1A15;
    --surface-2: #26211B;
    --border: #322C24;
    --text: #F4F0EA;
    --text-secondary: #B3AB9F;
    --text-muted: #8A8076;
    --shadow: 0 1px 3px rgba(0,0,0,.4), 0 8px 24px rgba(0,0,0,.3);
    --success-soft: rgba(30,142,90,.18);
    --warning-soft: rgba(184,134,11,.18);
    --danger-soft: rgba(192,57,43,.18);
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent-dark); text-decoration: none; }
a:hover { text-decoration: underline; }

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

.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 40;
  transition: transform .25s ease;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 22px 20px 18px;
  font-weight: 800;
  font-size: 17px;
}
.sidebar-brand .logo-dot {
  width: 30px; height: 30px; border-radius: 9px;
  background: var(--accent); color: var(--on-accent);
  display: grid; place-items: center; font-weight: 800; font-size: 15px;
}

.sidebar-nav { flex: 1; padding: 8px 12px; display: flex; flex-direction: column; gap: 2px; }
.nav-link {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 14px; border-radius: var(--radius-sm);
  color: var(--text-secondary); font-weight: 600; font-size: 14.5px;
}
.nav-link:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav-link.active { background: var(--accent-soft); color: var(--accent-dark); }
.nav-link .ico { width: 20px; text-align: center; font-size: 16px; }

.sidebar-version {
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-muted);
  display: flex; justify-content: space-between; align-items: center;
}
.sidebar-version button {
  background: none; border: none; color: var(--text-muted);
  cursor: pointer; font-size: 12px; padding: 2px 6px; border-radius: 6px;
}
.sidebar-version button:hover { background: var(--surface-2); color: var(--text); }

.main {
  flex: 1;
  margin-left: var(--sidebar-w);
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 28px; border-bottom: 1px solid var(--border);
  background: var(--surface); position: sticky; top: 0; z-index: 30;
}
.topbar h1 { font-size: 19px; font-weight: 800; margin: 0; }
.topbar .user { font-size: 13.5px; color: var(--text-secondary); display: flex; align-items: center; gap: 12px; }

.hamburger { display: none; background: none; border: none; font-size: 22px; cursor: pointer; color: var(--text); }

.content { padding: 28px; max-width: 1180px; width: 100%; }

/* ---------- Components ---------- */
.grid { display: grid; gap: 16px; }
.grid-stats { grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
}
.card-title { font-size: 14px; font-weight: 700; margin: 0 0 14px; color: var(--text); }

.stat .stat-label { font-size: 13px; color: var(--text-secondary); font-weight: 600; }
.stat .stat-value { font-size: 30px; font-weight: 800; margin-top: 6px; letter-spacing: -.5px; font-variant-numeric: tabular-nums; }
.stat .stat-value.accent { color: var(--accent); }
.stat .stat-value.success { color: var(--success); }
.stat .stat-sub { font-size: 12.5px; color: var(--text-muted); margin-top: 4px; }

.section-head { display: flex; align-items: center; justify-content: space-between; margin: 28px 0 12px; }
.section-head h2 { font-size: 16px; font-weight: 800; margin: 0; }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
thead th {
  text-align: left; padding: 10px 14px; font-size: 12px; text-transform: uppercase;
  letter-spacing: .04em; color: var(--text-muted); font-weight: 700; border-bottom: 1px solid var(--border);
}
tbody td { padding: 13px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--surface-2); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }

.badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 700;
}
.badge.andamento { background: var(--accent-soft); color: var(--accent-dark); }
.badge.fechada { background: var(--surface-2); color: var(--text-secondary); }
.badge.aberta { background: var(--warning-soft); color: var(--warning); }
.badge.negociando { background: var(--accent-soft); color: var(--accent-dark); }
.badge.recebida { background: var(--success-soft); color: var(--success); }
.badge.perdida { background: var(--danger-soft); color: var(--danger); }

.btn {
  display: inline-flex; align-items: center; gap: 8px; justify-content: center;
  padding: 11px 18px; border-radius: var(--radius-sm); border: none;
  font-weight: 700; font-size: 14.5px; cursor: pointer; font-family: var(--font);
  transition: filter .12s ease, transform .05s ease;
}
.btn:active { transform: scale(.985); }
.btn-primary { background: var(--accent); color: var(--on-accent); }
.btn-primary:hover { filter: brightness(.96); }
.btn-ghost { background: var(--surface-2); color: var(--text); }
.btn-ghost:hover { filter: brightness(.97); }
.btn:disabled { opacity: .55; cursor: not-allowed; }

label { display: block; font-size: 13.5px; font-weight: 600; margin-bottom: 6px; color: var(--text); }
input, select, textarea {
  width: 100%; padding: 11px 13px; border: 1.5px solid var(--border);
  border-radius: var(--radius-sm); background: var(--surface); color: var(--text);
  font-family: var(--font); font-size: 15px;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.field { margin-bottom: 16px; }
.field-hint { font-size: 12.5px; color: var(--text-muted); margin-top: 5px; }

/* States */
.empty, .loading {
  padding: 44px 20px; text-align: center; color: var(--text-muted); font-size: 14px;
}
.skeleton {
  background: linear-gradient(90deg, var(--surface-2) 25%, var(--border) 37%, var(--surface-2) 63%);
  background-size: 400% 100%; animation: shimmer 1.3s ease infinite; border-radius: 8px; height: 16px;
}
@keyframes shimmer { 0% { background-position: 100% 0; } 100% { background-position: -100% 0; } }
.spinner {
  width: 20px; height: 20px; border: 2.5px solid var(--accent-soft);
  border-top-color: var(--accent); border-radius: 50%; animation: spin .7s linear infinite; display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Bar chart (CSS puro, sem libs) */
.chart { display: flex; flex-direction: column; gap: 14px; }
.chart-row { display: grid; grid-template-columns: 110px 1fr 44px; align-items: center; gap: 12px; }
.chart-label { font-size: 13.5px; font-weight: 600; color: var(--text-secondary); }
.chart-track { height: 14px; background: var(--surface-2); border-radius: 999px; overflow: hidden; }
.chart-bar { height: 100%; border-radius: 999px; transition: width .4s ease; min-width: 2px; }
.chart-bar.aberta { background: var(--warning); }
.chart-bar.negociando { background: var(--accent); }
.chart-bar.recebida { background: var(--success); }
.chart-bar.perdida { background: var(--danger); }
.chart-val { font-size: 14px; font-weight: 700; text-align: right; font-variant-numeric: tabular-nums; }

/* Detalhe / definicao */
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 24px; }
.detail-grid .dl { font-size: 12.5px; color: var(--text-muted); font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
.detail-grid .dv { font-size: 15px; font-weight: 600; margin-top: 2px; }
.nota-thumb { width: 100%; max-height: 320px; object-fit: contain; border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--surface-2); }
.search-bar { margin-bottom: 16px; max-width: 360px; }

/* Toast (REGRA 25) */
.toast-wrap { position: fixed; right: 20px; bottom: 20px; z-index: 100; display: flex; flex-direction: column; gap: 10px; }
.toast {
  background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--accent);
  border-radius: var(--radius-sm); box-shadow: var(--shadow); padding: 13px 16px; font-size: 14px;
  font-weight: 600; min-width: 240px; animation: toastin .2s ease;
}
.toast.success { border-left-color: var(--success); }
.toast.error { border-left-color: var(--danger); }
@keyframes toastin { from { opacity: 0; transform: translateY(8px); } }

/* Login */
.login-screen { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-card { width: 100%; max-width: 380px; }
.login-card .logo-dot { width: 44px; height: 44px; border-radius: 13px; font-size: 20px; margin: 0 auto 16px; }

.backdrop { display: none; }

/* ---------- Responsive (REGRA 25) ---------- */
@media (max-width: 860px) {
  .sidebar { transform: translateX(-100%); box-shadow: var(--shadow); }
  .sidebar.open { transform: translateX(0); }
  .main { margin-left: 0; }
  .hamburger { display: block; }
  .backdrop.show { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 35; }
  .content { padding: 18px; }
}
