/* ============================================================
   Sales Dashboard - white / black / green theme
   ============================================================ */
:root {
  --green: #16a34a;
  --green-dark: #15803d;
  --green-light: #dcfce7;
  --green-bg: #f0fdf4;
  --black: #0a0a0a;
  --ink: #18181b;
  --muted: #6b7280;
  --line: #e5e7eb;
  --bg: #ffffff;
  --card: #ffffff;
  --soft: #f8fafc;
  --red: #dc2626;
  --red-light: #fee2e2;
  --shadow: 0 1px 3px rgba(0,0,0,.06), 0 8px 24px rgba(0,0,0,.05);
  --radius: 16px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  color: var(--ink);
  background: var(--soft);
  -webkit-font-smoothing: antialiased;
  font-size: 15px;
  line-height: 1.5;
}
h1,h2,h3 { margin: 0; font-weight: 700; letter-spacing: -0.01em; }
button { font-family: inherit; cursor: pointer; }
a { color: var(--green-dark); }

.hidden { display: none !important; }

/* ---------- Login ---------- */
.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background:
    radial-gradient(1200px 500px at 50% -10%, var(--green-light), transparent),
    var(--soft);
  padding: 24px;
}
.login-card {
  width: 100%;
  max-width: 420px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 22px;
  box-shadow: var(--shadow);
  padding: 36px 32px;
}
.brand {
  display: flex; align-items: center; gap: 12px;
}
.brand .logo {
  width: 42px; height: 42px; border-radius: 11px;
  background: var(--black); color: var(--green);
  display: grid; place-items: center; font-weight: 800; font-size: 22px;
  font-family: Georgia, "Times New Roman", serif;
}
.brand .brand-text h1 { font-size: 19px; letter-spacing: .08em; font-weight: 800; }
.brand .brand-text span { font-size: 10.5px; letter-spacing: .22em; color: var(--muted); text-transform: uppercase; font-weight: 600; }
.login-brand { display: flex; justify-content: center; margin-bottom: 4px; }
.login-logo { max-height: 120px; max-width: 260px; object-fit: contain; }
.topbar-logo { max-height: 46px; max-width: 190px; object-fit: contain; }
.login-sub { color: var(--muted); margin: 10px 0 26px; font-size: 14px; text-align: center; }

.seg {
  display: flex; background: var(--soft); border: 1px solid var(--line);
  border-radius: 12px; padding: 4px; margin-bottom: 22px;
}
.seg button {
  flex: 1; border: 0; background: transparent; padding: 9px 10px;
  border-radius: 9px; font-weight: 600; color: var(--muted); font-size: 14px;
}
.seg button.active { background: #fff; color: var(--black); box-shadow: 0 1px 2px rgba(0,0,0,.08); }

label.fld { display: block; font-size: 13px; font-weight: 600; color: var(--ink); margin-bottom: 7px; }
input[type=text], input[type=password], input[type=number], input[type=date], select {
  width: 100%; padding: 12px 14px; border: 1px solid var(--line);
  border-radius: 11px; font-size: 15px; font-family: inherit; background: #fff;
  outline: none; transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus { border-color: var(--green); box-shadow: 0 0 0 3px var(--green-light); }

.btn {
  width: 100%; border: 0; background: var(--green); color: #fff;
  padding: 13px 16px; border-radius: 11px; font-weight: 700; font-size: 15px;
  transition: background .15s, transform .05s;
}
.btn:hover { background: var(--green-dark); }
.btn:active { transform: translateY(1px); }
.btn.secondary { background: var(--black); }
.btn.secondary:hover { background: #000; }
.btn.ghost { background: #fff; color: var(--ink); border: 1px solid var(--line); }
.btn.ghost:hover { background: var(--soft); }
.btn.sm { width: auto; padding: 9px 14px; font-size: 13px; }
.btn.danger { background: #fff; color: var(--red); border: 1px solid var(--red-light); }

.captcha-row { display: flex; align-items: center; gap: 10px; }
.captcha-img { width: 150px; height: 52px; flex: none; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: var(--soft); }
.captcha-img svg { display: block; }
.captcha-refresh { flex: none; width: 40px; height: 44px; border: 1px solid var(--line); background: #fff; border-radius: 9px; font-size: 18px; color: var(--muted); }
.captcha-refresh:hover { background: var(--soft); color: var(--ink); }
.captcha-row input { flex: 1; text-transform: uppercase; letter-spacing: .12em; }

.error-msg { color: var(--red); font-size: 13px; margin-top: 12px; min-height: 18px; }
.hint { color: var(--muted); font-size: 12.5px; margin-top: 16px; text-align: center; }

/* ---------- App shell ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: rgba(255,255,255,.85); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 24px;
}
.topbar .brand h1 { font-size: 16px; }
.topbar .right { display: flex; align-items: center; gap: 12px; }
.who { font-size: 13px; color: var(--muted); }
.who b { color: var(--ink); }
.pill {
  font-size: 12px; font-weight: 700; padding: 4px 10px; border-radius: 999px;
  background: var(--green-light); color: var(--green-dark);
}
.pill.admin { background: var(--black); color: #fff; }

.container { max-width: 1180px; margin: 0 auto; padding: 24px; }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; margin-bottom: 20px; gap: 16px; flex-wrap: wrap; }
.page-head .title { font-size: 24px; }
.page-head .meta { color: var(--muted); font-size: 14px; margin-top: 2px; }

/* ---------- Cards / grid ---------- */
.grid { display: grid; gap: 16px; }
.kpis { grid-template-columns: repeat(4, 1fr); }
.g3 { grid-template-columns: repeat(3, 1fr); }
.cols-2 { grid-template-columns: 1.4fr 1fr; }
@media (max-width: 900px) { .kpis, .g3 { grid-template-columns: repeat(2,1fr); } .cols-2 { grid-template-columns: 1fr; } }
@media (max-width: 560px) { .kpis, .g3 { grid-template-columns: 1fr; } }

.metas-grid { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.month-select { width: auto; min-width: 150px; padding: 9px 12px; font-weight: 600; font-size: 14px; }
.ro-badge { font-weight: 700; color: var(--red); }
.access-btn { border: 1px solid var(--line); border-radius: 9px; padding: 8px 14px; font-weight: 700; font-size: 13px; background: #fff; color: var(--muted); }
.access-btn.on { background: var(--green); border-color: var(--green); color: #fff; }
.access-btn.off:hover { background: var(--soft); }
.lock-tag { font-size: 11px; font-weight: 700; color: var(--muted); background: var(--soft); border: 1px solid var(--line); padding: 2px 8px; border-radius: 999px; white-space: nowrap; }
.entry-table input:disabled { background: #f1f5f9; color: #9ca3af; cursor: not-allowed; border-color: var(--line); }

.section-label { font-size: 12px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); margin: 22px 0 10px; }
.section-label:first-child { margin-top: 4px; }

/* status dot (Arriba / Abajo) */
.status { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 700; padding: 4px 11px; border-radius: 999px; }
.status .dot { width: 9px; height: 9px; border-radius: 50%; }
.status.arriba { background: var(--green-light); color: var(--green-dark); }
.status.arriba .dot { background: var(--green); }
.status.abajo { background: var(--red-light); color: var(--red); }
.status.abajo .dot { background: var(--red); }
.kpi .k-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.readonly-tag { font-size: 10.5px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); background: var(--soft); border: 1px solid var(--line); padding: 2px 7px; border-radius: 999px; }

.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px;
}
.card h3 { font-size: 14px; color: var(--muted); font-weight: 600; margin-bottom: 14px; }
.card.pad-lg { padding: 22px 22px 14px; }

.kpi .k-label { font-size: 13px; color: var(--muted); font-weight: 600; }
.kpi .k-value { font-size: 28px; font-weight: 800; margin-top: 6px; letter-spacing: -0.02em; }
.kpi .k-sub { font-size: 12.5px; color: var(--muted); margin-top: 4px; }
.kpi.accent { background: var(--green-bg); border-color: var(--green-light); }
.kpi.accent .k-value { color: var(--green-dark); }
.kpi.dark { background: var(--black); border-color: var(--black); }
.kpi.dark .k-label, .kpi.dark .k-sub { color: #a3a3a3; }
.kpi.dark .k-value { color: #fff; }

/* progress bar */
.progress { height: 9px; background: var(--line); border-radius: 999px; overflow: hidden; margin-top: 12px; }
.progress > span { display: block; height: 100%; background: var(--green); border-radius: 999px; transition: width .4s ease; }
.progress.g2 > span { background: var(--black); }

/* ---------- Ranking board ---------- */
.rank-list { display: flex; flex-direction: column; gap: 8px; }
.rank-row {
  display: flex; align-items: center; gap: 14px;
  padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px;
  background: #fff; transition: background .15s;
}
.rank-row.me { border-color: var(--green); background: var(--green-bg); box-shadow: 0 0 0 1px var(--green-light); }
.rank-row .pos {
  width: 34px; height: 34px; flex: none; border-radius: 9px;
  background: var(--soft); color: var(--ink);
  display: grid; place-items: center; font-weight: 800; font-size: 15px;
}
.rank-row.top1 .pos { background: #fde68a; color: #92400e; }
.rank-row.top2 .pos { background: #e5e7eb; color: #374151; }
.rank-row.top3 .pos { background: #fed7aa; color: #9a3412; }
.rank-row .rname { font-weight: 700; flex: 1; }
.rank-row .rname .tag-you { font-size: 11px; font-weight: 700; color: var(--green-dark); background: var(--green-light); padding: 2px 7px; border-radius: 999px; margin-left: 8px; }
.rank-row .move { display: flex; align-items: center; gap: 4px; font-weight: 700; font-size: 14px; min-width: 52px; justify-content: flex-end; }
.move.up { color: var(--green); }
.move.down { color: var(--red); }
.move.same { color: var(--muted); }
.move .arrow { font-size: 16px; }
.rank-row .radv { font-variant-numeric: tabular-nums; color: var(--muted); font-size: 13px; min-width: 64px; text-align: right; }

/* ---------- Table ---------- */
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 11px 12px; text-align: right; border-bottom: 1px solid var(--line); white-space: nowrap; }
th:first-child, td:first-child { text-align: left; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); font-weight: 700; }
tbody tr:hover { background: var(--soft); }
td.num { font-variant-numeric: tabular-nums; }
.badge { display: inline-block; padding: 3px 9px; border-radius: 999px; font-size: 12px; font-weight: 700; }
.badge.good { background: var(--green-light); color: var(--green-dark); }
.badge.warn { background: #fef3c7; color: #92400e; }
.badge.bad { background: var(--red-light); color: var(--red); }

/* entry table inputs */
.entry-table input { padding: 7px 9px; border-radius: 8px; text-align: right; max-width: 130px; }
.entry-table td { padding: 6px 8px; }
.day-today { background: var(--green-bg) !important; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }

/* tabs */
.tabs { display: flex; gap: 4px; background: var(--soft); border: 1px solid var(--line); border-radius: 12px; padding: 4px; margin-bottom: 20px; width: fit-content; }
.tabs button { border: 0; background: transparent; padding: 9px 16px; border-radius: 9px; font-weight: 600; color: var(--muted); }
.tabs button.active { background: #fff; color: var(--black); box-shadow: 0 1px 2px rgba(0,0,0,.08); }

/* modal */
.modal-back { position: fixed; inset: 0; background: rgba(0,0,0,.4); display: grid; place-items: center; z-index: 50; padding: 20px; }
.modal { background: #fff; border-radius: 18px; box-shadow: var(--shadow); width: 100%; max-width: 460px; padding: 24px; max-height: 90vh; overflow: auto; }
.modal h3 { font-size: 18px; color: var(--ink); margin-bottom: 16px; }
.form-row { margin-bottom: 14px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.modal-actions { display: flex; gap: 10px; margin-top: 8px; }
.modal-actions .btn { width: auto; flex: 1; }

.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--black); color: #fff; padding: 12px 20px; border-radius: 999px;
  font-size: 14px; font-weight: 600; box-shadow: var(--shadow); z-index: 60;
  opacity: 0; transition: opacity .2s, transform .2s; pointer-events: none;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(-4px); }

.row-actions { display: flex; gap: 8px; justify-content: flex-end; }
.section-gap { margin-top: 22px; }
canvas { max-width: 100%; }
.chart-box { position: relative; height: 280px; }
