@import url('https://fonts.googleapis.com/css2?family=Hanken+Grotesk:wght@400;500;600;700&family=Cinzel:wght@500&display=swap');

:root {
  --olive: #5E6B4E;
  --olive-mid: #4A5540;
  --olive-dark: #343C2C;
  --gold: #C9A45C;
  --gold-light: #DCC07F;
  --brass: #8E6C35;
  --ivory: #FBF9F4;
  --white: #FFFFFF;
  --stone-100: #F3EEE5;
  --stone-200: #E9E1D3;
  --stone-300: #D6CBB8;
  --stone-400: #ADA290;
  --stone-500: #857B69;
  --stone-600: #655D4F;
  --stone-700: #4A4439;
  --stone-800: #2B2E25;
  --border: var(--stone-200);
  --success: #059669;
  --success-bg: #ECFDF5;
  --danger: #DC2626;
  --danger-bg: #FEF2F2;
  --warning: #8A5A1F;
  --warning-bg: #FBF3E6;
  --shadow-sm: 0 1px 3px rgba(52,60,44,.06), 0 1px 2px rgba(52,60,44,.04);
  --shadow: 0 4px 12px rgba(52,60,44,.08), 0 2px 4px rgba(52,60,44,.04);
  --shadow-lg: 0 12px 32px rgba(52,60,44,.12), 0 4px 8px rgba(52,60,44,.06);
  --radius: 10px;
  --radius-lg: 14px;
  --radius-xl: 20px;
  --font: 'Hanken Grotesk', sans-serif;
  --font-wordmark: 'Cinzel', serif;
  --sidebar-w: 240px;
  --topbar-h: 56px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: var(--font);
  font-weight: 400;
  color: var(--stone-800);
  background: var(--ivory);
  line-height: 1.5;
}

h1, h2, h3 {
  font-family: var(--font);
  font-weight: 600;
}

/* --- Login page --- */
.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 1rem;
}

.login-box {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 2.5rem 2rem;
  width: 100%;
  max-width: 380px;
}

.login-logo {
  display: block;
  width: 120px;
  margin: 0 auto 1rem;
}

.login-box .subtitle {
  color: var(--stone-500);
  font-size: 0.9rem;
  margin-bottom: 1.5rem;
  text-align: center;
}

/* --- Forms --- */
label {
  display: block;
  font-size: 0.85rem;
  font-weight: 500;
  margin-bottom: 0.25rem;
  color: var(--stone-800);
}

input, select, textarea {
  font-family: var(--font);
  font-size: 0.95rem;
  width: 100%;
  padding: 0.55rem 0.75rem;
  border: 1px solid var(--stone-300);
  border-radius: 4px;
  background: var(--white);
  color: var(--stone-800);
  margin-bottom: 1rem;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--olive);
}

button {
  font-family: var(--font);
  font-size: 0.9rem;
  font-weight: 500;
  padding: 0.6rem 1.2rem;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  display: inline-block;
  text-decoration: none;
}

.btn {
  font-family: var(--font);
  font-size: 13px;
  font-weight: 600;
  padding: 8px 16px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  cursor: pointer;
  display: inline-block;
  text-decoration: none;
}
.btn-primary { background: var(--olive); color: var(--ivory); }
.btn-primary:hover { background: var(--olive-mid); }
.btn-outline { background: var(--white); border-color: var(--stone-300); color: var(--olive-dark); }
.btn-outline:hover { background: var(--stone-100); }
.btn-sm { font-size: 12px; padding: 5px 12px; }
.btn-secondary { background: var(--stone-200); color: var(--stone-800); }
.btn-secondary:hover { background: var(--stone-300); }
.btn-danger { background: var(--danger); color: var(--white); }
.btn-small { font-size: 0.8rem; padding: 0.35rem 0.75rem; }

/* --- Shared: card, form, filter, pill, state --- */
.card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.form-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--stone-600);
  margin-bottom: 6px;
}

.form-input {
  font-family: var(--font);
  font-size: 14px;
  width: 100%;
  height: 38px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0 12px;
  background: var(--white);
  color: var(--stone-800);
}
textarea.form-input { height: auto; }
.form-input:focus {
  outline: none;
  border-color: var(--olive);
  box-shadow: 0 0 0 3px rgba(94,107,78,.15);
}

.filter-chip {
  display: inline-block;
  font-size: 13px;
  padding: 5px 12px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: var(--white);
  color: var(--stone-700);
  cursor: pointer;
  user-select: none;
}
.filter-chip.active {
  background: var(--olive);
  color: var(--ivory);
  border-color: var(--olive);
}

.pill {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 20px;
  background: var(--stone-200);
  color: var(--stone-600);
}
.pill-muted { background: var(--stone-100); color: var(--stone-400); }
.pill-live { background: var(--success-bg); color: var(--success); }

.btn-danger-outline {
  background: var(--white);
  border-color: var(--danger);
  color: var(--danger);
}
.btn-danger-outline:hover { background: var(--danger-bg); }

.state-empty, .state-loading {
  text-align: center;
  font-size: 14px;
  color: var(--stone-400);
  padding: 24px;
}
.state-error {
  font-size: 14px;
  color: var(--danger);
  padding: 16px 20px;
}

.error-msg {
  background: var(--danger-bg);
  color: var(--danger);
  padding: 0.6rem 0.75rem;
  border-radius: 4px;
  font-size: 0.85rem;
  margin-bottom: 1rem;
  display: none;
}
.error-msg.visible { display: block; }

.warning-msg {
  background: var(--warning-bg);
  color: var(--warning);
  padding: 0.6rem 0.75rem;
  border-radius: 4px;
  font-size: 0.85rem;
  margin-bottom: 1rem;
}

/* --- Home page --- */
.home-topbar {
  background: var(--olive);
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
}

.home-topbar-brand {
  font-family: var(--font-wordmark);
  font-size: 17px;
  font-weight: 500;
  letter-spacing: .14em;
  color: var(--ivory);
  text-decoration: none;
}

.home-topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.home-topbar-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--gold-light);
  color: var(--olive-dark);
  font-size: 12px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.home-topbar-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--ivory);
}

.home-topbar-logout {
  font-size: 12px;
  color: var(--gold);
  text-decoration: none;
  cursor: pointer;
  margin-left: 6px;
}

.home-content {
  background: var(--ivory);
  padding: 24px 28px;
}

.home-greeting {
  font-size: 22px;
  font-weight: 700;
  color: var(--olive-dark);
}

.home-subtitle {
  color: var(--stone-500);
  font-size: 15px;
  margin-top: 2px;
  margin-bottom: 18px;
}

.home-cards {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
  max-width: 800px;
}

.home-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 20px 22px;
  cursor: pointer;
  text-decoration: none;
  color: var(--stone-800);
  transition: box-shadow 0.15s;
  display: flex;
  flex-direction: column;
}

.home-card:hover { box-shadow: var(--shadow); }

.home-card-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--olive-dark);
  margin-bottom: 4px;
}

.home-card-screens {
  font-size: 14px;
  color: var(--stone-500);
  line-height: 1.6;
  flex: 1;
}

.home-card-btn {
  display: inline-block;
  background: var(--olive);
  color: var(--ivory);
  font-size: 13px;
  font-weight: 600;
  padding: 8px 16px;
  border-radius: var(--radius);
  margin-top: 14px;
  text-decoration: none;
  text-align: center;
}

/* --- Section layout --- */
.section-body {
  display: flex;
  min-height: 100vh;
}

.section-sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: var(--sidebar-w);
  height: 100vh;
  background: var(--olive);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  z-index: 10;
}

.section-sidebar-brand {
  display: block;
  padding: 20px 20px 4px;
  text-decoration: none;
}

.section-sidebar-brand .wordmark {
  font-family: var(--font-wordmark);
  font-size: 17px;
  font-weight: 500;
  letter-spacing: .14em;
  color: var(--ivory);
  display: block;
}

.section-sidebar-brand .hub-badge {
  display: inline-block;
  background: var(--gold-light);
  color: var(--olive-dark);
  font-size: 11px;
  font-weight: 600;
  border-radius: 4px;
  padding: 2px 7px;
  margin-top: 6px;
}

.section-sidebar-menu {
  flex: 1;
  padding: 12px 0;
  overflow-y: auto;
}

.section-sidebar-link {
  display: block;
  padding: 9px 20px;
  color: var(--stone-100);
  text-decoration: none;
  font-size: 14px;
  cursor: pointer;
  border-left: 3px solid transparent;
}

.section-sidebar-link:hover {
  background: rgba(251,249,244,.08);
}

.section-sidebar-link.active {
  color: var(--white);
  font-weight: 600;
  background: rgba(220,192,127,.18);
  border-left-color: var(--gold-light);
}

.section-sidebar-back {
  display: block;
  border: 1px solid rgba(251,249,244,.4);
  color: var(--ivory);
  font-size: 13px;
  font-weight: 500;
  padding: 8px 16px;
  border-radius: var(--radius);
  margin: 16px 20px;
  text-decoration: none;
  text-align: center;
  cursor: pointer;
  background: transparent;
}

.section-sidebar-back:hover {
  background: rgba(251,249,244,.08);
}

.section-sidebar-user {
  border-top: 1px solid rgba(251,249,244,.15);
  padding: 14px 20px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.section-sidebar-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--gold-light);
  color: var(--olive-dark);
  font-size: 12px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.section-sidebar-user-info {
  min-width: 0;
}

.section-sidebar-user-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--ivory);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.section-sidebar-user-role {
  font-size: 11px;
  color: var(--stone-400);
}

.section-sidebar-logout {
  font-size: 12px;
  color: var(--gold);
  text-decoration: none;
  cursor: pointer;
  margin-left: auto;
}

.section-content {
  flex: 1;
  margin-left: var(--sidebar-w);
  padding: 1.5rem;
  overflow-y: auto;
  min-height: 100vh;
}

.section-content h2 {
  color: var(--olive);
  font-size: 1.5rem;
  margin-bottom: 1rem;
}

.content-panel {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 1.25rem;
}

.not-built {
  color: var(--stone-500);
  font-style: italic;
  padding: 2rem 0;
}

/* --- Tables --- */
table {
  width: 100%;
  border-collapse: collapse;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 4px;
  margin-bottom: 1rem;
  font-size: 0.88rem;
}

th {
  text-align: left;
  padding: 0.6rem 0.75rem;
  background: var(--stone-200);
  font-weight: 500;
  font-size: 0.8rem;
}

td {
  padding: 0.55rem 0.75rem;
  border-top: 1px solid var(--border);
}

.paging {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.82rem;
  color: var(--stone-500);
  margin-bottom: 1rem;
}

.paging button { font-size: 0.8rem; padding: 0.3rem 0.7rem; }

/* --- Panels and fields --- */
.panel {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 1.25rem;
  margin-bottom: 1rem;
}

.panel h3 {
  color: var(--olive);
  font-size: 1.15rem;
  margin-bottom: 0.75rem;
}

.field-row { display: flex; gap: 1rem; }
.field-row > * { flex: 1; }

.toolbar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.toolbar input[type="search"] { max-width: 300px; margin-bottom: 0; }

.badge-archived {
  background: var(--stone-200);
  color: var(--stone-500);
  font-size: 0.72rem;
  padding: 0.15rem 0.4rem;
  border-radius: 3px;
  margin-left: 0.4rem;
}

.missing-value { color: var(--stone-500); font-style: italic; }
.clickable { cursor: pointer; }
.clickable:hover td { background: var(--ivory); }

/* --- Section topbar --- */
.section-topbar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  margin-bottom: 16px;
  min-height: 38px;
}

/* --- Settings blocks --- */
.settings-blocks { display: flex; flex-direction: column; gap: 16px; }
.settings-block-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  border-bottom: 1px solid var(--stone-100);
}
.settings-block-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--olive-dark);
}
.settings-block-body { padding: 16px 20px; }
.settings-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.settings-field { min-width: 0; }
.settings-field-help {
  font-size: 12px;
  color: var(--stone-500);
  margin-bottom: 4px;
}
.settings-field-status {
  color: var(--stone-500);
  font-style: italic;
  margin-bottom: 6px;
  font-size: 13px;
}
.settings-field .form-input { margin-bottom: 6px; }
.settings-field-ok {
  color: var(--success);
  font-size: 13px;
  margin-top: 4px;
}
.settings-test-section {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--stone-100);
}
.settings-test-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--olive-dark);
  margin-bottom: 4px;
}
.settings-test-desc {
  font-size: 13px;
  color: var(--stone-500);
  margin-bottom: 12px;
}

/* --- Team list --- */
.team-table-wrap { overflow-x: auto; }
.team-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
.team-table th {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--stone-500);
  background: var(--ivory);
  padding: 10px 14px;
  text-align: left;
  border: none;
}
.team-table td {
  font-size: 14px;
  color: var(--stone-800);
  padding: 12px 14px;
  border-top: none;
  border-bottom: 1px solid var(--stone-100);
}
.team-name { font-weight: 600; color: var(--olive); }
.team-paging {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 13px;
  color: var(--stone-500);
  padding: 10px 14px;
  border-top: 1px solid var(--stone-100);
}

/* --- Customer detail and forms --- */
.cust-detail { padding: 16px 20px; margin-bottom: 1rem; }
.cust-detail-title {
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--olive);
  margin-bottom: 12px;
}
.cust-detail-section {
  font-size: 14px;
  font-weight: 700;
  color: var(--olive-dark);
  margin-bottom: 8px;
  margin-top: 16px;
}
.cust-detail .form-label { margin-top: 0; }
.cust-detail .form-input { margin-bottom: 0; }
.cust-detail .cust-field { margin-bottom: 16px; }
.cust-detail .field-row { gap: 16px; margin-bottom: 16px; }
.cust-detail .field-row .form-input { margin-bottom: 0; }
.cust-detail-actions {
  display: flex;
  gap: 8px;
  margin: 16px 0;
  flex-wrap: wrap;
}
.cust-detail-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}
.cust-detail-row-btns { display: flex; gap: 6px; }
.cust-detail .error-msg { margin-top: 12px; }

/* --- Customer list --- */
.cust-filter-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.cust-filter-bar .form-input {
  max-width: 320px;
  margin-bottom: 0;
}
.cust-table-wrap { overflow-x: auto; }
.cust-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
.cust-table th {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--stone-500);
  background: var(--ivory);
  padding: 10px 14px;
  text-align: left;
  border: none;
}
.cust-table td {
  font-size: 14px;
  color: var(--stone-800);
  padding: 12px 14px;
  border-top: none;
  border-bottom: 1px solid var(--stone-100);
}
.cust-row { cursor: pointer; }
.cust-row:hover td { background: var(--stone-100); }
.cust-name { font-weight: 600; color: var(--olive); }
.cust-paging {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 13px;
  color: var(--stone-500);
  padding: 10px 14px;
  border-top: 1px solid var(--stone-100);
}

/* --- Responsive --- */
@media (max-width: 768px) {
  .home-cards { grid-template-columns: 1fr; }
  .home-content { padding: 16px; }
  .home-topbar { padding: 0 12px; }
  .section-sidebar {
    position: static;
    width: 100%;
    height: auto;
    flex-direction: row;
    flex-wrap: wrap;
    padding: 0.5rem;
  }
  .section-sidebar-brand { padding: 8px 12px 4px; }
  .section-sidebar-menu { display: flex; overflow-x: auto; padding: 4px 0; flex: none; width: 100%; }
  .section-sidebar-link { padding: 6px 12px; font-size: 13px; white-space: nowrap; border-left: none; border-bottom: 2px solid transparent; }
  .section-sidebar-link.active { border-left: none; border-bottom-color: var(--gold-light); }
  .section-sidebar-back { margin: 4px 8px; padding: 6px 12px; font-size: 12px; }
  .section-sidebar-user { padding: 8px 12px; border-top: none; }
  .section-content { margin-left: 0; padding: 1rem; min-height: auto; }
  .field-row { flex-direction: column; gap: 0; }
  table { font-size: 0.82rem; }
  th, td { padding: 0.4rem 0.5rem; }
  .cust-filter-bar .form-input { max-width: none; }
  .settings-fields { grid-template-columns: 1fr; }
  .ea-layout { grid-template-columns: 1fr; }
}

/* --- Email Automation --- */
.ea-layout {
  display: grid;
  grid-template-columns: 1.05fr 1fr;
  gap: 16px;
  align-items: start;
}
.ea-card + .ea-card { margin-top: 16px; }
.ea-process-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}
.ea-process-name {
  font-size: 15px;
  font-weight: 700;
  color: var(--olive-dark);
}
.ea-process-count {
  font-size: 12px;
  color: var(--stone-500);
}
.ea-category {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--stone-500);
  background: var(--ivory);
  padding: 10px 16px 6px;
}
.ea-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  cursor: pointer;
  border-bottom: 1px solid var(--stone-100);
}
.ea-row:hover { background: var(--stone-100); }
.ea-row-active { background: var(--stone-100); }
.ea-row-info { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.ea-row-name { font-size: 14px; font-weight: 500; }
.ea-row-meta { display: flex; align-items: center; gap: 6px; font-size: 12px; }
.ea-row-recip { color: var(--stone-500); }
.ea-always-on { font-size: 12px; color: var(--stone-400); font-style: italic; white-space: nowrap; }

/* On/off toggle */
.ea-toggle {
  position: relative;
  width: 40px;
  height: 22px;
  border-radius: 11px;
  border: none;
  background: var(--stone-300);
  cursor: pointer;
  padding: 0;
  flex-shrink: 0;
  transition: background 0.15s;
}
.ea-toggle-on { background: var(--olive); }
.ea-toggle-thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--white);
  transition: transform 0.15s;
}
.ea-toggle-on .ea-toggle-thumb { transform: translateX(18px); }

/* Editor */
.ea-editor-card { padding: 20px; }
.ea-editor-header { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; }
.ea-editor-title { font-size: 18px; font-weight: 600; }
.ea-field { margin-bottom: 12px; }
.ea-sms-prefix {
  font-size: 13px;
  color: var(--stone-500);
  background: var(--stone-100);
  padding: 8px 12px;
  border-radius: 6px 6px 0 0;
  border: 1px solid var(--border);
  border-bottom: none;
  margin-bottom: 0;
}
.ea-sms-prefix + .ea-field textarea.form-input {
  border-radius: 0 0 6px 6px;
}
.ea-vars { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-bottom: 12px; }
.ea-vars-label { font-size: 12px; color: var(--stone-500); font-weight: 500; }
.ea-var-chip {
  font-size: 12px;
  font-family: var(--font);
  padding: 3px 8px;
  border-radius: 4px;
  border: 1px solid var(--stone-300);
  background: var(--white);
  cursor: pointer;
  color: var(--stone-700);
}
.ea-var-chip:hover { background: var(--stone-100); }
.ea-sms-count { font-size: 13px; color: var(--stone-500); margin-bottom: 12px; }
.ea-actions { display: flex; gap: 8px; margin-bottom: 12px; }
.ea-error { font-size: 14px; color: var(--danger); min-height: 20px; margin-bottom: 8px; }
.ea-success { color: var(--success); }
.ea-preview-subject { font-size: 14px; font-weight: 500; margin-bottom: 8px; padding: 8px; background: var(--stone-100); border-radius: 6px; }
.ea-preview-iframe { width: 100%; min-height: 500px; border: 1px solid var(--border); border-radius: 6px; background: var(--white); }
.ea-preview-text { white-space: pre-wrap; font-size: 14px; padding: 12px; background: var(--stone-100); border-radius: 6px; }
