:root {
  --ink: #16202A;
  --ink-soft: #4B5A66;
  --paper: #F6F7F5;
  --panel: #FFFFFF;
  --line: #E1E4E1;
  --brand: #0F5C4E;      /* deep teal — Hoopoe-ish, not generic SaaS blue */
  --brand-soft: #E4F0ED;
  --accent: #C8622C;     /* warm terracotta accent, used sparingly */
  --danger: #B3261E;
  --radius: 10px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, "Segoe UI", Inter, Roboto, sans-serif;
  color: var(--ink);
  background: var(--paper);
}

.app {
  display: grid;
  grid-template-columns: 232px 1fr;
  min-height: 100vh;
}

/* ---------- Sidebar ---------- */
.sidebar {
  background: #0D2B24;
  color: #EAF3F0;
  display: flex;
  flex-direction: column;
  padding: 20px 16px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 4px 20px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  margin-bottom: 16px;
}
.brand-mark {
  width: 34px; height: 34px;
  background: var(--accent);
  color: #fff;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700;
  font-size: 16px;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.25; }
.brand-text strong { font-size: 14px; }
.brand-text span { font-size: 11px; color: #9CC7BC; }

.nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.nav-item {
  text-align: left;
  background: none;
  border: none;
  color: #CFE4DE;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 14px;
  cursor: pointer;
}
.nav-item:hover { background: rgba(255,255,255,0.06); }
.nav-item.active { background: #16453A; color: #fff; font-weight: 600; }

.sidebar-footer { border-top: 1px solid rgba(255,255,255,0.1); padding-top: 14px; }
.current-user-box {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 12px; color: #CFE4DE; margin-bottom: 12px; gap: 8px;
}
.current-user-box .link-btn { color: #9CC7BC; flex-shrink: 0; }
.current-user-box .link-btn:hover { color: #fff; }
.profile-link {
  background: none; border: none; padding: 0; margin: 0; font: inherit; text-align: left;
  color: #CFE4DE; cursor: pointer; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0;
}
.profile-link:hover { color: #fff; text-decoration: underline; }

/* ---------- Settings (HubSpot-style category nav) ---------- */
.settings-layout { display: flex; align-items: flex-start; gap: 24px; margin-top: 8px; }
.settings-nav {
  display: flex; flex-direction: column; gap: 2px; width: 200px; flex-shrink: 0;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 8px;
}
.settings-nav-item {
  text-align: left; background: none; border: none; padding: 10px 12px; border-radius: 8px;
  font-size: 13.5px; color: var(--ink-soft); cursor: pointer;
}
.settings-nav-item:hover { background: #F0F1EE; color: var(--ink); }
.settings-nav-item.active { background: var(--brand-soft); color: var(--brand); font-weight: 600; }
.settings-content { flex: 1; min-width: 0; }
.settings-section { display: none; }
.settings-section.active { display: block; }
.sync-btn {
  width: 100%;
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  display: flex; align-items: center; gap: 8px; justify-content: center;
}
.sync-btn:hover { filter: brightness(1.08); }
.sync-btn:disabled { opacity: 0.6; cursor: default; }
.sync-dot { width: 7px; height: 7px; border-radius: 50%; background: #fff; }
.sync-status { font-size: 11.5px; color: #9CC7BC; margin-top: 8px; min-height: 14px; }

/* ---------- Main content ---------- */
.content { padding: 32px 40px; max-width: 1100px; }
.tab { display: none; }
.tab.active { display: block; }

h1 { font-size: 22px; margin: 0 0 4px; }
h2 { font-size: 15px; margin: 28px 0 12px; color: var(--ink-soft); }
.subtle { color: var(--ink-soft); font-size: 13.5px; margin: 0 0 20px; }
code { background: var(--brand-soft); padding: 1px 6px; border-radius: 4px; font-size: 12.5px; }

.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-top: 8px; }
.stat-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  display: flex; flex-direction: column; gap: 4px;
}
.stat-card[data-tab] { cursor: pointer; transition: border-color 0.1s, box-shadow 0.1s; }
.stat-card[data-tab]:hover { border-color: var(--brand); box-shadow: 0 1px 4px rgba(15,92,78,0.15); }
.stat-value { font-size: 26px; font-weight: 700; color: var(--brand); }
.stat-label { font-size: 12.5px; color: var(--ink-soft); }

.sync-log { display: flex; flex-direction: column; gap: 6px; }
.sync-log-row {
  font-size: 12.5px; color: var(--ink-soft);
  display: flex; gap: 10px; padding: 6px 10px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 6px;
}
.sync-log-row .ok { color: var(--brand); font-weight: 600; }
.sync-log-row .error { color: var(--danger); font-weight: 600; }

.tab-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.tab-actions { display: flex; gap: 8px; }
.tab-actions input[type="search"] {
  padding: 8px 12px; border: 1px solid var(--line); border-radius: 8px; font-size: 13px; width: 220px;
}

.primary-btn {
  background: var(--brand); color: #fff; border: none;
  padding: 8px 14px; border-radius: 8px; font-size: 13px; font-weight: 600; cursor: pointer;
}
.primary-btn:hover { filter: brightness(1.1); }
.secondary-btn {
  background: #fff; color: var(--ink); border: 1px solid var(--line);
  padding: 8px 14px; border-radius: 8px; font-size: 13px; font-weight: 600; cursor: pointer;
}
.secondary-btn:hover { background: #F0F1EE; }
.link-btn {
  background: none; border: none; color: var(--brand-soft); cursor: pointer; font-size: 12.5px;
}

.data-table { width: 100%; border-collapse: collapse; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.data-table th {
  text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.03em;
  color: var(--ink-soft); background: #F0F1EE; padding: 10px 14px; border-bottom: 1px solid var(--line);
}
.data-table th.sortable { cursor: pointer; user-select: none; }
.data-table th.sortable:hover { color: var(--ink); }
.data-table td { padding: 10px 14px; font-size: 13.5px; border-bottom: 1px solid var(--line); }
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: #FAFBF9; }
.row-actions button { background: none; border: none; cursor: pointer; font-size: 12.5px; color: var(--brand); margin-right: 10px; }
.row-actions button.danger { color: var(--danger); }

.badge {
  display: inline-block; font-size: 10.5px; font-weight: 700; padding: 2px 7px; border-radius: 999px;
  background: var(--brand-soft); color: var(--brand); text-transform: uppercase; letter-spacing: 0.02em;
}
.badge.local { background: #FBEAE0; color: var(--accent); }
.enriched-tag { margin-top: 4px; font-size: 10.5px; font-weight: 600; color: var(--brand); }

.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; max-width: 640px; }
.form-row { display: flex; gap: 8px; margin-top: 10px; }
.form-row input[type="password"], .form-row input[type="text"] {
  flex: 1; padding: 9px 12px; border: 1px solid var(--line); border-radius: 8px; font-size: 13.5px;
}
.token-status { font-size: 13px; margin-bottom: 4px; }
.token-status.ok { color: var(--brand); }
.token-status.missing { color: var(--danger); }
.token-message { margin-top: 10px; font-size: 13px; }
.token-message.ok { color: var(--brand); }
.token-message.error { color: var(--danger); }

.settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 14px; }
.settings-grid .field.full { grid-column: 1 / -1; }
.settings-grid .field { display: flex; flex-direction: column; gap: 4px; }
.settings-grid .field label { font-size: 12px; color: var(--ink-soft); }
.settings-grid .field input, .settings-grid .field textarea {
  padding: 8px 10px; border: 1px solid var(--line); border-radius: 7px; font-size: 13.5px; font-family: inherit;
}

/* ---------- Password show/hide ---------- */
.password-field { position: relative; }
.password-field input { width: 100%; padding-right: 54px; }
/* Both .form-row and .auth-form set their own (more specific) input padding —
   these re-assert padding-right so it isn't clobbered by those rules. */
.form-row .password-field input,
.auth-form .password-field input {
  padding-right: 54px;
}
.form-row .password-field { flex: 1; }
.password-toggle-btn {
  position: absolute; right: 4px; top: 50%; transform: translateY(-50%);
  background: none; border: none; color: var(--brand); font-size: 11.5px; font-weight: 600;
  cursor: pointer; padding: 4px 8px;
}
.password-toggle-btn:hover { text-decoration: underline; }

/* ---------- Auth overlay ---------- */
.auth-overlay {
  position: fixed; inset: 0; background: var(--paper);
  display: flex; align-items: center; justify-content: center; z-index: 100;
}
.auth-box {
  background: #fff; border-radius: 12px; padding: 32px; width: 380px; max-width: 90vw;
  box-shadow: 0 20px 60px rgba(0,0,0,0.12); border: 1px solid var(--line);
}
.auth-form .field { margin-bottom: 14px; display: flex; flex-direction: column; gap: 4px; }
.auth-form .field label { font-size: 12px; color: var(--ink-soft); }
.auth-form .field input {
  padding: 9px 11px; border: 1px solid var(--line); border-radius: 8px; font-size: 13.5px;
}
.auth-form .token-message:empty { display: none; }
.auth-forgot-row { text-align: right; margin: -8px 0 14px; }
.auth-link {
  background: none; border: none; padding: 0; margin: 0; font-size: 12.5px; font-weight: 600;
  color: var(--brand); cursor: pointer;
}
.auth-link:hover { text-decoration: underline; }

/* ---------- Modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(13,43,36,0.35);
  display: flex; align-items: center; justify-content: center; z-index: 50;
}
.modal {
  background: #fff; border-radius: 12px; padding: 24px; width: 420px; max-width: 90vw;
  box-shadow: 0 20px 60px rgba(0,0,0,0.2);
}
.modal h3 { margin: 0 0 16px; font-size: 16px; }
.modal .field { margin-bottom: 12px; display: flex; flex-direction: column; gap: 4px; }
.modal .field label { font-size: 12px; color: var(--ink-soft); }
.modal .field input {
  padding: 8px 10px; border: 1px solid var(--line); border-radius: 7px; font-size: 13.5px;
}
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }

.empty-state { padding: 40px 20px; text-align: center; color: var(--ink-soft); font-size: 13.5px; }

/* ---------- Quote editor ---------- */
.quote-header-grid {
  display: grid; grid-template-columns: 2fr 1fr 1fr 1.2fr 0.8fr; gap: 16px; align-items: end;
}
.quote-header-grid .field { display: flex; flex-direction: column; gap: 4px; }
.quote-header-grid .field label { font-size: 12px; color: var(--ink-soft); }
.quote-header-grid .field input, .quote-header-grid .field select {
  padding: 8px 10px; border: 1px solid var(--line); border-radius: 7px; font-size: 13.5px; background: #fff;
}
.quote-meta-line { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line); font-size: 12.5px; color: var(--ink-soft); }

.cell-input {
  width: 100%; border: 1px solid transparent; background: transparent; padding: 4px 6px; border-radius: 5px;
  font-size: 13.5px; font-family: inherit;
}
.cell-input:hover, .cell-input:focus { border-color: var(--line); background: #fff; outline: none; }
.cell-desc { font-size: 12px; color: var(--ink-soft); margin-top: 2px; }
.cell-desc::placeholder { color: #B7BFC5; }

.totals-row { display: flex; justify-content: space-between; font-size: 13.5px; padding: 5px 0; color: var(--ink-soft); }
.totals-row.grand { font-size: 16px; font-weight: 700; color: var(--brand); border-top: 1px solid var(--line); margin-top: 8px; padding-top: 10px; }

.tax-control { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; padding-bottom: 12px; border-bottom: 1px solid var(--line); }
.tax-control input[type="text"] { flex: 1; min-width: 0; padding: 6px 8px; border: 1px solid var(--line); border-radius: 6px; font-size: 13px; }
.tax-control input[type="number"] { width: 64px; padding: 6px 8px; border: 1px solid var(--line); border-radius: 6px; font-size: 13px; }

/* select elements inside the generic modal */
.modal select {
  padding: 8px 10px; border: 1px solid var(--line); border-radius: 7px; font-size: 13.5px; width: 100%; background: #fff;
}

/* ---------- Detail views (Company / Deal) ---------- */
.clickable-row { cursor: pointer; }

/* ---------- Quote Wizard ---------- */
.wizard-backdrop {
  position: fixed; inset: 0; background: rgba(13,43,36,0.4);
  display: flex; align-items: center; justify-content: center; z-index: 60; padding: 20px;
}
.wizard {
  background: #fff; border-radius: 14px; width: 640px; max-width: 100%; max-height: 88vh;
  display: flex; flex-direction: column; box-shadow: 0 24px 70px rgba(0,0,0,0.25);
}
.wizard-header { padding: 20px 26px 0; }
.wizard-header h3 { margin: 0 0 14px; font-size: 17px; }
.wizard-steps { display: flex; gap: 6px; margin-bottom: 18px; }
.wizard-step-dot {
  flex: 1; height: 4px; border-radius: 999px; background: var(--line);
}
.wizard-step-dot.active, .wizard-step-dot.done { background: var(--brand); }
.wizard-body { padding: 0 26px 20px; overflow-y: auto; flex: 1; }
.wizard-footer {
  padding: 16px 26px; border-top: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center;
}
.wizard-body .field { margin-bottom: 14px; display: flex; flex-direction: column; gap: 4px; }
.wizard-body .field label { font-size: 12px; color: var(--ink-soft); }
.wizard-body .field input, .wizard-body .field select {
  padding: 9px 11px; border: 1px solid var(--line); border-radius: 8px; font-size: 13.5px;
}
.wizard-tabs { display: flex; gap: 8px; margin-bottom: 14px; }
.wizard-tab-btn {
  flex: 1; padding: 9px; border-radius: 8px; border: 1px solid var(--line); background: #fff;
  font-size: 13px; font-weight: 600; cursor: pointer; color: var(--ink-soft);
}
.wizard-tab-btn.active { background: var(--brand); color: #fff; border-color: var(--brand); }
.product-search { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.product-search-input {
  flex: 1; min-width: 0; padding: 8px 10px; border: 1px solid var(--line); border-radius: 7px; font-size: 13.5px;
}
.product-search-input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.product-search-count { font-size: 12px; color: var(--ink-soft); white-space: nowrap; }
.product-pick-list { max-height: 300px; overflow-y: auto; border: 1px solid var(--line); border-radius: 8px; }
.product-pick-row {
  display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 12px;
  border-bottom: 1px solid var(--line); font-size: 13px;
}
.product-pick-row:last-child { border-bottom: none; }
.product-pick-row.active { background: var(--brand-soft); }
.product-pick-row button { font-size: 12px; }
.product-pick-row mark { background: #FBE3B8; color: inherit; border-radius: 2px; padding: 0 1px; }
.product-pick-info { min-width: 0; flex: 1; }
.product-pick-sku { color: var(--ink-soft); }
.product-pick-desc {
  margin-top: 2px; font-size: 12px; color: var(--ink-soft);
  overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
}
.product-pick-actions { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.product-pick-empty { color: var(--ink-soft); }
.staged-items-list { margin-top: 14px; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.staged-item-row {
  display: flex; justify-content: space-between; align-items: center; padding: 9px 12px;
  border-bottom: 1px solid var(--line); font-size: 13px;
}
.staged-item-row:last-child { border-bottom: none; }
