:root {
  --bg-base: #090d16;
  --bg-surface: #111827;
  --bg-elevated: #1a2333;
  --bg-hover: #243046;
  --border: #283548;
  --border-bright: #3b4d6b;
  --text-main: #f3f6fc;
  --text-muted: #94a3b8;
  --text-dim: #64748b;
  --accent: #10b981;
  --accent-hover: #059669;
  --accent-soft: rgba(16, 185, 129, 0.14);
  --partner-a: #38bdf8;
  --partner-a-bg: rgba(56, 189, 248, 0.14);
  --partner-b: #a78bfa;
  --partner-b-bg: rgba(167, 139, 250, 0.14);
  --partner-both: #fbbf24;
  --partner-both-bg: rgba(251, 191, 36, 0.14);
  --danger: #ef4444;
  --danger-bg: rgba(239, 68, 68, 0.14);
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', Consolas, monospace;
}

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

html, body {
  background: var(--bg-base);
  color: var(--text-main);
  font-family: var(--font-sans);
  line-height: 1.55;
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--partner-a);
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}

/* Header & Top Bar */
.app-header {
  background: linear-gradient(180deg, #11192c 0%, #0c1220 100%);
  border-bottom: 1px solid var(--border);
  padding: 20px 24px 0 24px;
  position: sticky;
  top: 0;
  z-index: 50;
}

.header-inner {
  max-width: 1320px;
  margin: 0 auto;
}

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

.brand-title {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-badge {
  background: var(--accent-soft);
  color: var(--accent);
  border: 1px solid rgba(16, 185, 129, 0.35);
  font-weight: 700;
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 999px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.brand-title h1 {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.brand-sub {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 2px;
}

.header-kpis {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.kpi-pill {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  font-size: 12.5px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
}
.kpi-pill strong {
  color: var(--text-main);
  font-weight: 700;
}

/* Main Navigation Tabs */
.nav-tabs {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: none;
  padding-bottom: 0;
}
.nav-tabs::-webkit-scrollbar {
  display: none;
}

.tab-btn {
  background: transparent;
  color: var(--text-muted);
  border: none;
  border-bottom: 3px solid transparent;
  padding: 12px 16px;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.16s ease;
  font-family: inherit;
  border-radius: 8px 8px 0 0;
}
.tab-btn:hover {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.03);
}
.tab-btn.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
  background: rgba(16, 185, 129, 0.07);
}

/* Main Content Container */
.main-container {
  max-width: 1320px;
  margin: 0 auto;
  padding: 24px;
}

.tab-panel {
  display: none;
  animation: fadeIn 0.18s ease;
}
.tab-panel.active {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Cards & Grids */
.card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 20px;
  box-shadow: var(--shadow);
}

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

.card-title {
  font-size: 17px;
  font-weight: 700;
  color: var(--text-main);
}

.card-desc {
  color: var(--text-muted);
  font-size: 13.5px;
  margin-bottom: 14px;
}

.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px;
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

.grid-4 {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

@media (max-width: 980px) {
  .grid-2, .grid-3, .grid-4 {
    grid-template-columns: 1fr;
  }
  .main-container {
    padding: 16px;
  }
  .app-header {
    padding: 14px 16px 0 16px;
  }
}

/* Alert Callouts */
.callout {
  border-radius: var(--radius-sm);
  padding: 13px 16px;
  font-size: 13.5px;
  margin-bottom: 18px;
  border-left: 4px solid var(--accent);
  background: var(--accent-soft);
  color: #d1fae5;
}
.callout.warn {
  border-left-color: var(--partner-both);
  background: var(--partner-both-bg);
  color: #fef3c7;
}
.callout.danger {
  border-left-color: var(--danger);
  background: var(--danger-bg);
  color: #fee2e2;
}
.callout strong {
  color: #ffffff;
}

/* Badges */
.role-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11.5px;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 999px;
  white-space: nowrap;
}
.role-a {
  background: var(--partner-a-bg);
  color: var(--partner-a);
  border: 1px solid rgba(56, 189, 248, 0.35);
}
.role-b {
  background: var(--partner-b-bg);
  color: var(--partner-b);
  border: 1px solid rgba(167, 139, 250, 0.35);
}
.role-both {
  background: var(--partner-both-bg);
  color: var(--partner-both);
  border: 1px solid rgba(251, 191, 36, 0.35);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 9px 15px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  border: 1px solid var(--border-bright);
  background: var(--bg-elevated);
  color: var(--text-main);
  transition: all 0.15s ease;
}
.btn:hover {
  background: var(--bg-hover);
  border-color: var(--text-muted);
}
.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #04130d;
  font-weight: 700;
}
.btn-primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  color: #ffffff;
}
.btn-sm {
  padding: 6px 11px;
  font-size: 12px;
}
.btn.copied {
  background: #10b981 !important;
  border-color: #10b981 !important;
  color: #03150e !important;
}

/* Filter Bar & Progress */
.toolbar-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
}

.filter-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.filter-btn {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 7px 14px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.15s ease;
}
.filter-btn:hover {
  color: var(--text-main);
  border-color: var(--border-bright);
}
.filter-btn.active {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: var(--accent);
}

.progress-wrap {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  margin-bottom: 20px;
}
.progress-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  font-size: 13.5px;
  font-weight: 600;
}
.progress-bar-outer {
  width: 100%;
  height: 10px;
  background: var(--bg-elevated);
  border-radius: 999px;
  overflow: hidden;
}
.progress-bar-inner {
  height: 100%;
  background: linear-gradient(90deg, #10b981, #38bdf8);
  width: 0%;
  transition: width 0.25s ease;
}

/* Checklist Items */
.phase-block {
  margin-bottom: 22px;
}
.phase-header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}
.phase-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-main);
}
.phase-tag {
  font-size: 12px;
  color: var(--text-muted);
  background: var(--bg-elevated);
  padding: 3px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
}

.check-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.step-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: border-color 0.16s ease, background 0.16s ease;
  overflow: hidden;
}
.step-card:hover {
  border-color: var(--border-bright);
}
.step-card.done {
  border-color: rgba(16, 185, 129, 0.35);
  background: rgba(16, 185, 129, 0.04);
}

.step-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  padding: 16px 18px;
  cursor: pointer;
  user-select: none;
}

.step-top-left {
  display: flex;
  align-items: flex-start;
  gap: 13px;
  flex: 1;
  min-width: 0;
}

.step-checkbox {
  width: 22px;
  height: 22px;
  margin-top: 2px;
  accent-color: var(--accent);
  cursor: pointer;
  flex-shrink: 0;
}

.step-head-info {
  flex: 1;
  min-width: 0;
}

.step-badges-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 7px;
  margin-bottom: 6px;
}

.step-num-pill {
  background: rgba(255, 255, 255, 0.08);
  color: #ffffff;
  font-size: 11px;
  font-weight: 800;
  padding: 2px 8px;
  border-radius: 6px;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.meta-pill {
  background: rgba(15, 23, 42, 0.65);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 11.5px;
  font-weight: 600;
  padding: 2px 9px;
  border-radius: 999px;
  white-space: nowrap;
}
.meta-pill.free {
  color: #6ee7b7;
  border-color: rgba(16, 185, 129, 0.3);
  background: rgba(16, 185, 129, 0.09);
}

.step-title-text {
  font-size: 15.5px;
  font-weight: 700;
  color: var(--text-main);
  line-height: 1.4;
}
.step-card.done .step-title-text {
  text-decoration: line-through;
  color: var(--text-muted);
}

.step-toggle-btn {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
  padding: 6px 11px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  white-space: nowrap;
  font-family: inherit;
  flex-shrink: 0;
  transition: all 0.15s ease;
}
.step-toggle-btn:hover {
  color: var(--text-main);
  border-color: var(--border-bright);
  background: var(--bg-hover);
}

.step-details {
  padding: 0 18px 18px 53px;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
}
.step-details.collapsed {
  display: none;
}

@media (max-width: 720px) {
  .step-top {
    flex-direction: column;
    gap: 10px;
  }
  .step-toggle-btn {
    align-self: flex-start;
    margin-left: 35px;
  }
  .step-details {
    padding: 0 14px 16px 14px;
  }
}

.step-goal {
  margin-top: 13px;
  margin-bottom: 12px;
  padding: 10px 13px;
  background: rgba(56, 189, 248, 0.08);
  border-left: 3px solid var(--partner-a);
  border-radius: 6px;
  font-size: 13.5px;
  color: #e0f2fe;
}
.step-goal strong {
  color: #ffffff;
}

.step-substeps {
  list-style: none;
  counter-reset: substep-counter;
  display: flex;
  flex-direction: column;
  gap: 9px;
  margin-bottom: 13px;
}

.step-substeps li {
  counter-increment: substep-counter;
  position: relative;
  padding: 10px 13px 10px 40px;
  background: rgba(9, 13, 22, 0.65);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  color: #e2e8f0;
  line-height: 1.55;
}

.step-substeps li::before {
  content: counter(substep-counter);
  position: absolute;
  left: 11px;
  top: 10px;
  width: 21px;
  height: 21px;
  border-radius: 50%;
  background: var(--bg-hover);
  border: 1px solid var(--border-bright);
  color: var(--accent);
  font-size: 11.5px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
}

.step-substeps li strong {
  color: #ffffff;
}

.step-mistake {
  margin-bottom: 12px;
  padding: 9px 13px;
  background: rgba(251, 191, 36, 0.09);
  border-left: 3px solid var(--partner-both);
  border-radius: 6px;
  font-size: 13px;
  color: #fef3c7;
}
.step-mistake strong {
  color: #fde68a;
}

.step-done-box {
  padding: 10px 13px;
  background: rgba(16, 185, 129, 0.10);
  border: 1px solid rgba(16, 185, 129, 0.32);
  border-radius: 6px;
  font-size: 13px;
  color: #d1fae5;
  margin-bottom: 12px;
}
.step-done-box strong {
  color: #6ee7b7;
}

.step-links-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding-top: 4px;
}

.btn-jump {
  background: rgba(16, 185, 129, 0.12);
  border-color: rgba(16, 185, 129, 0.45);
  color: #6ee7b7;
}
.btn-jump:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: #03150e;
}

.btn-ext {
  background: rgba(56, 189, 248, 0.10);
  border-color: rgba(56, 189, 248, 0.35);
  color: #7dd3fc;
}
.btn-ext:hover {
  background: rgba(56, 189, 248, 0.22);
  border-color: var(--partner-a);
  color: #ffffff;
}

.step-card code, .card code {
  background: rgba(0, 0, 0, 0.42);
  border: 1px solid var(--border);
  padding: 1px 6px;
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 12.2px;
  color: #6ee7b7;
}

/* CRM Table & Lead Cards */
.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

table.crm-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}

.crm-table th {
  background: var(--bg-elevated);
  color: var(--text-muted);
  text-align: left;
  font-weight: 600;
  padding: 11px 12px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.crm-table td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.crm-table tr:hover td {
  background: rgba(255, 255, 255, 0.025);
}

.crm-table tr.selected-lead td {
  background: rgba(16, 185, 129, 0.10);
}

/* Inputs & Selects */
input[type="text"],
input[type="number"],
input[type="date"],
input[type="email"],
select,
textarea {
  width: 100%;
  background: var(--bg-base);
  color: var(--text-main);
  border: 1px solid var(--border-bright);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  font-size: 13.5px;
  font-family: inherit;
}

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

label.field-label {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 5px;
}

.field-group {
  margin-bottom: 13px;
}

.status-select {
  min-width: 145px;
  padding: 6px 8px;
  font-size: 12.5px;
  font-weight: 600;
}

/* Script & Prompt Pre Blocks */
.copy-box {
  background: #070b12;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px;
  margin-top: 8px;
}

.copy-box-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.copy-box-label {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--partner-a);
}

pre.copy-content {
  white-space: pre-wrap;
  word-wrap: break-word;
  font-family: var(--font-mono);
  font-size: 12.8px;
  color: #e2e8f0;
  line-height: 1.55;
}

/* Calculator Metrics */
.stat-box {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px;
}
.stat-label {
  font-size: 12px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 600;
}
.stat-value {
  font-size: 26px;
  font-weight: 800;
  margin-top: 4px;
  color: var(--text-main);
}
.stat-value.accent {
  color: var(--accent);
}
.stat-sub {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* Toast Notification */
.toast {
  position: fixed;
  bottom: 22px;
  right: 22px;
  background: #10b981;
  color: #03150e;
  font-weight: 700;
  font-size: 13.5px;
  padding: 11px 18px;
  border-radius: var(--radius-sm);
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.45);
  opacity: 0;
  pointer-events: none;
  transform: translateY(10px);
  transition: all 0.2s ease;
  z-index: 999;
}
.toast.show {
  opacity: 1;
  transform: translateY(0);
}

/* Printable Latvian Invoice Sheet Preview */
.invoice-paper {
  background: #ffffff;
  color: #111827;
  border-radius: var(--radius-sm);
  padding: 36px 40px;
  font-family: Arial, Helvetica, sans-serif;
  font-size: 13px;
  line-height: 1.45;
  box-shadow: var(--shadow);
}

.inv-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  border-bottom: 2px solid #111827;
  padding-bottom: 14px;
  margin-bottom: 20px;
}

.inv-title {
  font-size: 22px;
  font-weight: 800;
  color: #111827;
  letter-spacing: 0.02em;
}

.inv-meta {
  text-align: right;
  font-size: 13px;
  color: #1f2937;
}

.inv-parties {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  margin-bottom: 22px;
}

.inv-party-box {
  background: #f8fafc;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  padding: 12px 14px;
}

.inv-party-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  color: #475569;
  margin-bottom: 6px;
}

.inv-party-row {
  margin-bottom: 3px;
  color: #0f172a;
}

.inv-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 18px;
}

.inv-table th {
  background: #0f172a;
  color: #ffffff;
  text-align: left;
  padding: 9px 10px;
  font-size: 12px;
}

.inv-table td {
  border-bottom: 1px solid #cbd5e1;
  padding: 10px;
  color: #0f172a;
}

.inv-totals {
  margin-left: auto;
  width: 280px;
  margin-bottom: 18px;
}

.inv-total-row {
  display: flex;
  justify-content: space-between;
  padding: 5px 0;
  border-bottom: 1px solid #e2e8f0;
  color: #0f172a;
}
.inv-total-row.grand {
  font-weight: 800;
  font-size: 15px;
  border-bottom: 2px solid #0f172a;
  padding-top: 8px;
}

.inv-words {
  background: #f1f5f9;
  border-left: 3px solid #0f172a;
  padding: 9px 12px;
  margin-bottom: 18px;
  font-size: 12.5px;
  color: #0f172a;
}

.inv-legal-notes {
  border-top: 1px solid #cbd5e1;
  padding-top: 12px;
  font-size: 11.5px;
  color: #334155;
}
.inv-legal-notes p {
  margin-bottom: 5px;
}

/* Share & Sync Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(5, 8, 15, 0.78);
  backdrop-filter: blur(5px);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 18px;
  z-index: 900;
}

.modal-overlay.open {
  display: flex;
}

.modal-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-bright);
  border-radius: var(--radius);
  max-width: 680px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  padding: 22px 24px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.65);
}

.modal-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 14px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

/* PRINT STYLESHEET — Crisp White A4 Latvian Invoice ONLY */
@media print {
  @page {
    size: A4 portrait;
    margin: 14mm;
  }

  html, body {
    background: #ffffff !important;
    color: #000000 !important;
  }

  .app-header,
  .no-print,
  .modal-overlay,
  .toast {
    display: none !important;
  }

  .main-container {
    max-width: 100% !important;
    padding: 0 !important;
    margin: 0 !important;
  }

  .tab-panel {
    display: none !important;
  }

  #tab-legal {
    display: block !important;
  }

  .invoice-paper {
    box-shadow: none !important;
    border: none !important;
    padding: 0 !important;
    margin: 0 !important;
    width: 100% !important;
  }
}
