/* ═══════════════════════════════════════════════════
   VeriFactu — Diseño Airbnb-inspired
   Tipografía: DM Sans + DM Mono
   Paleta: Coral Airbnb, blancos cálidos, gris pizarra
═══════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=DM+Sans:ital,opsz,wght@0,9..40,300..700;1,9..40,300..700&family=DM+Mono:wght@400;500&display=swap');

/* ── Tokens ─────────────────────────────────────── */
:root {
  --coral:       #FF385C;
  --coral-dark:  #E31C5F;
  --coral-dim:   rgba(255,56,92,.10);
  --coral-glow:  rgba(255,56,92,.20);

  --ink:         #222222;
  --body:        #484848;
  --muted:       #767676;
  --line:        #DDDDDD;
  --line-soft:   #EBEBEB;

  --canvas:      #F7F7F7;
  --card:        #FFFFFF;
  --sidebar-bg:  #FFFFFF;

  --green:       #008A05;  --green-bg:  #ECFDF3;
  --red:         #C13515;  --red-bg:    #FFF1EE;
  --amber:       #8A6116;  --amber-bg:  #FFF8EC;
  --blue:        #2963CA;  --blue-bg:   #EEF3FF;

  --radius-sm:   8px;
  --radius:      12px;
  --radius-lg:   16px;
  --radius-xl:   24px;

  --shadow-xs:  0 1px 2px rgba(0,0,0,.06);
  --shadow-sm:  0 1px 4px rgba(0,0,0,.08), 0 4px 12px rgba(0,0,0,.04);
  --shadow:     0 2px 8px rgba(0,0,0,.08), 0 8px 24px rgba(0,0,0,.06);

  --sidebar-w: 256px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--canvas);
  color: var(--body);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--coral); text-decoration: none; transition: color .15s; }
a:hover { color: var(--coral-dark); }
svg { width: 18px; height: 18px; fill: currentColor; flex-shrink: 0; }

/* ══════════════════════════════════════════════════
   LOGIN
══════════════════════════════════════════════════ */
.login-body {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: var(--card);
}
.login-visual {
  background: linear-gradient(150deg, #FF385C 0%, #D93B52 60%, #bf2d47 100%);
  display: flex; flex-direction: column;
  justify-content: space-between;
  padding: 52px 56px;
  position: relative; overflow: hidden;
}
.login-visual::before {
  content: ''; position: absolute;
  width: 500px; height: 500px; border-radius: 50%;
  background: rgba(255,255,255,.07);
  top: -150px; right: -150px; pointer-events: none;
}
.login-visual::after {
  content: ''; position: absolute;
  width: 280px; height: 280px; border-radius: 50%;
  background: rgba(255,255,255,.05);
  bottom: -60px; left: -60px; pointer-events: none;
}
.login-visual-brand {
  display: flex; align-items: center; gap: 14px;
  position: relative; z-index: 1;
}
.login-visual-brand .logo-box {
  width: 42px; height: 42px; border-radius: 11px;
  background: rgba(255,255,255,.22);
  display: grid; place-items: center;
  color: #fff; font-size: 13px; font-weight: 700; letter-spacing: -.02em;
}
.login-visual-brand > span {
  color: rgba(255,255,255,.92); font-size: 20px;
  font-weight: 700; letter-spacing: -.04em;
}
.login-visual-copy { position: relative; z-index: 1; }
.login-visual-copy h2 {
  color: #fff; font-size: 34px; font-weight: 700;
  line-height: 1.15; letter-spacing: -.05em; margin-bottom: 14px;
}
.login-visual-copy p { color: rgba(255,255,255,.72); font-size: 15px; line-height: 1.65; }
.login-form-wrap {
  display: flex; align-items: center; justify-content: center;
  padding: 52px 56px;
}
.login-form-inner { width: 100%; max-width: 360px; }
.login-form-inner h1 {
  font-size: 26px; font-weight: 700; color: var(--ink);
  letter-spacing: -.05em; margin-bottom: 6px;
}
.login-form-inner > p { color: var(--muted); font-size: 14px; margin-bottom: 30px; }

@media (max-width: 768px) {
  .login-body { grid-template-columns: 1fr; }
  .login-visual { display: none; }
  .login-form-wrap { padding: 36px 28px; }
}

/* ══════════════════════════════════════════════════
   CONTROLS
══════════════════════════════════════════════════ */
label {
  display: flex; flex-direction: column; gap: 6px;
  font-size: 13px; font-weight: 600; color: var(--ink);
  margin-bottom: 16px;
}
input[type="text"], input[type="email"], input[type="password"],
input[type="number"], input[type="date"], select, textarea {
  width: 100%;
  border: 1.5px solid var(--line);
  border-radius: var(--radius);
  padding: 11px 14px;
  font-size: 14px; font-family: inherit;
  background: var(--card); color: var(--ink);
  outline: none;
  transition: border-color .18s, box-shadow .18s;
  appearance: none; -webkit-appearance: none;
}
input::placeholder, textarea::placeholder { color: #bbb; }
input:focus, select:focus, textarea:focus {
  border-color: var(--ink);
  box-shadow: 0 0 0 3px rgba(0,0,0,.07);
}
textarea { min-height: 100px; resize: vertical; }
input[type="checkbox"] { width: auto; accent-color: var(--coral); }
select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='%23767676'%3E%3Cpath d='M7 10l5 5 5-5z'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; padding-right: 36px;
}

.password-box { position: relative; }
.password-box input { padding-right: 48px; }
.password-box button {
  position: absolute; right: 10px; top: 50%; transform: translateY(-50%);
  border: none; background: transparent; padding: 6px; cursor: pointer;
  color: var(--muted); border-radius: 8px; transition: color .15s;
  display: grid; place-items: center;
}
.password-box button:hover { color: var(--ink); }

/* ══════════════════════════════════════════════════
   BUTTONS
══════════════════════════════════════════════════ */
.btn-primary, .btn-secondary, .btn-ghost, .logout-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: none; border-radius: var(--radius); padding: 11px 20px;
  font-size: 14px; font-weight: 600; font-family: inherit;
  cursor: pointer; transition: all .18s; white-space: nowrap; text-decoration: none;
}
.btn-primary { background: var(--coral); color: #fff; box-shadow: 0 2px 8px var(--coral-glow); }
.btn-primary:hover { background: var(--coral-dark); color: #fff; transform: translateY(-1px); box-shadow: 0 4px 16px var(--coral-glow); }
.btn-secondary { background: var(--card); color: var(--ink); border: 1.5px solid var(--line); }
.btn-secondary:hover { background: var(--canvas); color: var(--ink); border-color: #bbb; }
.btn-ghost { background: var(--canvas); color: var(--body); padding: 8px 12px; }
.btn-ghost:hover { background: var(--line-soft); color: var(--ink); }
.full { width: 100%; margin-top: 4px; }

.alert-error {
  background: var(--red-bg); color: var(--red);
  padding: 12px 16px; border-radius: var(--radius);
  font-size: 13px; font-weight: 500;
  border: 1px solid rgba(193,53,21,.15); margin-bottom: 20px;
}
.alert-success {
  background: var(--green-bg); color: var(--green);
  padding: 12px 16px; border-radius: var(--radius);
  font-size: 13px; font-weight: 500;
  border: 1px solid rgba(0,138,5,.15); margin-bottom: 20px;
}

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

.sidebar {
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  border-right: 1px solid var(--line-soft);
  display: flex; flex-direction: column;
  position: fixed; inset: 0 auto 0 0; z-index: 50;
  overflow-y: auto;
}
.sidebar::-webkit-scrollbar { width: 0; }

.brand {
  display: flex; align-items: center; gap: 11px;
  padding: 20px 18px 18px;
  border-bottom: 1px solid var(--line-soft);
  flex-shrink: 0;
}
.brand-icon {
  width: 36px; height: 36px; border-radius: 9px;
  background: var(--coral); color: #fff;
  display: grid; place-items: center;
  font-size: 12px; font-weight: 700; letter-spacing: -.02em; flex-shrink: 0;
}
.brand strong { font-size: 15px; font-weight: 700; color: var(--ink); letter-spacing: -.03em; }
.brand span { font-size: 11px; color: var(--muted); margin-top: 1px; display: block; }

.nav-section { padding: 18px 10px 6px; }
.nav-section-label {
  font-size: 10px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .09em; color: var(--muted);
  padding: 0 8px; margin-bottom: 4px; display: block;
}
.menu { display: flex; flex-direction: column; gap: 1px; }
.menu a {
  padding: 9px 10px; border-radius: var(--radius-sm);
  color: var(--body); font-weight: 500; font-size: 13.5px;
  display: flex; align-items: center; gap: 10px;
  position: relative; transition: all .14s; text-decoration: none;
}
.menu a svg { color: var(--muted); transition: color .14s; }
.menu a:hover { background: var(--canvas); color: var(--ink); }
.menu a:hover svg { color: var(--ink); }
.menu a.active { background: var(--coral-dim); color: var(--coral); font-weight: 600; }
.menu a.active svg { color: var(--coral); }
.menu a.active::before {
  content: ''; position: absolute; left: -10px;
  width: 3px; height: 18px; background: var(--coral); border-radius: 0 3px 3px 0;
}

.menu-sub { margin-left: 28px; display: flex; flex-direction: column; gap: 1px; }
.menu-sub a {
  font-size: 12.5px; color: var(--muted); font-weight: 500;
  padding: 6px 10px; border-radius: var(--radius-sm);
  display: flex; align-items: center; gap: 7px;
}
.menu-sub a:hover { background: var(--canvas); color: var(--coral); }
.menu-sub a svg { width: 13px; height: 13px; color: inherit; }

.sidebar-footer {
  margin-top: auto; border-top: 1px solid var(--line-soft);
  padding: 14px 10px; flex-shrink: 0;
}
.user-mini {
  display: flex; align-items: center; gap: 10px;
  padding: 10px; border-radius: var(--radius);
  background: var(--canvas); margin-bottom: 6px;
}
.avatar {
  width: 34px; height: 34px; border-radius: 9px;
  background: var(--ink); color: #fff;
  display: grid; place-items: center;
  font-weight: 700; font-size: 13px; flex-shrink: 0;
}
.user-mini strong { font-size: 13px; font-weight: 600; color: var(--ink); display: block; }
.user-mini span { font-size: 11px; color: var(--muted); display: block; }
.logout-btn {
  width: 100%; justify-content: flex-start;
  color: var(--muted); background: transparent; padding: 9px 10px;
  font-size: 13px; font-weight: 500; border-radius: var(--radius-sm);
}
.logout-btn:hover { background: var(--red-bg); color: var(--red); }
.logout-btn svg { color: currentColor; }

.content {
  margin-left: var(--sidebar-w);
  width: calc(100% - var(--sidebar-w));
  padding: 36px 40px;
}
.page-title {
  display: flex; justify-content: space-between;
  align-items: flex-start; gap: 20px; margin-bottom: 28px;
}
.page-title h1 {
  font-size: 26px; font-weight: 700; color: var(--ink);
  letter-spacing: -.05em; line-height: 1.1; margin-bottom: 3px;
}
.page-title p { color: var(--muted); font-size: 13.5px; }

/* ══════════════════════════════════════════════════
   CARDS
══════════════════════════════════════════════════ */
.card, .invoice-paper {
  background: var(--card);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-xs);
  margin-bottom: 20px;
}
.card h2 {
  font-size: 15px; font-weight: 700; color: var(--ink);
  letter-spacing: -.03em; margin-bottom: 16px;
}

/* ══════════════════════════════════════════════════
   STATS
══════════════════════════════════════════════════ */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0,1fr));
  gap: 14px; margin-bottom: 20px;
}
.stats-grid.two { grid-template-columns: repeat(2, minmax(0,1fr)); }

.stat-card {
  background: var(--card);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-lg);
  padding: 20px 20px 18px;
  box-shadow: var(--shadow-xs);
  transition: box-shadow .2s, transform .2s;
}
.stat-card:hover { box-shadow: var(--shadow-sm); transform: translateY(-1px); }
.stat-card-icon {
  width: 38px; height: 38px; border-radius: 10px;
  display: grid; place-items: center; margin-bottom: 14px;
}
.stat-card-icon.coral { background: var(--coral-dim); color: var(--coral); }
.stat-card-icon.green { background: var(--green-bg);  color: var(--green); }
.stat-card-icon.blue  { background: var(--blue-bg);   color: var(--blue); }
.stat-card-icon.amber { background: var(--amber-bg);  color: var(--amber); }
.stat-card span {
  display: block; font-size: 11.5px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .06em;
  color: var(--muted); margin-bottom: 5px;
}
.stat-card strong {
  display: block; font-size: 24px; font-weight: 700; color: var(--ink);
  letter-spacing: -.04em; line-height: 1;
  font-family: 'DM Mono', monospace;
}

/* ══════════════════════════════════════════════════
   TABLES
══════════════════════════════════════════════════ */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 580px; }
thead th {
  padding: 10px 14px; text-align: left; vertical-align: middle;
  font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .08em; color: var(--muted);
  border-bottom: 1.5px solid var(--line-soft);
  background: #FAFAFA; white-space: nowrap;
}
tbody td {
  padding: 13px 14px; border-bottom: 1px solid var(--line-soft);
  vertical-align: middle; font-size: 13.5px; color: var(--body);
}
tbody tr:last-child td { border-bottom: none; }
tbody tr { transition: background .1s; }
tbody tr:hover { background: #FCFCFC; }

.badge {
  display: inline-flex; align-items: center;
  padding: 3px 10px; border-radius: 999px;
  font-size: 11.5px; font-weight: 600;
  background: var(--canvas); color: var(--muted);
  border: 1px solid var(--line);
}
.badge.success { background: var(--green-bg); color: var(--green); border-color: rgba(0,138,5,.15); }
.badge.danger  { background: var(--red-bg);   color: var(--red);   border-color: rgba(193,53,21,.15); }
.badge.amber   { background: var(--amber-bg); color: var(--amber); border-color: rgba(138,97,22,.15); }
.badge.blue    { background: var(--blue-bg);  color: var(--blue);  border-color: rgba(41,99,202,.15); }
.badge.coral   { background: var(--coral-dim); color: var(--coral); border-color: var(--coral-glow); }
.badge.soft    { background: var(--canvas); color: var(--muted); }

/* ══════════════════════════════════════════════════
   FORMS
══════════════════════════════════════════════════ */
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0,1fr));
  gap: 4px 20px;
}
.full-row { grid-column: 1 / -1; }
.form-actions {
  grid-column: 1 / -1; margin-top: 12px;
  display: flex; justify-content: flex-end; gap: 10px;
}
.form-section-title {
  grid-column: 1 / -1;
  font-size: 13px; font-weight: 700; color: var(--ink);
  letter-spacing: -.02em;
  padding: 12px 0 2px;
  border-bottom: 1px solid var(--line-soft);
  margin-bottom: 4px;
}

/* ══════════════════════════════════════════════════
   INVOICE LINES
══════════════════════════════════════════════════ */
#itemsTable input, #itemsTable select {
  min-width: 90px; font-size: 13px; padding: 9px 12px; border-radius: var(--radius-sm);
}
#itemsTable input[name="description[]"] { min-width: 200px; }
#itemsTable td { padding: 9px 8px; }

.totals-box {
  max-width: 360px; margin-left: auto; margin-top: 18px;
  background: var(--canvas); border: 1px solid var(--line-soft);
  border-radius: var(--radius-lg); padding: 16px 20px;
}
.totals-box p {
  display: flex; justify-content: space-between;
  font-size: 13.5px; color: var(--body);
  padding: 6px 0; border-bottom: 1px solid var(--line-soft);
}
.totals-box p:last-of-type { border-bottom: none; }
.totals-box p strong { font-weight: 600; color: var(--ink); font-family: 'DM Mono', monospace; }
.grand-total {
  border-top: 2px solid var(--line) !important;
  padding-top: 12px !important; margin-top: 4px;
  font-size: 15px !important; font-weight: 700;
}
.grand-total strong { font-size: 17px !important; color: var(--coral) !important; }

/* ══════════════════════════════════════════════════
   INVOICE VIEW
══════════════════════════════════════════════════ */
.invoice-paper { border-radius: var(--radius-xl); padding: 32px; }
.invoice-head {
  display: flex; justify-content: space-between; align-items: flex-start;
  gap: 24px; margin-bottom: 28px; padding-bottom: 24px;
  border-bottom: 1.5px solid var(--line-soft);
}
.invoice-head h2 { font-size: 20px; font-weight: 700; color: var(--ink); letter-spacing: -.04em; }
.invoice-head p { color: var(--muted); font-size: 13px; margin-top: 2px; }
.invoice-number {
  background: var(--coral-dim); color: var(--coral);
  padding: 10px 16px; border-radius: var(--radius);
  font-weight: 700; font-size: 14px; letter-spacing: -.01em;
  font-family: 'DM Mono', monospace; white-space: nowrap; flex-shrink: 0;
}
.invoice-meta { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; margin-bottom: 28px; }
.invoice-meta strong {
  display: block; font-size: 11px; text-transform: uppercase;
  letter-spacing: .07em; color: var(--muted); font-weight: 700; margin-bottom: 6px;
}
.invoice-meta p { color: var(--body); font-size: 13.5px; line-height: 1.7; }
.qr-img { max-width: 130px; border-radius: var(--radius); border: 1px solid var(--line); padding: 6px; margin-top: 16px; }

/* ══════════════════════════════════════════════════
   LEDGER
══════════════════════════════════════════════════ */
.ledger-summary {
  display: grid; grid-template-columns: repeat(4, minmax(0,1fr));
  gap: 14px; margin-bottom: 20px;
}
.ledger-card {
  background: var(--card); border: 1px solid var(--line-soft);
  border-radius: var(--radius-lg); padding: 20px; box-shadow: var(--shadow-xs);
}
.ledger-card span {
  display: block; font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .08em;
  color: var(--muted); margin-bottom: 8px;
}
.ledger-card strong {
  font-size: 22px; font-weight: 700; color: var(--ink);
  font-family: 'DM Mono', monospace; letter-spacing: -.03em;
}

/* ══════════════════════════════════════════════════
   RESPONSIVE
══════════════════════════════════════════════════ */
@media (max-width: 1100px) {
  .stats-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .ledger-summary { grid-template-columns: repeat(2, minmax(0,1fr)); }
}
@media (max-width: 860px) {
  .sidebar { position: static; width: 100%; }
  .app-shell { display: block; }
  .content { margin-left: 0; width: 100%; padding: 24px 20px; }
}
@media (max-width: 600px) {
  .stats-grid, .stats-grid.two, .ledger-summary { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .full-row { grid-column: 1; }
  .page-title { flex-direction: column; align-items: flex-start; }
  .invoice-head { flex-direction: column; }
  .invoice-meta { grid-template-columns: 1fr; }
  .content { padding: 20px 16px; }
}

small { display: block; color: var(--muted); font-size: 12px; margin-top: 12px; }
.mono { font-family: 'DM Mono', monospace; font-size: 12.5px; }
