/* CAS Inventory Manager - estilos autoalojados (sin CDN). Colores sustituibles por los oficiales. */
:root {
  --brand: #123047;
  --brand-2: #1f5f7a;
  --accent: #1f7a8c;
  --bg: #f4f6f8;
  --surface: #ffffff;
  --text: #1d2733;
  --muted: #5f6b78;
  --border: #dde3e9;
  --ok: #1b7f4c;
  --ok-bg: #e6f4ec;
  --warn: #9a6200;
  --warn-bg: #fff4dc;
  --err: #b42318;
  --err-bg: #fdeceb;
  --info-bg: #e8f1f8;
  --radius: 8px;
  --side: 248px;
  font-size: 15px;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body { font-family: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif; background: var(--bg); color: var(--text); line-height: 1.45; }
a { color: var(--brand-2); }
a:hover { color: var(--accent); }
h1 { font-size: 1.45rem; margin: 0 0 .25rem; }
h2 { font-size: 1.15rem; margin: 1.4rem 0 .6rem; }
h3 { font-size: 1rem; margin: 1rem 0 .5rem; }
code, .mono { font-family: Consolas, "Cascadia Mono", Menlo, monospace; font-size: .9em; }
small, .muted { color: var(--muted); }

/* Estructura */
.layout { display: flex; min-height: 100vh; }
.sidebar { width: var(--side); background: var(--brand); color: #dce6ee; flex-shrink: 0; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.brand { padding: 1rem 1.1rem; font-weight: 700; color: #fff; font-size: 1.05rem; letter-spacing: .2px; border-bottom: 1px solid rgba(255,255,255,.08); }
.brand small { display: block; color: #9fb4c4; font-weight: 400; font-size: .75rem; }
.nav { padding: .5rem 0 1rem; }
.nav .group { padding: .9rem 1.1rem .3rem; font-size: .72rem; text-transform: uppercase; letter-spacing: .08em; color: #8ea6b8; }
.nav a { display: block; padding: .45rem 1.1rem; color: #dce6ee; text-decoration: none; border-left: 3px solid transparent; }
.nav a:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav a.active { background: rgba(255,255,255,.1); border-left-color: #5cc2d6; color: #fff; }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { background: var(--surface); border-bottom: 1px solid var(--border); padding: .55rem 1.2rem; display: flex; align-items: center; gap: .8rem; flex-wrap: wrap; position: sticky; top: 0; z-index: 5; }
.topbar .tenant { font-weight: 600; color: var(--brand); }
.topbar .tenant .badge { margin-left: .3rem; }
.topbar form.search { flex: 1; min-width: 160px; max-width: 420px; }
.topbar .spacer { flex: 1; }
.content { padding: 1.2rem; max-width: 1400px; width: 100%; }
.menu-toggle { display: none; background: none; border: 1px solid var(--border); border-radius: 6px; padding: .3rem .55rem; font-size: 1.1rem; cursor: pointer; }
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.page-head .actions { display: flex; gap: .5rem; flex-wrap: wrap; }

/* Componentes */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem 1.1rem; margin-bottom: 1rem; }
.card > h2:first-child, .card > h3:first-child { margin-top: 0; }
.grid { display: grid; gap: 1rem; }
.grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: .9rem 1rem; text-decoration: none; color: inherit; display: block; }
.kpi .n { font-size: 1.7rem; font-weight: 700; color: var(--brand); }
.kpi .l { color: var(--muted); font-size: .85rem; }
.kpi.warn .n { color: var(--warn); }
.kpi.err .n { color: var(--err); }
.bar { display: flex; align-items: center; gap: .5rem; margin: .25rem 0; font-size: .9rem; }
.bar .label { width: 42%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar .track { flex: 1; background: #e9eef2; border-radius: 4px; height: 10px; }
.bar .fill { background: var(--accent); height: 10px; border-radius: 4px; }
.bar .val { width: 3rem; text-align: right; color: var(--muted); }

.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { padding: .5rem .6rem; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
th { background: #f0f3f6; font-weight: 600; color: #3c4a57; white-space: nowrap; }
tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #f9fbfc; }
td.num, th.num { text-align: right; }
table.kv th { width: 34%; background: transparent; font-weight: 600; white-space: normal; }

.badge { display: inline-block; padding: .1rem .5rem; border-radius: 999px; font-size: .75rem; font-weight: 600; background: #e9eef2; color: #3c4a57; white-space: nowrap; }
.badge.ok { background: var(--ok-bg); color: var(--ok); }
.badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.err { background: var(--err-bg); color: var(--err); }
.badge.info { background: var(--info-bg); color: var(--brand-2); }

.alert { padding: .7rem .9rem; border-radius: var(--radius); margin-bottom: .8rem; border: 1px solid transparent; }
.alert.success { background: var(--ok-bg); border-color: #b9e0c9; }
.alert.error { background: var(--err-bg); border-color: #f4c3bf; }
.alert.info { background: var(--info-bg); border-color: #c6dbeb; }
.alert.warn { background: var(--warn-bg); border-color: #f1d9a6; }

.btn { display: inline-block; padding: .45rem .9rem; border-radius: 6px; border: 1px solid var(--brand-2); background: var(--brand-2); color: #fff; text-decoration: none; cursor: pointer; font-size: .9rem; line-height: 1.3; font-family: inherit; }
.btn:hover { background: var(--brand); color: #fff; }
.btn.secondary { background: #fff; color: var(--brand-2); }
.btn.secondary:hover { background: #eef4f8; }
.btn.danger { background: var(--err); border-color: var(--err); }
.btn.small { padding: .2rem .55rem; font-size: .8rem; }
.btn:disabled { opacity: .6; cursor: not-allowed; }

form.inline { display: inline; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: .8rem 1rem; }
.field { display: flex; flex-direction: column; gap: .25rem; }
.field.wide { grid-column: 1 / -1; }
label { font-weight: 600; font-size: .85rem; color: #3c4a57; }
input[type=text], input[type=email], input[type=password], input[type=date], input[type=number], input[type=search], input[type=time], select, textarea {
  width: 100%; padding: .45rem .55rem; border: 1px solid #c5ced7; border-radius: 6px; font: inherit; background: #fff; color: var(--text);
}
textarea { min-height: 4.5rem; }
input:focus, select:focus, textarea:focus { outline: 2px solid #9cd3df; border-color: var(--accent); }
.field .err { color: var(--err); font-size: .8rem; }
.checkbox { display: flex; gap: .45rem; align-items: center; font-weight: 400; }
.filters { display: flex; gap: .5rem; flex-wrap: wrap; align-items: flex-end; margin-bottom: .8rem; }
.filters .field { min-width: 150px; }
.pager { display: flex; gap: .4rem; align-items: center; margin: .8rem 0; flex-wrap: wrap; }

.tabs { display: flex; gap: .2rem; border-bottom: 2px solid var(--border); margin-bottom: 1rem; overflow-x: auto; }
.tabs a { padding: .5rem .85rem; text-decoration: none; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -2px; white-space: nowrap; }
.tabs a.active { color: var(--brand); border-bottom-color: var(--accent); font-weight: 600; }
details { margin: .4rem 0; }
details summary { cursor: pointer; font-weight: 600; }
.prov { font-size: .78rem; color: var(--muted); }
.stale { background: var(--warn-bg); }
.diff-added { background: #eaf7ef; }
.diff-removed { background: #fdeeed; }
.diff-changed { background: #fff8e6; }
.secret-box { font-family: Consolas, Menlo, monospace; background: #0f2233; color: #d8f3f8; padding: .8rem; border-radius: 6px; word-break: break-all; user-select: all; }
.progress { background: #e9eef2; border-radius: 6px; height: 14px; overflow: hidden; }
.progress > div { background: var(--accent); height: 14px; width: 0; transition: width .3s; }
.guest { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 1rem; background: linear-gradient(160deg, #123047, #1f5f7a); }
.guest .card { width: 100%; max-width: 420px; }
.guest .brand-big { color: var(--brand); font-weight: 700; font-size: 1.25rem; margin-bottom: .2rem; }
.empty { padding: 1.4rem; text-align: center; color: var(--muted); }
.hide { display: none !important; }

@media (max-width: 900px) {
  .grid.cols-3, .grid.cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid.cols-2 { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; top: 0; z-index: 20; transform: translateX(-100%); transition: transform .2s; }
  body.nav-open .sidebar { transform: translateX(0); box-shadow: 0 0 0 100vmax rgba(0,0,0,.35); }
  .menu-toggle { display: inline-block; }
  .content { padding: .8rem; }
  .bar .label { width: 50%; }
}
@media (max-width: 520px) {
  .grid.cols-3, .grid.cols-4 { grid-template-columns: 1fr 1fr; }
  table.responsive thead { display: none; }
  table.responsive tr { display: block; border-bottom: 1px solid var(--border); padding: .4rem 0; }
  table.responsive td { display: flex; justify-content: space-between; gap: .8rem; border: none; padding: .25rem .6rem; }
  table.responsive td::before { content: attr(data-label); font-weight: 600; color: var(--muted); }
}
@media print { .sidebar, .topbar, .actions, .filters, .btn { display: none !important; } .content { padding: 0; } }
.narrow { max-width: 560px; }
.mt { margin-top: .7rem; }
.mt0 { margin-top: 0; }
meter { flex: 1; height: 12px; }
progress.wide-progress { width: 100%; height: 16px; }
pre.mono { white-space: pre-wrap; word-break: break-word; background: #f6f8fa; padding: .6rem; border-radius: 6px; }
