@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 rediseñado (pantalla dividida) ---------- */
.login-split { display: flex; min-height: 100vh; background: var(--navy); }
.login-info { flex: 1; padding: 70px 60px; display: flex; flex-direction: column; justify-content: center; color: #fff; }
.login-info-brand { display: flex; align-items: center; gap: 14px; margin-bottom: 8px; }
.login-info-badge { width: 48px; height: 48px; border-radius: 50%; background: var(--navy); border: 1.5px solid var(--brass); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.login-info-name { font-family: 'Libre Baskerville', serif; font-size: 38px; }
.login-info-tagline { font-size: 14px; color: var(--brass-light); margin-bottom: 24px; margin-left: 62px; }
.login-info-rule { width: 60px; height: 1px; background: var(--brass); margin-bottom: 24px; }
.login-info-headline { font-family: 'Libre Baskerville', serif; font-size: 32px; line-height: 1.3; margin-bottom: 14px; }
.login-info-headline span { color: var(--brass-light); }
.login-info-sub { font-size: 14px; color: #B9C2D6; line-height: 1.6; margin-bottom: 36px; max-width: 420px; }

.icon-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; max-width: 460px; }
.icon-box { text-align: center; }
.icon-circle { width: 48px; height: 48px; border: 1px solid #2c3b5c; border-radius: 10px; display: flex; align-items: center; justify-content: center; margin: 0 auto 8px; }
.icon-box span { font-size: 11px; color: #B9C2D6; }

.login-card-new { width: 440px; flex-shrink: 0; background: var(--paper); display: flex; flex-direction: column; justify-content: center; padding: 50px 44px; }
.login-card-header { text-align: center; margin-bottom: 26px; }
.login-card-badge { width: 56px; height: 56px; border-radius: 50%; background: var(--navy); display: flex; align-items: center; justify-content: center; margin: 0 auto 12px; }
.login-card-title { font-family: 'Libre Baskerville', serif; font-size: 24px; color: var(--navy); }
.login-card-sub { font-size: 13px; color: var(--slate); }
.login-card-footer { text-align: center; font-size: 12px; color: var(--slate); margin-top: 4px; }

.input-icon-wrap { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 6px; background: #fff; margin-top: 4px; }
.input-icon-wrap input { border: none; outline: none; flex: 1; font-size: 13px; color: var(--ink); background: transparent; font-family: inherit; }
.input-icon-wrap svg { flex-shrink: 0; }

.login-bottom-bar { text-align: center; padding: 14px; font-size: 12px; color: #8A93A8; background: var(--navy); }

@media (max-width: 860px) {
  .login-split { flex-direction: column; }
  .login-info { padding: 30px 24px 20px; text-align: center; }
  .login-info-brand { justify-content: center; }
  .login-info-tagline { margin-left: 0; }
  .login-info-rule { margin-left: auto; margin-right: auto; }
  .login-info-headline { font-size: 26px; }
  .login-info-sub { margin-left: auto; margin-right: auto; }
  .icon-grid { grid-template-columns: repeat(4, 1fr); gap: 8px; max-width: 100%; margin: 0 auto; }
  .icon-circle { width: 36px; height: 36px; border-radius: 8px; }
  .icon-circle svg { width: 15px; height: 15px; }
  .icon-box span { font-size: 8.5px; }
  .login-card-new { width: 100%; border-radius: 14px 14px 0 0; padding: 28px 22px; }
}

.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: 8px;
  border: none;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s, border-color .15s, box-shadow .15s;
}
.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-outline:hover { border-color: var(--brass); color: var(--brass); }
.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;
  text-decoration: none;
}
.nav-item.active { background: var(--navy-light); color: #fff; }
.nav-item:hover { color: #fff; }
.nav-item .ni { width: 17px; height: 17px; flex-shrink: 0; stroke: currentColor; }
.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 {
  display: block; text-decoration: none; transition: box-shadow .15s, transform .15s;
  background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 18px;
  box-shadow: 0 2px 8px rgba(20,33,61,.05);
}
.stat-card:hover { box-shadow: 0 6px 16px rgba(20,33,61,.1); transform: translateY(-1px); }
.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); }
.stat-icon { width: 38px; height: 38px; border-radius: 10px; display: flex; align-items: center; justify-content: center; margin-bottom: 12px; }
.stat-icon svg { width: 18px; height: 18px; }
.section-title-icon { display: inline-flex; align-items: center; gap: 10px; }
.section-title-icon .sic { width: 28px; height: 28px; border-radius: 8px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.section-title-icon .sic svg { width: 14px; height: 14px; }

.panel { background: #fff; border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 2px 8px rgba(20,33,61,.05); }
.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: 36px 20px; color: var(--slate); font-size: 13px; text-align: center; }

.toast-flash {
  position: fixed; bottom: 20px; right: 20px; z-index: 999;
  background: var(--navy); color: #fff; padding: 12px 18px; border-radius: 8px;
  font-size: 13px; box-shadow: 0 4px 16px rgba(0,0,0,.22);
  display: flex; align-items: center; gap: 8px;
  animation: toast-in .25s ease-out, toast-out .3s ease-in 3.2s forwards;
}
.toast-flash .dot { color: var(--green); font-size: 16px; line-height: 0; }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
@keyframes toast-out { to { opacity: 0; transform: translateY(10px); } }
@media (max-width: 860px) {
  .toast-flash { left: 16px; right: 16px; bottom: 78px; }
}

.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 10px;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .1em;
  border-radius: 999px;
  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(auto-fit, minmax(150px, 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: 12px; padding: 20px; margin-bottom: 24px; box-shadow: 0 2px 8px rgba(20,33,61,.05); }

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

  .sidebar {
    width: 100%;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-around;
    padding: 8px 4px;
    gap: 0;
    position: sticky;
    top: 0;
    z-index: 30;
    overflow: hidden;
  }
  .sidebar > div:first-child,
  .sidebar-footer {
    display: contents;
  }
  .sidebar .brand {
    display: block;
    flex-basis: 100%;
    text-align: left;
    font-size: 23px;
    padding: 2px 0 8px 6px;
  }
  .sidebar > div:first-child > a[href="https://portalabogado.cl"] {
    display: none;
  }

  .nav-item {
    padding: 7px 4px;
    margin-bottom: 0;
    border-radius: 8px;
    flex: 1 1 0;
    justify-content: center;
    min-width: 0;
    font-size: 19px;
  }
  .nav-item .ni { width: 20px; height: 20px; }
  .nav-item span { display: none; }

  .sidebar-footer a.nav-item[href="logout.php"] {
    color: #fff;
  }

  .sidebar-footer .name-area { display: none !important; }
  .sidebar-footer a.nav-item { margin-left: 0; }

  .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) {
  .nav-item { font-size: 17px; }
}

/* ---------- Íconos de título de página (aplica en todo el sistema) ---------- */
.page-title-icon { display: inline-flex; align-items: center; gap: 12px; }
.page-title-icon .pic { width: 34px; height: 34px; border-radius: 10px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.page-title-icon .pic svg { width: 17px; height: 17px; }
.info-chip svg { width: 13px; height: 13px; vertical-align: -2px; margin-right: 3px; }
