:root {
  --bg: #12151a;
  --bg-elevated: #1a1f27;
  --bg-soft: #232a35;
  --line: rgba(212, 175, 106, 0.22);
  --gold: #d4af6a;
  --gold-bright: #f0d9a0;
  --gold-dim: #8a7348;
  --text: #f4f0e8;
  --muted: #9aa3b2;
  --ok: #3dba7e;
  --bad: #e35d5d;
  --in: #4db8a8;
  --out: #e8a87c;
  --shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
  --radius: 18px;
  --font-display: "Cormorant Garamond", Georgia, serif;
  --font-body: "Source Sans 3", "Segoe UI", sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(ellipse 80% 50% at 10% -10%, rgba(212, 175, 106, 0.16), transparent 55%),
    radial-gradient(ellipse 60% 40% at 100% 0%, rgba(77, 184, 168, 0.08), transparent 50%),
    var(--bg);
  color: var(--text);
  font-family: var(--font-body);
}

.hidden {
  display: none !important;
}

.view {
  min-height: 100vh;
}

.shell {
  width: min(1100px, 94vw);
  margin: 0 auto;
  padding: 2.5rem 0 3rem;
}

.shell-narrow {
  width: min(480px, 92vw);
  padding-top: 4rem;
}

.brand-block .eyebrow,
.eyebrow {
  margin: 0 0 0.4rem;
  font-size: 0.75rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--gold);
}

.brand-block h1,
.panel-head h2,
.crm-intro h1,
.block-head h2 {
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: 0.02em;
}

.lede,
.panel-head p,
.hero-copy {
  color: var(--muted);
  line-height: 1.55;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  margin: 1rem 0;
  padding: 0.45rem 0.9rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(26, 31, 39, 0.8);
  font-size: 0.9rem;
  font-weight: 600;
}

.status-pill.ok {
  color: var(--ok);
}

.status-pill.bad {
  color: var(--bad);
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.dot.ok {
  background: var(--ok);
  box-shadow: 0 0 0 5px rgba(61, 186, 126, 0.18);
  animation: pulse 2s ease-in-out infinite;
}

.dot.bad {
  background: var(--bad);
  box-shadow: 0 0 0 5px rgba(227, 93, 93, 0.18);
}

@keyframes pulse {
  0%,
  100% {
    box-shadow: 0 0 0 5px rgba(61, 186, 126, 0.18);
  }
  50% {
    box-shadow: 0 0 0 9px rgba(61, 186, 126, 0.08);
  }
}

.issues {
  margin: 1.25rem 0 1.5rem;
  display: grid;
  gap: 0.65rem;
}

.issue {
  text-align: left;
  padding: 0.9rem 1rem;
  border-radius: 12px;
  border: 1px solid rgba(227, 93, 93, 0.35);
  background: rgba(227, 93, 93, 0.08);
}

.issue-type {
  font-weight: 600;
  color: var(--bad);
  font-size: 0.92rem;
}

.issue-msg {
  margin-top: 0.3rem;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.4;
}

/* Welcome */
.welcome-layout {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  min-height: 100vh;
}

.welcome-hero {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: clamp(2rem, 6vw, 5rem);
  overflow: hidden;
  border-right: 1px solid var(--line);
}

.hero-glow {
  position: absolute;
  inset: auto -20% 10% -10%;
  height: 50%;
  background: radial-gradient(circle, rgba(212, 175, 106, 0.2), transparent 65%);
  pointer-events: none;
  animation: drift 12s ease-in-out infinite alternate;
}

@keyframes drift {
  from {
    transform: translateX(0);
  }
  to {
    transform: translateX(8%);
  }
}

.hero-title {
  margin: 0.2rem 0 1rem;
  font-family: var(--font-display);
  font-size: clamp(2.8rem, 6vw, 4.4rem);
  font-weight: 700;
  line-height: 1.05;
  color: var(--gold-bright);
}

.hero-copy {
  max-width: 28rem;
  margin: 0 0 1.5rem;
  font-size: 1.05rem;
}

.welcome-panel {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: clamp(2rem, 5vw, 4rem);
  background: linear-gradient(180deg, rgba(26, 31, 39, 0.92), rgba(18, 21, 26, 0.98));
}

.panel-head h2 {
  margin: 0;
  font-size: 2rem;
}

.panel-head p {
  margin: 0.4rem 0 1.6rem;
}

.login-form {
  display: grid;
  gap: 1rem;
  max-width: 380px;
}

.field {
  display: grid;
  gap: 0.4rem;
}

.field > span {
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

.field input,
.field select {
  width: 100%;
  padding: 0.85rem 1rem;
  border-radius: 12px;
  border: 1px solid rgba(154, 163, 178, 0.28);
  background: var(--bg-soft);
  color: var(--text);
  font: inherit;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.field input:focus,
.field select:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(212, 175, 106, 0.18);
}

.password-wrap {
  position: relative;
}

.password-wrap .link-btn {
  position: absolute;
  right: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
}

.link-btn {
  border: 0;
  background: none;
  color: var(--gold);
  font: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  padding: 0;
}

.form-error {
  margin: 0;
  padding: 0.7rem 0.85rem;
  border-radius: 10px;
  background: rgba(227, 93, 93, 0.12);
  border: 1px solid rgba(227, 93, 93, 0.35);
  color: #ffb4b4;
  font-size: 0.9rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.55rem;
  border: 0;
  border-radius: 12px;
  padding: 0.9rem 1.2rem;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.15s, opacity 0.15s, background 0.2s;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn:disabled {
  opacity: 0.65;
  cursor: wait;
  transform: none;
}

.btn-primary {
  margin-top: 0.35rem;
  background: linear-gradient(135deg, #e2c285, #b8924a);
  color: #1a1408;
}

.btn-ghost {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--text);
}

.btn-sm {
  padding: 0.5rem 0.85rem;
  font-size: 0.88rem;
  border-radius: 10px;
}

.btn-spinner {
  width: 1rem;
  height: 1rem;
  border-radius: 50%;
  border: 2px solid rgba(26, 20, 8, 0.25);
  border-top-color: #1a1408;
  animation: spin 0.7s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* CRM */
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.9rem clamp(1rem, 4vw, 2rem);
  background: rgba(18, 21, 26, 0.88);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}

.topbar-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.logo-mark {
  display: grid;
  place-items: center;
  width: 2.4rem;
  height: 2.4rem;
  border-radius: 10px;
  background: linear-gradient(145deg, var(--gold-bright), var(--gold-dim));
  color: #1a1408;
  font-weight: 700;
  font-size: 0.78rem;
  letter-spacing: 0.06em;
}

.topbar-brand strong {
  display: block;
  font-size: 0.98rem;
}

.topbar-brand .muted,
.muted {
  color: var(--muted);
  font-size: 0.85rem;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
  background: var(--bg-elevated);
  border: 1px solid var(--line);
  font-size: 0.9rem;
}

.crm-main {
  width: min(1180px, 94vw);
  margin: 0 auto;
  padding: 1.75rem 0 3rem;
}

.crm-intro h1 {
  margin: 0;
  font-size: 2.1rem;
}

.crm-intro p {
  margin: 0.25rem 0 1.25rem;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 0.85rem;
  margin-bottom: 1.25rem;
}

.metric {
  padding: 1rem 1.05rem;
  border-radius: var(--radius);
  background: var(--bg-elevated);
  border: 1px solid rgba(154, 163, 178, 0.15);
  box-shadow: var(--shadow);
  animation: rise 0.55s ease both;
}

.metric:nth-child(2) {
  animation-delay: 0.05s;
}
.metric:nth-child(3) {
  animation-delay: 0.1s;
}
.metric:nth-child(4) {
  animation-delay: 0.15s;
}
.metric:nth-child(5) {
  animation-delay: 0.2s;
}
.metric:nth-child(6) {
  animation-delay: 0.25s;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.metric-sale {
  border-color: rgba(212, 175, 106, 0.45);
  background: linear-gradient(160deg, rgba(212, 175, 106, 0.18), var(--bg-elevated) 60%);
}

.metric-alert {
  border-color: rgba(227, 93, 93, 0.4);
  background: linear-gradient(160deg, rgba(227, 93, 93, 0.14), var(--bg-elevated) 60%);
}

.metric-label {
  margin: 0;
  font-size: 0.78rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted);
}

.metric-value {
  margin: 0.45rem 0 0;
  font-family: var(--font-display);
  font-size: 1.65rem;
  font-weight: 600;
}

.metric-sub {
  margin: 0.2rem 0 0;
  font-size: 0.8rem;
  color: var(--muted);
}

.crm-grid {
  display: grid;
  grid-template-columns: 1.15fr 0.85fr;
  gap: 1rem;
  margin-bottom: 1rem;
}

.card-block {
  padding: 1.15rem 1.2rem 1.25rem;
  border-radius: var(--radius);
  background: var(--bg-elevated);
  border: 1px solid rgba(154, 163, 178, 0.14);
  box-shadow: var(--shadow);
}

.block-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.9rem;
}

.block-head h2 {
  margin: 0;
  font-size: 1.35rem;
}

.badge {
  min-width: 1.6rem;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  background: rgba(212, 175, 106, 0.2);
  color: var(--gold-bright);
  font-size: 0.8rem;
  font-weight: 700;
  text-align: center;
}

.inout-cols {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.inout-title {
  margin: 0 0 0.65rem;
  font-size: 0.85rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.inout-title.in {
  color: var(--in);
}

.inout-title.out {
  color: var(--out);
}

.txn-list,
.notif-panel {
  max-height: 320px;
  overflow: auto;
  display: grid;
  gap: 0.55rem;
}

.txn-item,
.notif-item {
  padding: 0.7rem 0.8rem;
  border-radius: 12px;
  background: var(--bg-soft);
  border: 1px solid rgba(154, 163, 178, 0.12);
}

.txn-item strong,
.notif-item strong {
  display: block;
  font-size: 0.92rem;
}

.txn-meta,
.notif-meta {
  margin-top: 0.25rem;
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.4;
}

.txn-amt {
  margin-top: 0.35rem;
  font-weight: 700;
  color: var(--gold-bright);
  font-size: 0.92rem;
}

.empty {
  margin: 0;
  padding: 1rem 0.25rem;
  color: var(--muted);
  font-size: 0.92rem;
}

.notif-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 0.85rem;
}

.tab {
  border: 1px solid rgba(154, 163, 178, 0.2);
  background: transparent;
  color: var(--muted);
  border-radius: 999px;
  padding: 0.4rem 0.75rem;
  font: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
}

.tab.active {
  background: rgba(212, 175, 106, 0.18);
  border-color: var(--line);
  color: var(--gold-bright);
}

.modules-block .block-head {
  flex-direction: column;
  align-items: flex-start;
}

.module-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 0.65rem;
}

.module-chip {
  padding: 0.85rem 0.9rem;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: linear-gradient(160deg, rgba(212, 175, 106, 0.1), transparent 70%);
  font-size: 0.9rem;
  font-weight: 600;
}

.module-chip.off {
  opacity: 0.45;
  border-color: rgba(154, 163, 178, 0.18);
  background: var(--bg-soft);
}

@media (max-width: 980px) {
  .welcome-layout {
    grid-template-columns: 1fr;
  }

  .welcome-hero {
    min-height: 36vh;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .crm-grid,
  .inout-cols {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 560px) {
  .topbar {
    flex-direction: column;
    align-items: stretch;
  }

  .topbar-actions {
    justify-content: space-between;
  }

  .metrics {
    grid-template-columns: 1fr;
  }
}
