:root {
  --bg: #f5f7fb;
  --panel: #ffffff;
  --panel-2: #f0f4fa;
  --text: #0f172a;
  --muted: #5b6474;
  --border: #d7e0ee;
  --brand: #0f766e;
  --brand-2: #155e75;
  --danger: #be123c;
  --ok: #0f766e;
  --warning: #92400e;
  --radius: 16px;
  --shadow: 0 16px 40px rgba(15, 23, 42, 0.08);
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  background:
    radial-gradient(circle at 10% 0%, #e7fff7, transparent 45%),
    radial-gradient(circle at 90% 10%, #e8f3ff, transparent 40%),
    var(--bg);
  color: var(--text);
  font-family: "Sora", "Avenir Next", "Segoe UI", sans-serif;
  min-height: 100vh;
}

button,
input,
select {
  font: inherit;
}

.shell {
  min-height: 100vh;
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
  padding: 16px;
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 16px;
  transition: grid-template-columns 0.2s ease;
}

.shell.sidebar-collapsed {
  grid-template-columns: 88px 1fr;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  min-width: 0;
}

.sidebar {
  padding: 14px;
  position: sticky;
  top: 12px;
  height: fit-content;
}

.brand {
  padding: 10px;
  border-radius: 14px;
  background: #fff;
  color: var(--text);
  margin-bottom: 14px;
  border: 1px solid var(--border);
}

.brand-logo {
  display: block;
  width: 100%;
  max-height: 134px;
  object-fit: contain;
}

.brand-title {
  margin-top: 8px;
  text-align: center;
  font-weight: 700;
  font-size: 0.94rem;
  color: var(--text);
}

.nav {
  display: grid;
  gap: 8px;
}

.nav button {
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  padding: 10px 12px;
  border-radius: 12px;
  text-align: left;
  cursor: pointer;
}

.nav button.active {
  background: #dff7f4;
  border-color: #8ad6ce;
}

.nav-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
}

.nav-icon svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.nav-label {
  display: inline;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.shell.sidebar-collapsed .brand {
  padding: 8px;
}

.shell.sidebar-collapsed .brand-logo {
  max-height: 86px;
}

.shell.sidebar-collapsed .brand-title {
  display: none;
}

.shell.sidebar-collapsed .nav button {
  justify-content: center;
  padding: 10px;
}

.shell.sidebar-collapsed .nav-label {
  display: none;
}

.content {
  display: grid;
  gap: 18px;
  align-content: start;
  min-width: 0;
}

#mainContent {
  display: grid;
  gap: 9px;
}

.topbar {
  padding: 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.topbar-main {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.sidebar-toggle {
  width: 40px;
  height: 40px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
}

.sidebar-toggle svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.shell.sidebar-collapsed .sidebar-toggle svg {
  transform: rotate(180deg);
}

.mobile-menu-toggle {
  display: none;
}

.userline {
  color: var(--muted);
  font-size: 0.9rem;
  overflow-wrap: anywhere;
}

.btn {
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  border-radius: 12px;
  padding: 10px 12px;
  cursor: pointer;
}

.btn.primary {
  background: linear-gradient(120deg, var(--brand), var(--brand-2));
  color: #fff;
  border-color: transparent;
}

.btn.danger {
  color: var(--danger);
  border-color: #fecdd3;
}

.btn-with-spinner {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.loading-spinner {
  width: 16px;
  height: 16px;
  border: 2px solid #c9d6ee;
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.15s ease;
}

.loading-spinner.is-visible {
  opacity: 1;
  visibility: visible;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.icon-btn {
  width: 44px;
  height: 40px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.icon-btn svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.icon-btn.is-sent {
  color: var(--ok);
  border-color: #8dd3c8;
  background: #ecfdf7;
  position: relative;
}

.icon-btn.is-sent[disabled] {
  opacity: 1;
  cursor: not-allowed;
}

.icon-btn.is-sent[disabled]:hover::after {
  content: "";
  position: absolute;
  width: 14px;
  height: 14px;
  border: 2px solid #991b1b;
  border-radius: 50%;
  right: 5px;
  top: 5px;
}

.icon-btn.is-sent[disabled]:hover::before {
  content: "";
  position: absolute;
  width: 12px;
  height: 2px;
  background: #991b1b;
  right: 6px;
  top: 12px;
  transform: rotate(-35deg);
}

.toast-stack {
  position: fixed;
  right: 14px;
  bottom: 14px;
  z-index: 9999;
  display: grid;
  gap: 8px;
  max-width: min(380px, calc(100vw - 28px));
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  border-radius: 12px;
  border: 1px solid transparent;
  padding: 10px 12px;
  font-size: 0.92rem;
  line-height: 1.35;
  box-shadow: 0 12px 26px rgba(15, 23, 42, 0.18);
  transform: translateY(8px);
  opacity: 0;
  transition: opacity 0.2s ease, transform 0.2s ease;
  cursor: pointer;
}

.toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.toast-success {
  background: #ecfdf7;
  border-color: #8dd3c8;
  color: #065f46;
}

.toast-warning {
  background: #fffbeb;
  border-color: #f4cc77;
  color: #7c2d12;
}

.toast-error {
  background: #fff1f2;
  border-color: #fda4af;
  color: #9f1239;
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.projection-panel {
  background:
    radial-gradient(circle at 10% 0%, rgba(27, 163, 156, 0.12), transparent 45%),
    radial-gradient(circle at 100% 0%, rgba(21, 94, 117, 0.1), transparent 40%),
    var(--panel);
}

.projection-modern {
  border: 1px solid #d7e6f4;
  border-radius: 18px;
  padding: 14px;
  background:
    radial-gradient(circle at 0% 0%, rgba(26, 165, 155, 0.14), transparent 42%),
    radial-gradient(circle at 100% 0%, rgba(21, 94, 117, 0.12), transparent 40%),
    rgba(255, 255, 255, 0.96);
}

.projection-modern-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.projection-modern-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text);
}

.projection-modern-subtitle {
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.8rem;
}

.projection-trend {
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 0.76rem;
  font-weight: 700;
  border: 1px solid transparent;
}

.projection-trend.up {
  color: #065f46;
  background: #ecfdf5;
  border-color: #a7f3d0;
}

.projection-trend.down {
  color: #9f1239;
  background: #fff1f2;
  border-color: #fda4af;
}

.projection-trend.flat {
  color: #334155;
  background: #f1f5f9;
  border-color: #cbd5e1;
}

.projection-modern-meta {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 10px;
}

.projection-kpi {
  border: 1px solid #d9e7f3;
  background: rgba(255, 255, 255, 0.78);
  border-radius: 12px;
  padding: 8px 10px;
}

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

.projection-kpi strong {
  display: block;
  margin-top: 4px;
  color: var(--text);
  font-size: 1rem;
}

.projection-chart {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(84px, 1fr));
  gap: 10px;
  align-items: end;
  min-height: 240px;
  padding: 8px 0 4px;
}

.projection-bar-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
}

.projection-bar-wrap.is-peak .projection-value-pill {
  color: #065f46;
  border-color: #86efac;
  background: #ecfdf5;
}

.projection-bar-wrap.is-min .projection-value-pill {
  color: #1e3a8a;
  border-color: #bfdbfe;
  background: #eff6ff;
}

.projection-value-pill {
  font-size: 0.74rem;
  color: #0f172a;
  text-align: center;
  border: 1px solid #d8e6f2;
  border-radius: 999px;
  padding: 3px 8px;
  background: rgba(255, 255, 255, 0.92);
  min-width: 60px;
}

.projection-bar-shell {
  width: 42px;
  height: 188px;
  border-radius: 14px;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.76), rgba(227, 239, 252, 0.6)),
    linear-gradient(180deg, rgba(15, 118, 110, 0.15), rgba(21, 94, 117, 0.05));
  border: 1px solid rgba(22, 119, 141, 0.22);
  overflow: hidden;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.72);
}

.projection-bar {
  width: 100%;
  border-radius: 12px 12px 9px 9px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.42) 0%, rgba(255, 255, 255, 0) 36%),
    linear-gradient(180deg, #22c3b6 0%, #0f766e 56%, #155e75 100%);
  box-shadow: 0 -8px 18px rgba(15, 118, 110, 0.26);
  transform-origin: bottom;
  animation: projection-grow 0.55s ease both;
}

@keyframes projection-grow {
  from {
    transform: scaleY(0.12);
    opacity: 0.35;
  }

  to {
    transform: scaleY(1);
    opacity: 1;
  }
}

.projection-label {
  font-size: 0.74rem;
  color: #1f2937;
  text-align: center;
  font-weight: 600;
}

.card {
  padding: 14px;
}

.metric .label {
  color: var(--muted);
  font-size: 0.85rem;
}

.metric .value {
  font-size: 1.4rem;
  font-weight: 700;
  margin-top: 6px;
}

.toolbar {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  padding: 14px;
}

.audit-toolbar {
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  column-gap: 12px;
  row-gap: 10px;
}

.audit-toolbar .field {
  min-width: 0;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  padding: 14px;
}

.field {
  display: grid;
  gap: 6px;
}

.field label {
  font-size: 0.82rem;
  color: var(--muted);
}

input,
select {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px;
  background: #fff;
}

.table-wrap {
  overflow: auto;
  max-width: 100%;
  -webkit-overflow-scrolling: touch;
  padding: 0 14px 14px;
}

.pager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 0 2px;
}

.pager-info {
  color: var(--muted);
  font-size: 0.88rem;
}

.pager-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.88rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.pager-size {
  width: auto;
  min-width: 74px;
  padding: 8px 10px;
}

.pager-btn {
  width: 34px;
  height: 34px;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 880px;
}

th,
td {
  border-bottom: 1px solid var(--border);
  text-align: left;
  padding: 10px 8px;
  font-size: 0.9rem;
}

th {
  color: var(--muted);
  font-weight: 600;
}

.badge {
  display: inline-block;
  border-radius: 999px;
  padding: 2px 10px;
  font-size: 0.76rem;
  border: 1px solid var(--border);
}

.badge.active {
  color: #065f46;
  border-color: #6ee7b7;
  background: #ecfdf5;
}

.badge.paid {
  color: #1d4ed8;
  border-color: #93c5fd;
  background: #eff6ff;
}

.badge.cancelled {
  color: #9f1239;
  border-color: #fda4af;
  background: #fff1f2;
}

.login {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 16px;
}

.login-box {
  width: min(460px, 100%);
  padding: 20px;
}

.login-box h2 {
  margin: 0 0 8px;
}

.login-box p {
  margin: 0 0 16px;
  color: var(--muted);
}

.error {
  margin-top: 8px;
  color: var(--danger);
  font-size: 0.85rem;
  min-height: 18px;
}

.mobile-nav {
  display: none;
}

.mobile-drawer,
.mobile-drawer-backdrop {
  display: none;
}

.modal {
  position: fixed;
  inset: 0;
  display: none;
  z-index: 40;
}

.modal.is-open {
  display: block;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
}

.modal-card {
  position: relative;
  width: min(980px, calc(100% - 24px));
  max-height: calc(100vh - 24px);
  overflow: auto;
  margin: 12px auto;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 14px;
  border-bottom: 1px solid var(--border);
}

.modal-head h3 {
  margin: 0;
}

.statement-sim-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  padding: 12px 14px 0;
}

.statement-sim-kpi {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 12px;
  background: var(--panel-2);
}

.statement-sim-kpi span {
  display: block;
  color: var(--muted);
  font-size: 0.82rem;
}

.statement-sim-kpi strong {
  display: block;
  margin-top: 4px;
  font-size: 1rem;
}

@media (max-width: 1024px) {
  .shell {
    grid-template-columns: 1fr;
    gap: 12px;
    padding: 10px;
    max-width: 100%;
  }

  .sidebar {
    display: none;
  }

  .topbar {
    justify-content: flex-start;
  }

  .topbar-main {
    min-width: 0;
    flex: 1;
  }

  .sidebar-toggle {
    display: none;
  }

  .mobile-menu-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    padding: 0;
    border-radius: 10px;
    flex: 0 0 auto;
  }

  .grid-3,
  .toolbar,
  .form-grid,
  .statement-sim-summary {
    grid-template-columns: 1fr;
  }


  .projection-modern-meta {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .projection-bar-shell {
    width: 36px;
    height: 156px;
  }
  .pager {
    flex-direction: column;
    align-items: flex-start;
  }

  .mobile-nav {
    display: grid;
    gap: 8px;
  }

  .mobile-drawer-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.35);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
    z-index: 48;
  }

  .mobile-drawer-backdrop.is-open {
    opacity: 1;
    pointer-events: auto;
  }

  .mobile-drawer {
    display: block;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: min(78vw, 320px);
    padding: 12px;
    background: #fff;
    border-right: 1px solid var(--border);
    box-shadow: var(--shadow);
    transform: translateX(-105%);
    transition: transform 0.2s ease;
    z-index: 49;
    overflow: auto;
  }

  .mobile-drawer.is-open {
    transform: translateX(0);
  }

  .mobile-drawer .brand {
    margin-bottom: 12px;
  }

  table {
    min-width: 720px;
  }

  .mobile-nav button {
    width: 100%;
    text-align: left;
    border: 1px solid var(--border);
    background: #fff;
    border-radius: 10px;
    padding: 10px 12px;
    font-size: 0.9rem;
  }

  .mobile-nav button.active {
    background: #dff7f4;
    border-color: #8ad6ce;
  }

  .modal-card {
    width: calc(100% - 16px);
    max-height: calc(100vh - 16px);
    margin: 8px auto;
  }
}

@media (max-width: 768px) {
  table {
    min-width: 640px;
  }
}

@media (max-width: 480px) {
  table {
    min-width: 560px;
  }

  .mobile-drawer {
    width: 86vw;
  }
}
