:root {
  --bg-1: #070b14;
  --bg-2: #0d1524;
  --bg-3: #111d33;
  --card: rgba(18, 30, 48, 0.76);
  --card-strong: rgba(14, 23, 38, 0.92);
  --line: rgba(155, 189, 255, 0.2);
  --text: #edf4ff;
  --muted: #98a8c2;
  --brand: #4ee3c4;
  --brand-2: #7b7bff;
  --ok: #45d7aa;
  --error: #ff7195;
  --radius-xl: 22px;
  --radius-lg: 16px;
  --radius-md: 12px;
  --shadow-1: 0 12px 34px rgba(0, 0, 0, 0.35);
  --shadow-2: 0 30px 80px rgba(0, 0, 0, 0.5);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

body {
  font-family: "Segoe UI", "Poppins", Tahoma, sans-serif;
  color: var(--text);
  background:
    radial-gradient(900px 450px at 10% -10%, rgba(78, 227, 196, 0.17), transparent 64%),
    radial-gradient(800px 420px at 95% 0%, rgba(123, 123, 255, 0.14), transparent 62%),
    linear-gradient(145deg, var(--bg-1), var(--bg-2) 45%, var(--bg-3));
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.02) 1px, transparent 1px),
    linear-gradient(rgba(255, 255, 255, 0.02) 1px, transparent 1px);
  background-size: 36px 36px;
  opacity: 0.23;
}

.app-layout {
  width: min(1400px, calc(100vw - 1.4rem));
  margin: 0.7rem auto 1rem;
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 1rem;
  position: relative;
  z-index: 1;
}

.side-rail {
  min-height: calc(100vh - 2rem);
  border: 1px solid var(--line);
  border-radius: 26px;
  background: linear-gradient(170deg, rgba(14, 23, 37, 0.92), rgba(11, 18, 30, 0.95));
  backdrop-filter: blur(12px);
  box-shadow: var(--shadow-1);
  padding: 0.9rem 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  position: sticky;
  top: 0.7rem;
}

.rail-brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  border: 1px solid rgba(136, 174, 255, 0.23);
  border-radius: 14px;
  padding: 0.6rem;
  background: rgba(19, 32, 51, 0.66);
}

.rail-brand img {
  width: 42px;
  height: 42px;
  object-fit: contain;
  border-radius: 10px;
  background: rgba(78, 227, 196, 0.16);
  border: 1px solid rgba(102, 248, 214, 0.35);
}

.rail-brand strong {
  display: block;
  font-size: 0.95rem;
}

.rail-brand span {
  display: block;
  font-size: 0.75rem;
  color: var(--muted);
}

.rail-nav {
  display: grid;
  gap: 0.48rem;
}

.rail-item {
  width: 100%;
  text-align: left;
  border: 1px solid transparent;
  border-radius: 11px;
  padding: 0.62rem 0.72rem;
  background: rgba(13, 22, 36, 0.75);
  color: #cad8f0;
  cursor: pointer;
  font-weight: 600;
  min-height: 40px;
}

.rail-item.active,
.rail-item:hover {
  border-color: rgba(78, 227, 196, 0.48);
  color: #dcfff7;
  background: rgba(16, 35, 50, 0.9);
}

.rail-footer {
  margin-top: auto;
  text-align: center;
  color: var(--muted);
  font-size: 0.78rem;
}

.workspace {
  border: 1px solid var(--line);
  border-radius: 28px;
  background: linear-gradient(155deg, rgba(11, 19, 32, 0.84), rgba(8, 14, 24, 0.86));
  box-shadow: var(--shadow-2);
  padding: 0.9rem;
}

.app-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.82rem 0.95rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  background: linear-gradient(125deg, rgba(19, 35, 56, 0.92), rgba(14, 24, 39, 0.96));
  box-shadow: var(--shadow-1);
}

.brand h1 {
  margin: 0;
  font-size: 1.45rem;
}

.brand p {
  margin: 0.2rem 0 0;
  font-size: 0.86rem;
  color: var(--muted);
}

.user-badge {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.35rem 0.42rem 0.35rem 0.75rem;
  background: rgba(10, 16, 28, 0.85);
}

.user-badge span {
  font-size: 0.9rem;
  font-weight: 600;
  color: #d8e5ff;
}

.message-banner {
  margin-top: 0.8rem;
  border-radius: var(--radius-md);
  padding: 0.76rem 0.95rem;
  border: 1px solid transparent;
  font-size: 0.92rem;
}

.message-banner.ok {
  color: #c4ffec;
  background: rgba(37, 143, 115, 0.25);
  border-color: rgba(69, 215, 170, 0.58);
}

.message-banner.error {
  color: #ffd4df;
  background: rgba(161, 44, 77, 0.26);
  border-color: rgba(255, 113, 149, 0.55);
}

.content-grid {
  margin-top: 0.85rem;
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(320px, 0.85fr);
  gap: 0.85rem;
  align-items: start;
}

.content-grid.single-page {
  grid-template-columns: 1fr;
}

.card {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: linear-gradient(160deg, var(--card), var(--card-strong));
  box-shadow: var(--shadow-1);
  padding: 0.95rem;
}

#admin-users-card,
#admin-audit-card {
  grid-column: 2 / 3;
}

#auth-card,
#calculator-card,
#result-card {
  grid-column: 1 / 2;
}

#subscription-card,
#history-card {
  grid-column: 2 / 3;
}

#account-profile-card {
  grid-column: 1 / 2;
}

#account-profile-card .account-status-row strong {
  text-align: right;
  max-width: 62%;
  overflow-wrap: anywhere;
}

#auth-card {
  grid-column: 1 / -1;
}

.card h2 {
  margin: 0 0 0.7rem;
  font-size: 1.2rem;
}

.auth-card p {
  margin: 0;
  color: var(--muted);
}

.auth-grid {
  margin-top: 0.8rem;
  display: grid;
  gap: 0.75rem;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
}

.secondary-auth-grid {
  margin-top: 0.7rem;
}

.admin-access-form {
  margin-top: 0.75rem;
}

.mini-form {
  background: linear-gradient(150deg, rgba(22, 35, 55, 0.9), rgba(14, 23, 38, 0.94));
  border: 1px solid rgba(156, 189, 255, 0.2);
  border-radius: var(--radius-md);
  padding: 0.75rem;
  display: grid;
  gap: 0.4rem;
}

.mini-form h3 {
  margin: 0 0 0.2rem;
  font-size: 1.02rem;
}

form {
  display: grid;
  gap: 0.7rem;
}

.form-block {
  border: 1px solid rgba(149, 184, 252, 0.2);
  border-radius: var(--radius-md);
  background: rgba(11, 18, 30, 0.62);
  padding: 0.72rem;
}

.form-block h3 {
  margin: 0 0 0.5rem;
  font-size: 0.98rem;
  color: #d9e8ff;
}

.field-grid {
  display: grid;
  gap: 0.64rem;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
}

.field {
  display: grid;
  gap: 0.34rem;
}

label {
  font-size: 0.83rem;
  font-weight: 700;
  color: #d6e5ff;
}

input,
select,
button {
  font: inherit;
}

input:not([type="checkbox"]),
select {
  border: 1px solid rgba(154, 188, 250, 0.26);
  border-radius: 11px;
  padding: 0.62rem 0.7rem;
  background: rgba(8, 14, 25, 0.7);
  color: #ecf4ff;
}

input:not([type="checkbox"]):focus,
select:focus {
  outline: none;
  border-color: rgba(78, 227, 196, 0.66);
  box-shadow: 0 0 0 3px rgba(78, 227, 196, 0.2);
}

button {
  border: 0;
  border-radius: 11px;
  background: linear-gradient(130deg, #16305a, #112544);
  color: #f5fbff;
  font-weight: 700;
  padding: 0.7rem 0.88rem;
  cursor: pointer;
  transition: transform 0.15s ease, filter 0.15s ease;
}

button:hover {
  transform: translateY(-1px);
  filter: brightness(1.08);
}

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

.check-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  border: 1px solid rgba(149, 183, 248, 0.2);
  background: rgba(8, 14, 23, 0.72);
  border-radius: 11px;
  padding: 0.48rem 0.62rem;
}

.check-row input {
  width: 16px;
  height: 16px;
}

#resultados {
  border: 1px solid rgba(150, 184, 251, 0.22);
  border-radius: var(--radius-md);
  overflow: hidden;
  background: rgba(8, 14, 23, 0.58);
}

#resultados .item {
  display: flex;
  justify-content: space-between;
  gap: 0.7rem;
  padding: 0.72rem 0.88rem;
  border-bottom: 1px solid rgba(146, 182, 248, 0.17);
}

#resultados .item:last-child {
  border-bottom: 0;
}

#resultados .item.highlight-base {
  background: rgba(78, 227, 196, 0.13);
}

#resultados .item.total-liquido {
  background: rgba(69, 215, 170, 0.2);
  color: #c8ffef;
}

#resultados .item.total-descontos {
  background: rgba(255, 113, 149, 0.18);
  color: #ffd7e2;
}

#resultados .item.reserve-row {
  background: rgba(123, 123, 255, 0.2);
  color: #e7e7ff;
}

#resultados .item.meta-row {
  background: rgba(78, 227, 196, 0.16);
}

.print-control {
  margin-top: 0.8rem;
  display: none;
}

.history-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.55rem;
}

.history-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.72rem;
  border: 1px solid rgba(149, 184, 251, 0.2);
  border-radius: 11px;
  background: rgba(9, 16, 27, 0.72);
  padding: 0.65rem 0.76rem;
}

.history-list li p {
  margin: 0.25rem 0 0;
  color: var(--muted);
}

.history-empty {
  text-align: center;
  color: var(--muted);
}

#subscription-card {
  border-left: 4px solid var(--brand);
}

.info-card {
  background: linear-gradient(160deg, rgba(18, 37, 53, 0.92), rgba(13, 25, 39, 0.92));
}

.account-status-grid {
  display: grid;
  gap: 0.45rem;
}

.account-status-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  padding: 0.58rem 0.64rem;
  border: 1px solid rgba(149, 184, 251, 0.22);
  border-radius: 10px;
  background: rgba(9, 16, 27, 0.72);
}

.account-status-row span {
  color: var(--muted);
  font-size: 0.82rem;
}

.account-status-row strong {
  color: #e6f1ff;
}

.pix-text {
  margin: 0.62rem 0 0;
  color: #d6fff4;
  font-weight: 700;
}

.admin-card {
  border-left: 4px solid #7f8da6;
}

.admin-grid {
  display: grid;
  gap: 0.75rem;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}

.stats-grid {
  display: grid;
  gap: 0.55rem;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.stat-box {
  border: 1px solid rgba(149, 184, 251, 0.2);
  border-radius: 12px;
  background: rgba(8, 14, 24, 0.64);
  padding: 0.62rem 0.7rem;
}

.stat-box span {
  display: block;
  color: var(--muted);
  font-size: 0.8rem;
}

.stat-box strong {
  display: block;
  margin-top: 0.2rem;
  font-size: 1.2rem;
  color: #deecff;
}

.admin-actions {
  margin: 0.76rem 0;
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.admin-row-actions {
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
}

.admin-fill-btn,
.admin-status-btn {
  padding: 0.54rem 0.74rem;
}

.admin-expire-btn {
  background: linear-gradient(130deg, #7c6813, #64520f);
}

.admin-cancel-btn {
  background: linear-gradient(130deg, #7b243b, #5f1b2e);
}

.footer {
  width: min(1400px, calc(100vw - 1.4rem));
  margin: 0 auto 0.9rem;
  border: 1px solid rgba(152, 186, 251, 0.2);
  border-radius: 14px;
  background: rgba(9, 15, 26, 0.72);
  color: #a7b8d4;
  padding: 0.85rem;
  font-size: 0.8rem;
}

.footer p {
  margin: 0.24rem 0;
}

.footer a {
  color: #95ffe6;
  font-weight: 700;
  text-decoration: none;
}

.footer a:hover {
  text-decoration: underline;
}

.hidden {
  display: none !important;
}

.print-only {
  display: none !important;
}

@media (max-width: 1240px) {
  .app-layout {
    grid-template-columns: 1fr;
    gap: 0.75rem;
  }

  .side-rail {
    min-height: auto;
    padding: 0.72rem;
    position: static;
    border-radius: 18px;
  }

  .rail-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 0.44rem;
  }

  .rail-item {
    width: auto;
    flex: 1 1 180px;
    text-align: center;
  }
}

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

  #auth-card,
  #calculator-card,
  #result-card,
  #account-profile-card,
  #subscription-card,
  #history-card,
  #admin-users-card,
  #admin-audit-card {
    grid-column: 1 / -1;
  }
}

@media (max-width: 760px) {
  .workspace {
    padding: 0.72rem;
    border-radius: 20px;
  }

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

  .user-badge {
    width: 100%;
    justify-content: space-between;
  }

  .field-grid,
  .checkbox-grid {
    grid-template-columns: 1fr;
  }

  .app-layout {
    width: calc(100vw - 0.8rem);
    margin: 0.4rem auto 0.7rem;
  }

  .side-rail {
    padding: 0.62rem;
  }

  .rail-brand {
    padding: 0.52rem;
  }

  .rail-item {
    flex: 1 1 100%;
    text-align: left;
  }
}

@media print {
  body {
    background: #fff;
    color: #000;
  }

  .side-rail,
  .app-topbar,
  #auth-card,
  #subscription-card,
  #calculator-card,
  #history-card,
  .message-banner,
  .print-control,
  .footer {
    display: none !important;
  }

  .app-layout,
  .workspace {
    width: 100%;
    margin: 0;
    border: 0;
    padding: 0;
    box-shadow: none;
    background: #fff;
  }

  #result-card {
    box-shadow: none;
    border: 0;
    background: #fff;
    color: #000;
  }

  #print-header {
    display: block !important;
    margin-bottom: 0.72rem;
  }

  #resultados .item {
    border: 1px solid #000 !important;
    background: #fff !important;
    color: #000 !important;
  }
}
