/* PortalPBX Portal — premium account shell
   Brand tokens from portalpbx.com GUIA-UI · Digicorp-like layout (not Digicorp lime) */
@font-face {
  font-family: "Inter";
  font-style: normal;
  font-display: swap;
  font-weight: 100 900;
  src: url("/static/fonts/inter-latin.woff2") format("woff2-variations");
}

:root {
  --navy: #102653;
  --blue: #1560D6;
  --blue-dark: #123B81;
  --green: #15803D;
  --green-hover: #116A33;
  --text: #263B5D;
  --muted: #5A6A85;
  --bg: #F3F7FC;
  --surface: #FFFFFF;
  --border: #E1EAF5;
  --border-strong: #C9D8EC;
  --green-light: #EAF9EF;
  --blue-light: #E8F1FE;
  --danger: #9B1C22;
  --danger-soft: #FDECEC;
  --warn: #B45309;
  --warn-soft: #FFF7ED;
  --shadow-sm: 0 1px 2px rgba(16, 38, 83, .04);
  --shadow: 0 8px 28px rgba(20, 59, 129, .07);
  --shadow-lg: 0 18px 50px rgba(16, 38, 83, .10);
  --radius: 16px;
  --radius-md: 12px;
  --radius-btn: 10px;
  --sidebar-w: 278px;
  --font: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --ring: 0 0 0 4px rgba(21, 96, 214, .14);
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: var(--font);
  background:
    radial-gradient(900px 420px at 0% -5%, rgba(21, 96, 214, .06), transparent 55%),
    radial-gradient(700px 380px at 100% 0%, rgba(21, 128, 61, .05), transparent 50%),
    var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--blue); text-decoration: none; transition: color .15s ease; }
a:hover { color: var(--blue-dark); text-decoration: underline; }
img { max-width: 100%; height: auto; display: block; }

/* ========== Topbar ========== */
.topbar {
  background: rgba(255,255,255,.92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  padding: .7rem 1.5rem;
  display: flex; align-items: center; gap: 1.15rem;
  position: sticky; top: 0; z-index: 50;
  box-shadow: var(--shadow-sm);
}
.topbar .logo {
  display: flex; align-items: center; gap: .5rem;
  text-decoration: none; flex-shrink: 0;
}
.topbar .logo:hover { text-decoration: none; opacity: .92; }
.topbar .logo img { height: 32px; width: auto; }
.top-search {
  flex: 1; max-width: 520px; display: flex; margin: 0 auto;
  border: 1px solid var(--border); border-radius: 999px; overflow: hidden;
  background: #fff; transition: border-color .15s, box-shadow .15s;
}
.top-search:focus-within {
  border-color: #A9C8FF; box-shadow: var(--ring);
}
.top-search input {
  flex: 1; border: 0; background: transparent; padding: .55rem 1.05rem;
  outline: none; max-width: none; font: inherit; font-size: .9rem; color: var(--text);
}
.top-search input::placeholder { color: #8FA0B8; }
.top-search button {
  border: 0; background: var(--blue); color: #fff;
  width: 46px; padding: 0; border-radius: 0; box-shadow: none;
  display: grid; place-items: center; transition: background .15s;
}
.top-search button:hover { background: var(--blue-dark); filter: none; }
.top-search button svg { width: 17px; height: 17px; stroke: currentColor; fill: none; stroke-width: 1.85; }
.top-user {
  display: flex; align-items: center; gap: .65rem;
  color: var(--muted); font-size: .8125rem; margin-left: auto; flex-shrink: 0;
}
.top-user strong { color: var(--navy); font-weight: 700; font-size: .875rem; }
.avatar {
  width: 36px; height: 36px; border-radius: 999px;
  background: linear-gradient(145deg, var(--blue-light), #fff);
  color: var(--blue); display: grid; place-items: center;
  font-weight: 750; font-size: .8rem;
  border: 1px solid #D4E4FF;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.8);
}

/* ========== Layout ========== */
.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  gap: 1.2rem;
  max-width: 1240px;
  margin: 1.2rem auto 2.25rem;
  padding: 0 1.25rem;
}
@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: static; order: 2; }
}

.sidebar {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.05rem .8rem 1rem;
  align-self: start;
  position: sticky; top: 4.35rem;
}
.side-identity {
  display: flex; gap: .75rem; align-items: center;
  padding: .15rem .45rem .95rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: .7rem;
}
.side-identity img.side-logo { width: 40px; height: 40px; object-fit: contain; object-position: center; flex-shrink: 0; border-radius: 10px; background: #fff; border: 1px solid var(--border); padding: 5px; display: block; box-sizing: border-box; }
.side-identity .org {
  font-weight: 750; color: var(--navy); font-size: .875rem; line-height: 1.3;
  letter-spacing: -.01em;
}
.side-identity .meta {
  color: var(--muted); font-size: .72rem; margin-top: .2rem;
  word-break: break-all; line-height: 1.35;
}
.side-role {
  display: inline-block; margin-top: .35rem;
  font-size: .65rem; font-weight: 750; letter-spacing: .04em; text-transform: uppercase;
  color: var(--blue); background: var(--blue-light);
  border: 1px solid #D4E4FF; border-radius: 999px; padding: .12rem .45rem;
}

.nav-group { margin: .4rem 0 .65rem; }
.nav-group-title {
  display: flex; align-items: center; gap: .35rem;
  font-size: .6875rem; font-weight: 750; letter-spacing: .07em;
  text-transform: uppercase; color: #7B8BA6;
  padding: .45rem .55rem .3rem;
}
.nav-group-title .chev { color: var(--green); display: inline-flex; }
.nav-group-title .chev svg { width: 11px; height: 11px; stroke: currentColor; fill: none; stroke-width: 2.2; }

.nav-group a {
  display: flex; align-items: center; gap: .65rem;
  padding: .6rem .75rem; margin: .08rem 0;
  border-radius: 9px; color: var(--text);
  font-size: .875rem; font-weight: 550; text-decoration: none;
  transition: background .15s, color .15s, box-shadow .15s, transform .15s;
}
.nav-group a .ico {
  width: 20px; height: 20px; flex-shrink: 0; color: #8FA0B8;
  display: inline-flex; align-items: center; justify-content: center;
  transition: color .15s;
}
.nav-group a .ico svg {
  width: 18px; height: 18px; stroke: currentColor; fill: none;
  stroke-width: 1.55; stroke-linecap: round; stroke-linejoin: round;
}
.nav-group a:hover {
  background: var(--blue-light); text-decoration: none; color: var(--navy);
}
.nav-group a:hover .ico { color: var(--blue); }
.nav-group a.active {
  background: var(--green); color: #fff; font-weight: 650;
  box-shadow: 0 4px 14px rgba(21, 128, 61, .28);
}
.nav-group a.active .ico { color: #fff; }
.nav-group a.active:hover { background: var(--green-hover); color: #fff; }

.side-logout {
  display: flex; align-items: center; gap: .5rem;
  margin-top: .55rem; padding: .85rem .7rem 0;
  color: var(--muted); font-size: .8125rem; font-weight: 550;
  border-top: 1px solid var(--border);
  text-decoration: none; transition: color .15s;
}
.side-logout:hover { color: var(--navy); text-decoration: none; }
.side-logout svg { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 1.6; }

.main { min-width: 0; }
.main-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.45rem 1.55rem 1.7rem;
  min-height: 440px;
  animation: rise .35s ease;
}
@keyframes rise {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

.crumbs {
  display: flex; flex-wrap: wrap; gap: .35rem; align-items: center;
  font-size: .75rem; color: var(--muted); margin-bottom: .85rem;
}
.crumbs a { color: var(--muted); font-weight: 550; }
.crumbs a:hover { color: var(--blue); }
.crumbs .sep { opacity: .45; }

.page-toolbar {
  display: flex; justify-content: space-between; align-items: flex-start;
  gap: 1rem; flex-wrap: wrap; margin-bottom: .15rem;
}
.page-title {
  margin: 0; font-size: 1.55rem; color: var(--navy);
  letter-spacing: -.03em; font-weight: 800; line-height: 1.15;
}
.page-title::after {
  content: ""; display: block; width: 40px; height: 3px;
  background: linear-gradient(90deg, var(--green), var(--blue));
  border-radius: 4px; margin-top: .55rem;
}
.page-desc {
  margin: .7rem 0 1.25rem; color: var(--muted); font-size: .9rem; line-height: 1.5;
  max-width: 42rem;
}

/* Metric cards */
.grid {
  display: grid; gap: .9rem;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin: 0 0 1.35rem;
}
@media (max-width: 980px) { .grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 520px) { .grid { grid-template-columns: 1fr; } }
.card {
  position: relative;
  background: linear-gradient(180deg, #fff 0%, #fbfdff 100%);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1rem 1.05rem 1.05rem;
  box-shadow: var(--shadow-sm);
  transition: border-color .15s, box-shadow .15s, transform .15s;
  overflow: hidden;
}
.card::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px;
  background: var(--blue); opacity: .55; border-radius: 3px 0 0 3px;
}
.card.tone-green::before { background: var(--green); opacity: .75; }
.card.tone-warn::before { background: var(--warn); opacity: .8; }
.card.tone-blue::before { background: var(--blue); opacity: .85; }
.card:hover {
  border-color: #C5D7F0;
  box-shadow: 0 10px 24px rgba(20, 59, 129, .08);
  transform: translateY(-1px);
}
.card h3 {
  margin: 0 0 .45rem; font-size: .6875rem; color: var(--muted);
  font-weight: 750; text-transform: uppercase; letter-spacing: .05em;
}
.card .n {
  font-size: 1.65rem; font-weight: 800; color: var(--navy);
  letter-spacing: -.03em; line-height: 1.1;
}
.card .n.accent { color: var(--green); }
.card .n.blue { color: var(--blue); }
.card .n.warn { color: var(--warn); }
.card .hint { margin-top: .4rem; font-size: .75rem; color: var(--muted); }

/* Buttons */
.btn, button, input[type=submit] {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  background: var(--green); color: #fff; border: 1px solid var(--green);
  border-radius: var(--radius-btn); padding: .58rem 1.15rem;
  font-weight: 700; font-size: .875rem; cursor: pointer;
  text-decoration: none; min-height: 42px;
  transition: background .15s, border-color .15s, transform .15s, box-shadow .15s;
  box-shadow: 0 2px 8px rgba(21, 128, 61, .18);
}
.btn:hover, button:hover {
  background: var(--green-hover); border-color: var(--green-hover);
  text-decoration: none; filter: none; transform: translateY(-1px);
}
.btn.secondary, button.secondary {
  background: #fff; color: var(--blue);
  border: 1px solid #A9C8FF; box-shadow: none;
}
.btn.secondary:hover { border-color: var(--blue); background: var(--blue-light); }
.btn.ghost { background: transparent; color: var(--muted); border-color: transparent; box-shadow: none; }
.btn.danger { background: var(--danger); border-color: var(--danger); box-shadow: none; }
.actions { display: flex; flex-wrap: wrap; gap: .55rem; margin: .5rem 0 1.15rem; }

form.stack label {
  display: block; margin: .75rem 0 .3rem; color: var(--muted);
  font-size: .78rem; font-weight: 650;
}
input, select, textarea {
  width: 100%; max-width: 520px; padding: .7rem .9rem;
  border-radius: 12px; border: 1px solid var(--border-strong);
  background: #fff; color: var(--text); font: inherit; font-size: .875rem;
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--blue); box-shadow: var(--ring);
}
textarea { min-height: 120px; resize: vertical; }

/* Tables */
.table-panel {
  border: 1px solid var(--border); border-radius: var(--radius-md);
  overflow: hidden; background: #fff;
  box-shadow: var(--shadow-sm);
}
.table-panel .table-head {
  display: flex; justify-content: space-between; align-items: center;
  gap: .75rem; padding: .75rem 1rem; border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, #fafcff, #f5f9ff);
}
.table-panel .table-head h2 {
  margin: 0; font-size: .875rem; font-weight: 750; color: var(--navy);
}
table { width: 100%; border-collapse: collapse; font-size: .875rem; }
th, td {
  text-align: left; padding: .85rem 1.05rem;
  border-bottom: 1px solid var(--border); vertical-align: middle;
}
th {
  background: #F7FAFF; color: var(--muted); font-size: .6875rem;
  text-transform: uppercase; letter-spacing: .055em; font-weight: 750;
}
tr:last-child td { border-bottom: 0; }
tbody tr { transition: background .12s; }
tbody tr:hover { background: #F7FAFF; }
td.strong { font-weight: 700; color: var(--navy); }
td a { font-weight: 650; }
.cell-sub { display: block; color: var(--muted); font-size: .75rem; margin-top: .15rem; font-weight: 500; }

.badge {
  display: inline-flex; align-items: center; gap: .3rem;
  padding: .2rem .55rem; border-radius: 999px;
  background: var(--bg); color: var(--text); font-size: .6875rem; font-weight: 700;
  border: 1px solid var(--border); letter-spacing: .01em;
}
.badge::before {
  content: ""; width: 6px; height: 6px; border-radius: 999px; background: currentColor; opacity: .75;
}
.badge.abierto, .badge.nueva, .badge.pendiente, .badge.open,
.badge.emitida { background: var(--blue-light); color: var(--blue); border-color: #C9DCFF; }
.badge.en_progreso, .badge.en_curso, .badge.enviada { background: #EEF6FF; color: var(--blue-dark); border-color: #C9DCFF; }
.badge.resuelto, .badge.activa, .badge.pagada, .badge.aplicado, .badge.estimada,
.badge.aceptada, .badge.instalado { background: var(--green-light); color: var(--green); border-color: #B8E6C8; }
.badge.alta, .badge.critica, .badge.vencida { background: var(--danger-soft); color: var(--danger); border-color: #F3B8BB; }
.badge.media, .badge.esperando_cliente { background: var(--warn-soft); color: var(--warn); border-color: #FED7AA; }
.badge.cerrado, .badge.cancelada, .badge.baja { background: #F3F5F8; color: #6B7C95; }

/* Empty state */
.empty {
  text-align: center; padding: 2.75rem 1.5rem;
  color: var(--muted);
}
.empty .empty-ico {
  width: 52px; height: 52px; margin: 0 auto .9rem;
  border-radius: 14px; background: var(--blue-light); color: var(--blue);
  display: grid; place-items: center;
  border: 1px solid #D4E4FF;
}
.empty .empty-ico svg { width: 24px; height: 24px; stroke: currentColor; fill: none; stroke-width: 1.6; }
.empty strong { display: block; color: var(--navy); font-size: 1rem; margin-bottom: .35rem; }
.empty p { margin: 0 auto; max-width: 28rem; font-size: .875rem; }

.msg {
  border: 1px solid var(--border); border-radius: 12px;
  padding: .9rem 1.05rem; margin: .7rem 0; background: #F8FBFF;
}
.msg.internal { border-color: #FCD34D; background: #FFFBEB; }
.msg .meta { color: var(--muted); font-size: .75rem; margin-bottom: .4rem; font-weight: 550; }
.err {
  background: var(--danger-soft); color: var(--danger); border: 1px solid #F3B8BB;
  padding: .75rem .9rem; border-radius: 12px; margin-bottom: 1rem;
  font-size: .875rem; font-weight: 550;
}
.note { color: var(--muted); font-size: .8125rem; margin-top: 1rem; }
.foot-note {
  margin: 0 auto 1.75rem; color: #8FA0B8; font-size: .72rem; text-align: center;
}
h1 { font-size: 1.5rem; margin: 0 0 1rem; color: var(--navy); font-weight: 800; letter-spacing: -.03em; }
h2 { font-size: 1rem; margin: 1.4rem 0 .7rem; color: var(--navy); font-weight: 750; }

.wrap { max-width: none; margin: 0; padding: 0; }

/* Login premium */
body.login-page {
  display: grid; place-items: center; min-height: 100vh; padding: 1.5rem;
  background:
    radial-gradient(800px 380px at 10% -10%, rgba(21,96,214,.12), transparent 55%),
    radial-gradient(700px 360px at 100% 0%, rgba(21,128,61,.10), transparent 50%),
    linear-gradient(160deg, #FFFFFF 10%, #F3F8FF 55%, #EEF8F2 100%);
}
.login-box {
  width: min(420px, calc(100vw - 2rem));
  background: #fff; border: 1px solid var(--border);
  border-radius: 18px; padding: 1.85rem 1.65rem 1.5rem;
  box-shadow: var(--shadow-lg);
}
.login-box .logo {
  margin-bottom: 1.1rem; display: flex; align-items: center; gap: .55rem;
  text-decoration: none;
}
.login-box .logo img { height: 36px; width: auto; }
.login-box h1 {
  font-size: 1.35rem; margin: 0 0 .35rem;
}
.login-box .lead {
  margin: 0 0 1.15rem; color: var(--muted); font-size: .875rem;
}
.login-box input { max-width: none; }
.login-box button { width: 100%; margin-top: .55rem; min-height: 46px; font-size: .9375rem; }
.login-box .note { font-size: .78rem; line-height: 1.45; }
.login-box .note code {
  background: var(--blue-light); color: var(--blue-dark);
  padding: .05rem .35rem; border-radius: 4px; font-size: .72rem;
}
.login-divider {
  height: 1px; background: var(--border); margin: 1.15rem 0 .9rem;
}
