@import url('https://fonts.googleapis.com/css2?family=Libre+Baskerville:ital,wght@0,400;0,700;1,400&family=Inter:wght@400;500;600;700&family=IBM+Plex+Mono:wght@400;500&display=swap');

:root {
  --navy: #14213D;
  --navy-light: #1F2E52;
  --paper: #F7F5F0;
  --paper-dark: #EFEBE2;
  --ink: #2A2E36;
  --slate: #5B6270;
  --brass: #B08D57;
  --brass-light: #D9C6A0;
  --rose: #C1666B;
  --green: #4A7C59;
  --line: #DED8C9;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 14px;
}

.font-display { font-family: 'Libre Baskerville', Georgia, serif; }
.font-mono { font-family: 'IBM Plex Mono', monospace; }

a { color: inherit; text-decoration: none; }

/* ---------- Login ---------- */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--navy);
}
.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--paper);
  border-radius: 12px;
  padding: 40px 32px;
}
.login-title { text-align: center; margin-bottom: 32px; }
.login-title .brand { font-family: 'Libre Baskerville', serif; font-size: 34px; color: var(--navy); }
.login-title .sub { font-size: 13px; color: var(--slate); margin-top: 2px; }
.field { display: block; margin-bottom: 16px; }
.field .label { display: block; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--slate); margin-bottom: 4px; }
.field input, .field select, .field textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-family: inherit;
  font-size: 14px;
  color: var(--ink);
  background: #fff;
}
.field textarea { resize: vertical; }
.error-box { display: flex; gap: 6px; align-items: center; font-size: 12px; color: var(--rose); margin: 8px 0; }
.demo-hint { margin-top: 24px; padding-top: 16px; border-top: 1px solid var(--line); font-size: 11px; color: var(--slate); }
.demo-hint .h { text-transform: uppercase; letter-spacing: .08em; margin-bottom: 6px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 16px;
  border-radius: 6px;
  border: none;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.btn-primary { background: var(--navy); color: #fff; width: 100%; }
.btn-primary:hover { background: var(--navy-light); }
.btn-outline { background: #fff; border: 1px solid var(--line); color: var(--ink); }
.btn-sm { padding: 6px 10px; font-size: 12px; }
.btn-rose { background: var(--rose); color: #fff; }
.btn-green { background: var(--green); color: #fff; }

/* ---------- App layout ---------- */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: 220px;
  flex-shrink: 0;
  background: var(--navy);
  padding: 24px 12px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}
.sidebar .brand { font-family: 'Libre Baskerville', serif; font-size: 24px; color: #fff; padding: 0 12px 24px; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; border-radius: 6px; margin-bottom: 4px;
  color: #B9C2D6; font-size: 14px;
}
.nav-item.active { background: var(--navy-light); color: #fff; }
.nav-item:hover { color: #fff; }
.sidebar-footer { padding: 0 12px; }
.avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--navy-light); color: var(--brass-light);
  display: flex; align-items: center; justify-content: center;
  font-family: 'Libre Baskerville', serif; font-size: 12px;
}
.main { flex: 1; padding: 32px; overflow-y: auto; }
.page-title { font-family: 'Libre Baskerville', serif; font-size: 26px; color: var(--navy); margin: 0 0 4px; }
.page-sub { color: var(--slate); font-size: 14px; margin-bottom: 24px; }

/* ---------- Cards / stats ---------- */
.grid-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-bottom: 32px; }
.stat-card {
  background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 18px;
}
.stat-card .row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.stat-card .label { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--slate); }
.stat-card .value { font-family: 'Libre Baskerville', serif; font-size: 24px; color: var(--navy); }

.panel { background: #fff; border: 1px solid var(--line); border-radius: 10px; }
.panel-row { display: flex; justify-content: space-between; align-items: center; padding: 14px 20px; border-bottom: 1px solid var(--line); }
.panel-row:last-child { border-bottom: none; }
.panel-empty { padding: 20px; color: var(--slate); font-size: 13px; }

.list-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 16px 20px; border-bottom: 1px solid var(--line);
  background: #fff;
}
.list-row:last-child { border-bottom: none; }
.list-row:hover { background: var(--paper-dark); }
.list-title { font-weight: 600; color: var(--ink); font-size: 14px; }
.list-sub { font-size: 12px; color: var(--slate); margin-top: 2px; }

.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
.section-title { font-family: 'Libre Baskerville', serif; font-size: 18px; color: var(--navy); margin: 0 0 12px; }

/* ---------- Stamp ---------- */
.stamp {
  font-family: 'IBM Plex Mono', monospace;
  display: inline-block;
  padding: 4px 8px;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .1em;
  border-radius: 3px;
  transform: rotate(-2deg);
  border: 1.5px solid;
}
.stamp-activo { color: var(--brass); border-color: var(--brass); }
.stamp-pendiente { color: var(--rose); border-color: var(--rose); }
.stamp-cerrado { color: var(--slate); border-color: var(--slate); }

select.stamp-select {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .1em;
  padding: 4px 8px;
  border-radius: 4px;
  background: #fff;
}

/* ---------- Misc ---------- */
.topbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.search-box {
  display: flex; align-items: center; gap: 8px;
  background: #fff; border: 1px solid var(--line); border-radius: 6px;
  padding: 8px 12px; max-width: 320px; margin-bottom: 16px;
}
.search-box input { border: none; outline: none; width: 100%; font-size: 13px; background: transparent; }
.info-chip { display: flex; align-items: center; gap: 8px; padding: 12px; background: #fff; border: 1px solid var(--line); border-radius: 8px; font-size: 13px; }
.info-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 20px; }
.notes-box { background: var(--paper-dark); border-radius: 8px; padding: 14px; font-size: 13px; margin-bottom: 20px; }
.back-link { font-size: 12px; color: var(--slate); margin-bottom: 16px; display: inline-block; }
.task-row { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.task-row form { display: inline; }
.task-done { text-decoration: line-through; color: var(--slate); }
.fee-box { display: flex; justify-content: space-between; align-items: center; background: var(--paper-dark); border-radius: 8px; padding: 14px; margin-bottom: 20px; }
.new-form { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 20px; margin-bottom: 24px; }

@media (max-width: 780px) {
  .app { flex-direction: column; min-height: auto; }

  .sidebar {
    width: 100%;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    gap: 8px;
    position: sticky;
    top: 0;
    z-index: 30;
  }
  .sidebar > div:first-child {
    display: flex;
    align-items: center;
    gap: 2px;
  }
  .sidebar .brand { font-size: 18px; padding: 0 8px 0 0; }
  .sidebar > div:first-child > a[href="https://portalabogado.cl"]:nth-child(2) { display: none; } /* oculta el tagline largo en móvil */

  .nav-item {
    padding: 8px 9px;
    margin-bottom: 0;
    border-radius: 8px;
  }
  .nav-item span { display: none; }

  .sidebar-footer {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0;
  }
  .sidebar-footer .name-area { display: none !important; }
  .sidebar-footer a.nav-item { padding: 8px; }

  .main { padding: 16px; }
  .page-title { font-size: 21px; }

  .grid-stats, .two-col, .info-grid { grid-template-columns: 1fr; }

  .topbar { flex-direction: column; align-items: stretch; gap: 10px; }
  .topbar .btn { width: 100%; }

  .list-row, .panel-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }
  .list-row > div:last-child, .panel-row > div:last-child {
    align-self: flex-end;
  }

  .fee-box { flex-direction: column; align-items: flex-start; gap: 10px; }
  .fee-box button { width: 100%; }

  /* Filas de acciones (ej: panel de administración) */
  .panel-row form { display: inline-flex; }
  .panel-row > div[style*="display:flex"],
  .panel-row > div[style*="display: flex"] {
    flex-wrap: wrap;
    width: 100%;
    justify-content: flex-start;
  }
  .panel-row .btn-sm, .panel-row a.btn-sm { flex: 1 1 auto; text-align: center; }

  .search-box { max-width: 100%; }
  .login-card { padding: 32px 22px; margin: 0 16px; }
}

@media (max-width: 420px) {
  .sidebar .brand { display: none; }
}
