:root {
  --bg0: #0f1c1a;
  --bg1: #152824;
  --bg2: #1c342f;
  --line: rgba(180, 220, 200, 0.12);
  --text: #e8f2ed;
  --muted: #8aa89a;
  --accent: #3ecf8e;
  --accent-dim: #1f8a5a;
  --warn: #e8b84a;
  --danger: #e86a5c;
  --sidebar: 248px;
  --radius: 10px;
  --font: "Figtree", system-ui, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
[hidden] { display: none !important; }
body {
  font-family: var(--font);
  color: var(--text);
  background:
    radial-gradient(1200px 600px at 10% -10%, rgba(62, 207, 142, 0.14), transparent 55%),
    radial-gradient(900px 500px at 90% 0%, rgba(40, 120, 100, 0.18), transparent 50%),
    linear-gradient(160deg, var(--bg0), #0a1412 70%);
}
body:not(.is-authed) #app-view { display: none !important; }
body.is-authed #login-view { display: none !important; }
body:not(.is-authed) { overflow: hidden; }


code { font-family: var(--mono); font-size: 0.85em; color: var(--accent); }

.login-view {
  position: fixed;
  inset: 0;
  z-index: 100;
  min-height: 100%;
  display: grid;
  place-items: center;
  padding: 24px;
  overflow: auto;
  background:
    radial-gradient(1200px 600px at 10% -10%, rgba(62, 207, 142, 0.14), transparent 55%),
    radial-gradient(900px 500px at 90% 0%, rgba(40, 120, 100, 0.18), transparent 50%),
    linear-gradient(160deg, var(--bg0), #0a1412 70%);
}
.login-panel {
  width: min(420px, 100%);
  padding: 32px 28px;
  background: linear-gradient(180deg, rgba(28, 52, 47, 0.95), rgba(15, 28, 26, 0.98));
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.35);
  animation: rise 420ms ease-out;
}
.login-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}
.brand-row {
  display: flex;
  align-items: center;
  gap: 12px;
}
.login-logo-icon {
  width: 72px;
  height: 72px;
  object-fit: contain;
  flex: 0 0 auto;
  filter: drop-shadow(0 0 14px rgba(57, 255, 20, 0.28));
}
.brand-name {
  margin: 0;
  font-weight: 800;
  letter-spacing: -0.03em;
  font-size: 1.55rem;
  line-height: 1.05;
  color: var(--accent);
  white-space: nowrap;
}
.login-brand .brand-name {
  font-size: 2rem;
}
.brand {
  margin: 0;
  font-weight: 800;
  letter-spacing: -0.03em;
  font-size: 1.6rem;
  color: var(--accent);
}
.login-panel h1 {
  margin: 0 0 8px;
  font-size: 1.35rem;
  letter-spacing: -0.02em;
}
.login-sub { color: var(--muted); margin: 0 0 20px; line-height: 1.45; font-size: 0.95rem; }
.login-panel label, .panel label {
  display: grid;
  gap: 6px;
  margin-bottom: 12px;
  font-size: 0.85rem;
  color: var(--muted);
}
input, select {
  width: 100%;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.25);
  color: var(--text);
  font: inherit;
}
input:focus, select:focus {
  outline: 2px solid rgba(62, 207, 142, 0.35);
  border-color: var(--accent-dim);
}
.hint { color: var(--muted); font-size: 0.82rem; margin: 14px 0 0; }
.error { color: var(--danger); margin-top: 10px; font-size: 0.9rem; }

.btn {
  border: 1px solid var(--line);
  background: var(--bg2);
  color: var(--text);
  border-radius: 8px;
  padding: 10px 14px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
.btn.primary {
  background: linear-gradient(180deg, #49d89a, var(--accent-dim));
  border-color: transparent;
  color: #062018;
  width: 100%;
  margin-top: 4px;
}
.btn.ghost { background: transparent; width: 100%; }
.btn:hover { filter: brightness(1.08); }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; }
.btn-row .btn { width: auto; flex: 1; }

.app-view {
  display: grid;
  grid-template-columns: var(--sidebar) 1fr;
  min-height: 100%;
  animation: rise 280ms ease-out;
}
.sidebar {
  border-right: 1px solid var(--line);
  background: rgba(10, 20, 18, 0.72);
  backdrop-filter: blur(10px);
  display: flex;
  flex-direction: column;
  padding: 18px 14px;
  gap: 18px;
}
.sidebar-brand {
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: flex-start;
}
.sidebar-brand .brand-row {
  gap: 10px;
}
.sidebar-brand .brand-name {
  font-size: 1.15rem;
}
.brand-mark {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  font-weight: 800;
  background: linear-gradient(145deg, var(--accent), #1a6b4a);
  color: #062018;
}
.brand-mark-img {
  width: 40px;
  height: 40px;
  object-fit: contain;
  border-radius: 10px;
  flex: 0 0 auto;
  filter: drop-shadow(0 0 10px rgba(57, 255, 20, 0.22));
}
.sidebar-user {
  display: grid;
  gap: 2px;
  min-width: 0;
  width: 100%;
}
.sidebar-user #session-user-name {
  margin: 0;
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.01em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sidebar-user #role-badge,
.sidebar-brand small {
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: 0.68rem;
}
.nav-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  text-align: left;
  background: transparent;
  border: 0;
  color: var(--muted);
  padding: 10px 12px;
  border-radius: 8px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  margin-bottom: 4px;
}
.nav-item:hover { background: rgba(62, 207, 142, 0.08); color: var(--text); }
.nav-item.active {
  background: rgba(62, 207, 142, 0.16);
  color: var(--accent);
}
.nav-alert {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.35rem;
  height: 1.35rem;
  padding: 0 6px;
  border-radius: 999px;
  background: #e24b4b;
  color: #fff;
  font-size: 0.72rem;
  font-weight: 800;
  line-height: 1;
  letter-spacing: 0;
  box-shadow: 0 0 0 2px rgba(226, 75, 75, 0.25);
}
.nav-alert[hidden] { display: none !important; }
.sidebar-foot { margin-top: auto; display: grid; gap: 8px; }
.sync-meta { margin: 0; font-size: 0.75rem; color: var(--muted); line-height: 1.35; }

.main { padding: 22px 28px 40px; min-width: 0; }
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}
.topbar h2 { margin: 0; font-size: 1.45rem; letter-spacing: -0.03em; }
.pill {
  font-size: 0.75rem;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--muted);
  background: rgba(0, 0, 0, 0.2);
}
.tab { display: none; }
.tab.active { display: block; animation: fade 220ms ease; }

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}
.metrics-grid-secondary {
  margin-bottom: 16px;
}
.painel-server-slots {
  display: contents;
}
.metric-card {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(21, 40, 36, 0.72);
  min-height: 118px;
}
.metric-icon {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--accent);
  background: rgba(62, 207, 142, 0.12);
  border: 1px solid rgba(62, 207, 142, 0.25);
}
.metric-icon.is-sync {
  color: #6ec8ff;
  background: rgba(110, 200, 255, 0.12);
  border-color: rgba(110, 200, 255, 0.28);
}
.metric-icon.is-warn {
  color: var(--warn);
  background: rgba(232, 184, 74, 0.12);
  border-color: rgba(232, 184, 74, 0.3);
}
.metric-icon.is-muted {
  color: var(--muted);
  background: rgba(138, 168, 154, 0.1);
  border-color: rgba(138, 168, 154, 0.22);
}
.metric-body {
  min-width: 0;
  flex: 1;
}
.metric-body h3 {
  margin: 0 0 6px;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--muted);
}
.metric-value {
  margin: 0;
  font-size: 1.7rem;
  font-weight: 750;
  letter-spacing: -0.03em;
  line-height: 1.1;
}
.card-ok .metric-value { color: var(--accent); }
.card-expired .metric-value { color: var(--warn); }
.card-expired .metric-icon {
  color: var(--warn);
  background: rgba(232, 184, 74, 0.12);
  border-color: rgba(232, 184, 74, 0.3);
}
.card-server .metric-value { color: var(--accent); }
.metric-trend {
  display: block;
  margin-top: 8px;
  font-size: 0.75rem;
  color: var(--muted);
  line-height: 1.35;
}
.metric-matrix {
  display: grid;
  grid-template-columns: auto 1fr 1fr;
  gap: 4px 12px;
  align-items: center;
  margin-top: 2px;
}
.metric-matrix-head {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  text-align: center;
}
.metric-matrix-period {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.metric-matrix strong {
  text-align: center;
  font-size: 1.25rem;
  letter-spacing: -0.03em;
}
.metric-matrix strong.is-accent { color: var(--accent); }
.metric-matrix strong.is-sync-accent { color: #6ec8ff; }
.metric-trend.is-sync-summary { color: #6ec8ff; }
.card-webhook .metric-trend { color: var(--accent); }

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

.dashboard-mirror-panel {
  margin-top: 8px;
  margin-bottom: 12px;
}
.dashboard-mirror-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}
.dashboard-mirror-header h3 {
  margin: 0;
}
.dashboard-mirror-sub {
  margin: 6px 0 0;
  font-size: 0.85rem;
  max-width: 52rem;
}
.badge-month {
  flex: 0 0 auto;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--accent);
  background: rgba(62, 207, 142, 0.12);
  border: 1px solid rgba(62, 207, 142, 0.28);
}
.dashboard-mirror-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}
.dashboard-mirror-stat {
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(15, 28, 26, 0.45);
}
.dashboard-mirror-stat span {
  display: block;
  color: var(--muted);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 8px;
}
.dashboard-mirror-stat strong {
  font-size: 1.55rem;
  letter-spacing: -0.03em;
}
.dashboard-mirror-stat.is-primary strong {
  color: var(--accent);
}
.dashboard-mirror-stat.is-warn strong {
  color: var(--warn);
}
.dashboard-mirror-date {
  font-size: 1.15rem !important;
}
.dashboard-mirror-status {
  margin: 14px 0 0;
  font-size: 0.85rem;
  line-height: 1.45;
  color: var(--muted);
}
.dashboard-mirror-status.is-ok {
  color: var(--accent);
}
.dashboard-mirror-status.is-warn {
  color: var(--warn);
}
@media (max-width: 560px) {
  .dashboard-mirror-stats { grid-template-columns: 1fr; }
  .dashboard-mirror-header { flex-direction: column; }
}

.sync-server-stats-panel {
  margin: 0 0 12px;
}
.sync-server-stats-panel h3 {
  margin: 0 0 6px;
  font-size: 1rem;
  color: var(--muted);
  font-weight: 600;
}
.sync-server-matrix {
  display: grid;
  gap: 0;
  margin-top: 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  background: rgba(0, 0, 0, 0.16);
}
.sync-server-matrix-head,
.sync-server-matrix-row {
  display: grid;
  grid-template-columns: minmax(7rem, 1.2fr) repeat(4, minmax(4.5rem, 1fr));
  gap: 8px 12px;
  align-items: center;
  padding: 10px 14px;
}
.sync-server-matrix-head {
  border-bottom: 1px solid var(--line);
  background: rgba(21, 40, 36, 0.75);
}
.sync-server-matrix-head span {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  text-align: center;
}
.sync-server-matrix-head span:first-child {
  text-align: left;
}
.sync-server-matrix-row {
  border-bottom: 1px solid rgba(138, 168, 154, 0.12);
}
.sync-server-matrix-row:last-child {
  border-bottom: 0;
}
.sync-server-matrix-row.is-total {
  border-top: 1px solid rgba(138, 168, 154, 0.28);
  background: rgba(21, 40, 36, 0.55);
}
.sync-server-matrix-row.is-total .sync-server-name {
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-size: 0.82rem;
  color: var(--muted);
}
.sync-server-name {
  font-weight: 700;
  font-size: 0.95rem;
}
.sync-server-matrix-row strong {
  text-align: center;
  font-size: 1.2rem;
  letter-spacing: -0.03em;
}
.sync-server-matrix-row strong.is-day { color: #6ec8ff; }
.sync-server-matrix-row strong.is-month { color: var(--accent); }
@media (max-width: 720px) {
  .sync-server-matrix-head,
  .sync-server-matrix-row {
    grid-template-columns: minmax(5.5rem, 1fr) repeat(4, minmax(3.2rem, 1fr));
    gap: 6px 8px;
    padding: 8px 10px;
  }
  .sync-server-matrix-row strong { font-size: 1.05rem; }
  .sync-server-matrix-head span { font-size: 0.62rem; }
}

.lede { color: var(--muted); line-height: 1.5; max-width: 62ch; }
.muted { color: var(--muted); font-size: 0.88rem; }

.toolbar { display: flex; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.toolbar input { flex: 1; min-width: 200px; }
.toolbar select { width: 220px; }

.table-wrap {
  overflow: auto;
  max-height: calc(100vh - 220px);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(10, 18, 16, 0.45);
}
table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
th, td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { position: sticky; top: 0; background: #13231f; color: var(--muted); font-weight: 600; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.04em; }
tr:hover td { background: rgba(62, 207, 142, 0.05); }

.clients-empty {
  text-align: center !important;
  white-space: normal !important;
  padding: 48px 20px !important;
  color: var(--muted);
  font-size: 0.95rem;
}

.conta-cell {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
}
.conta-value {
  font-family: var(--mono);
  font-size: 0.92em;
}
.btn-copy-conta {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  padding: 0;
  border: none;
  border-radius: 5px;
  background: transparent;
  color: var(--muted);
  font-size: 0.85rem;
  line-height: 1;
  cursor: pointer;
  opacity: 0.55;
  transition: opacity 120ms ease, color 120ms ease, background 120ms ease;
}
.btn-copy-conta:hover,
.btn-copy-conta:focus-visible {
  opacity: 1;
  color: var(--accent);
  background: rgba(62, 207, 142, 0.12);
}
.btn-copy-conta.is-copied {
  opacity: 1;
  color: var(--accent);
}

.secret-cell {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
}
.secret-value {
  font-family: var(--mono);
  font-size: 0.9em;
  letter-spacing: 0.04em;
  color: var(--muted);
}
.secret-cell:has(.btn-reveal-secret.is-open) .secret-value {
  color: var(--text);
  letter-spacing: 0;
}
.btn-reveal-secret {
  flex: 0 0 auto;
  width: 26px;
  height: 26px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.2);
  color: var(--muted);
  font-size: 0.85rem;
  line-height: 1;
  cursor: pointer;
  opacity: 0.75;
  transition: opacity 120ms ease, color 120ms ease, border-color 120ms ease, background 120ms ease;
}
.btn-reveal-secret:hover,
.btn-reveal-secret:focus-visible {
  opacity: 1;
  color: var(--accent);
  border-color: rgba(62, 207, 142, 0.4);
  background: rgba(62, 207, 142, 0.1);
}
.btn-reveal-secret.is-open {
  opacity: 1;
  color: var(--accent);
  border-color: rgba(62, 207, 142, 0.45);
}

.clients-table-wrap {
  max-height: min(42vh, 420px);
}
.sent-today-panel { margin-top: 16px; }
.sent-today-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.sent-today-head h3 { margin: 0 0 4px; }
.sent-filter-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 8px;
}
.sent-filter-label {
  display: grid;
  gap: 4px;
  margin: 0;
  font-size: 0.78rem;
  color: var(--muted);
}
.sent-filter-label select {
  min-width: 9.5rem;
  width: auto;
}
.sent-today-stats {
  display: flex;
  gap: 16px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.sent-stat-card {
  min-width: 140px;
  padding: 12px 16px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.22);
}
.sent-stat-card span {
  display: block;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-bottom: 4px;
}
.sent-stat-card strong {
  font-size: 1.8rem;
  color: var(--accent, #3ecf8e);
  letter-spacing: -0.03em;
}
.sent-today-list { display: grid; gap: 10px; }
.sent-card {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.18);
}
.sent-card-fields {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 18px;
  font-size: 0.88rem;
}
.sent-card-fields .fld { display: grid; gap: 2px; }
.sent-card-fields .fld span {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}
.sent-card-fields .fld strong { font-weight: 600; }
.sent-card-fields .fld strong.is-months { color: var(--accent, #3ecf8e); }
.sent-card-side {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 10px 12px;
  min-width: 0;
}
.sent-card-side .op-line {
  margin: 0;
  font-size: 0.82rem;
  color: var(--muted);
  white-space: nowrap;
}
.sent-card-side .op-line strong { color: var(--text, #e8f0ec); }
.panel label.renewal-confirmed-check {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 0;
  font-size: 0.82rem;
  color: var(--muted);
  cursor: pointer;
  white-space: nowrap;
}
.panel label.renewal-confirmed-check input[type="checkbox"] {
  width: 16px;
  height: 16px;
  margin: 0;
  padding: 0;
  flex: 0 0 auto;
}
.sent-card-side .btn.sm {
  width: auto;
  white-space: nowrap;
}
@media (max-width: 720px) {
  .sent-card { grid-template-columns: 1fr; }
  .sent-card-side { justify-content: flex-start; }
}

.ops-table-wrap {
  max-height: 18rem; /* ~5 linhas + cabeçalho */
  overflow-y: auto;
  overflow-x: auto;
}
.ops-table-wrap thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: rgba(21, 40, 36, 0.96);
}
.ops-table-wrap td.ops-registro {
  white-space: normal;
  min-width: 280px;
  max-width: 640px;
  line-height: 1.45;
  color: var(--text, #e8f0ec);
}
.ops-table-wrap td.ops-tipo { font-weight: 600; }
.badge-status {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 4px;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: #fff;
  background: #1f9d55;
}
.badge-status.is-pending { background: #b8860b; }
.badge-status.is-error { background: #c0392b; }

.panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  background: rgba(21, 40, 36, 0.55);
  margin-bottom: 14px;
}
.panel h3 { margin: 0 0 12px; font-size: 1.05rem; }

.panel-collapsible > summary {
  list-style: none;
}
.panel-collapsible > summary::-webkit-details-marker {
  display: none;
}
.panel-collapsible-summary {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  cursor: pointer;
  user-select: none;
}
.panel-collapsible-summary:hover .panel-collapsible-heading h3 {
  color: var(--accent, #8aa89a);
}
.panel-collapsible-chevron {
  flex: 0 0 auto;
  width: 0.7rem;
  height: 0.7rem;
  margin-top: 0.45rem;
  border-right: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted);
  transform: rotate(-45deg);
  transition: transform 0.15s ease;
}
.panel-collapsible[open] > .panel-collapsible-summary .panel-collapsible-chevron {
  margin-top: 0.35rem;
  transform: rotate(45deg);
}
.panel-collapsible-heading {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
  flex: 1;
}
.panel-collapsible-heading h3 {
  margin: 0;
}
.panel-collapsible-body {
  margin-top: 12px;
}
.not-renewed-table-wrap {
  max-height: 15.5rem; /* ~5 linhas + cabeçalho */
  overflow-y: auto;
  overflow-x: auto;
}
.not-renewed-table-wrap thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: rgba(21, 40, 36, 0.96);
}
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.audit-toolbar {
  align-items: flex-end;
  margin-bottom: 10px;
}
.audit-table th,
.audit-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}
.audit-table th {
  color: var(--muted);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
}
.audit-actor-role {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 500;
}
.audit-action {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 6px;
  background: rgba(62, 207, 142, 0.1);
  border: 1px solid rgba(62, 207, 142, 0.22);
  font-size: 0.82rem;
  color: var(--accent);
}

.finance-toolbar {
  align-items: flex-end;
  margin-bottom: 14px;
}
.fin-filter-label {
  display: grid;
  gap: 6px;
  margin: 0;
  font-size: 0.8rem;
  color: var(--muted);
  min-width: 140px;
}
.finance-period-label {
  margin: 0 0 6px;
  flex: 1;
}
.finance-kpi-grid {
  margin-bottom: 8px;
}
.finance-kpi-grid .metric-value.is-sync-accent {
  color: #6ec8ff;
}
.finance-kpi-grid .metric-value.is-loss {
  color: var(--warn);
}
.finance-webhook-note {
  margin: 0 0 14px;
  font-size: 0.85rem;
}
.finance-forms {
  margin-top: 14px;
}
.fin-breakdown {
  margin-top: 8px;
}
.fin-breakdown-table-wrap {
  overflow-x: auto;
}
.fin-breakdown-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}
.fin-breakdown-table th,
.fin-breakdown-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  white-space: nowrap;
}
.fin-breakdown-table th {
  color: var(--muted);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
}
.fin-breakdown-table td.is-in { color: var(--accent); font-weight: 600; }
.fin-breakdown-table td.is-out { color: var(--warn); font-weight: 600; }

.fin-summary { display: grid; gap: 8px; }
.fin-card {
  padding: 12px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.18);
}
.fin-card strong { display: block; margin-bottom: 4px; }
.fin-card span { color: var(--muted); font-size: 0.85rem; }
.log-list { list-style: none; padding: 0; margin: 0; font-size: 0.85rem; color: var(--muted); }
.log-list li { padding: 6px 0; border-bottom: 1px solid var(--line); }
.mt { margin-top: 18px; }
.wh-item {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}
.btn.sm { padding: 6px 10px; font-size: 0.82rem; width: auto; }
.action-btns {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}
.action-btns .btn.sm {
  white-space: nowrap;
}
.op-create-panel .op-create-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: flex-end;
}
.op-create-panel .op-create-row label {
  flex: 1;
  min-width: 200px;
  margin: 0;
}
.op-create-panel .op-create-row .btn {
  width: auto;
  min-width: 120px;
}
.op-list-toolbar {
  margin-bottom: 12px;
  align-items: center;
}
.op-list { display: grid; gap: 10px; }
.op-card {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.18);
  margin-bottom: 0;
}
.op-card-top {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: flex-start;
  flex-wrap: wrap;
}
.op-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
}
.op-tabs label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 0;
  font-size: 0.82rem;
  color: var(--muted);
  cursor: pointer;
}
.op-tabs input { width: auto; }
.op-client-cols {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  padding-top: 8px;
  border-top: 1px solid var(--line);
}
.op-client-cols-label {
  font-size: 0.75rem;
  color: var(--muted);
  width: 100%;
  margin: 0;
}
.op-client-cols label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 0;
  font-size: 0.82rem;
  color: var(--text);
  cursor: pointer;
}
.op-client-cols input { width: auto; }
.btn.danger {
  border-color: rgba(232, 106, 92, 0.45);
  color: #ffb4aa;
}
.config-stack { display: grid; gap: 4px; }
.config-step {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin: 8px 0 12px;
}
.config-step h3 {
  margin: 0 0 4px;
  font-size: 1.1rem;
}
.config-step .muted { margin: 0; }
.config-step-num {
  flex: 0 0 auto;
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 700;
  color: #062016;
  background: var(--accent);
}
.brand-config-row {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 20px;
  align-items: start;
}
.brand-config-preview {
  display: grid;
  gap: 8px;
  justify-items: center;
  min-width: 110px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.18);
}
.brand-config-preview img {
  width: 64px;
  height: 64px;
  object-fit: contain;
  border-radius: 10px;
  background: #0a1612;
}
.brand-config-preview strong {
  font-size: 0.92rem;
  text-align: center;
}
.brand-config-fields {
  display: grid;
  gap: 10px;
  min-width: 0;
}
@media (max-width: 640px) {
  .brand-config-row { grid-template-columns: 1fr; }
}
.config-source-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 14px 20px;
}
.config-source-label {
  min-width: min(280px, 100%);
  margin: 0;
}
.config-source-hint {
  margin: 0;
  flex: 1;
  min-width: 200px;
  padding-bottom: 2px;
}
.config-sources { align-items: stretch; }
.config-source-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  opacity: 0.72;
  transition: opacity 160ms ease, border-color 160ms ease, box-shadow 160ms ease;
}
.config-source-card.is-active-source {
  opacity: 1;
  border-color: rgba(62, 207, 142, 0.45);
  box-shadow: 0 0 0 1px rgba(62, 207, 142, 0.12);
}
.config-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.config-card-head h3 { margin: 0; }
.config-card-tag {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 3px 8px;
  border-radius: 999px;
  color: #062016;
  background: var(--accent);
}
.config-card-tag.is-optional {
  color: var(--muted);
  background: rgba(138, 168, 154, 0.16);
  border: 1px solid var(--line);
}
.config-advanced {
  margin-top: 4px;
  border-top: 1px solid var(--line);
  padding-top: 10px;
}
.config-advanced summary {
  cursor: pointer;
  color: var(--muted);
  font-size: 0.88rem;
  margin-bottom: 10px;
  user-select: none;
}
.config-advanced summary:hover { color: var(--text); }
.config-map-toolbar {
  justify-content: flex-end;
  margin-bottom: 10px;
  gap: 8px;
}

.map-fields { display: grid; gap: 10px; }
.map-row {
  display: grid;
  grid-template-columns: 1fr 1.4fr auto auto;
  gap: 10px;
  align-items: end;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
}
.map-row label { margin: 0; }
.map-check {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 0.85rem;
  padding-bottom: 10px;
}
@media (max-width: 720px) {
  .map-row { grid-template-columns: 1fr; }
  .config-sources { grid-template-columns: 1fr; }
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(0, 0, 0, 0.65);
}
.modal[hidden] { display: none !important; }
.modal-card {
  width: min(920px, 100%);
  max-height: min(92vh, 900px);
  overflow: auto;
  background: linear-gradient(180deg, #1a332d, #101c19);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 18px 18px 14px;
  animation: rise 220ms ease;
}
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}
.modal-head h2 { margin: 0; font-size: 1.25rem; letter-spacing: -0.02em; }
.modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 14px;
}
.renewal-buyer-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin: 12px 0;
  flex-wrap: wrap;
}
.renewal-lines { display: grid; gap: 10px; }
.renewal-line {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px;
  background: rgba(0, 0, 0, 0.2);
  display: grid;
  gap: 8px;
}
.renewal-line.is-seed {
  border-color: rgba(62, 207, 142, 0.55);
  background: rgba(62, 207, 142, 0.08);
}
.renewal-line-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr auto;
  gap: 8px;
  align-items: end;
}
.renewal-line label { margin: 0; font-size: 0.75rem; color: var(--muted); display: grid; gap: 4px; }
.renewal-line input[readonly] { opacity: 0.85; }
.qty-ctrl { display: flex; gap: 4px; align-items: center; }
.qty-ctrl input { width: 64px; text-align: center; }
.renewal-total-bar {
  margin-top: 12px;
  padding: 12px 14px;
  border-radius: 10px;
  background: rgba(62, 207, 142, 0.12);
  border: 1px solid rgba(62, 207, 142, 0.25);
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
}
.payload-pre {
  margin: 8px 0 0;
  padding: 10px;
  border-radius: 8px;
  background: #0a1412;
  border: 1px solid var(--line);
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.72rem;
  max-height: 180px;
  overflow: auto;
  white-space: pre-wrap;
}
@media (max-width: 720px) {
  .renewal-line-grid { grid-template-columns: 1fr 1fr; }
}

.toast {
  position: fixed;
  bottom: 20px;
  right: 20px;
  background: #16362d;
  border: 1px solid var(--accent-dim);
  color: var(--text);
  padding: 12px 16px;
  border-radius: 10px;
  z-index: 90;
  animation: rise 200ms ease;
}

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

@media (max-width: 900px) {
  .app-view { grid-template-columns: 1fr; }
  .sidebar { position: sticky; top: 0; z-index: 5; }
  .grid-2 { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 560px) {
  .grid-2 { grid-template-columns: 1fr; }
}
