/* Registro de Proveedores — estilos propios (sin librerías externas). Misma identidad que Control de Proyectos. */
: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; }
p { margin: 0 0 .6rem; }
code { background: #efece3; padding: 1px 6px; border-radius: 5px; font-size: .88em; }
.muted { color: var(--muted); }
.small { font-size: .84rem; }
.nowrap { white-space: nowrap; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.center { text-align: center; }
.mt { margin-top: 1.2rem; }
.mb { margin-bottom: 1.2rem; }
.hidden, [hidden] { display: none !important; }
.neg { color: var(--red); } .pos { color: var(--green); }

/* ---------------------------------------------------------------- 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 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; }
.sidebar .brand { flex-direction: column; align-items: flex-start; gap: 12px; }
.brand img.logo { width: 150px; height: auto; filter: brightness(0) invert(1); }
.brand img.mark { width: 34px; height: 34px; filter: brightness(0) invert(1); }
.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); }
.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; }
.linkbtn-dark { background: none; border: 0; padding: 0; cursor: pointer; font-family: inherit; color: var(--red); }
.linkbtn-dark:hover { 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; }
.cardhead { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.cardhead h2 { margin: 0; }
.grid { display: grid; gap: 16px; align-content: start; }
.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.wide { grid-template-columns: minmax(0, 2fr) 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-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; }
form.inline-form { display: flex; gap: 8px; align-items: flex-end; flex-wrap: wrap; }
form.inline-form .field { min-width: 150px; }

.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-warn { background: var(--amber-l); color: #7a5407; }
.badge-ok { background: var(--green-l); color: #1f5a41; }
.badge-bad { background: var(--red-l); color: #8a2f1f; }
.badge-neutral { background: #ecebe6; color: var(--ink-3); }
.badge-blue { background: var(--blue-l); color: #2d4a6d; }
.stars { color: var(--gold); letter-spacing: 1px; margin-left: 6px; }

/* KPIs */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 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; 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); }
.sectiontitle { font-size: .78rem; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); font-weight: 700; margin: 26px 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 { 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; }
.table .title a { color: var(--ink); } .table .title a:hover { color: var(--gold-d); }
.table .sub { color: var(--muted); font-size: .8rem; }
.table td.projcell { min-width: 260px; }
.table td.empty { text-align: center; }
tr.rejected td { opacity: .6; }
tr.best td { background: #f3faf6; }
.clip { display: inline-flex; align-items: center; gap: 3px; color: var(--muted); font-size: .8rem; vertical-align: middle; }
.clip svg { width: 14px; height: 14px; }
.clip.missing { color: #c58a12; white-space: nowrap; }

/* ranking con barras (HTML, se adapta a cualquier ancho) */
.rank { list-style: none; margin: 0; padding: 0; display: grid; gap: 14px; }
.rank li { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 12px; align-items: baseline; }
.rank-label { min-width: 0; font-weight: 600; }
.rank-label a { color: var(--ink); } .rank-label a:hover { color: var(--gold-d); }
.rank-label small { display: block; font-weight: 400; color: var(--muted); font-size: .78rem; }
.rank-value { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.rank-value small { display: block; color: var(--muted); font-size: .78rem; }
.rank-track { grid-column: 1 / -1; grid-row: 2; height: 8px; background: #ebe8df; border-radius: 4px; overflow: hidden; }
.rank-track span { display: block; height: 100%; background: var(--gold); border-radius: 0 4px 4px 0; }
.rank li > .rank-value { grid-row: 1; grid-column: 2; }

/* gráfico SVG */
.chart { width: 100%; height: auto; display: block; }
.chart-grid { stroke: var(--line); stroke-width: 1; }
.chart-axis { stroke: #c9c5b8; stroke-width: 1; }
.chart-tick { fill: var(--muted); font-size: 11px; }
.chart-value { fill: var(--ink-3); font-size: 11px; font-weight: 600; }
.chart-bar { fill: var(--ink); }
.chart-hit { fill: transparent; }
.chart-col:hover .chart-bar { fill: var(--gold-d); }
.chart-col:hover .chart-hit { fill: rgba(184, 146, 58, .08); }

/* 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; }
.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; }
.total-preview { padding: 8px 10px; border: 1px dashed #cfcabd; border-radius: 8px; background: #faf8f3; text-align: right; font-weight: 700; 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: 210px; }
.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; background: var(--card); }
legend { font-size: .78rem; text-transform: uppercase; letter-spacing: .8px; font-weight: 700; color: var(--muted); padding: 0 6px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { cursor: pointer; }
.chip input { position: absolute; opacity: 0; pointer-events: none; }
.chip span, .chip-ro { display: inline-block; padding: 5px 12px; border: 1px solid #d3cfc3; border-radius: 999px; font-size: .86rem; background: #fff; }
.chip input:checked + span { background: var(--gold-l); border-color: var(--gold); font-weight: 600; }
.chip input:focus-visible + span { outline: 2px solid var(--gold); }
.chip-ro { background: var(--gold-l); border-color: #dcc98f; margin: 0 6px 6px 0; }

dl.dl { display: grid; grid-template-columns: 170px 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; }

/* archivos */
.files { list-style: none; margin: 0 0 14px; padding: 0; }
.files li { display: flex; justify-content: space-between; gap: 12px; padding: 9px 0; border-bottom: 1px solid #efece5; }
.files li:last-child { border-bottom: 0; }
.files .fname { min-width: 0; overflow-wrap: anywhere; }
.files .fact { display: flex; gap: 10px; align-items: flex-start; white-space: nowrap; }
.uploadform { display: grid; gap: 10px; padding-top: 12px; border-top: 1px dashed var(--line); }

.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); }
.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; }
.rolehelp { margin: 0; padding-left: 18px; font-size: .84rem; color: var(--ink-3); }
.rolehelp li { margin-bottom: 4px; }

/* mostrar/ocultar contraseña */
.pwwrap { position: relative; display: block; }
.pwwrap input { padding-right: 46px; }
.pwtoggle { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); display: flex; background: none; border: 0; padding: 6px; border-radius: 6px; color: var(--muted); cursor: pointer; }
.pwtoggle:hover, .pwtoggle:focus-visible { color: var(--ink); background: rgba(0, 0, 0, .05); outline: none; }

/* ---------------------------------------------------------------- adaptable */
@media (max-width: 1100px) {
  .grid.wide, .grid.two { 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.05rem; }
}
@media print {
  .sidebar, .topbar, .actions, .filters, .formactions, .uploadform { display: none !important; }
  body { background: #fff; }
  .main { padding: 0; }
  .card, .kpi, .table-wrap { box-shadow: none; }
}
