:root {
  --bg: #ecf2fb;
  --surface: #ffffff;
  --surface-2: #f4f8ff;
  --ink: #0b1222;
  --ink-soft: #3a4b66;
  --brand: #0a4fb0;
  --brand-strong: #073983;
  --brand-soft: #d8e6ff;
  --line: rgba(7, 57, 131, 0.16);
  --danger: #d73c4a;
  --ok: #0f8a63;
  --radius: 12px;
  --radius-lg: 18px;
  --shadow: 0 14px 36px rgba(7, 25, 59, 0.12);
  --grid: rgba(10, 79, 176, 0.15);
}

* {
  box-sizing: border-box;
}

html,
body {
  max-width: 100%;
  overflow-x: hidden;
}

body {
  margin: 0;
  font-family: "Rajdhani", "Segoe UI", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(1000px 420px at 0% 0%, rgba(7, 57, 131, 0.17) 0%, rgba(7, 57, 131, 0) 70%),
    radial-gradient(800px 300px at 100% 0%, rgba(10, 79, 176, 0.14) 0%, rgba(10, 79, 176, 0) 70%),
    linear-gradient(180deg, #eef4ff 0%, #f7faff 42%, #edf3fd 100%);
  min-height: 100vh;
}

.bg-decor {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(90deg, rgba(10, 79, 176, 0.05) 1px, transparent 1px),
    linear-gradient(rgba(10, 79, 176, 0.05) 1px, transparent 1px);
  background-size: 28px 28px;
}

.app-shell {
  max-width: 1280px;
  margin: 0 auto;
  padding: 24px;
  position: relative;
  z-index: 1;
}

.card {
  border-radius: var(--radius-lg);
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 16px;
  animation: rise 300ms ease;
  overflow: hidden;
}

.login-card {
  max-width: 500px;
  margin: 72px auto;
}

.brand-header {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 8px;
}

.brand-kicker {
  margin: 0;
  font-family: "Orbitron", "Segoe UI", sans-serif;
  font-size: 12px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--brand);
}

.login-description {
  color: var(--ink-soft);
  margin-bottom: 14px;
}

.brand-logo {
  width: 86px;
  height: 86px;
  border-radius: 999px;
  background-color: #fff;
  background-image: url("/logo.jpeg"), linear-gradient(140deg, #0a4fb0 0%, #073983 100%);
  background-size: contain, cover;
  background-position: center;
  background-repeat: no-repeat;
  border: 2px solid rgba(10, 79, 176, 0.24);
  box-shadow: 0 8px 22px rgba(7, 57, 131, 0.2);
}

.brand-logo.compact {
  width: 54px;
  height: 54px;
  box-shadow: none;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1,
h2,
h3 {
  font-family: "Orbitron", "Segoe UI", sans-serif;
  letter-spacing: 0.02em;
}

label {
  display: grid;
  gap: 6px;
  margin-bottom: 10px;
  font-size: 15px;
  font-weight: 600;
  color: #1f2d44;
}

input,
select,
button {
  border: 1px solid rgba(7, 57, 131, 0.26);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 15px;
}

input,
select {
  background: #fff;
  font-family: "Roboto Mono", "Consolas", monospace;
  transition: border-color 140ms ease, box-shadow 140ms ease;
}

input:focus,
select:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(10, 79, 176, 0.16);
  outline: none;
}

button {
  border: none;
  background: linear-gradient(120deg, var(--brand) 0%, var(--brand-strong) 100%);
  color: #ffffff;
  cursor: pointer;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  white-space: nowrap;
  transition: transform 120ms ease, box-shadow 120ms ease;
}

button:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 22px rgba(7, 57, 131, 0.24);
}

button.ghost {
  background: transparent;
  color: var(--brand);
  border: 1px solid rgba(7, 57, 131, 0.3);
}

button.danger {
  background: linear-gradient(120deg, #ec5065 0%, var(--danger) 100%);
}

button.tiny {
  padding: 6px 10px;
  font-size: 12px;
}

.error {
  min-height: 16px;
  color: var(--danger);
}

.hidden {
  display: none !important;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  background: linear-gradient(118deg, #f6f9ff 0%, #f0f5ff 55%, #eef3fe 100%);
}

.topbar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.top-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.top-actions > label {
  min-width: 130px;
}

.tabs {
  display: flex;
  gap: 8px;
  overflow: auto;
  padding: 8px;
  background: linear-gradient(115deg, #f7fbff 0%, #edf4ff 100%);
}

.tab {
  border: 1px solid rgba(10, 79, 176, 0.3);
  background: #f2f7ff;
  color: var(--brand);
  white-space: nowrap;
  font-family: "Orbitron", "Segoe UI", sans-serif;
  font-size: 12px;
  text-transform: uppercase;
}

.tab.active {
  background: linear-gradient(130deg, var(--brand) 0%, var(--brand-strong) 100%);
  color: #fff;
  border-color: transparent;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.metric {
  border: 1px solid var(--grid);
  background: linear-gradient(140deg, #fbfdff 0%, #f4f8ff 100%);
  border-radius: 12px;
  padding: 12px;
}

.metric.warn {
  border-color: rgba(204, 63, 79, 0.35);
  background: #fff4f6;
}

.metric .label {
  color: var(--ink-soft);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.metric .value {
  margin-top: 5px;
  font-size: 18px;
  font-weight: 700;
}

.split {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
}

.crm-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  align-items: start;
}

.crm-column {
  min-width: 0;
}

.crm-form {
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.form-inline {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  margin-bottom: 12px;
  align-items: end;
}

.finance-form {
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
}

.finance-form > label {
  margin-bottom: 0;
}

.finance-form > button {
  min-height: 52px;
}

.sheet-form {
  background: var(--surface-2);
  border: 1px solid var(--grid);
  border-radius: 12px;
  padding: 10px;
}

.checkbox-inline {
  display: flex;
  align-items: center;
  gap: 6px;
}

.list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 6px;
}

.list-item {
  border: 1px solid var(--grid);
  border-radius: 10px;
  padding: 8px 10px;
  background: #fff;
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
  min-width: 0;
}

.sheet-list .list-item:nth-child(odd) {
  background: #f9fcff;
}

.sheet-list .list-item:nth-child(even) {
  background: #eff5ff;
}

.sheet-row {
  display: grid;
  grid-template-columns: minmax(140px, 2fr) minmax(110px, 1fr) minmax(130px, 1fr);
  gap: 10px;
  align-items: center;
  width: 100%;
}

.sheet-row > * {
  min-width: 0;
}

.sheet-row.compact {
  grid-template-columns: minmax(160px, 2fr) minmax(140px, 1fr);
}

.sheet-row .cell-main {
  font-weight: 600;
  overflow-wrap: anywhere;
}

.sheet-row .cell-meta,
.sheet-row .cell-value {
  color: var(--ink-soft);
  font-size: 12px;
}

.sheet-row .cell-value {
  text-align: right;
  font-family: "Roboto Mono", "Consolas", monospace;
  color: var(--ink);
  font-weight: 600;
}

.list-item .meta {
  color: var(--ink-soft);
  font-size: 12px;
}

.actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.crm-list .list-item {
  align-items: flex-start;
  flex-wrap: wrap;
}

.crm-list .sheet-row {
  grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr) minmax(0, 0.8fr);
}

.crm-list .cell-main,
.crm-list .cell-meta,
.crm-list .cell-value {
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.crm-list .cell-value {
  text-align: left;
}

.crm-list .actions {
  margin-left: auto;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: baseline;
  margin-bottom: 10px;
  border-bottom: 1px dashed rgba(7, 57, 131, 0.22);
  padding-bottom: 8px;
}

.panel-head p {
  margin-bottom: 0;
}

.muted {
  color: var(--ink-soft);
}

.whatsapp-status-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  margin-bottom: 12px;
}

.wa-status-card {
  border: 1px solid var(--grid);
  border-radius: 12px;
  padding: 12px;
  background: linear-gradient(140deg, #fbfdff 0%, #f4f8ff 100%);
}

.wa-status-card h4 {
  margin: 0 0 8px;
  font-family: "Orbitron", "Segoe UI", sans-serif;
}

.wa-status-pill {
  display: inline-block;
  padding: 6px 10px;
  border-radius: 999px;
  margin: 0 0 8px;
  font-family: "Roboto Mono", "Consolas", monospace;
  font-size: 12px;
  background: #dde7f7;
  color: #243959;
}

.wa-status-pill.connected {
  background: #d3f3e8;
  color: #0f6a4d;
}

.wa-status-pill.pending {
  background: #ffe9bd;
  color: #7a5200;
}

.wa-status-pill.error {
  background: #ffd6dc;
  color: #8f1f37;
}

.wa-qr-shell {
  min-height: 220px;
  border: 1px dashed var(--grid);
  border-radius: 12px;
  padding: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #fff;
}

#wa-qrcode-image {
  width: min(100%, 260px);
  height: auto;
  border-radius: 10px;
  border: 1px solid var(--line);
}

.wa-actions {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  align-items: stretch;
}

.wa-actions > select {
  min-height: 44px;
  min-width: 0;
}

.wa-actions > button {
  min-width: 0;
  white-space: normal;
  line-height: 1.1;
  text-align: center;
  min-height: 48px;
}

.agenda-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: end;
  margin-bottom: 12px;
}

.agenda-toolbar > label {
  min-width: 220px;
  margin-bottom: 0;
}

.agenda-toolbar > button {
  min-height: 44px;
}

.agenda-calendar {
  border: 1px solid var(--grid);
  border-radius: 14px;
  padding: 10px;
  background: linear-gradient(180deg, #fbfdff 0%, #f4f8ff 100%);
  margin-bottom: 12px;
}

.agenda-calendar .fc {
  --fc-page-bg-color: transparent;
  --fc-neutral-bg-color: rgba(10, 79, 176, 0.04);
  --fc-border-color: rgba(7, 57, 131, 0.14);
  --fc-today-bg-color: rgba(10, 79, 176, 0.08);
  --fc-list-event-hover-bg-color: rgba(10, 79, 176, 0.06);
}

.agenda-calendar .fc .fc-toolbar-title {
  font-family: "Orbitron", "Segoe UI", sans-serif;
  font-size: 18px;
}

.agenda-calendar .fc .fc-button {
  background: linear-gradient(120deg, var(--brand) 0%, var(--brand-strong) 100%);
  border: none;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  box-shadow: none;
}

.agenda-calendar .fc .fc-button:disabled {
  opacity: 0.5;
}

.agenda-split {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 12px;
}

.agenda-legend li {
  display: flex;
  align-items: center;
  gap: 8px;
}

.legend-pill {
  width: 12px;
  height: 12px;
  border-radius: 999px;
  display: inline-block;
  flex: 0 0 auto;
}

.legend-session {
  background: #0a4fb0;
}

.legend-plan {
  background: #0f8a63;
}

.legend-contract {
  background: #d97706;
}

.legend-alert {
  background: #e11d48;
}

.pwa-banner {
  position: sticky;
  bottom: 16px;
  z-index: 10;
  margin: 0 auto 16px;
  width: min(100%, 720px);
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  background: linear-gradient(135deg, rgba(7, 57, 131, 0.98) 0%, rgba(10, 79, 176, 0.96) 100%);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 18px;
  box-shadow: 0 20px 40px rgba(7, 25, 59, 0.28);
  padding: 14px 16px;
}

.pwa-banner strong {
  display: block;
  font-family: "Orbitron", "Segoe UI", sans-serif;
  margin-bottom: 4px;
}

.pwa-banner p {
  margin: 0;
  color: rgba(255, 255, 255, 0.88);
}

.pwa-banner-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.pwa-banner .ghost {
  color: #fff;
  border-color: rgba(255, 255, 255, 0.3);
}

.pwa-banner button:not(.ghost) {
  background: #ffffff;
  color: var(--brand-strong);
}

.toast {
  position: fixed;
  right: 16px;
  bottom: 16px;
  background: linear-gradient(120deg, #0f8a63 0%, #0d6f51 100%);
  color: #fff;
  padding: 10px 14px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.24);
  box-shadow: 0 12px 24px rgba(8, 35, 30, 0.3);
}

@media (max-width: 720px) {
  .app-shell {
    padding: 12px;
  }

  .topbar {
    flex-direction: column;
    align-items: flex-start;
  }

  .topbar-brand {
    width: 100%;
  }

  .top-actions {
    width: 100%;
  }

  .top-actions > label,
  .top-actions > button {
    width: 100%;
  }

  .brand-logo {
    width: 68px;
    height: 68px;
  }

  .panel-head {
    flex-direction: column;
    align-items: flex-start;
  }

  .wa-actions > button {
    width: 100%;
  }

  .wa-actions > select {
    width: 100%;
  }

  .sheet-row,
  .sheet-row.compact {
    grid-template-columns: 1fr;
    gap: 2px;
  }

  .sheet-row .cell-value {
    text-align: left;
  }
}

@media (max-width: 1180px) {
  .crm-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 860px) {
  .crm-grid {
    grid-template-columns: 1fr;
  }

  .crm-list .actions {
    margin-left: 0;
  }
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}
