:root {
  --bg-page: #131716;
  --bg-surface: #1E2423;
  --bg-elevated: #262E2D;
  --bg-active-nav: #39403F;
  --bg-hover: #293130;
  --border-subtle: #313938;
  --border-default: #404747;
  --border-strong: #525B5A;
  --text-primary: #FFFFFF;
  --text-secondary: #CBD3D2;
  --text-muted: #919C9B;
  --teal-primary: #2F8481;
  --teal-hover: #389995;
  --teal-surface: #163D3C;
  --green-badge-bg: #1A5939;
  --green-badge-text: #9EE6B8;
  --amber-banner-bg: #9C7635;
  --violet-accent: #38389A;
  --violet-link: #9E9EFF;
  --danger-bg: #4C1D24;
  --danger-text: #FDA4AF;
  --font-display: 'Faktum', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-body: 'Roboto', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  min-height: 100vh;
  background-color: var(--bg-page);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.45;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

a {
  color: inherit;
  text-decoration: none;
}

button, input, select, textarea {
  font-family: inherit;
  font-size: inherit;
}

/* 2FA Security Banner (#9C7635 exact match) */
.security-banner {
  background: var(--amber-banner-bg);
  color: #FFFFFF;
  min-height: 40px;
  padding: 8px 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  font-size: 13.5px;
  font-weight: 500;
  gap: 8px;
}
.security-banner a {
  text-decoration: underline;
  font-weight: 700;
  cursor: pointer;
}
.security-banner .banner-close {
  position: absolute;
  right: 16px;
  background: transparent;
  border: none;
  color: #FFFFFF;
  font-size: 18px;
  cursor: pointer;
  padding: 4px 8px;
}

/* Global Top Header (56px height) */
.top-header {
  height: 56px;
  background: var(--bg-page);
  border-bottom: 1px solid var(--border-subtle);
  padding: 0 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 40;
}

.brand-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-display);
  font-size: 21px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: #FFFFFF;
  cursor: pointer;
}
.brand-logo-icon {
  width: 24px;
  height: 24px;
  background: #FFFFFF;
  color: #131716;
  border-radius: 5px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 900;
  font-size: 15px;
}

.top-header-right {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

.header-nav-btn {
  background: transparent;
  border: none;
  color: var(--text-primary);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
}
.header-nav-btn:hover {
  background: var(--bg-surface);
}

.ai-tools-pill {
  background: transparent;
  border: 1px solid #3E9B74;
  color: #9EE6B8;
  font-size: 11.5px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
}

.btn-upgrade {
  background: var(--teal-primary);
  color: #FFFFFF;
  border: none;
  border-radius: 6px;
  padding: 7px 14px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease;
}
.btn-upgrade:hover {
  background: var(--teal-hover);
}

/* Main Workspace Layout */
.workspace-shell {
  display: flex;
  min-height: calc(100vh - 96px);
  width: 100%;
}

/* Left Sidebar (228px exact width) */
.left-sidebar {
  width: 228px;
  min-width: 228px;
  background: var(--bg-page);
  border-right: 1px solid var(--border-subtle);
  padding: 12px 10px 32px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  user-select: none;
}

.store-switcher {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  margin-bottom: 8px;
  border-radius: 8px;
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-primary);
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
}
.store-switcher:hover {
  background: var(--bg-surface);
  border-color: var(--border-subtle);
}

.nav-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 12px;
  border-radius: 6px;
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
}
.nav-item:hover {
  background: var(--bg-surface);
  color: #FFFFFF;
}
.nav-item.active {
  background: var(--bg-active-nav);
  color: #FFFFFF;
  font-weight: 600;
}
.nav-item-left {
  display: flex;
  align-items: center;
  gap: 10px;
}
.nav-icon {
  width: 18px;
  text-align: center;
  font-size: 15px;
  opacity: 0.9;
}

.nav-children {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding-left: 28px;
  margin-bottom: 4px;
}
.nav-subitem {
  padding: 7px 12px;
  border-radius: 6px;
  color: var(--text-secondary);
  font-size: 13.5px;
  cursor: pointer;
}
.nav-subitem:hover {
  background: var(--bg-surface);
  color: #FFFFFF;
}
.nav-subitem.active {
  background: var(--bg-active-nav);
  color: #FFFFFF;
  font-weight: 600;
}

.badge-new {
  background: var(--green-badge-bg);
  color: var(--green-badge-text);
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}
.badge-success, .badge-sent, .badge-active, .badge-subscribed, .badge-enabled {
  background: var(--green-badge-bg);
  color: var(--green-badge-text);
}
.badge-draft, .badge-disabled, .badge-nonSubscribed {
  background: #2C3433;
  color: var(--text-secondary);
}
.badge-scheduled, .badge-waiting {
  background: #3B2F1E;
  color: #FCD34D;
}
.badge-danger, .badge-unsubscribed, .badge-canceled, .badge-exited {
  background: var(--danger-bg);
  color: var(--danger-text);
}
.badge-info {
  background: var(--teal-surface);
  color: #7CE8E4;
}

/* Main Content Area */
.main-content {
  flex: 1;
  min-width: 0;
  padding: 28px 36px 64px;
  max-width: 1440px;
}

/* Exact Dashboard Goals Hero (matching reference screenshot) */
.goals-hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 40px;
  padding: 32px 24px 44px;
  max-width: 1060px;
  margin: 0 auto;
}
.goals-hero-left {
  max-width: 560px;
}
.goals-hero-title {
  font-family: var(--font-display);
  font-size: 32px;
  line-height: 40px;
  font-weight: 600;
  color: #FFFFFF;
  margin: 0 0 28px;
  letter-spacing: -0.01em;
}
.goals-cta-block {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}
.goals-cta-label {
  font-size: 14px;
  font-weight: 600;
  color: #FFFFFF;
}
.btn-connect-store {
  background: var(--teal-primary);
  color: #FFFFFF;
  border: none;
  border-radius: 6px;
  width: 248px;
  height: 44px;
  font-size: 14.5px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.btn-connect-store:hover {
  background: var(--teal-hover);
}
.goals-cta-sub {
  font-size: 12px;
  color: var(--text-secondary);
  font-weight: 600;
}

.goals-hero-art {
  width: 260px;
  height: 220px;
  background: linear-gradient(145deg, #74D680 0%, #ABE8B2 55%, #FFFFFF 55%);
  border-radius: 20px;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.35);
  flex-shrink: 0;
}
.goals-art-store-badge {
  position: absolute;
  left: -24px;
  top: 28px;
  width: 68px;
  height: 68px;
  background: var(--teal-primary);
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 30px;
  box-shadow: 0 10px 24px rgba(0,0,0,0.3);
}
.goals-art-plus-badge {
  position: absolute;
  left: -46px;
  bottom: 44px;
  width: 54px;
  height: 54px;
  background: #A7E3AF;
  color: #FFFFFF;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  font-weight: 400;
}
.goals-art-radio {
  width: 126px;
  height: 76px;
  background: #236B68;
  border-radius: 10px;
  margin-top: 24px;
  display: flex;
  align-items: center;
  padding: 0 14px;
  gap: 12px;
  box-shadow: 0 8px 20px rgba(0,0,0,0.28);
}
.goals-art-dial {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: #E5EFEF;
  border: 3px solid #8FA8A7;
  position: relative;
}

.goals-cards-heading {
  text-align: center;
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 600;
  margin: 16px 0 24px;
}
.goals-feature-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
  max-width: 1060px;
  margin: 0 auto;
}
.goals-feature-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: 10px;
  padding: 28px 24px;
  text-align: center;
}
.goals-feature-icon {
  width: 52px;
  height: 52px;
  border-radius: 12px;
  background: #DCE5E5;
  color: #1E4E4C;
  margin: 0 auto 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
}

/* Standard Page Headers, Cards, Metrics, Tables, Buttons */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}
.page-title {
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 600;
  margin: 0;
}
.page-subtitle {
  color: var(--text-secondary);
  font-size: 13.5px;
  margin: 4px 0 0;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid var(--border-strong);
  background: var(--bg-surface);
  color: var(--text-primary);
  transition: all 0.14s ease;
}
.btn:hover {
  background: var(--bg-hover);
}
.btn-primary {
  background: var(--teal-primary);
  border-color: var(--teal-primary);
  color: #FFFFFF;
}
.btn-primary:hover {
  background: var(--teal-hover);
  border-color: var(--teal-hover);
}
.btn-danger {
  background: var(--danger-bg);
  border-color: #7F1D1D;
  color: var(--danger-text);
}
.btn-sm {
  padding: 5px 10px;
  font-size: 12.5px;
}

.card {
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: 10px;
  padding: 20px;
  margin-bottom: 20px;
  max-width: 100%;
  overflow-x: hidden;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.kpi-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: 10px;
  padding: 18px 20px;
}
.kpi-label {
  color: var(--text-secondary);
  font-size: 12.5px;
  font-weight: 500;
  margin-bottom: 6px;
}
.kpi-value {
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 700;
  color: #FFFFFF;
}
.kpi-delta {
  margin-top: 6px;
  font-size: 12px;
  color: var(--green-badge-text);
}

/* Filter Tabs & Search Toolbar */
.tabs-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  border-bottom: 1px solid var(--border-default);
  margin-bottom: 20px;
  overflow-x: auto;
}
.tab-btn {
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-secondary);
  padding: 10px 14px;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}
.tab-btn:hover {
  color: #FFFFFF;
}
.tab-btn.active {
  color: #FFFFFF;
  border-bottom-color: var(--teal-primary);
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.input, .select, .textarea {
  background: var(--bg-page);
  border: 1px solid var(--border-strong);
  color: var(--text-primary);
  border-radius: 6px;
  padding: 8px 12px;
  font-size: 13.5px;
}
.input:focus, .select:focus, .textarea:focus {
  outline: none;
  border-color: var(--teal-primary);
}

/* Data Tables */
.table-wrap {
  width: 100%;
  overflow-x: auto;
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: 10px;
}
table.data-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}
table.data-table th {
  padding: 12px 16px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-default);
  background: rgba(19, 23, 22, 0.45);
}
table.data-table td {
  padding: 13px 16px;
  border-bottom: 1px solid var(--border-subtle);
  vertical-align: middle;
}
table.data-table tr:last-child td {
  border-bottom: none;
}
table.data-table tr:hover td {
  background: var(--bg-hover);
}

/* Visual Builders & Canvases (Campaign Editor, Segment AST Builder, Workflow Canvas) */
.builder-grid {
  display: grid;
  grid-template-columns: 340px 1fr 340px;
  gap: 20px;
  align-items: start;
}

.email-canvas-preview {
  background: #FFFFFF;
  color: #131716;
  border-radius: 10px;
  margin: 0 auto;
  overflow: hidden;
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.45);
  transition: width 0.2s ease;
}

.workflow-canvas {
  background: radial-gradient(#2c3534 1px, transparent 1px);
  background-size: 20px 20px;
  background-color: #151A19;
  border: 1px solid var(--border-default);
  border-radius: 12px;
  padding: 32px 20px;
  min-height: 540px;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.wf-node {
  width: 340px;
  max-width: 100%;
  background: var(--bg-surface);
  border: 2px solid var(--border-default);
  border-radius: 10px;
  padding: 14px 16px;
  cursor: pointer;
  transition: border-color 0.15s, transform 0.12s;
  position: relative;
}
.wf-node:hover, .wf-node.selected {
  border-color: var(--teal-primary);
  transform: translateY(-1px);
}
.wf-edge {
  width: 2px;
  height: 34px;
  background: var(--border-strong);
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}
.wf-add-btn {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--teal-primary);
  color: #FFFFFF;
  border: none;
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.wf-branches {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  width: 100%;
  max-width: 740px;
  padding: 16px;
  border: 1px dashed var(--border-strong);
  border-radius: 10px;
  background: rgba(30, 36, 35, 0.45);
}

/* Modal & Drawer */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.68);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  width: 100%;
  max-width: 780px;
  max-height: 90vh;
  overflow-y: auto;
  padding: 24px;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.6);
}

.toast-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.toast {
  background: var(--teal-surface);
  border: 1px solid var(--teal-primary);
  color: #FFFFFF;
  padding: 12px 18px;
  border-radius: 8px;
  box-shadow: 0 10px 24px rgba(0,0,0,0.4);
  font-size: 13.5px;
  font-weight: 500;
}

/* Settings 2-column layout */
.settings-layout {
  display: grid;
  grid-template-columns: 230px 1fr;
  gap: 24px;
}

.overview-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 20px;
}

/* Responsive Mobile (<= 900px) */
@media (max-width: 900px) {
  .workspace-shell {
    flex-direction: column;
  }
  .left-sidebar {
    width: 100%;
    min-width: 0;
    border-right: none;
    border-bottom: 1px solid var(--border-subtle);
    flex-direction: row;
    flex-wrap: wrap;
    overflow: visible;
    padding: 8px 12px;
    gap: 4px;
  }
  .nav-children {
    display: none;
  }
  .main-content {
    padding: 18px 14px 48px;
  }
  .goals-hero {
    flex-direction: column;
    padding: 16px 8px;
    gap: 24px;
  }
  .goals-feature-grid,
  .overview-grid,
  .builder-grid,
  .settings-layout,
  .wf-branches {
    grid-template-columns: 1fr;
  }
  .top-header {
    padding: 4px 8px;
    gap: 4px;
    height: auto;
    min-height: var(--header-height);
    flex-wrap: wrap;
    overflow: visible;
  }
  .brand-logo {
    font-size: 15px;
    gap: 6px;
    flex-shrink: 0;
  }
  .top-header-right {
    gap: 4px;
    flex-shrink: 1;
    min-width: 0;
    flex-wrap: wrap;
  }
  .header-nav-btn {
    padding: 4px 6px;
    font-size: 11px;
    gap: 3px;
  }
  .ai-tools-pill {
    padding: 1px 4px;
    font-size: 9.5px;
  }
  .btn-upgrade {
    padding: 4px 7px;
    font-size: 10.5px;
    white-space: nowrap;
  }
  .page-header,
  .toolbar,
  .tabs-bar {
    flex-wrap: wrap;
    overflow-x: hidden;
    max-width: 100%;
  }
  .tab-btn {
    padding: 8px 10px;
    font-size: 12px;
    white-space: normal;
  }
  .table-wrap {
    overflow-x: hidden;
    max-width: 100%;
  }
  table.data-table {
    table-layout: fixed;
    width: 100%;
  }
  table.data-table th,
  table.data-table td {
    padding: 5px 2px;
    font-size: 9.5px;
    word-break: break-word;
    overflow-wrap: anywhere;
    white-space: normal;
    overflow: hidden;
  }
  .card,
  .metric-card,
  .btn,
  .input,
  .select,
  .textarea {
    max-width: 100%;
    min-width: 0;
  }
}
