/* Control de Proyectos — estilos propios (sin librerías externas) */
:root {
  --ink: #2b2f36;
  --ink-2: #3a3f47;
  --ink-3: #565b64;
  --gold: #b8923a;
  --gold-d: #96751f;
  --gold-l: #f3ead2;
  --paper: #f6f4ef;
  --card: #ffffff;
  --line: #e3e0d8;
  --muted: #6d7179;
  --green: #2f7d5b;
  --green-l: #dcefe4;
  --amber: #b07a0c;
  --amber-l: #f8ecc8;
  --red: #b4432f;
  --red-l: #f6d9d2;
  --blue: #3b5f8a;
  --blue-l: #dfe8f3;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(43, 47, 54, .06), 0 2px 8px rgba(43, 47, 54, .05);
  --font: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Roboto, Arial, sans-serif;
  --serif: Georgia, "Times New Roman", serif;
}
* { box-sizing: border-box; }
html { font-size: 15px; }
body { margin: 0; font-family: var(--font); color: var(--ink); background: var(--paper); line-height: 1.45; -webkit-font-smoothing: antialiased; }
a { color: var(--gold-d); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; font-weight: 600; line-height: 1.2; }
h1 { font-family: var(--serif); font-size: 1.65rem; letter-spacing: .1px; }
h2 { font-size: 1.05rem; }
h3 { font-size: .95rem; }
p { margin: 0 0 .6rem; }
.muted { color: var(--muted); }
.small { font-size: .84rem; }
.nowrap { white-space: nowrap; }
.right, .num { text-align: right; }
.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.center { text-align: center; }
.mt { margin-top: 1.2rem; }
.mb { margin-bottom: 1.2rem; }
.hidden { display: none !important; }

/* ---------------------------------------------------------------- estructura */
.shell { display: flex; min-height: 100vh; }
.sidebar { width: 252px; flex: 0 0 252px; background: var(--ink); color: #d8d9dc; display: flex; flex-direction: column; padding: 18px 14px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 18px; border-bottom: 1px solid rgba(255, 255, 255, .1); margin-bottom: 14px; color: #fff; }
.brand:hover { text-decoration: none; }
.brand img { width: 40px; height: 40px; object-fit: contain; background: #fff; border-radius: 8px; padding: 3px; }
.brand b { display: block; font-family: var(--serif); font-size: 1.02rem; letter-spacing: .3px; line-height: 1.15; }
.brand span { display: block; font-size: .72rem; color: #a9acb2; letter-spacing: .6px; text-transform: uppercase; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav h4 { margin: 16px 10px 4px; font-size: .68rem; letter-spacing: 1px; text-transform: uppercase; color: #8b8f97; font-weight: 600; }
.nav a { display: flex; align-items: center; justify-content: space-between; color: #d8d9dc; padding: 8px 10px; border-radius: 8px; font-size: .93rem; }
.nav a:hover { background: rgba(255, 255, 255, .07); text-decoration: none; }
.nav a.active { background: rgba(184, 146, 58, .2); color: #fff; box-shadow: inset 3px 0 0 var(--gold); }
.nav .count { background: var(--gold); color: #1e2126; border-radius: 999px; font-size: .72rem; font-weight: 700; padding: 1px 8px; }
.sidebar .me { margin-top: auto; padding: 14px 8px 2px; border-top: 1px solid rgba(255, 255, 255, .1); font-size: .85rem; }
.sidebar .me b { display: block; color: #fff; font-weight: 600; }
.sidebar .me .role { color: #a9acb2; font-size: .75rem; }
.sidebar .me .links { display: flex; gap: 10px; margin-top: 8px; align-items: center; }
.sidebar .me a, .linkbtn { color: #d8d9dc; font-size: .82rem; background: none; border: 0; padding: 0; cursor: pointer; font-family: inherit; }
.sidebar .me a:hover, .linkbtn:hover { color: #fff; text-decoration: underline; }
.main { flex: 1; min-width: 0; padding: 26px 32px 60px; max-width: 1500px; }
.topbar { display: none; }
.pagehead { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.pagehead .sub { color: var(--muted); margin-top: 4px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

.public { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.public .box { width: 100%; max-width: 410px; }
.public .logo { display: block; margin: 0 auto 22px; width: 190px; max-width: 70%; }

/* ---------------------------------------------------------------- componentes */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px 20px; }
.card > h2, .card .cardhead h2 { margin-bottom: 12px; }
.cardhead { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.cardhead h2 { margin: 0; }
.grid { display: grid; gap: 16px; }
.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.wide { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }

.btn { display: inline-flex; align-items: center; gap: 6px; font: inherit; font-size: .92rem; font-weight: 600; padding: 8px 15px; border-radius: 8px; border: 1px solid var(--line); background: #fff; color: var(--ink); cursor: pointer; text-decoration: none; line-height: 1.2; }
.btn:hover { background: #faf8f3; text-decoration: none; border-color: #cfcabd; }
.btn-primary { background: var(--ink); color: #fff; border-color: var(--ink); }
.btn-primary:hover { background: var(--ink-2); border-color: var(--ink-2); }
.btn-gold { background: var(--gold); color: #fff; border-color: var(--gold); }
.btn-gold:hover { background: var(--gold-d); border-color: var(--gold-d); }
.btn-danger { color: var(--red); border-color: #e4b9b0; background: #fff; }
.btn-danger:hover { background: var(--red-l); }
.btn-ok { background: var(--green); border-color: var(--green); color: #fff; }
.btn-ok:hover { background: #256649; border-color: #256649; }
.btn-sm { padding: 4px 10px; font-size: .82rem; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
form.inline { display: inline; }

.flashes { margin-bottom: 16px; display: grid; gap: 8px; }
.flash { padding: 10px 14px; border-radius: 8px; border: 1px solid; font-size: .93rem; }
.flash-success { background: var(--green-l); border-color: #b9dbc8; color: #1f5a41; }
.flash-danger { background: var(--red-l); border-color: #ebbcb1; color: #8a2f1f; }
.flash-warning { background: var(--amber-l); border-color: #ead9a0; color: #7a5407; }
.flash-info { background: var(--blue-l); border-color: #c1d1e6; color: #2d4a6d; }

.badge { display: inline-block; font-size: .74rem; font-weight: 700; padding: 2px 9px; border-radius: 999px; letter-spacing: .2px; white-space: nowrap; }
.badge-pendiente { background: var(--amber-l); color: #7a5407; }
.badge-aprobado { background: var(--green-l); color: #1f5a41; }
.badge-rechazado { background: var(--red-l); color: #8a2f1f; }
.badge-neutral { background: #ecebe6; color: var(--ink-3); }
.badge-gold { background: var(--gold-l); color: #7a5c14; }
.badge-blue { background: var(--blue-l); color: #2d4a6d; }
.light { display: inline-flex; align-items: center; gap: 7px; font-size: .84rem; font-weight: 600; white-space: nowrap; }
.light i { width: 11px; height: 11px; border-radius: 50%; background: #b9bcc2; box-shadow: 0 0 0 3px rgba(0, 0, 0, .05); }
.light-verde i { background: var(--green); }
.light-ambar i { background: #e0a21b; }
.light-rojo i { background: var(--red); }
.light-verde { color: #1f5a41; } .light-ambar { color: #8a5f06; } .light-rojo { color: #8a2f1f; } .light-sin_datos { color: var(--muted); }

/* KPIs */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(168px, 1fr)); gap: 12px; }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); min-width: 0; }
.kpi .label { font-size: .76rem; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); font-weight: 600; }
.kpi .value { font-size: 1.3rem; font-weight: 650; margin-top: 4px; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi .sub { font-size: .8rem; color: var(--muted); margin-top: 2px; }
.kpi.tone-green { border-top: 3px solid var(--green); } .kpi.tone-amber { border-top: 3px solid #e0a21b; }
.kpi.tone-red { border-top: 3px solid var(--red); } .kpi.tone-gold { border-top: 3px solid var(--gold); } .kpi.tone-ink { border-top: 3px solid var(--ink); }
.neg { color: var(--red); } .pos { color: var(--green); }
.sectiontitle { font-size: .78rem; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); font-weight: 700; margin: 22px 0 8px; }

/* tablas */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); box-shadow: var(--shadow); }
.card .table-wrap { border: 0; box-shadow: none; border-radius: 0; }
table.table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.table th { text-align: left; font-size: .72rem; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); font-weight: 700; padding: 10px 12px; background: #faf8f3; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table th.num, .table td.num { text-align: right; }
.table td { padding: 10px 12px; border-bottom: 1px solid #efece5; vertical-align: top; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: #fcfbf8; }
.table tfoot td { font-weight: 700; background: #faf8f3; border-top: 1px solid var(--line); }
.table .title { font-weight: 600; color: var(--ink); }
.table td.projcell { min-width: 280px; }
.table .title a { color: var(--ink); }
.table .title a:hover { color: var(--gold-d); }
.table .sub { color: var(--muted); font-size: .8rem; }
tr.rejected td { opacity: .65; }
.clip { display: inline-flex; align-items: center; gap: 3px; color: var(--muted); font-size: .8rem; }
.clip svg { width: 14px; height: 14px; }
.clip.missing { color: #c58a12; white-space: nowrap; }
.acta-ok { color: var(--green); font-weight: 600; font-size: .8rem; }

/* barras */
.bar { position: relative; height: 8px; background: #ebe8df; border-radius: 999px; overflow: hidden; min-width: 48px; }
.bar > span { display: block; height: 100%; border-radius: 999px; background: var(--ink); }
.bar.gold > span { background: var(--gold); }
.bar.ok > span { background: var(--green); }
.bar.warn > span { background: #e0a21b; }
.bar.bad > span { background: var(--red); }
.barrow { display: flex; align-items: center; gap: 8px; }
.barrow .bar { flex: 1; }
.barrow small { min-width: 46px; text-align: right; font-variant-numeric: tabular-nums; font-size: .78rem; color: var(--ink-3); }
.pair { display: grid; gap: 5px; min-width: 150px; }
.pair .lbl { font-size: .7rem; color: var(--muted); width: 44px; }

/* alertas */
.alerts { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.alerts li { display: flex; gap: 10px; align-items: flex-start; padding: 9px 12px; border-radius: 8px; font-size: .9rem; border: 1px solid; }
.alerts li::before { content: ""; flex: 0 0 9px; height: 9px; border-radius: 50%; margin-top: 6px; }
.alerts .rojo { background: #fbeeea; border-color: #efc9c0; } .alerts .rojo::before { background: var(--red); }
.alerts .ambar { background: #fcf5e0; border-color: #f0e0ae; } .alerts .ambar::before { background: #e0a21b; }
.alerts .info { background: #f1f4f9; border-color: #d6dfec; } .alerts .info::before { background: var(--blue); }
.alerts .pcode { font-weight: 700; margin-right: 4px; }

/* pestañas */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin: 14px 0 20px; flex-wrap: wrap; }
.tabs a { padding: 9px 14px; color: var(--ink-3); font-weight: 600; font-size: .92rem; border-bottom: 3px solid transparent; margin-bottom: -1px; display: inline-flex; gap: 6px; align-items: center; }
.tabs a:hover { color: var(--ink); text-decoration: none; }
.tabs a.active { color: var(--ink); border-bottom-color: var(--gold); }
.tabs .count { background: var(--amber-l); color: #7a5407; border-radius: 999px; font-size: .72rem; padding: 0 7px; font-weight: 700; }

/* formularios */
.form { display: grid; gap: 14px; }
.row { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }
.field { display: grid; gap: 5px; align-content: start; min-width: 0; }
.field label, .lbl-t { font-size: .82rem; font-weight: 600; color: var(--ink-3); }
.field .hint { font-size: .78rem; color: var(--muted); }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], input[type=search], select, textarea {
  font: inherit; width: 100%; padding: 8px 10px; border: 1px solid #d3cfc3; border-radius: 8px; background: #fff; color: var(--ink); min-width: 0; }
textarea { min-height: 78px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(184, 146, 58, .45); border-color: var(--gold); }
input[type=file] { font: inherit; font-size: .88rem; }
.check { display: flex; gap: 8px; align-items: flex-start; font-size: .92rem; font-weight: 500; color: var(--ink); }
.check input { margin-top: 3px; accent-color: var(--gold-d); }
.moneyin { position: relative; }
.moneyin::before { content: "S/"; position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--muted); font-size: .85rem; }
.moneyin input { padding-left: 30px; text-align: right; font-variant-numeric: tabular-nums; }
.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; margin-bottom: 14px; }
.filters .field { min-width: 130px; }
.filters .field.grow { flex: 1; min-width: 190px; }
.formactions { display: flex; gap: 10px; align-items: center; margin-top: 4px; flex-wrap: wrap; }
.errors { background: var(--red-l); border: 1px solid #ebbcb1; color: #8a2f1f; border-radius: 8px; padding: 10px 14px; }
.errors ul { margin: 4px 0 0; padding-left: 18px; }
fieldset { border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 16px 14px; margin: 0; }
legend { font-size: .78rem; text-transform: uppercase; letter-spacing: .8px; font-weight: 700; color: var(--muted); padding: 0 6px; }
.membrow { display: flex; align-items: center; gap: 14px; padding: 6px 0; border-bottom: 1px dashed var(--line); flex-wrap: wrap; }
.membrow:last-child { border-bottom: 0; }
.membrow .who { flex: 1; min-width: 180px; }

dl.dl { display: grid; grid-template-columns: 210px minmax(0, 1fr); gap: 8px 16px; margin: 0; }
dl.dl dt { color: var(--muted); font-size: .85rem; font-weight: 600; }
dl.dl dd { margin: 0; overflow-wrap: anywhere; }

.legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: .8rem; color: var(--ink-3); margin-top: 6px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.chart { width: 100%; height: auto; display: block; }
.share { display: flex; height: 14px; border-radius: 999px; overflow: hidden; background: #ebe8df; margin-top: 4px; }
.share span { display: block; height: 100%; }
.empty { color: var(--muted); padding: 18px 4px; text-align: center; font-size: .92rem; }
.pager { display: flex; gap: 6px; align-items: center; justify-content: center; margin-top: 14px; }
.pager a, .pager span { padding: 5px 11px; border: 1px solid var(--line); border-radius: 7px; background: #fff; font-size: .85rem; color: var(--ink); }
.pager span.cur { background: var(--ink); color: #fff; border-color: var(--ink); }
.timeline { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.timeline li { padding-left: 14px; border-left: 3px solid var(--gold-l); font-size: .87rem; }
.timeline .when { color: var(--muted); font-size: .76rem; }
.pwbox { font-family: ui-monospace, Consolas, monospace; font-size: 1.5rem; letter-spacing: 1px; background: var(--gold-l); border: 1px dashed var(--gold); border-radius: 10px; padding: 14px 18px; text-align: center; user-select: all; }
.note { background: var(--blue-l); border: 1px solid #c1d1e6; color: #2d4a6d; border-radius: 8px; padding: 10px 14px; font-size: .9rem; }
.note.warn { background: var(--amber-l); border-color: #ead9a0; color: #7a5407; }
.decision { border: 1px solid var(--line); border-left: 4px solid var(--gold); border-radius: 8px; padding: 14px 16px; background: #fffdf7; }
.helpdoc h2 { margin: 22px 0 8px; font-family: var(--serif); font-size: 1.2rem; }
.helpdoc p, .helpdoc li { max-width: 78ch; }
.helpdoc code { background: #efece3; padding: 1px 6px; border-radius: 5px; font-size: .88em; }

/* ---------------------------------------------------------------- adaptable */
@media (max-width: 1100px) {
  .grid.wide, .grid.two, .grid.three { grid-template-columns: minmax(0, 1fr); }
  .main { padding: 22px 20px 50px; }
}
@media (max-width: 860px) {
  .shell { display: block; }
  .topbar { display: flex; align-items: center; justify-content: space-between; background: var(--ink); color: #fff; padding: 10px 14px; position: sticky; top: 0; z-index: 30; }
  .topbar .brand { border: 0; margin: 0; padding: 0; }
  .topbar button { background: rgba(255, 255, 255, .12); color: #fff; border: 0; border-radius: 8px; padding: 8px 12px; font: inherit; cursor: pointer; }
  .sidebar { display: none; position: fixed; inset: 52px 0 0 0; width: auto; height: auto; z-index: 25; }
  body.menu-open .sidebar { display: flex; }
  .sidebar .brand { display: none; }
  .main { padding: 18px 14px 50px; }
  h1 { font-size: 1.4rem; }
  dl.dl { grid-template-columns: 1fr; gap: 2px 0; }
  dl.dl dd { margin-bottom: 8px; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .hide-sm { display: none; }
  .table td.projcell { min-width: 0; }
  .kpi .value { font-size: 1.02rem; }
  .tabs { flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .tabs a { white-space: nowrap; }
}
@media print {
  .sidebar, .topbar, .actions, .tabs, .filters, .formactions { display: none !important; }
  body { background: #fff; }
  .main { padding: 0; }
  .card, .kpi, .table-wrap { box-shadow: none; }
}
