/* ============================================================================
   Panel Larután — hoja de estilos
   Paleta tomada del logo (verde hoja). Responsive: sidebar en escritorio,
   barra inferior en celular.
   ============================================================================ */

:root {
  --green-50:  #F1F8EC;
  --green-100: #DFF0D2;
  --green-200: #BFE2A8;
  --green-500: #5AA428;
  --green-600: #4C8C21;
  --green-700: #2E6B15;
  --green-900: #1C4A0C;
  --ink-900: #1B2016;
  --ink-700: #3B4432;
  --ink-500: #67715C;
  --ink-300: #A6AE9B;
  --paper: #FFFFFF;
  --canvas: #F6F7F2;
  --line: #E3E6DC;
  --amber-600: #B2660F;
  --amber-50:  #FBF0DF;
  --red-600: #B23A2E;
  --red-50:  #FBE7E3;
  --shadow-sm: 0 1px 2px rgba(27,32,22,0.06), 0 1px 1px rgba(27,32,22,0.04);
  --shadow-md: 0 6px 20px rgba(27,32,22,0.08), 0 2px 6px rgba(27,32,22,0.05);
  --radius: 14px;
  --font-display: 'Manrope', system-ui, -apple-system, sans-serif;
  --font-body: 'Source Sans 3', system-ui, -apple-system, sans-serif;
  --sidebar-w: 240px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --green-50:  #122410;
    --green-100: #163318;
    --green-200: #1E4A20;
    --green-500: #6CC13A;
    --green-600: #7FD64B;
    --green-700: #9BE56C;
    --green-900: #D7F5C2;
    --ink-900: #EFF3E8;
    --ink-700: #C7D0BC;
    --ink-500: #8E9A82;
    --ink-300: #5B6552;
    --paper: #171B13;
    --canvas: #10130D;
    --line: #2A2F22;
    --amber-600: #E3A75E;
    --amber-50: #3A2C18;
    --red-600: #E0847A;
    --red-50: #3A201C;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.3);
    --shadow-md: 0 6px 20px rgba(0,0,0,0.35);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --green-50:  #122410; --green-100: #163318; --green-200: #1E4A20;
  --green-500: #6CC13A; --green-600: #7FD64B; --green-700: #9BE56C; --green-900: #D7F5C2;
  --ink-900: #EFF3E8; --ink-700: #C7D0BC; --ink-500: #8E9A82; --ink-300: #5B6552;
  --paper: #171B13; --canvas: #10130D; --line: #2A2F22;
  --amber-600: #E3A75E; --amber-50: #3A2C18; --red-600: #E0847A; --red-50: #3A201C;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--canvas);
  color: var(--ink-900);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, .display { font-family: var(--font-display); letter-spacing: -0.01em; }
button, input, select { font-family: inherit; }
a { color: inherit; }

/* ---------------------------------------------------------------- login -- */
.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(circle at 15% 15%, var(--green-100), transparent 55%),
    radial-gradient(circle at 85% 85%, var(--green-50), transparent 50%),
    var(--canvas);
}
.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 20px;
  box-shadow: var(--shadow-md);
  padding: 36px 32px 32px;
  text-align: center;
}
.login-card img.logo { width: 92px; height: auto; margin-bottom: 10px; }
.login-card h1 { font-size: 1.3rem; font-weight: 800; margin: 0 0 4px; }
.login-card p.tag { color: var(--ink-500); font-size: 0.88rem; margin: 0 0 26px; }
.field { text-align: left; margin-bottom: 14px; }
.field label { display: block; font-size: 0.78rem; font-weight: 700; color: var(--ink-500); margin-bottom: 6px; }
.field input {
  width: 100%; padding: 11px 13px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--canvas); color: var(--ink-900); font-size: 0.95rem;
}
.field input:focus { outline: 2px solid var(--green-500); outline-offset: 1px; background: var(--paper); }
.btn-primary {
  width: 100%; padding: 12px; border: none; border-radius: 10px;
  background: var(--green-600); color: #fff; font-family: var(--font-display);
  font-weight: 700; font-size: 0.95rem; cursor: pointer; margin-top: 6px;
  box-shadow: var(--shadow-sm);
}
.btn-primary:active { transform: translateY(1px); }
.btn-primary:disabled { opacity: 0.6; cursor: default; }
.login-error {
  margin-top: 14px; padding: 10px 12px; border-radius: 9px;
  background: var(--red-50); color: var(--red-600); font-size: 0.84rem; display: none;
}
.login-error.show { display: block; }
.login-foot { margin-top: 22px; font-size: 0.76rem; color: var(--ink-300); }

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

.sidebar {
  width: var(--sidebar-w); flex-shrink: 0; background: var(--paper);
  border-right: 1px solid var(--line); display: flex; flex-direction: column;
  padding: 22px 16px; position: sticky; top: 0; height: 100vh;
}
.sidebar .brand { display: flex; align-items: center; gap: 10px; padding: 0 6px 22px; }
.sidebar .brand img { height: 32px; width: auto; display: block; }
.sidebar .brand span { display: none; }
.nav-group { display: flex; flex-direction: column; gap: 3px; margin-bottom: 18px; }
.nav-group .nav-label { font-size: 0.68rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-300); padding: 10px 10px 4px; }
.nav-item {
  display: flex; align-items: center; gap: 11px; padding: 10px 12px; border-radius: 10px;
  color: var(--ink-700); text-decoration: none; font-size: 0.89rem; font-weight: 600;
  cursor: pointer; border: none; background: transparent; width: 100%; text-align: left;
}
.nav-item .ico { width: 19px; text-align: center; flex-shrink: 0; font-size: 1.02rem; }
.nav-item:hover { background: var(--canvas); }
.nav-item.active { background: var(--green-500); color: #fff; }
.sidebar-foot { margin-top: auto; padding-top: 14px; border-top: 1px solid var(--line); }
.user-chip { display: flex; align-items: center; gap: 10px; padding: 8px 6px; }
.user-chip .avatar {
  width: 32px; height: 32px; border-radius: 50%; background: var(--green-100); color: var(--green-700);
  display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 0.85rem; flex-shrink: 0;
}
.user-chip .who { min-width: 0; }
.user-chip .name { font-size: 0.85rem; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-chip .role { font-size: 0.72rem; color: var(--ink-500); }
.logout-btn {
  margin-top: 8px; width: 100%; padding: 8px 10px; border-radius: 9px; border: 1px solid var(--line);
  background: transparent; color: var(--ink-500); font-size: 0.8rem; font-weight: 600; cursor: pointer;
}
.logout-btn:hover { background: var(--red-50); color: var(--red-600); border-color: transparent; }

.topbar {
  display: none; align-items: center; justify-content: space-between;
  padding: 14px 16px; background: var(--paper); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 20;
}
.topbar .brand { display: flex; align-items: center; gap: 9px; }
.topbar .brand img { height: 26px; width: auto; display: block; }
.topbar .brand span { display: none; }
.topbar .logout-btn { width: auto; padding: 7px 10px; }

.bottom-nav {
  display: none; position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  background: var(--paper); border-top: 1px solid var(--line);
  padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); gap: 2px;
  justify-content: space-around;
  box-shadow: 0 -4px 16px rgba(0,0,0,0.05);
}
.bottom-nav .nav-item {
  flex-direction: column; gap: 2px; padding: 6px 4px; font-size: 0.66rem; text-align: center;
  border-radius: 10px; flex: 1;
}
.bottom-nav .nav-item .ico { font-size: 1.18rem; }
.bottom-nav .nav-item.active { background: var(--green-50); color: var(--green-700); }

.content-col { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.main { flex: 1; min-width: 0; }
.main-inner { max-width: 980px; margin: 0 auto; padding: 28px 28px 70px; }

.page-head { margin-bottom: 20px; }
.page-head h1 { font-size: 1.4rem; font-weight: 800; margin: 0 0 3px; }
.page-head p { color: var(--ink-500); font-size: 0.9rem; margin: 0; }

h2.section-title { font-size: 0.92rem; font-weight: 700; margin: 26px 0 9px; color: var(--ink-700); }
h2.section-title:first-child { margin-top: 0; }

.card {
  background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.card.pad { padding: 18px 20px; }

.row {
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  padding: 12px 16px; border-bottom: 1px solid var(--line);
}
.row:last-child { border-bottom: none; }
.row .name { font-weight: 600; font-size: 0.92rem; min-width: 0; }
.row .name span.meta { display: block; font-size: 0.72rem; color: var(--ink-500); font-weight: 400; margin-top: 1px; }

.qty-wrap { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
input.qty {
  width: 68px; padding: 8px 9px; border: 1px solid var(--line); border-radius: 9px;
  background: var(--canvas); color: var(--ink-900); font-size: 0.9rem; text-align: right;
  font-variant-numeric: tabular-nums;
}
input.qty.kg { width: 56px; }
input.qty:focus { outline: 2px solid var(--green-500); outline-offset: 1px; background: var(--paper); }
.unit-label { font-size: 0.74rem; color: var(--ink-500); width: 32px; }
.sep-dot { color: var(--line); font-size: 0.85rem; }

.ro-qty { font-weight: 700; font-variant-numeric: tabular-nums; font-size: 0.95rem; }
.ro-qty.zero { color: var(--amber-600); }
.ro-unit { font-size: 0.76rem; color: var(--ink-500); margin-left: 4px; font-weight: 400; }

.progress-bar { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.progress-bar .track { flex: 1; height: 8px; border-radius: 5px; background: var(--line); overflow: hidden; }
.progress-bar .fill { height: 100%; background: var(--green-500); border-radius: 5px; transition: width .25s ease; }
.progress-bar .label { font-size: 0.78rem; color: var(--ink-500); white-space: nowrap; font-variant-numeric: tabular-nums; }

.save-pill {
  position: fixed; top: 16px; right: 16px; z-index: 50;
  font-size: 0.76rem; font-weight: 700; padding: 7px 14px; border-radius: 999px;
  background: var(--green-50); color: var(--green-700); box-shadow: var(--shadow-md);
  opacity: 0; transform: translateY(-6px); transition: all .2s ease; pointer-events: none;
}
.save-pill.show { opacity: 1; transform: translateY(0); }
.save-pill.err { background: var(--red-50); color: var(--red-600); }

.banner {
  display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap;
  background: var(--green-50); border: 1px solid var(--green-200); color: var(--green-900);
  border-radius: var(--radius); padding: 14px 18px; margin-bottom: 20px; font-size: 0.88rem;
}
.banner .btn-ghost {
  border: 1px solid var(--green-500); background: transparent; color: var(--green-700);
  font-weight: 700; font-size: 0.82rem; padding: 7px 13px; border-radius: 9px; cursor: pointer; white-space: nowrap;
}
.banner.warn { background: var(--amber-50); border-color: #E0C089; color: var(--amber-600); }

/* ------------------------------------------------------------------ forms */
.form-grid { display: grid; grid-template-columns: 1fr; gap: 14px; }
@media (min-width: 640px) { .form-grid.two { grid-template-columns: 1fr 1fr; } }
.field-g label { display: block; font-size: 0.78rem; font-weight: 700; color: var(--ink-500); margin-bottom: 6px; }
.field-g select, .field-g input[type=text], .field-g input[type=number] {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 9px;
  background: var(--canvas); color: var(--ink-900); font-size: 0.92rem;
}
.field-g select:focus, .field-g input:focus { outline: 2px solid var(--green-500); outline-offset: 1px; background: var(--paper); }
.field-g { margin-bottom: 14px; }
.chip-row { display: flex; gap: 7px; flex-wrap: wrap; margin-top: 7px; }
.chip {
  font-size: 0.78rem; padding: 6px 12px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--paper); color: var(--ink-500); cursor: pointer;
}
.chip.selected { background: var(--green-500); color: #fff; border-color: var(--green-500); }
.btn-submit {
  font-family: var(--font-display); font-weight: 700; font-size: 0.92rem; width: 100%;
  padding: 12px; border: none; border-radius: 10px; background: var(--green-600); color: #fff;
  cursor: pointer; margin-top: 6px; box-shadow: var(--shadow-sm);
}
.btn-submit.danger { background: var(--red-600); }
.btn-submit.secondary { background: transparent; color: var(--green-700); border: 1px solid var(--green-500); box-shadow: none; }
.form-msg { font-size: 0.84rem; margin-top: 12px; padding: 10px 13px; border-radius: 9px; display: none; }
.form-msg.show { display: block; }
.form-msg.ok { background: var(--green-50); color: var(--green-700); }
.form-msg.warn { background: var(--amber-50); color: var(--amber-600); }

/* -------------------------------------------------------------- activity */
.activity-item { padding: 12px 16px; border-bottom: 1px solid var(--line); font-size: 0.87rem; }
.activity-item:last-child { border-bottom: none; }
.activity-item .a-top { display: flex; justify-content: space-between; gap: 8px; font-weight: 600; }
.activity-item .a-meta { color: var(--ink-500); font-size: 0.76rem; margin-top: 2px; }
.tag { font-size: 0.66rem; font-weight: 700; padding: 3px 8px; border-radius: 999px; text-transform: uppercase; letter-spacing: 0.3px; flex-shrink: 0; }
.tag.venta { background: var(--green-50); color: var(--green-700); }
.tag.perdida { background: var(--red-50); color: var(--red-600); }
.tag.compra { background: var(--amber-50); color: var(--amber-600); }
.empty-note { color: var(--ink-300); font-size: 0.85rem; text-align: center; padding: 30px 10px; }

/* -------------------------------------------------------------- dashboard */
.kpi-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin-bottom: 22px; }
@media (min-width: 640px) { .kpi-grid { grid-template-columns: repeat(4, 1fr); } }
.kpi-card { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow-sm); }
.kpi-card .kpi-label { font-size: 0.74rem; color: var(--ink-500); font-weight: 600; margin-bottom: 6px; }
.kpi-card .kpi-value { font-family: var(--font-display); font-size: 1.32rem; font-weight: 800; }
.kpi-card.good .kpi-value { color: var(--green-700); }
.kpi-card.bad .kpi-value { color: var(--red-600); }
.month-switch { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; }
.month-switch select { padding: 8px 12px; border-radius: 9px; border: 1px solid var(--line); background: var(--paper); font-size: 0.88rem; font-weight: 600; }
.bar-list .bar-row { display: flex; align-items: center; gap: 10px; padding: 9px 16px; }
.bar-list .bar-name { flex: 0 0 38%; font-size: 0.84rem; font-weight: 600; line-height: 1.25; }
.bar-list .bar-track { flex: 1; height: 9px; border-radius: 5px; background: var(--canvas); overflow: hidden; min-width: 30px; }
.bar-list .bar-fill { height: 100%; border-radius: 5px; background: var(--green-500); }
.bar-list .bar-val { font-size: 0.8rem; color: var(--ink-500); width: 64px; text-align: right; font-variant-numeric: tabular-nums; flex-shrink: 0; }
@media (max-width: 480px) {
  .bar-list .bar-row { flex-wrap: wrap; }
  .bar-list .bar-name { flex: 1 1 100%; }
  .bar-list .bar-track { order: 3; flex: 1 1 auto; }
  .bar-list .bar-val { order: 4; }
}

/* ---------------------------------------------------------------- prices */
.price-row { display: grid; grid-template-columns: 1fr; gap: 8px; padding: 14px 16px; border-bottom: 1px solid var(--line); }
@media (min-width: 760px) {
  .price-row { grid-template-columns: 1.6fr 1fr 1fr 1fr 1fr; align-items: center; gap: 12px; }
}
.price-row:last-child { border-bottom: none; }
.price-row .p-name { font-weight: 700; font-size: 0.9rem; }
.price-row .p-name span.meta { display: block; font-size: 0.72rem; color: var(--ink-500); font-weight: 400; }
.price-row .p-field label { display: block; font-size: 0.68rem; color: var(--ink-500); font-weight: 700; margin-bottom: 3px; text-transform: uppercase; letter-spacing: 0.03em; }
.price-row .p-field input {
  width: 100%; padding: 7px 9px; border: 1px solid var(--line); border-radius: 8px;
  background: var(--canvas); font-size: 0.86rem; text-align: right; font-variant-numeric: tabular-nums;
}
.price-row .p-field.readout { font-size: 0.86rem; font-weight: 700; color: var(--green-700); text-align: right; padding-top: 18px; }
.price-row.needs-pricing { background: var(--amber-50); }

/* ------------------------------------------------------------------ misc */
.loading-screen { min-height: 100vh; display: flex; align-items: center; justify-content: center; color: var(--ink-300); font-size: 0.9rem; }
.hidden { display: none !important; }

/* ------------------------------------------------------------- mobile ---*/
@media (max-width: 899px) {
  .sidebar { display: none; }
  .topbar { display: flex; }
  .bottom-nav { display: flex; }
  .main-inner { padding: 20px 16px 90px; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
}
