:root {
  --bg-base: #f3efe7;
  --bg-deep: #0d1b2a;
  --bg-panel: rgba(11, 24, 38, 0.78);
  --bg-panel-soft: rgba(255, 255, 255, 0.08);
  --text-strong: #f8fafc;
  --text-soft: #bed1df;
  --text-dark: #102033;
  --line-strong: rgba(160, 181, 203, 0.22);
  --line-soft: rgba(255, 255, 255, 0.08);
  --accent: #c96f32;
  --accent-strong: #de8451;
  --danger: #8b1e2d;
  --shadow-soft: 0 24px 70px rgba(8, 15, 27, 0.22);
  --shadow-deep: 0 28px 90px rgba(4, 10, 20, 0.4);
}

body {
  margin: 0;
  font-family: "Avenir Next", "Trebuchet MS", "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at top left, rgba(212, 130, 77, 0.18), transparent 30%),
    radial-gradient(circle at 85% 10%, rgba(84, 128, 161, 0.2), transparent 28%),
    linear-gradient(160deg, #e9e1d4 0%, #f4f0e8 38%, #dfe8ee 100%);
  color: var(--text-strong);
  min-height: 100vh;
}

.app {
  max-width: 1120px;
  margin: 0 auto;
  padding: 28px 20px 120px;
}

.header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 22px;
}

.header h1 {
  margin: 4px 0 0;
  color: var(--text-dark);
  font-size: clamp(2rem, 4vw, 3.4rem);
  line-height: 0.95;
  letter-spacing: 0;
}

.eyebrow,
.section-eyebrow {
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 11px;
  font-weight: 700;
}

.eyebrow {
  color: rgba(16, 32, 51, 0.62);
}

.section-eyebrow {
  color: #9fb9cb;
}

.header-actions,
.top-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

button {
  padding: 11px 15px;
  border: 1px solid transparent;
  border-radius: 12px;
  cursor: pointer;
  margin-top: 8px;
  background: #203246;
  color: var(--text-strong);
  font-size: 13px;
  font-weight: 600;
  transition: transform 160ms ease, box-shadow 160ms ease, background 160ms ease, border-color 160ms ease;
}

button:hover {
  transform: translateY(-1px);
}

.primary-btn {
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  box-shadow: 0 16px 34px rgba(201, 111, 50, 0.22);
}

.secondary-btn {
  background: rgba(16, 32, 51, 0.86);
  border-color: rgba(190, 209, 223, 0.18);
}

.view {
  margin-top: 20px;
}

.hidden {
  display: none !important;
}

.card {
  background: var(--bg-panel);
  backdrop-filter: blur(16px);
  border: 1px solid var(--line-soft);
  padding: 14px;
  margin-top: 12px;
  border-radius: 18px;
  box-shadow: var(--shadow-soft);
}

.auth-gate {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(6, 15, 26, 0.78);
  backdrop-filter: blur(10px);
}

.auth-card {
  width: min(420px, 100%);
  padding: 30px;
  border-radius: 22px;
  background: linear-gradient(180deg, rgba(11, 24, 38, 0.96), rgba(13, 27, 42, 0.94));
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: var(--shadow-deep);
}

.auth-card h2 {
  margin: 10px 0 6px;
  font-size: 2rem;
  color: var(--text-strong);
}

.auth-copy {
  margin: 0 0 16px;
  color: var(--text-soft);
  line-height: 1.5;
}

.auth-actions {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.auth-link-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.auth-form label {
  color: #cbd5e1;
  font-size: 12px;
  font-weight: 600;
}

.auth-form button {
  margin-top: 4px;
}

.auth-form input {
  margin-top: 0;
}

.auth-error {
  min-height: 18px;
  color: #fca5a5;
  font-size: 12px;
}

.hero-shell {
  position: relative;
  overflow: hidden;
  background:
    linear-gradient(145deg, rgba(10, 23, 37, 0.95), rgba(14, 37, 58, 0.9)),
    linear-gradient(90deg, rgba(255, 255, 255, 0.08), transparent);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 32px;
  padding: 32px;
  box-shadow: var(--shadow-deep);
}

.hero-home-actions {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 18px;
  position: relative;
  z-index: 1;
}

.hero-new-quote-btn {
  margin-top: 0;
}

.hero-shell::before {
  content: "";
  position: absolute;
  inset: auto -8% -30% auto;
  width: 320px;
  height: 320px;
  background: radial-gradient(circle, rgba(201, 111, 50, 0.28), transparent 68%);
  pointer-events: none;
}

.home-grid {
  margin-top: 0;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  position: relative;
  z-index: 1;
}

.version-select {
  min-width: 170px;
  margin-top: 8px;
  background: rgba(8, 18, 31, 0.86);
  color: var(--text-strong);
}

.home-tile {
  margin-top: 0;
  min-height: 180px;
  padding: 22px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: space-between;
  text-align: left;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 24px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.home-tile strong {
  display: block;
  margin-top: 20px;
  font-size: 1.35rem;
  line-height: 1.05;
}

.home-tile-label {
  color: #f2bf9c;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.home-tile-text {
  display: block;
  margin-top: 10px;
  color: var(--text-soft);
  line-height: 1.5;
}

.home-tile-primary {
  background: linear-gradient(135deg, rgba(201, 111, 50, 0.2), rgba(255, 255, 255, 0.08));
}

.list-shell {
  padding: 20px;
}

.list-shell-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 8px;
}

.list-view-title {
  margin: 6px 0 0;
  font-size: clamp(1.5rem, 3vw, 2.2rem);
  color: var(--text-strong);
}

.search-card {
  margin-bottom: 14px;
}

.empty-list {
  padding: 24px 16px;
  color: rgba(16, 32, 51, 0.62);
  text-align: center;
  background: rgba(255, 255, 255, 0.42);
  border: 1px dashed rgba(16, 32, 51, 0.12);
  border-radius: 18px;
}

.quote-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.quote-main {
  flex: 1;
  margin-top: 0;
  padding: 6px 0;
  background: transparent;
  text-align: left;
  color: var(--text-strong);
}

.delete-quote-btn {
  flex: 0 0 auto;
  margin-top: 0;
  background: var(--danger);
}

input,
select {
  width: 100%;
  padding: 10px;
  border-radius: 10px;
  border: 1px solid var(--line-strong);
  margin-top: 6px;
  background: rgba(8, 18, 31, 0.86);
  color: var(--text-strong);
  outline: none;
  box-sizing: border-box;
}

input::placeholder {
  color: rgba(190, 209, 223, 0.62);
}

.client-name-group {
  display: grid;
  grid-template-columns: 110px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
}

.client-name-group input,
.client-name-group select {
  margin-top: 6px;
}

/* ROW */
.row {
  display: flex;
  gap: 10px;
  margin-top: 10px;
}

.compact-row {
  align-items: center;
  margin-top: 0;
}

.compact-row button {
  flex: 0 0 auto;
}

.field {
  flex: 1;
}

.field label {
  display: block;
  font-size: 12px;
  color: #cbd5e1;
}

.lead-link-row {
  align-items: end;
}

.lead-link-field {
  flex: 1 1 100%;
}

.lead-link-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 42px;
  margin-top: 6px;
  padding: 8px 10px;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  background: rgba(8, 18, 31, 0.56);
}

.lead-link-actions button {
  margin-top: 0;
  flex: 0 0 auto;
}

.lead-link-status {
  color: var(--text-soft);
  font-size: 12px;
  font-weight: 600;
}

.chat-command {
  margin-top: 8px;
}

.chat-command input,
.row-command input {
  border: 1px solid #334155;
}

.command-feedback {
  min-height: 18px;
  margin-top: 8px;
  color: #94a3b8;
  font-size: 12px;
}

.command-feedback[data-type="success"] {
  color: #86efac;
}

.command-feedback[data-type="error"] {
  color: #fca5a5;
}

.row-command {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: center;
  margin-top: 10px;
}

.row-command input {
  margin-top: 8px;
}

.row-command button {
  white-space: nowrap;
}

/* SECTION LIST */
#sectionList > div {
  background: #1e293b;
  padding: 12px;
  margin-top: 12px;
  border-radius: 10px;
}

/* STICKY TOTAL */
.sticky-total {
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
  background: #111827;
  color: white;
  padding: 12px 16px;
  display: flex;
  justify-content: center;
  gap: 22px;
  flex-wrap: wrap;
  font-size: 14px;
  border-top: 1px solid #334155;
  z-index: 999;
  box-sizing: border-box;
}

.sticky-total strong {
  font-size: 18px;
}

/* ============================= */
/* ⚡ FINAL EXCEL GRID (LOCKED) */
/* ============================= */

.item-row {
  display: grid;
  grid-template-columns: 2.2fr 0.75fr 0.75fr 0.75fr 0.9fr 1fr 1.35fr 40px;

  gap: 8px;

  align-items: center;
  min-height: 46px;

  padding: 6px 0;
  border-bottom: 1px solid #334155;

  font-size: 13px;
}

/* ============================= */
/* ALL CELLS SAME HEIGHT SYSTEM */
/* ============================= */

.item-name,
.item-field,
.item-total,
.item-row button {
  display: flex;
  align-items: center;
  height: 46px;
}

/* ============================= */
/* NAME CELL */
/* ============================= */

.item-name {
  padding: 0 10px;

  background: #0f172a;
  border: 1px solid #334155;
  border-radius: 6px;

  font-weight: 600;
  color: #f8fafc;

  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;

  box-sizing: border-box;
}

/* ============================= */
/* INPUT COLUMN */
/* ============================= */

.item-field {
  flex-direction: column;
  justify-content: center;
  gap: 2px;
}

/* LABEL */
.item-field label {
  font-size: 10px;
  opacity: 0.55;
  line-height: 1;
}

/* INPUT */
.item-row input,
.item-row select {
  height: 28px;

  width: 100%;
  margin: 0 !important;

  padding: 4px 6px;

  font-size: 12px;

  background: #0f172a;
  border: 1px solid #334155;
  border-radius: 6px;

  color: white;

  box-sizing: border-box;
}

/* ============================= */
/* TOTAL COLUMN */
/* ============================= */

.item-total {
  justify-content: flex-end;
  padding-right: 6px;

  font-size: 12px;
  font-weight: 600;
  color: #f8fafc;
}

/* ============================= */
/* DELETE BUTTON */
/* ============================= */

.item-row button {
  width: 36px;
  height: 36px;

  justify-content: center;

  background: transparent;
  border: none;
  color: #ef4444;
  font-size: 16px;
  cursor: pointer;
}

/* ============================= */
/* HOVER EFFECT */
/* ============================= */

.item-row:hover {
  background: #0b1220;
}

/* ============================= */
/* SECTION HEADER */
/* ============================= */

/* ============================= */
/* SECTION HEADER */
/* ============================= */

.section-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}

.section-header input {
  flex: 1;
  margin-top: 0;
}

.section-header button {
  background: #0f172a;
  border: 1px solid #334155;
  padding: 6px 10px;
  font-size: 12px;
  flex-shrink: 0;
  margin-top: 0;
}

.delete-section-btn {
  background: #7f1d1d !important;
  border: 1px solid #dc2626 !important;
  color: #fca5a5 !important;
}

.delete-section-btn:hover {
  background: #991b1b !important;
  border-color: #ef4444 !important;
}

@media (max-width: 820px) {
  .app {
    padding: 18px 14px 110px;
  }

  .header,
  .top-bar {
    flex-direction: column;
    align-items: stretch;
  }

  .header-actions,
  .top-actions {
    width: 100%;
  }

  .header-actions button,
  .top-actions button {
    flex: 1 1 0;
  }

  .hero-shell {
    padding: 24px 18px;
    border-radius: 24px;
  }

  .home-grid {
    grid-template-columns: 1fr;
  }

  .hero-home-actions {
    justify-content: stretch;
  }

  .hero-new-quote-btn {
    width: 100%;
  }

  .home-tile {
    min-height: 150px;
  }

  .row {
    flex-direction: column;
  }

  .compact-row {
    flex-direction: row;
  }

  .client-name-group {
    grid-template-columns: 96px minmax(0, 1fr);
  }

  .sticky-total {
    justify-content: flex-start;
    gap: 10px 18px;
    padding: 12px 14px;
  }
}
