:root {
  --bg: #f7f1e8;
  --paper: #fffaf2;
  --paper-2: #ffffff;
  --ink: #2d251b;
  --muted: #766a5a;
  --line: #e2d5c1;
  --brand: #7c1f1d;
  --brand-dark: #541615;
  --gold: #b1863c;
  --success: #2f7d4f;
  --danger: #b33a32;
  --shadow: 0 12px 40px rgba(45, 37, 27, .10);
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: Arial, Helvetica, sans-serif;
  color: var(--ink);
  background: var(--bg);
  line-height: 1.55;
}
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
.container { width: min(1120px, calc(100% - 32px)); margin: 0 auto; }
.site-header { background: rgba(255,250,242,.96); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; }
.header-inner { min-height: 76px; display: flex; align-items: center; justify-content: space-between; gap: 24px; }
.brand { display: flex; align-items: center; gap: 12px; color: var(--ink); }
.brand:hover { text-decoration: none; }
.brand-mark, .login-logo { width: 46px; height: 46px; border-radius: 50%; background: var(--brand); color: #fff; display: grid; place-items: center; font-weight: bold; letter-spacing: 1px; }
.brand small { display: block; color: var(--muted); font-size: 12px; line-height: 1.25; }
.site-nav { display: flex; gap: 18px; flex-wrap: wrap; }
.site-nav a { color: var(--ink); font-weight: 600; }
.nav-toggle, .hamburger-button { display: none; }
.hero { padding: 76px 0; background: linear-gradient(135deg, #fffaf2 0%, #efe1cc 100%); border-bottom: 1px solid var(--line); }
.hero-grid { display: grid; grid-template-columns: 1fr 320px; gap: 42px; align-items: center; }
.eyebrow { color: var(--gold); text-transform: uppercase; font-weight: 700; letter-spacing: .12em; font-size: 12px; margin: 0 0 8px; }
h1, h2, h3 { line-height: 1.15; margin: 0 0 14px; }
h1 { font-size: clamp(34px, 6vw, 58px); }
h2 { font-size: 28px; }
h3 { font-size: 20px; }
.hero-text, .page-title p, .section-heading p { color: var(--muted); font-size: 18px; max-width: 720px; }
.hero-actions, .form-actions, .head-actions { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.btn { display: inline-flex; justify-content: center; align-items: center; min-height: 42px; padding: 10px 18px; border-radius: 10px; border: 1px solid transparent; font-weight: 700; cursor: pointer; font-size: 15px; }
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-dark); }
.btn-secondary { background: var(--paper); color: var(--brand); border-color: var(--line); }
.btn-danger { background: var(--danger); color: #fff; }
.btn.full { width: 100%; }
.hero-card { background: var(--brand); color: #fff; border-radius: 24px; padding: 28px; box-shadow: var(--shadow); }
.hero-card strong { display: block; font-size: 38px; line-height: 1; margin-top: 12px; }
.hero-card span { display: block; opacity: .82; }
.section { padding: 52px 0; }
.section-heading { margin-bottom: 22px; }
.year-pills { display: flex; flex-wrap: wrap; gap: 10px; }
.year-pills a { background: var(--paper); border: 1px solid var(--line); border-radius: 999px; padding: 8px 14px; font-weight: 700; }
.page-title { padding: 48px 0 34px; background: var(--paper); border-bottom: 1px solid var(--line); }
.chronology { padding: 38px 0 70px; }
.year-block { margin-bottom: 38px; }
.year-header { display: flex; align-items: baseline; justify-content: space-between; gap: 18px; border-bottom: 3px solid var(--brand); padding-bottom: 10px; margin-bottom: 18px; }
.year-header h2 { color: var(--brand); font-size: 38px; margin: 0; }
.timeline-list { display: grid; gap: 16px; }
.timeline-list-flat { margin-top: 24px; }
.timeline-item { background: var(--paper-2); border: 1px solid var(--line); border-radius: 18px; padding: 16px; display: grid; grid-template-columns: 86px 1fr; gap: 16px; box-shadow: 0 4px 20px rgba(45,37,27,.05); }
.timeline-item img, .person-card img { width: 86px; height: 108px; object-fit: cover; border-radius: 12px; background: #e7ddce; }
.thumb-link { line-height: 0; }
.timeline-item h3 { margin-bottom: 4px; }
.meta { color: var(--muted); margin: 0 0 8px; font-size: 14px; }
.source { color: var(--muted); font-size: 13px; font-style: italic; }
.search-box, .admin-search { display: flex; gap: 10px; margin-bottom: 24px; }
.search-box input, .admin-search input { flex: 1; }
.admin-search select { width: auto; min-width: 170px; }
.admin-search-wrap { flex-wrap: wrap; }
input, textarea, select { width: 100%; border: 1px solid var(--line); border-radius: 10px; padding: 11px 12px; font: inherit; color: var(--ink); background: #fff; }
textarea { resize: vertical; }
label { display: grid; gap: 6px; font-weight: 700; color: var(--ink); }
label small { color: var(--muted); font-weight: 400; }
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 16px; }
.person-card { background: var(--paper-2); border: 1px solid var(--line); border-radius: 18px; padding: 14px; display: flex; gap: 14px; color: var(--ink); box-shadow: 0 4px 20px rgba(45,37,27,.05); }
.person-card:hover { text-decoration: none; transform: translateY(-1px); }
.person-card strong, .person-card small { display: block; }
.person-card small { color: var(--muted); }
.person-hero { padding: 48px 0; background: linear-gradient(135deg, var(--brand) 0%, #2e1110 100%); color: #fff; }
.person-hero-grid { display: grid; grid-template-columns: 190px 1fr; gap: 28px; align-items: center; }
.person-photo-large { width: 190px; height: 245px; object-fit: cover; border-radius: 22px; border: 4px solid rgba(255,255,255,.25); background: #e7ddce; }
.person-subtitle { color: rgba(255,255,255,.82); font-size: 22px; }
.badge { display: inline-flex; background: rgba(255,255,255,.14); border: 1px solid rgba(255,255,255,.22); border-radius: 999px; padding: 7px 12px; }
.person-layout { display: grid; grid-template-columns: 330px 1fr; gap: 24px; padding: 42px 0 70px; }
.info-card, .text-card, .admin-card { background: var(--paper-2); border: 1px solid var(--line); border-radius: 18px; padding: 22px; box-shadow: 0 4px 20px rgba(45,37,27,.05); }
.data-list { display: grid; gap: 10px; }
.data-list dt { color: var(--muted); font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; }
.data-list dd { margin: -8px 0 8px; }
.person-main { display: grid; gap: 22px; }
.personal-timeline { display: grid; gap: 16px; }
.personal-timeline section { border-left: 4px solid var(--gold); padding: 4px 0 4px 16px; }
.empty-state { background: var(--paper-2); border: 1px dashed var(--line); border-radius: 18px; padding: 24px; color: var(--muted); }
.site-footer { border-top: 1px solid var(--line); background: var(--paper); padding: 24px 0; color: var(--muted); }
.login-body { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: linear-gradient(135deg, var(--brand) 0%, #24100f 100%); }
.login-card { width: min(420px, 100%); background: var(--paper-2); border-radius: 24px; padding: 30px; box-shadow: var(--shadow); }
.login-logo { margin-bottom: 16px; }
.login-title { font-size: 24px; line-height: 1.2; margin: 0 0 4px; font-weight: 800; color: var(--ink); }
.login-subtitle { margin: 0 0 22px; color: var(--muted); font-size: 15px; }
.login-card form { display: grid; gap: 16px; }
.admin-body { background: #f3f4f6; }
.admin-topbar { background: #191716; color: #fff; }
.admin-topbar-inner { min-height: 58px; display: flex; justify-content: space-between; align-items: center; gap: 16px; }
.admin-brand, .admin-user a { color: #fff; font-weight: 700; }
.admin-shell { display: grid; grid-template-columns: 220px 1fr; gap: 22px; padding: 24px 0 60px; }
.admin-sidebar { background: #fff; border: 1px solid #e5e7eb; border-radius: 18px; padding: 12px; align-self: start; position: sticky; top: 76px; }
.admin-sidebar a { display: block; padding: 10px 12px; border-radius: 10px; color: #222; font-weight: 700; }
.admin-sidebar a.active, .admin-sidebar a:hover { background: #f8eee2; color: var(--brand); text-decoration: none; }
.admin-content { min-width: 0; }
.admin-page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 22px; }
.admin-page-head p { color: #6b7280; margin: 0; }
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px; margin-bottom: 22px; }
.stats-grid div { background: #fff; border: 1px solid #e5e7eb; border-radius: 18px; padding: 18px; }
.stats-grid strong { display: block; font-size: 32px; color: var(--brand); }
.stats-grid span { color: #6b7280; }
.admin-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.admin-table th { text-align: left; color: #6b7280; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; }
.admin-table th, .admin-table td { padding: 12px 10px; border-bottom: 1px solid #eee; vertical-align: top; }
.admin-table tr:last-child td { border-bottom: none; }
.actions { white-space: nowrap; display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.inline-form { display: inline; }
.inline-form button { border: 0; background: transparent; color: var(--danger); cursor: pointer; padding: 0; font: inherit; font-weight: 700; }
.admin-form { background: #fff; border: 1px solid #e5e7eb; border-radius: 18px; padding: 22px; display: grid; gap: 18px; }
.form-grid { display: grid; gap: 16px; }
.form-grid.two { grid-template-columns: repeat(2, 1fr); }
.form-grid.three { grid-template-columns: repeat(3, 1fr); }
.checkbox-line { display: flex; align-items: center; gap: 8px; font-weight: 700; }
.checkbox-line input { width: auto; }
.current-photo { display: flex; align-items: center; gap: 16px; padding: 14px; border: 1px solid #e5e7eb; border-radius: 14px; }
.current-photo img { width: 90px; height: 112px; object-fit: cover; border-radius: 10px; }
.flash { padding: 12px 14px; border-radius: 12px; margin-bottom: 16px; font-weight: 700; }
.flash-success { background: #e8f6ee; color: #235c3d; border: 1px solid #c8ead6; }
.flash-error { background: #fff0ee; color: #8c2b25; border: 1px solid #f4c4bf; }
.status-ok { color: var(--success); font-weight: 700; }
.status-draft { color: #94711f; font-weight: 700; }
@media (max-width: 850px) {
  .header-inner { min-height: 64px; flex-direction: row; align-items: center; position: relative; gap: 12px; }
  .brand { min-width: 0; flex: 1; }
  .brand-mark { width: 40px; height: 40px; font-size: 13px; }
  .brand-text { min-width: 0; }
  .brand strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 16px; line-height: 1.15; }
  .brand small { display: none; }
  .nav-toggle { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .hamburger-button { margin-left: auto; width: 44px; height: 44px; border: 1px solid var(--line); border-radius: 12px; background: var(--paper-2); display: inline-flex; flex-direction: column; align-items: center; justify-content: center; gap: 5px; cursor: pointer; box-shadow: 0 4px 16px rgba(45,37,27,.06); }
  .hamburger-button span { width: 20px; height: 2px; border-radius: 999px; background: var(--ink); transition: transform .2s ease, opacity .2s ease; }
  .nav-toggle:focus-visible + .hamburger-button { outline: 2px solid var(--gold); outline-offset: 2px; }
  .nav-toggle:checked + .hamburger-button span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
  .nav-toggle:checked + .hamburger-button span:nth-child(2) { opacity: 0; }
  .nav-toggle:checked + .hamburger-button span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }
  .site-nav { display: none; position: absolute; top: calc(100% + 8px); left: 0; right: 0; z-index: 30; flex-direction: column; gap: 0; padding: 8px; background: var(--paper-2); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow); }
  .nav-toggle:checked ~ .site-nav { display: flex; }
  .site-nav a { padding: 12px 14px; border-radius: 10px; }
  .site-nav a:hover { background: #f8eee2; text-decoration: none; color: var(--brand); }
  .admin-page-head { align-items: flex-start; flex-direction: column; }
  .hero-grid, .person-hero-grid, .person-layout, .admin-shell { grid-template-columns: 1fr; }
  .stats-grid, .form-grid.two, .form-grid.three { grid-template-columns: 1fr; }
  .admin-sidebar { position: static; }
  .timeline-item { grid-template-columns: 70px 1fr; }
  .timeline-item img, .person-card img { width: 70px; height: 90px; }
  .search-box, .admin-search { flex-direction: column; }
  .admin-search select { width: 100%; }
}

/* Fase Colonial */
.colonial-summary-grid { display: grid; grid-template-columns: 1fr 320px; gap: 24px; align-items: stretch; }
.colonial-stats { min-height: 100%; }
.colonial-records { display: grid; gap: 18px; }
.colonial-card { display: grid; grid-template-columns: 140px 1fr; gap: 18px; background: var(--paper-2); border: 1px solid var(--line); border-radius: 18px; padding: 18px; box-shadow: 0 4px 20px rgba(45,37,27,.05); }
.colonial-period { color: var(--brand); font-weight: 900; font-size: 26px; line-height: 1; padding-top: 4px; }
.colonial-content { min-width: 0; }
.colonial-card-head { display: flex; justify-content: space-between; gap: 16px; align-items: flex-start; margin-bottom: 12px; }
.colonial-card-head h3 { margin-bottom: 4px; }
.colonial-data { gap: 8px; }
.confidence { display: inline-flex; align-items: center; justify-content: center; white-space: nowrap; border-radius: 999px; padding: 6px 10px; font-size: 12px; font-weight: 800; border: 1px solid var(--line); background: var(--paper); color: var(--muted); }
.confidence-alta { color: var(--success); border-color: #c8ead6; background: #e8f6ee; }
.confidence-media { color: #856018; border-color: #ead9a8; background: #fff7df; }
.confidence-baixa { color: var(--danger); border-color: #f4c4bf; background: #fff0ee; }

@media (max-width: 850px) {
  .colonial-summary-grid, .colonial-card { grid-template-columns: 1fr; }
  .colonial-card { gap: 10px; }
  .colonial-period { font-size: 24px; }
  .colonial-card-head { flex-direction: column; }
  .confidence { align-self: flex-start; }
}

.external-source-link::after {
    content: '↗';
    font-size: .78em;
    margin-left: 6px;
    opacity: .72;
}

.field-hint {
    color: #6f625c;
    display: block;
    font-size: 12px;
    line-height: 1.35;
    margin-top: 6px;
}

/* Fase Colonial v1.1.4 */
.colonial-subnav {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: center;
    margin-top: 18px;
}
.colonial-subnav a,
.colonial-subnav strong {
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 8px 14px;
    font-weight: 800;
    background: var(--paper);
}
.colonial-subnav strong {
    background: var(--brand);
    color: #fff;
    border-color: var(--brand);
}
.colonial-chronology .year-header span {
    color: var(--muted);
    font-size: 14px;
    font-weight: 700;
}
.colonial-year-empty {
    opacity: .72;
    margin-bottom: 18px;
}
.colonial-year-empty .year-header {
    border-bottom-color: var(--line);
}
.colonial-year-empty .year-header h2 {
    color: var(--muted);
    font-size: 30px;
}
.empty-state-compact {
    padding: 14px 16px;
    border-radius: 14px;
    font-size: 14px;
}
.colonial-timeline-item img,
.colonial-person-card img,
.colonial-profile-hero .person-photo-large {
    object-fit: contain;
}
.colonial-profile-hero .person-photo-large {
    background: rgba(255,255,255,.12);
}
.colonial-person-grid .person-card small {
    margin-top: 2px;
}
.colonial-profile-layout .info-card .confidence {
    margin-top: 4px;
}
.colonial-year-links {
    margin-top: 8px;
}

@media (max-width: 850px) {
    .colonial-year-empty .year-header h2 {
        font-size: 26px;
    }
    .colonial-subnav {
        flex-direction: column;
        align-items: stretch;
    }
    .colonial-subnav a,
    .colonial-subnav strong {
        text-align: center;
    }
}

.context-note {
    margin-top: 12px;
    padding: 12px 14px;
    border-left: 3px solid var(--line);
    background: rgba(0,0,0,.025);
    border-radius: 8px;
}

.compact-data-list {
    margin-top: 14px;
}

.colonial-profile-year {
    border-top: 1px solid var(--line);
    padding-top: 18px;
    margin-top: 18px;
}

.colonial-profile-year:first-child {
    border-top: 0;
    padding-top: 0;
    margin-top: 0;
}
