:root {
  --brand: #8f0a47;
  --brand-dark: #6e0836;
  --brand-soft: #f8e8ef;
  --accent: #1a4c55;
  --accent-soft: #e7f2f4;
  --ink: #1a2330;
  --muted: #6b7785;
  --line: #e5e9ef;
  --bg: #eef2f6;
  --card: #fff;
  --ok: #0f766e;
  --ok-bg: #e6f7f4;
  --warn: #b45309;
  --warn-bg: #fff7ed;
  --info: #0369a1;
  --info-bg: #e0f2fe;
  --danger: #be123c;
  --danger-bg: #ffe4e6;
  --radius: 6px;
  --font: "Plus Jakarta Sans", "Segoe UI", sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  font-size: 13px;
  color: var(--ink);
  background: var(--bg);
  line-height: 1.35;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--brand); }
img { max-width: 100%; display: block; }

h1, h2, h3 {
  margin: 0;
  font-weight: 650;
  letter-spacing: -0.01em;
  line-height: 1.2;
  color: var(--ink);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .25rem;
  border: 1px solid transparent;
  border-radius: 5px;
  padding: .28rem .6rem;
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.2;
  cursor: pointer;
  transition: background .1s ease, border-color .1s ease;
}
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-dark); color: #fff; }
.btn-secondary { background: #fff; color: var(--ink); border-color: var(--line); }
.btn-secondary:hover { background: #f7f9fb; color: var(--ink); }
.btn-sm { padding: .2rem .5rem; font-size: 11.5px; }

.field { margin-bottom: .55rem; }
.field label {
  display: block;
  margin-bottom: .18rem;
  font-size: 11px;
  font-weight: 600;
  color: #4a5565;
}
.field input,
.field select,
.field textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: .35rem .55rem;
  font: inherit;
  font-size: 13px;
  color: var(--ink);
  background: #fff;
}
.field textarea { min-height: 84px; resize: vertical; }
.field input:focus,
.field select:focus,
.field textarea:focus {
  outline: none;
  border-color: #b9c4d1;
  box-shadow: 0 0 0 2px rgba(26, 76, 85, 0.08);
}

.alert {
  border-radius: 5px;
  padding: .4rem .6rem;
  margin-bottom: .55rem;
  font-weight: 600;
  font-size: 12px;
}
.alert-error { background: var(--danger-bg); color: var(--danger); }
.alert-success { background: var(--ok-bg); color: var(--ok); }
.alert-info { background: var(--info-bg); color: var(--info); }

.badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 0 .4rem;
  height: 18px;
  font-size: 10.5px;
  font-weight: 700;
  white-space: nowrap;
}
.badge-open { background: var(--info-bg); color: var(--info); }
.badge-progress { background: var(--warn-bg); color: var(--warn); }
.badge-done { background: var(--ok-bg); color: var(--ok); }
.badge-prio-baja { background: #eef2f6; color: #475569; }
.badge-prio-media { background: var(--info-bg); color: var(--info); }
.badge-prio-alta { background: #fff1e6; color: #c2410c; }
.badge-prio-urgente { background: #fde8ef; color: #9f1239; }

.muted { color: var(--muted); }
.stack { display: grid; gap: .55rem; }
.row-actions { display: flex; gap: .35rem; flex-wrap: wrap; align-items: center; }

/* Auth */
.auth-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: .75rem;
  background: linear-gradient(180deg, #f8fafc, #eef3f8);
}
.auth-card {
  width: min(340px, 100%);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 1rem .95rem .85rem;
}
.auth-logo { width: 100px; margin: 0 auto .65rem; }
.auth-card h1 { text-align: center; font-size: 1.05rem; margin-bottom: .15rem; }
.auth-card .lede {
  text-align: center;
  color: var(--muted);
  margin: 0 0 .7rem;
  font-size: 12px;
}
.auth-meta {
  margin-top: .65rem;
  display: flex;
  justify-content: center;
  gap: .75rem;
  font-size: 12px;
  font-weight: 600;
}
.auth-foot {
  margin-top: .7rem;
  text-align: center;
  color: var(--muted);
  font-size: 11px;
}
.auth-card .btn { width: 100%; padding: .4rem .7rem; }

/* Shell */
.app-shell {
  display: grid;
  grid-template-columns: 180px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: #fff;
  border-right: 1px solid var(--line);
  padding: .5rem .4rem .55rem;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: auto;
  display: flex;
  flex-direction: column;
}

.brand-block {
  padding: .15rem .35rem .5rem;
  border-bottom: 1px solid var(--line);
  margin-bottom: .45rem;
  flex: 0 0 auto;
}
.brand-block img { width: 88px; }
.brand-block small {
  display: block;
  margin-top: .1rem;
  color: var(--muted);
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
}

.nav-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 1px;
  flex: 1 1 auto;
  align-content: start;
}
.nav-list a {
  display: block;
  padding: .32rem .45rem;
  border-radius: 5px;
  color: #4b5868;
  font-weight: 600;
  font-size: 12.5px;
}
.nav-list a:hover { background: #f4f7fa; color: var(--ink); text-decoration: none; }
.nav-list a.active { background: var(--brand-soft); color: var(--brand); }

.sidebar-foot {
  flex: 0 0 auto;
  margin-top: 1rem;
  padding-top: .55rem;
  border-top: 1px solid var(--line);
}
.nav-exit {
  display: block;
  padding: .38rem .45rem;
  border-radius: 5px;
  color: var(--danger);
  font-weight: 600;
  font-size: 12.5px;
  background: transparent;
  border: 1px solid transparent;
}
.nav-exit:hover {
  background: var(--danger-bg);
  color: var(--danger);
  text-decoration: none;
  border-color: #f5c2c7;
}

.main {
  padding: .65rem .85rem .9rem;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: .5rem;
  margin-bottom: .5rem;
}
.topbar h1 { font-size: 1rem; }
.topbar p { margin: .1rem 0 0; color: var(--muted); font-size: 11.5px; }

.user-chip {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: .18rem .5rem;
  font-size: 11.5px;
  font-weight: 600;
  color: #3d4b5f;
  white-space: nowrap;
}

.panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: .5rem;
  min-height: 36px;
  padding: .3rem .55rem;
  border-bottom: 1px solid var(--line);
  background: #fafbfc;
  font-size: 12px;
}

.panel-body { padding: .55rem; }

.table-wrap { overflow: auto; }

table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
  table-layout: fixed;
}

table.data th,
table.data td {
  text-align: left;
  padding: .28rem .5rem;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
  line-height: 1.25;
}

table.data th {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .03em;
  color: var(--muted);
  background: #f7f9fb;
  font-weight: 700;
  white-space: nowrap;
}

table.data td {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

table.data tr:last-child td { border-bottom: 0; }
table.data tr:hover td { background: #f8fafc; }

table.data td:last-child,
table.data th:last-child {
  width: 64px;
  text-align: right;
  white-space: nowrap;
  overflow: visible;
}

.search {
  width: 160px;
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: .25rem .45rem;
  font: inherit;
  font-size: 12px;
  background: #fff;
}

.ticket-meta {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: .4rem;
  margin-bottom: .5rem;
}
.meta-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: .4rem .55rem;
  min-width: 0;
  overflow: hidden;
}
.meta-card span {
  display: block;
  font-size: 9.5px;
  text-transform: uppercase;
  letter-spacing: .03em;
  color: var(--muted);
  margin-bottom: .1rem;
  font-weight: 700;
}
.meta-card .meta-value {
  display: block;
  font-size: 12px;
  line-height: 1.35;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  word-break: break-all;
}

.thread { display: grid; gap: .4rem; }
.bubble {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: .45rem .55rem;
  background: #fff;
}
.bubble.staff { background: var(--accent-soft); border-color: #d5e7eb; }
.bubble header {
  display: flex;
  justify-content: space-between;
  gap: .5rem;
  margin-bottom: .2rem;
  font-size: 11.5px;
}
.bubble .author { font-weight: 700; }

.landing-body {
  background: #f3f6f8;
}

.landing {
  position: relative;
  isolation: isolate;
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  grid-template-rows: auto 1fr auto;
  overflow: hidden;
  background:
    linear-gradient(180deg, #f7fafc 0%, #eef3f6 55%, #e8eef2 100%);
  color: var(--ink);
}

.landing-v2 .landing-wash {
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(900px 420px at 18% 0%, rgba(143, 10, 71, .10), transparent 60%),
    radial-gradient(700px 380px at 92% 18%, rgba(26, 76, 85, .12), transparent 55%);
}

.landing-orb {
  position: absolute;
  border-radius: 50%;
  pointer-events: none;
  z-index: 0;
  filter: blur(2px);
}
.landing-orb-a {
  width: 280px;
  height: 280px;
  right: -60px;
  top: 18%;
  background: radial-gradient(circle at 35% 35%, rgba(143, 10, 71, .18), transparent 68%);
  animation: landing-float 9s ease-in-out infinite;
}
.landing-orb-b {
  width: 220px;
  height: 220px;
  left: -40px;
  bottom: 12%;
  background: radial-gradient(circle at 40% 40%, rgba(26, 76, 85, .16), transparent 70%);
  animation: landing-float 11s ease-in-out infinite reverse;
}

.landing-nav,
.landing-hero,
.landing-foot {
  position: relative;
  z-index: 1;
  width: min(880px, calc(100% - 2rem));
  margin: 0 auto;
}

.landing-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.1rem 0 .4rem;
}

.landing-brand img {
  width: 124px;
}

.landing-hero {
  display: grid;
  align-content: center;
  justify-items: start;
  gap: .75rem;
  padding: 1.75rem 0 2.25rem;
  min-height: min(64vh, 520px);
}

.landing-kicker {
  margin: 0;
  color: var(--brand);
  font-weight: 700;
  font-size: 11.5px;
  letter-spacing: .1em;
  text-transform: uppercase;
}

.landing-headline {
  margin: 0;
  max-width: 11ch;
  font-family: "Fraunces", "Plus Jakarta Sans", serif;
  font-size: clamp(2.4rem, 7vw, 4.1rem);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: .98;
  color: #14202a;
}

.landing-lead {
  margin: 0;
  max-width: 32rem;
  color: var(--muted);
  font-size: clamp(14px, 1.7vw, 16px);
  line-height: 1.55;
}

.landing-actions {
  display: flex;
  gap: .5rem;
  flex-wrap: wrap;
  margin-top: .25rem;
}

.landing-cta {
  padding: .55rem 1.15rem;
  font-size: 13.5px;
  transition: transform .18s ease, box-shadow .18s ease;
  box-shadow: 0 8px 22px rgba(143, 10, 71, .22);
}
.landing-cta:hover {
  transform: translateY(-1px);
  box-shadow: 0 12px 26px rgba(143, 10, 71, .28);
}

.landing-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: .75rem;
  padding: .85rem 0 1.1rem;
  color: var(--muted);
  font-size: 11.5px;
  border-top: 1px solid rgba(20, 32, 42, .08);
}
.landing-foot a { color: var(--muted); }
.landing-foot a:hover { color: var(--brand); }

.reveal {
  opacity: 0;
  transform: translateY(12px);
  animation: landing-rise .65s ease forwards;
}
.reveal-delay-1 { animation-delay: .1s; }
.reveal-delay-2 { animation-delay: .2s; }
.reveal-delay-3 { animation-delay: .3s; }

@keyframes landing-rise {
  to { opacity: 1; transform: none; }
}

@keyframes landing-float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-14px); }
}

@media (prefers-reduced-motion: reduce) {
  .reveal,
  .landing-orb,
  .landing-cta {
    animation: none !important;
    transition: none !important;
    opacity: 1;
    transform: none;
  }
}

@media (max-width: 640px) {
  .landing-hero { min-height: auto; padding: 2rem 0 2.5rem; }
  .landing-headline { max-width: 12ch; }
  .landing-foot { flex-direction: column; align-items: flex-start; }
}

.terms-box {
  background: #f7f9fb;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: .65rem .8rem;
  font-size: 13px;
  color: #4a5565;
}
.terms-box ul {
  margin: 0;
  padding-left: 1.1rem;
  display: grid;
  gap: .35rem;
}

.terms-body {
  background: #f3f6f8;
  margin: 0;
}

.terms-page {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  grid-template-rows: auto 1fr auto;
}

.terms-top,
.terms-doc,
.terms-foot {
  width: min(760px, calc(100% - 2rem));
  margin: 0 auto;
}

.terms-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 0;
}

.terms-top img { width: 110px; }

.terms-doc {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 1.25rem 1.35rem 1.5rem;
  margin-bottom: 1rem;
}

.terms-kicker {
  margin: 0 0 .35rem;
  color: var(--brand);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.terms-doc h1 {
  margin: 0 0 .65rem;
  font-size: clamp(1.45rem, 3vw, 1.85rem);
}

.terms-intro {
  margin: 0 0 1.1rem;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.55;
}

.terms-doc section + section {
  margin-top: 1.05rem;
  padding-top: .95rem;
  border-top: 1px solid var(--line);
}

.terms-doc h2 {
  margin: 0 0 .4rem;
  font-size: 15px;
  font-weight: 700;
}

.terms-doc p {
  margin: 0 0 .45rem;
  color: #4a5565;
  font-size: 13.5px;
  line-height: 1.55;
}

.terms-doc p:last-child { margin-bottom: 0; }
.terms-sla {
  margin: .4rem 0 .55rem;
  padding-left: 1.1rem;
  color: #4a5565;
  font-size: 13.5px;
  line-height: 1.5;
  display: grid;
  gap: .35rem;
}

.terms-foot {
  display: flex;
  justify-content: space-between;
  gap: .75rem;
  padding: .75rem 0 1.1rem;
  color: var(--muted);
  font-size: 11.5px;
}

.terms-foot a { color: var(--muted); }
.terms-foot a:hover { color: var(--brand); }

@media (max-width: 640px) {
  .terms-doc { padding: 1rem; }
  .terms-foot { flex-direction: column; }
}

.pager {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: .5rem;
  flex-wrap: wrap;
  padding: .4rem .55rem;
  border-top: 1px solid var(--line);
  background: #fafbfc;
  font-size: 12px;
}
.pager-nav {
  display: flex;
  align-items: center;
  gap: .35rem;
}
.pager-page { font-weight: 600; }

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: .4rem;
  margin-bottom: .55rem;
}
.stat-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: .45rem .55rem;
}
.stat-card span {
  display: block;
  font-size: 9.5px;
  text-transform: uppercase;
  letter-spacing: .03em;
  color: var(--muted);
  font-weight: 700;
  margin-bottom: .15rem;
}
.stat-card strong {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--ink);
}
.charts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: .45rem;
}
.charts-grid .panel { margin: 0; }
.filter-select {
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: .25rem .4rem;
  font: inherit;
  font-size: 12px;
  background: #fff;
  max-width: 140px;
}
.kb-content {
  font-size: 13px;
  line-height: 1.55;
  white-space: normal;
}
.attach-list {
  list-style: none;
  margin: .45rem 0 0;
  padding: 0;
  display: grid;
  gap: .2rem;
}
.attach-list li a {
  font-size: 12px;
  word-break: break-all;
}
.field small.muted {
  display: block;
  margin-top: .2rem;
  font-size: 11px;
}
.panel-head .filters { flex-wrap: wrap; }

.profile-hero {
  display: flex;
  align-items: center;
  gap: .75rem;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: .65rem .75rem;
  margin-bottom: .55rem;
}
.profile-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--brand-soft);
  color: var(--brand);
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 14px;
  flex: 0 0 auto;
}
.profile-hero-text {
  display: grid;
  gap: .1rem;
  min-width: 0;
}
.profile-hero-text strong {
  font-size: 14px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.profile-hero-text > span {
  color: var(--muted);
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.profile-tags {
  display: flex;
  flex-wrap: wrap;
  gap: .25rem;
  margin-top: .2rem;
}
.profile-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr);
  gap: .45rem;
  align-items: start;
}
.profile-grid .panel { margin: 0; }
.form-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .45rem;
}
.panel-subhead {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .03em;
  color: var(--muted);
  margin: .15rem 0 .35rem;
  padding-top: .2rem;
  border-top: 1px solid var(--line);
}
@media (max-width: 860px) {
  .profile-grid,
  .form-2 { grid-template-columns: 1fr; }
}

.clients-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(280px, .95fr);
  gap: .45rem;
  align-items: start;
}
.clients-layout .stack { gap: .45rem; }
table.data tr.row-selected td {
  background: var(--brand-soft);
}
@media (max-width: 980px) {
  .clients-layout { grid-template-columns: 1fr; }
}

.mobile-toggle {
  display: none;
  position: fixed;
  right: .75rem;
  bottom: .75rem;
  z-index: 40;
}
.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(28, 36, 48, .28);
  z-index: 25;
}
.sidebar-backdrop.show { display: block; }

@media (max-width: 920px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: min(220px, 82vw);
    transform: translateX(-105%);
    transition: transform .18s ease;
    z-index: 30;
  }
  .sidebar.open { transform: none; }
  .mobile-toggle { display: inline-flex; }
  .topbar { align-items: flex-start; flex-direction: column; }
  table.data { table-layout: auto; }
  table.data td { white-space: normal; }
}
