/* Consola de soporte remoto: estilo macOS (Ajustes del Sistema), claro y oscuro automaticos. */
:root {
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI Variable Text", "Segoe UI", system-ui, sans-serif;
  --font-display: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI Variable Display", "Segoe UI", system-ui, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Code", Consolas, monospace;

  --bg: #f5f5f7;
  --window: #ffffff;
  --sidebar: rgba(236, 236, 240, 0.78);
  --sidebar-solid: #ececf0;
  --card: #ffffff;
  --card-hover: #f7f7f9;
  --field: #ffffff;
  --field-border: rgba(0, 0, 0, 0.14);
  --hairline: rgba(0, 0, 0, 0.09);
  --text: #1d1d1f;
  --text-2: #6e6e73;
  --text-3: #a1a1a6;
  --accent: #007aff;
  --accent-hover: #0066d6;
  --accent-soft: rgba(0, 122, 255, 0.12);
  --on-accent: #ffffff;
  --green: #28cd41;
  --green-ink: #1a8a2c;
  --orange: #ff9500;
  --red: #ff3b30;
  --red-ink: #d70015;
  --purple: #af52de;
  --teal: #30b0c7;
  --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.06), 0 0 0 0.5px rgba(0, 0, 0, 0.06);
  --shadow-2: 0 10px 40px rgba(0, 0, 0, 0.18), 0 0 0 0.5px rgba(0, 0, 0, 0.1);
  --scrim: rgba(0, 0, 0, 0.22);
  --radius: 12px;
  --radius-s: 8px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1c1c1e;
    --window: #1e1e20;
    --sidebar: rgba(44, 44, 48, 0.78);
    --sidebar-solid: #2a2a2e;
    --card: #2c2c2e;
    --card-hover: #333336;
    --field: #1c1c1e;
    --field-border: rgba(255, 255, 255, 0.14);
    --hairline: rgba(255, 255, 255, 0.09);
    --text: #f5f5f7;
    --text-2: #a1a1a6;
    --text-3: #6e6e73;
    --accent: #0a84ff;
    --accent-hover: #409cff;
    --accent-soft: rgba(10, 132, 255, 0.2);
    --green: #30d158;
    --green-ink: #30d158;
    --orange: #ff9f0a;
    --red: #ff453a;
    --red-ink: #ff6961;
    --shadow-1: 0 0 0 0.5px rgba(255, 255, 255, 0.08);
    --shadow-2: 0 10px 40px rgba(0, 0, 0, 0.6), 0 0 0 0.5px rgba(255, 255, 255, 0.12);
    --scrim: rgba(0, 0, 0, 0.45);
    --seg-on: #636366;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #1c1c1e; --window: #1e1e20; --sidebar: rgba(44, 44, 48, 0.78); --sidebar-solid: #2a2a2e;
  --card: #2c2c2e; --card-hover: #333336; --field: #1c1c1e; --field-border: rgba(255, 255, 255, 0.14);
  --hairline: rgba(255, 255, 255, 0.09); --text: #f5f5f7; --text-2: #a1a1a6; --text-3: #6e6e73;
  --accent: #0a84ff; --accent-hover: #409cff; --accent-soft: rgba(10, 132, 255, 0.2);
  --green: #30d158; --green-ink: #30d158; --orange: #ff9f0a; --red: #ff453a; --red-ink: #ff6961;
  --shadow-1: 0 0 0 0.5px rgba(255, 255, 255, 0.08);
  --shadow-2: 0 10px 40px rgba(0, 0, 0, 0.6), 0 0 0 0.5px rgba(255, 255, 255, 0.12);
  --scrim: rgba(0, 0, 0, 0.45); --seg-on: #636366; color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font: 13.5px/1.45 var(--font);
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
button, input, select, textarea { font: inherit; color: inherit; }
svg.i { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.7;
  stroke-linecap: round; stroke-linejoin: round; }
[hidden] { display: none !important; }

/* ------------------------------------------------------------------ estructura */
.app { display: grid; grid-template-columns: 236px 1fr; height: 100vh; }
.sidebar {
  background: var(--sidebar);
  backdrop-filter: saturate(180%) blur(30px);
  -webkit-backdrop-filter: saturate(180%) blur(30px);
  border-right: 0.5px solid var(--hairline);
  display: flex; flex-direction: column; padding: 18px 10px 12px; gap: 2px; overflow-y: auto;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 18px; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center; color: #fff;
  background: linear-gradient(160deg, #3d9bff, #0055d4); box-shadow: 0 2px 6px rgba(0, 85, 212, 0.35);
}
.brand-mark svg { width: 20px; height: 20px; stroke-width: 2; }
.brand-name { font: 600 14px/1.2 var(--font-display); }
.brand-sub { font-size: 11.5px; color: var(--text-2); }
.nav-label { font-size: 11px; font-weight: 600; color: var(--text-3); padding: 14px 10px 4px; }
.nav a {
  display: flex; align-items: center; gap: 10px; padding: 6px 10px; border-radius: 7px; color: var(--text);
  text-decoration: none; font-weight: 500; cursor: default; user-select: none;
}
.nav a:hover { background: rgba(127, 127, 127, 0.1); }
.nav a.active { background: var(--accent); color: var(--on-accent); }
.nav a .badge { margin-left: auto; font-size: 11px; color: var(--text-2); font-variant-numeric: tabular-nums; }
.nav a.active .badge { color: rgba(255, 255, 255, 0.85); }
.nav-icon { width: 24px; height: 24px; border-radius: 6px; display: grid; place-items: center; color: #fff; flex: none; }
.nav-icon svg { width: 15px; height: 15px; stroke-width: 2; }
.sidebar-foot { margin-top: auto; padding-top: 12px; }
.me {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 9px; cursor: default;
}
.me:hover { background: rgba(127, 127, 127, 0.1); }
.avatar {
  width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; flex: none;
  font: 600 12px var(--font); color: #fff; background: linear-gradient(160deg, #a0a0a8, #6e6e78);
}
.me-name { font-weight: 600; line-height: 1.2; }
.me-role { font-size: 11.5px; color: var(--text-2); }

.main { overflow-y: auto; background: var(--window); }
.page { max-width: 1120px; margin: 0 auto; padding: 26px 36px 60px; }
.toolbar { display: flex; align-items: center; gap: 12px; margin-bottom: 22px; flex-wrap: wrap; }
.toolbar h1 { font: 700 26px/1.15 var(--font-display); letter-spacing: -0.01em; margin: 0; }
.toolbar .sub { color: var(--text-2); margin-top: 3px; }
.toolbar .grow { flex: 1; }

/* ------------------------------------------------------------------ controles */
.btn {
  display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 13px; border-radius: 7px;
  border: 0.5px solid var(--field-border); background: var(--card); box-shadow: var(--shadow-1);
  font-weight: 500; cursor: default; white-space: nowrap;
}
.btn:hover { background: var(--card-hover); }
.btn:active { transform: translateY(0.5px); }
.btn svg.i { width: 15px; height: 15px; }
.btn.primary { background: var(--accent); border-color: transparent; color: var(--on-accent); }
.btn.primary:hover { background: var(--accent-hover); }
.btn.danger { color: var(--red-ink); }
.btn.danger-fill { background: var(--red); color: #fff; border-color: transparent; }
.btn.plain { background: transparent; border-color: transparent; box-shadow: none; color: var(--accent); }
.btn.icon { width: 30px; padding: 0; justify-content: center; }
.btn:disabled { opacity: 0.45; pointer-events: none; }
.btn.lg { height: 38px; font-size: 14.5px; border-radius: 9px; padding: 0 18px; }

.field {
  height: 30px; padding: 0 10px; border-radius: 7px; border: 0.5px solid var(--field-border);
  background: var(--field); outline: none; width: 100%; box-shadow: inset 0 0.5px 1px rgba(0, 0, 0, 0.05);
}
textarea.field { height: auto; min-height: 70px; padding: 7px 10px; resize: vertical; }
.field:focus, .search input:focus { box-shadow: 0 0 0 3.5px var(--accent-soft); border-color: var(--accent); }
.field.lg { height: 40px; font-size: 15px; border-radius: 9px; padding: 0 13px; }
select.field { appearance: none; padding-right: 28px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='14' viewBox='0 0 10 14'%3E%3Cpath d='M2 5l3-3 3 3M2 9l3 3 3-3' fill='none' stroke='%238e8e93' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 9px center; }
.search { position: relative; width: 240px; }
.search svg.i { position: absolute; left: 9px; top: 7px; width: 16px; height: 16px; color: var(--text-3); }
.search input {
  width: 100%; height: 30px; border-radius: 8px; border: 0.5px solid transparent; outline: none;
  background: rgba(127, 127, 127, 0.12); padding: 0 10px 0 31px;
}
.seg { display: inline-flex; padding: 2px; border-radius: 8px; background: rgba(127, 127, 127, 0.14); }
.seg button {
  border: 0; background: transparent; padding: 3px 12px; border-radius: 6px; font-weight: 500; cursor: default;
}
.seg button.on { background: var(--seg-on, var(--card)); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12), 0 0 0 0.5px rgba(0, 0, 0, 0.05); }
.switch { position: relative; width: 38px; height: 22px; flex: none; }
.switch input { opacity: 0; width: 100%; height: 100%; margin: 0; position: absolute; z-index: 1; cursor: default; }
.switch span {
  position: absolute; inset: 0; border-radius: 11px; background: rgba(127, 127, 127, 0.32); transition: background .2s;
}
.switch span::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3); transition: transform .2s;
}
.switch input:checked + span { background: var(--green); }
.switch input:checked + span::after { transform: translateX(16px); }

/* ------------------------------------------------------------------ tarjetas y listas */
.grid { display: grid; gap: 16px; }
.grid.stats { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); margin-bottom: 22px; }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); }
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow-1); }
.main .card { background: var(--card); }
.page { --card-bg: var(--card); }
.stat { padding: 16px 18px; display: flex; gap: 14px; align-items: center; }
.stat .ico { width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center; color: #fff; flex: none; }
.stat .ico svg { width: 21px; height: 21px; stroke-width: 2; }
.stat .num { font: 700 26px/1 var(--font-display); font-variant-numeric: tabular-nums; }
.stat .lbl { color: var(--text-2); margin-top: 4px; font-size: 12.5px; }
.section-title { font: 600 15px var(--font-display); margin: 26px 2px 10px; display: flex; align-items: center; gap: 8px; }
.section-title:first-child { margin-top: 0; }
.section-title .grow { flex: 1; }
.group { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow-1); overflow: hidden; }
.row {
  display: flex; align-items: center; gap: 12px; padding: 10px 16px; min-height: 46px; position: relative;
}
.row + .row::before {
  content: ""; position: absolute; top: 0; left: 16px; right: 0; border-top: 0.5px solid var(--hairline);
}
.row.click:hover { background: var(--card-hover); }
.row .grow { flex: 1; min-width: 0; }
.row .t { font-weight: 500; }
.row .s { color: var(--text-2); font-size: 12.5px; }
.row .end { color: var(--text-2); }
.row label.lbl { width: 170px; flex: none; }
.empty { padding: 44px 20px; text-align: center; color: var(--text-2); }
.empty svg.i { width: 40px; height: 40px; stroke-width: 1.3; color: var(--text-3); margin-bottom: 8px; }
.empty .t { font: 600 15px var(--font-display); color: var(--text); margin-bottom: 4px; }

/* tabla */
.table { width: 100%; border-collapse: separate; border-spacing: 0; }
.table th {
  text-align: left; font-weight: 500; color: var(--text-2); font-size: 12px; padding: 9px 14px;
  border-bottom: 0.5px solid var(--hairline); white-space: nowrap; user-select: none;
}
.table td { padding: 10px 14px; border-bottom: 0.5px solid var(--hairline); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: var(--card-hover); }
.table tbody tr.click { cursor: default; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.cell-main { display: flex; align-items: center; gap: 11px; min-width: 0; }
.cell-main .t { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cell-main .s { font-size: 12px; color: var(--text-2); }
.os-ico { width: 32px; height: 32px; border-radius: 8px; display: grid; place-items: center; flex: none; color: #fff; }
.os-ico svg { width: 18px; height: 18px; stroke-width: 1.9; }
.mono { font-family: var(--mono); font-size: 12.5px; letter-spacing: 0.01em; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; background: var(--text-3); flex: none; }
.dot.on { background: var(--green); box-shadow: 0 0 0 3px rgba(40, 205, 65, 0.18); }
.pill {
  display: inline-flex; align-items: center; gap: 5px; height: 21px; padding: 0 8px; border-radius: 11px;
  font-size: 11.5px; font-weight: 600; background: rgba(127, 127, 127, 0.14); color: var(--text-2); white-space: nowrap;
}
.pill.blue { background: var(--accent-soft); color: var(--accent); }
.pill.green { background: rgba(40, 205, 65, 0.15); color: var(--green-ink); }
.pill.red { background: rgba(255, 59, 48, 0.13); color: var(--red-ink); }
.pill.orange { background: rgba(255, 149, 0, 0.15); color: #c46a00; }
.tag { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; color: var(--text-2); margin-right: 8px; }
.tag i { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.muted { color: var(--text-2); }
.small { font-size: 12px; }

/* ------------------------------------------------------------------ hoja (modal) */
.scrim {
  position: fixed; inset: 0; background: var(--scrim); display: flex; justify-content: center; align-items: flex-start;
  padding-top: 8vh; z-index: 50; animation: fade .15s ease-out;
}
.sheet {
  width: min(520px, calc(100vw - 32px)); max-height: 84vh; overflow-y: auto; background: var(--window);
  border-radius: 14px; box-shadow: var(--shadow-2); animation: drop .22s cubic-bezier(.2, .9, .3, 1.1);
}
.sheet.wide { width: min(720px, calc(100vw - 32px)); }
.sheet-head { padding: 20px 22px 6px; display: flex; gap: 14px; align-items: flex-start; }
.sheet-head h2 { font: 700 17px/1.25 var(--font-display); margin: 0; }
.sheet-head p { margin: 4px 0 0; color: var(--text-2); }
.sheet-body { padding: 12px 22px 6px; }
.sheet-foot { display: flex; gap: 8px; justify-content: flex-end; padding: 14px 22px 18px; }
.sheet-foot .left { margin-right: auto; }
.form-row { display: grid; grid-template-columns: 130px 1fr; gap: 12px; align-items: center; margin-bottom: 11px; }
.form-row > label { text-align: right; color: var(--text-2); }
.form-row.top { align-items: start; }
.form-row.top > label { padding-top: 6px; }
.hint { font-size: 12px; color: var(--text-2); margin-top: 4px; }
.error-box {
  background: rgba(255, 59, 48, 0.1); color: var(--red-ink); border-radius: 8px; padding: 8px 12px; margin-bottom: 12px;
}
@keyframes fade { from { opacity: 0; } }
@keyframes drop { from { opacity: 0; transform: translateY(-14px) scale(.98); } }

/* aviso */
.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%); background: rgba(40, 40, 44, 0.92);
  color: #fff; padding: 9px 16px; border-radius: 10px; box-shadow: var(--shadow-2); z-index: 80;
  backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px); animation: rise .25s ease-out; font-weight: 500;
}
@keyframes rise { from { opacity: 0; transform: translate(-50%, 10px); } }

/* ------------------------------------------------------------------ ingreso */
.login-wrap {
  min-height: 100vh; display: grid; place-items: center; padding: 24px;
  background:
    radial-gradient(1200px 600px at 15% 10%, rgba(0, 122, 255, 0.22), transparent 60%),
    radial-gradient(900px 600px at 90% 90%, rgba(175, 82, 222, 0.18), transparent 60%),
    var(--bg);
}
.login {
  width: min(380px, 100%); background: var(--card); border-radius: 18px; box-shadow: var(--shadow-2);
  padding: 34px 32px 26px; text-align: center;
}
.login .brand-mark { width: 64px; height: 64px; border-radius: 16px; margin: 0 auto 16px; }
.login .brand-mark svg { width: 34px; height: 34px; }
.login h1 { font: 700 21px var(--font-display); margin: 0 0 4px; }
.login p { color: var(--text-2); margin: 0 0 22px; }
.login .field { margin-bottom: 10px; }
.login .btn { width: 100%; justify-content: center; margin-top: 6px; }
.login .foot { margin-top: 18px; font-size: 11.5px; color: var(--text-3); }

/* codigo / bloques */
.code {
  font-family: var(--mono); font-size: 12.5px; background: rgba(127, 127, 127, 0.1); border-radius: 8px;
  padding: 10px 12px; word-break: break-all; user-select: all;
}
.kv { display: grid; grid-template-columns: 150px 1fr; gap: 6px 14px; }
.kv dt { color: var(--text-2); }
.kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }

/* ------------------------------------------------------------------ movil */
@media (max-width: 820px) {
  .app { grid-template-columns: 1fr; grid-template-rows: auto 1fr; height: auto; min-height: 100vh; }
  .sidebar { flex-direction: row; overflow-x: auto; padding: 8px; gap: 4px; border-right: 0;
    border-bottom: 0.5px solid var(--hairline); position: sticky; top: 0; z-index: 10; }
  .brand, .nav-label, .sidebar-foot, .nav a .badge { display: none; }
  .nav { display: flex; gap: 4px; }
  .nav a { white-space: nowrap; }
  .page { padding: 18px 16px 50px; }
  .search { width: 100%; }
  .form-row { grid-template-columns: 1fr; gap: 4px; }
  .form-row > label { text-align: left; }
  .hide-m { display: none; }
  .table th, .table td { padding: 9px 10px; }
}
