:root {
  --bg-1: #f2f6fb;
  --bg-2: #e9f0f8;
  --card: #ffffff;
  --card-soft: #f7fbff;
  --primary: #1f4f80;
  --primary-strong: #173d65;
  --accent: #2f8f5b;
  --danger: #b42318;
  --text: #172432;
  --muted: #57697f;
  --border: #d8e2ee;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow-soft: 0 10px 26px rgba(16, 36, 58, 0.08);
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  font-family: "Avenir Next", "Nunito Sans", "Segoe UI", sans-serif;
  background:
    radial-gradient(1000px 520px at 15% -10%, #ffffff 0%, transparent 65%),
    linear-gradient(180deg, var(--bg-1) 0%, var(--bg-2) 100%);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  line-height: 1.42;
}

a {
  color: var(--primary);
  font-weight: 600;
  text-underline-offset: 2px;
}

a:hover {
  color: var(--primary-strong);
}

.topbar {
  background: linear-gradient(120deg, #173d65 0%, #1f4f80 56%, #2a628f 100%);
  color: #fff;
  padding: 14px 22px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.14);
  box-shadow: 0 6px 18px rgba(10, 28, 46, 0.16);
}

.topbar h1 {
  margin: 0;
  font-size: 19px;
  letter-spacing: 0.1px;
  font-weight: 750;
  line-height: 1.2;
}

.top-nav {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.top-nav a {
  margin: 0;
  color: #fff;
  text-decoration: none;
  font-weight: 650;
  padding: 8px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.14);
  transition: background 0.18s ease, transform 0.18s ease;
}

.top-nav a:hover {
  background: rgba(255, 255, 255, 0.18);
  transform: translateY(-1px);
}

.user-pill {
  background: rgba(255, 255, 255, 0.18);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 700;
}

.container {
  max-width: 1240px;
  margin: 22px auto;
  padding: 0 16px;
  width: 100%;
  flex: 1;
}

.card {
  background: linear-gradient(180deg, var(--card) 0%, #fcfeff 100%);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-soft);
}

.card h2,
.card h3,
.card h4 {
  margin: 0 0 10px 0;
  line-height: 1.2;
  color: #16283b;
}

.card h2 { font-size: 31px; }
.card h3 { font-size: 25px; }
.card h4 { font-size: 20px; }

.card p {
  margin: 8px 0;
}

.grid-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
}

.metric {
  position: relative;
  overflow: hidden;
}

.metric::after {
  content: "";
  position: absolute;
  right: -20px;
  top: -20px;
  width: 100px;
  height: 100px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(31, 79, 128, 0.14) 0%, rgba(31, 79, 128, 0) 70%);
}

.metric h3 {
  font-size: 16px;
  color: #2e4358;
  margin: 0;
}

.metric p {
  font-size: 29px;
  margin: 8px 0 0 0;
  color: var(--primary-strong);
  font-weight: 800;
  letter-spacing: 0.2px;
}

.inline-form {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.action-buttons-tight {
  display: inline-flex;
  gap: 4px;
  align-items: center;
  flex-wrap: nowrap;
}

.action-buttons-tight form {
  margin: 0;
}

input,
select,
textarea,
button {
  font: inherit;
}

input,
select,
textarea {
  width: 100%;
  padding: 10px 11px;
  border: 1px solid #cfdceb;
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--text);
  font-size: 14px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: #7fa3c6;
  box-shadow: 0 0 0 3px rgba(31, 79, 128, 0.12);
}

textarea {
  min-height: 92px;
  resize: vertical;
}

button,
.inline-form a,
a > button {
  appearance: none;
  border: 1px solid transparent;
  background: linear-gradient(120deg, var(--primary) 0%, #2e628f 100%);
  color: #fff;
  padding: 9px 12px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 700;
  line-height: 1.1;
  cursor: pointer;
  text-decoration: none;
  transition: transform 0.14s ease, box-shadow 0.14s ease, filter 0.14s ease;
  box-shadow: 0 4px 10px rgba(22, 50, 76, 0.22);
}

button:hover,
.inline-form a:hover,
a > button:hover {
  transform: translateY(-1px);
  filter: brightness(1.02);
}

button:active,
.inline-form a:active,
a > button:active {
  transform: translateY(0);
}

button.success {
  background: linear-gradient(120deg, #2b8151 0%, var(--accent) 100%);
}

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

button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.btn-light {
  background: #e8f0f8;
  color: #1b3956;
  border: 1px solid #c7d8ea;
  box-shadow: none;
}

.emoji-action {
  background: transparent !important;
  border: 0 !important;
  box-shadow: none !important;
  padding: 0 !important;
  margin: 0 !important;
  min-width: auto;
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
  transition: transform 0.12s ease;
}

.emoji-action:hover { transform: scale(1.08); }
.emoji-update { color: var(--primary); }
.emoji-confirm { color: var(--primary); }
.emoji-delete { color: var(--danger); }

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

.form-grid .full { grid-column: 1 / -1; }

label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  font-weight: 700;
  color: #2d4259;
}

label > input[type="checkbox"] {
  width: auto;
}

.login-card {
  max-width: 760px;
  margin-left: auto;
  margin-right: auto;
}

.new-client-note {
  margin-top: 14px;
  text-align: center;
  font-size: 15px;
  color: #33485f;
}

.register-notes {
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px dashed #c9d8e8;
  font-size: 14px;
}

.register-notes p { margin: 6px 0; }

.privacy-box {
  border: 1px solid #d3dfec;
  border-radius: 12px;
  padding: 14px;
  background: var(--card-soft);
}

.privacy-box p {
  margin: 0 0 8px 0;
  font-size: 14px;
}

.privacy-consent {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  font-size: 14px;
}

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px 14px;
  margin-bottom: 8px;
}

.stats > div,
.stat-item {
  background: #f8fbff;
  border: 1px solid #dbe6f2;
  border-radius: 10px;
  padding: 9px 10px;
}

.stats > div strong {
  display: block;
  margin-bottom: 3px;
  color: #1f3650;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.stat-item {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.stat-label {
  font-weight: 800;
  color: #1f3650;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.stat-value {
  font-size: 16px;
  font-weight: 650;
  color: #1a2c40;
  line-height: 1.25;
}

table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  margin-top: 8px;
  border: 1px solid #d5e1ee;
  border-radius: 10px;
  overflow: hidden;
  background: #fff;
}

thead th {
  background: #f1f6fc;
  color: #1d3650;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.2px;
}

th,
td {
  border-bottom: 1px solid #e1ebf5;
  text-align: left;
  padding: 9px;
  font-size: 14px;
  vertical-align: middle;
}

tbody tr:nth-child(even) {
  background: #fbfdff;
}

tbody tr:last-child td {
  border-bottom: 0;
}

.th-two-lines {
  display: inline-block;
  line-height: 1.1;
  white-space: normal;
}

.client-toggle {
  width: 100%;
  text-align: left;
  font-size: 18px;
  padding: 12px 14px;
  border-radius: 11px;
}

.modal-backdrop {
  min-height: calc(100vh - 140px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px 0;
}

.modal-card {
  width: 100%;
  max-width: 880px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px;
  box-shadow: 0 20px 44px rgba(20, 30, 40, 0.16);
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 22, 35, 0.46);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  padding: 16px;
}

.modal-small {
  max-width: 760px;
  width: 100%;
  max-height: 92vh;
  overflow-y: auto;
}

.slot-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.slot-chip {
  border: 1px solid #cfe0f0;
  background: #eef5fd;
  color: #24425d;
  border-radius: 999px;
  padding: 7px 10px;
  font-weight: 700;
}

.slot-chip.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.rules-box {
  margin: 0;
  padding: 10px;
  border: 1px solid #d8e4f0;
  border-radius: 10px;
  background: #f8fbff;
  white-space: pre-wrap;
  line-height: 1.36;
}

.term-scroll-box {
  max-height: 420px;
  overflow-y: auto;
  border: 1px solid #d7e3ef;
  border-radius: 10px;
  background: #f8fbff;
  padding: 4px;
}

.term-scroll-box .rules-box {
  border: 0;
  background: transparent;
  max-width: 100%;
}

.error-text {
  color: #8f1f16;
  font-weight: 700;
  background: #ffe8e6;
  border: 1px solid #ffc9c4;
  border-radius: 10px;
  padding: 9px 10px;
}

.success-text {
  color: #1f5f3f;
  font-weight: 700;
  background: #e9f9ef;
  border: 1px solid #b8e6ca;
  border-radius: 10px;
  padding: 9px 10px;
}

.warning-text {
  color: #8a3a08;
  background: #fff3e4;
  border: 1px solid #ffd19f;
  border-radius: 10px;
  padding: 9px 10px;
  font-weight: 700;
}

.muted {
  color: var(--muted);
  font-size: 13px;
}

.session-tag {
  display: inline-block;
  margin-top: 5px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
  background: #fff4e7;
  color: #9a4a10;
  border: 1px solid #ffd6a6;
}

.contract-complete-row {
  background: #ebf9f0 !important;
  box-shadow: inset 4px 0 0 #3a9b5b;
}
.financial-overdue-row {
  background: #fff2f1 !important;
  box-shadow: inset 4px 0 0 #c2352a;
}

.site-footer {
  border-top: 1px solid #d9e4ef;
  background: #f9fcff;
  color: #284059;
  text-align: center;
  padding: 12px 16px;
  font-size: 12px;
  font-weight: 650;
}

@media (max-width: 960px) {
  .topbar {
    flex-direction: column;
    align-items: flex-start;
  }

  .top-nav {
    width: 100%;
    justify-content: flex-start;
  }

  .card h2 { font-size: 25px; }
  .card h3 { font-size: 22px; }

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

@media (max-width: 700px) {
  .container {
    margin: 14px auto;
    padding: 0 10px;
  }

  .card {
    padding: 12px;
    border-radius: 12px;
  }

  .topbar {
    padding: 12px;
    gap: 10px;
  }

  .topbar h1 {
    font-size: 16px;
    line-height: 1.28;
  }

  .top-nav a {
    padding: 7px 9px;
    font-size: 13px;
  }

  .user-pill {
    font-size: 11px;
  }

  table {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .form-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  input,
  select,
  textarea,
  button,
  .inline-form a {
    font-size: 16px;
    min-height: 44px;
  }

  .emoji-action {
    min-height: auto;
    font-size: 24px;
  }

  .new-client-note { font-size: 16px; }
  .term-scroll-box { max-height: 62vh; }
}


.module-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 14px;
}

.module-button {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 170px;
  padding: 16px;
  border-radius: 14px;
  border: 1px solid #d3dfec;
  background: linear-gradient(180deg, #ffffff 0%, #f7fbff 100%);
  text-decoration: none;
  color: inherit;
  box-shadow: 0 8px 18px rgba(16, 36, 58, 0.08);
  transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease;
}

.module-button:hover {
  transform: translateY(-2px);
  border-color: #aac2d9;
  box-shadow: 0 14px 26px rgba(16, 36, 58, 0.13);
}

.module-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.module-head h3 {
  margin: 0;
  font-size: 18px;
  line-height: 1.2;
  color: #16324e;
}

.module-badge {
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .4px;
  padding: 5px 8px;
  border-radius: 999px;
  background: #eaf2fb;
  color: #2f567d;
  border: 1px solid #cddded;
  white-space: nowrap;
}

.module-desc {
  margin: 0;
  font-size: 14px;
  color: #3e556d;
  line-height: 1.35;
}

.module-cta {
  margin-top: auto;
  font-weight: 800;
  font-size: 14px;
  color: #1f4f80;
}

@media (max-width: 640px) {
  .module-button {
    min-height: 154px;
    padding: 14px;
  }

  .module-head h3 {
    font-size: 17px;
  }
}

/* Mosaico de módulos (SCG) */
.module-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 14px;
}

.module-button.module-tile {
  min-height: 190px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 10px;
  padding: 16px;
  border-radius: 14px;
  border: 1px solid #cfdeec;
  text-decoration: none;
  background: linear-gradient(155deg, #ffffff 0%, #f2f8ff 100%);
  box-shadow: 0 8px 18px rgba(19, 43, 68, 0.09);
  transition: transform .16s ease, box-shadow .16s ease, border-color .16s ease;
}

.module-button.module-tile:nth-child(1) { background: linear-gradient(155deg, #f8fcff 0%, #eaf4ff 100%); }
.module-button.module-tile:nth-child(2) { background: linear-gradient(155deg, #f8fffb 0%, #eafaf2 100%); }
.module-button.module-tile:nth-child(3) { background: linear-gradient(155deg, #fffcf8 0%, #fff3e7 100%); }
.module-button.module-tile:nth-child(4) { background: linear-gradient(155deg, #fffafd 0%, #f6edff 100%); }

.module-button.module-tile:hover {
  transform: translateY(-3px);
  box-shadow: 0 14px 28px rgba(19, 43, 68, 0.14);
  border-color: #adc5dc;
}

.module-title {
  font-size: 20px;
  font-weight: 800;
  color: #173854;
  line-height: 1.2;
}

.module-subtitle {
  font-size: 13px;
  font-weight: 650;
  color: #3e586f;
  line-height: 1.35;
}

.module-button.module-tile .module-badge {
  align-self: flex-start;
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .35px;
  padding: 6px 9px;
  border-radius: 999px;
  border: 1px solid #c2d7ea;
  background: rgba(255,255,255,.82);
  color: #2a4f73;
}

@media (max-width: 640px) {
  .module-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .module-button.module-tile {
    min-height: 162px;
    padding: 14px;
  }

  .module-title {
    font-size: 18px;
  }
}
