/* Panel de Odai Timbrado. Colores del logo de Odai: morado #8a64de y azul #54aaf6. El morado de los
   botones es un tono más oscuro para que el texto blanco se lea bien. Sin JavaScript. */
:root {
  --bg: #f4f3f8; --panel: #ffffff; --text: #1f2933; --muted: #5b6673; --line: #dfdde8; --line-soft: #eceaf2;
  --brand: #7350d0; --brand-hover: #5a3bb0; --brand-text: #ffffff; --logo: #8a64de; --accent: #54aaf6;
  --brand-soft: #f1edfb; --accent-soft: #e6f2fe;
  --ok: #1e7b45; --warn: #8a5800; --bad: #b42318; --info: #1f6fb8;
  --ok-bg: #e6f4ea; --warn-bg: #fff4dc; --bad-bg: #fde8e7; --info-bg: #e6f2fe;
}
* { box-sizing: border-box; }
body { margin: 0; font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--text); }
a { color: var(--brand); }
a:hover { color: var(--brand-hover); }
code { font-size: 13px; }

/* ---------- barra superior ---------- */
.topbar { background: #fff; border-bottom: 3px solid var(--logo); }
.topbar .bar { display: flex; flex-wrap: wrap; align-items: center; gap: 2px; padding: 0 16px; min-height: 52px; }
.brand { display: flex; align-items: center; gap: 8px; margin-right: 18px; text-decoration: none; }
.brand img { display: block; height: 24px; width: auto; }
.brand span { font-weight: 600; color: var(--muted); }
.topbar nav { display: flex; flex-wrap: wrap; flex: 1; }
.topbar nav a { color: var(--text); text-decoration: none; padding: 15px 12px; }
.topbar nav a:hover { background: var(--brand-soft); color: var(--text); }
.topbar nav a.active { color: var(--brand); font-weight: 600; box-shadow: inset 0 -3px 0 var(--accent); }
.usermenu { position: relative; }
.usermenu summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: 8px; padding: 10px 4px; }
.usermenu summary::-webkit-details-marker { display: none; }
.avatar { width: 28px; height: 28px; border-radius: 50%; background: var(--brand); color: #fff; display: inline-flex; align-items: center; justify-content: center; font-weight: 700; text-transform: uppercase; }
.usermenu .menu { position: absolute; right: 0; top: 100%; z-index: 10; min-width: 200px; background: #fff; border: 1px solid var(--line); border-radius: 6px; box-shadow: 0 8px 24px rgba(31,41,51,.14); padding: 6px 0; }
.usermenu .menu a, .usermenu .menu button { display: block; width: 100%; text-align: left; padding: 8px 14px; color: var(--text); text-decoration: none; background: none; border: 0; border-radius: 0; font: inherit; cursor: pointer; }
.usermenu .menu a:hover, .usermenu .menu button:hover { background: var(--brand-soft); }
.usermenu .menu small { display: block; padding: 6px 14px 2px; border-top: 1px solid var(--line-soft); margin-top: 4px; }
.usermenu form { margin: 0; }
.menu-toggle, .menu-btn { display: none; }

/* ---------- panel de control (título, botones, buscador) ---------- */
.control { background: #fff; border-bottom: 1px solid var(--line); padding: 10px 16px; display: flex; flex-wrap: wrap; gap: 10px 12px; align-items: center; }
.control h1 { font-size: 19px; font-weight: 500; margin: 0; flex: 1 1 auto; min-width: 0; }
.control h1 a { text-decoration: none; }
.control h1 .sep { color: var(--muted); margin: 0 6px; }
.control .search { display: flex; flex: 0 1 460px; min-width: 220px; border: 1px solid #c9c6d6; border-radius: 4px; background: #fff; }
.control .search input { border: 0; flex: 1; min-width: 60px; }
.control .search button { border: 0; border-left: 1px solid #c9c6d6; border-radius: 0 4px 4px 0; background: #fff; color: var(--brand); }
.control .count { color: var(--muted); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; padding: 10px 16px 0; }
.chips a { padding: 5px 12px; border-radius: 16px; border: 1px solid #c9c6d6; color: var(--text); text-decoration: none; background: #fff; }
.chips a.on { background: var(--accent-soft); border-color: var(--accent); color: #17558f; font-weight: 600; }
.chips .chip-group { align-self: center; color: var(--muted, #6b6880); font-size: 13px; }
.chips .chip-sep { width: 12px; }
.control .search .tag { align-self: center; margin-left: 6px; padding: 2px 8px; border-radius: 3px; background: var(--brand-soft);
  color: var(--brand-hover); text-decoration: none; font-size: 13px; white-space: nowrap; }
.control .search .tag span { margin-left: 4px; font-weight: 700; }

main { padding: 16px; }
footer.version { padding: 8px 16px 24px; color: var(--muted); font-size: 13px; text-align: center; }
footer.version b { color: var(--text); font-weight: 600; }
h1 { font-size: 20px; margin: 4px 0 14px; }
h2 { font-size: 16px; margin: 0 0 12px; }

/* ---------- ficha (como un formulario de Odoo) ---------- */
.sheet { max-width: 1160px; margin: 0 auto; background: var(--panel); border: 1px solid var(--line); border-radius: 6px; }
.sheet-bar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 10px 16px; border-bottom: 1px solid var(--line-soft); }
.sheet-bar .status { margin-left: auto; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.smart { display: flex; flex-wrap: wrap; justify-content: flex-end; border-bottom: 1px solid var(--line-soft); }
.smart a, .smart span.box { display: flex; flex-direction: column; align-items: center; justify-content: center; min-width: 120px; padding: 8px 16px; border-left: 1px solid var(--line-soft); color: var(--text); text-decoration: none; }
.smart a:hover { background: var(--brand-soft); }
.smart b { font-size: 18px; color: var(--brand); }
.smart span { font-size: 12px; color: var(--muted); }
.sheet-body { padding: 18px 24px 24px; }
.title-field label { font-size: 12px; color: var(--muted); }
.title-field input { width: 100%; font-size: 24px; font-weight: 600; border: 0; border-bottom: 1px solid #c9c6d6; border-radius: 0; padding: 2px 0; }
.title-field h2 { font-size: 24px; margin: 0; }
.fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 40px; margin-top: 14px; }
.field { display: grid; grid-template-columns: 170px minmax(0, 1fr); gap: 8px; align-items: center; padding: 4px 0; }
.field > label, .field > .label { font-size: 14px; color: var(--text); font-weight: 600; }
.field input:not([type=checkbox]):not([type=radio]), .field select, .field textarea { width: 100%; border: 0; border-bottom: 1px solid #c9c6d6; border-radius: 0; padding: 5px 0; background: transparent; }
.field input:focus, .field select:focus, .field textarea:focus { outline: none; border-bottom-color: var(--brand); }
.field .help { grid-column: 2; font-size: 12px; color: var(--muted); margin-top: -4px; }
.field.wide { grid-column: 1 / -1; }
.sheet .note { font-size: 13px; color: var(--muted); margin: 8px 0 0; }
.save-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }

/* Campos que dependen del tipo de cliente: se muestran sin JavaScript según el tipo elegido. */
form:has(select[name=kind] option[value=direct]:checked) .pool-only,
form:has(select[name=kind] option[value=direct]:checked) .distributor-only,
form:has(select[name=kind] option[value=distributor]:checked) .direct-only { display: none; }

.segmented { display: inline-flex; border: 1px solid #c9c6d6; border-radius: 4px; overflow: hidden; }
.segmented label { margin: 0; padding: 6px 14px; color: var(--muted); cursor: pointer; font-size: 14px; }
.segmented input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.segmented label:has(input:checked) { background: var(--brand); color: #fff; font-weight: 600; }
.segmented label:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: -2px; }

/* ---------- pestañas ---------- */
.tabs { display: flex; flex-wrap: wrap; border-bottom: 1px solid var(--line); margin: 22px 0 14px; }
.tabs a { padding: 8px 14px; color: var(--brand); text-decoration: none; border: 1px solid transparent; border-bottom: 0; margin-bottom: -1px; border-radius: 4px 4px 0 0; }
.tabs a:hover { background: var(--brand-soft); }
.tabs a.on { color: var(--text); font-weight: 600; background: #fff; border-color: var(--line); border-top: 3px solid var(--accent); }

/* ---------- configuración por secciones ---------- */
.settings { display: flex; flex-wrap: wrap; align-items: stretch; min-height: calc(100vh - 160px); }
.side-nav { flex: 1 1 200px; max-width: 230px; background: #fff; border-right: 1px solid var(--line); padding: 10px 0; display: flex; flex-direction: column; }
.side-nav a { padding: 10px 18px; color: var(--text); text-decoration: none; border-right: 3px solid transparent; }
.side-nav a:hover { background: var(--brand-soft); }
.side-nav a.on { background: var(--brand-soft); border-right-color: var(--accent); font-weight: 600; }
.settings-body { flex: 999 1 560px; min-width: 0; padding: 18px 24px; }
.settings-body h2 { background: #ebe9f2; padding: 8px 12px; border-radius: 4px; font-size: 15px; }
.setting-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px 40px; margin-bottom: 18px; }
.setting { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.setting > label, .setting > .label { font-weight: 600; color: var(--text); font-size: 14px; }
.setting > small { color: var(--muted); }
.setting input:not([type=checkbox]), .setting select, .setting textarea { width: 100%; }
.setting.wide { grid-column: 1 / -1; }

/* ---------- piezas generales ---------- */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 16px; margin-bottom: 16px; }
.grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(min(300px, 100%), 1fr)); }
.grid > *, .panel { min-width: 0; }
.stats { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); margin-bottom: 16px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 12px 14px; }
.stat b { display: block; font-size: 24px; color: var(--brand); }
.stat b a { text-decoration: none; }
.stat span { color: var(--muted); font-size: 13px; }
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table-wrap table { min-width: 560px; }
.list { background: #fff; border: 1px solid var(--line); border-radius: 6px; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line-soft); vertical-align: top; }
th { font-size: 13px; color: var(--text); font-weight: 600; background: #faf9fc; border-bottom-color: var(--line); }
tbody tr:hover td, table tr:hover td { background: #fbfaff; }
td.num, th.num { text-align: right; }
td.add a { text-decoration: none; }
dl { display: grid; grid-template-columns: max-content 1fr; gap: 6px 14px; margin: 0; }
dt { color: var(--muted); }
dd { margin: 0; }
form.inline { display: inline; }
.form-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: end; margin-bottom: 8px; }
label { display: block; font-size: 13px; color: var(--muted); }
input, select, textarea { font: inherit; padding: 6px 8px; border: 1px solid #c9c6d6; border-radius: 4px; background: #fff; color: var(--text); max-width: 100%; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent-soft); border-color: var(--brand); }
textarea { width: 100%; }
button, .button { font: inherit; padding: 6px 14px; border-radius: 4px; border: 1px solid var(--brand); background: var(--brand); color: #fff; cursor: pointer; text-decoration: none; display: inline-block; }
button:hover, .button:hover { background: var(--brand-hover); border-color: var(--brand-hover); color: #fff; }
button.secondary, .button.secondary { background: #fff; color: var(--text); border-color: #c9c6d6; }
button.secondary:hover, .button.secondary:hover { background: var(--brand-soft); color: var(--text); border-color: #c9c6d6; }
button.danger, .button.danger { background: var(--bad); border-color: var(--bad); color: #fff; }
.actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.flash { padding: 10px 12px; border-radius: 6px; margin-bottom: 10px; border: 1px solid transparent; }
.flash.success { background: var(--ok-bg); color: var(--ok); border-color: #b7dfc3; }
.flash.warning { background: var(--warn-bg); color: var(--warn); border-color: #f1d79a; }
.flash.danger { background: var(--bad-bg); color: var(--bad); border-color: #f4b9b4; }
.flash.info { background: var(--info-bg); color: var(--info); border-color: #b5d6f5; }
.badge { display: inline-block; padding: 1px 8px; border-radius: 10px; font-size: 12px; background: #eeedf3; color: var(--muted); white-space: nowrap; }
.badge.ok { background: var(--ok-bg); color: var(--ok); }
.badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.bad { background: var(--bad-bg); color: var(--bad); }
.badge.kind { background: var(--brand-soft); color: var(--brand-hover); }
.env { font-size: 12px; font-weight: 700; padding: 2px 8px; border-radius: 10px; }
.env.test { background: #ffd166; color: #3d2c00; }
.env.production { background: #c1f0c9; color: #0d3b1a; }
.secret { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 15px; background: #fff; border: 2px dashed var(--warn); padding: 10px; word-break: break-all; user-select: all; }
.muted { color: var(--muted); }
small { color: var(--muted); }
.login { max-width: 360px; margin: 60px auto; }
.login img { display: block; height: 34px; margin: 0 auto 14px; }
.login input { width: 100%; margin-bottom: 10px; }
.login button { width: 100%; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Celulares y tabletas: menú plegable, campos en una columna, tablas con desplazamiento. */
@media (max-width: 900px) {
  .brand { margin-right: auto; }
  .menu-btn { display: inline-block; order: 2; padding: 6px 12px; border: 1px solid #c9c6d6; border-radius: 4px; cursor: pointer; user-select: none; color: var(--text); font-size: 14px; }
  .topbar nav { order: 4; display: none; flex-basis: 100%; flex-direction: column; padding-bottom: 6px; }
  .topbar nav a { padding: 10px 12px; border-top: 1px solid var(--line-soft); }
  .topbar nav a.active { box-shadow: inset 3px 0 0 var(--accent); }
  .menu-toggle:checked ~ nav { display: flex; }
  .usermenu { order: 3; }
  .fields, .setting-grid { grid-template-columns: 1fr; }
  .side-nav { max-width: none; flex-basis: 100%; flex-direction: row; flex-wrap: wrap; border-right: 0; border-bottom: 1px solid var(--line); padding: 0; }
  .side-nav a { border-right: 0; border-bottom: 3px solid transparent; }
  .side-nav a.on { border-bottom-color: var(--accent); }
  main { padding: 12px; }
  .panel { padding: 12px; }
  .sheet-body { padding: 14px; }
}
@media (max-width: 600px) {
  body { font-size: 16px; }
  .field { grid-template-columns: 1fr; gap: 2px; }
  .field .help { grid-column: 1; }
  .smart a, .smart span.box { flex: 1 1 45%; min-width: 0; }
  dl { grid-template-columns: 1fr; } dt { margin-top: 6px; }
  input:not([type=checkbox]):not([type=radio]), select, textarea { width: 100%; font-size: 16px; }
  .form-row > div { width: 100%; }
  .form-row > button, .form-row > .button, .actions > button, .actions > .button { width: 100%; text-align: center; }
  .control .search { flex-basis: 100%; }
  .stats { grid-template-columns: 1fr 1fr; }
  .grid { grid-template-columns: 1fr; }
}
