:root {
  --page: #eef3f6;
  --canvas: #071b2c;
  --canvas-2: #0a2b3f;
  --ink: #102132;
  --muted: #687889;
  --line: #dce6ec;
  --panel: #ffffff;
  --soft: #f5f9fb;
  --brand: #18a957;
  --brand-strong: #087343;
  --brand-deep: #06314b;
  --accent: #72cf46;
  --gold: #d7a239;
  --warning: #c47b1e;
  --danger: #ba3b37;
  --shadow: 0 24px 60px rgba(5, 22, 35, 0.16);
  --shadow-soft: 0 14px 34px rgba(5, 22, 35, 0.09);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--page);
  color: var(--ink);
  font-family: "Segoe UI", Arial, Helvetica, sans-serif;
  position: relative;
}

body::before {
  content: "";
  position: fixed;
  inset: 0 0 auto;
  height: 360px;
  background:
    radial-gradient(circle at 18% 18%, rgba(114, 207, 70, 0.22), transparent 32%),
    radial-gradient(circle at 82% 8%, rgba(12, 118, 166, 0.28), transparent 34%),
    linear-gradient(135deg, #061827 0%, var(--canvas) 42%, var(--canvas-2) 100%);
  z-index: -1;
}

body.auth-locked .portal-shell {
  display: none;
}

body:not(.auth-locked) .login-screen {
  display: none;
}

.password-change-screen {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(6, 24, 39, 0.82);
  backdrop-filter: blur(12px);
}

.password-change-screen.is-hidden {
  display: none;
}

.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-card {
  width: min(440px, 100%);
  display: grid;
  gap: 16px;
  padding: 28px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 18px;
  background:
    linear-gradient(150deg, rgba(255, 255, 255, 0.98), rgba(244, 250, 247, 0.95)),
    #ffffff;
  box-shadow: var(--shadow);
}

.login-card img {
  width: 230px;
  max-width: 100%;
  height: auto;
}

.login-card .eyebrow {
  color: var(--brand-strong);
}

.login-card h1 {
  margin: 4px 0 0;
  color: var(--brand-deep);
  font-size: 2rem;
  line-height: 1.05;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

.portal-shell {
  display: grid;
  gap: 18px;
  width: min(1480px, calc(100% - 32px));
  margin: 0 auto;
  padding: 26px 0 34px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 118px;
  padding: 22px 24px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.13), rgba(255, 255, 255, 0.04)),
    rgba(255, 255, 255, 0.08);
  color: white;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 14px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.22);
  position: relative;
  overflow: hidden;
  backdrop-filter: blur(16px);
}

.topbar::after {
  content: "";
  position: absolute;
  inset: auto 22px 18px auto;
  width: 210px;
  height: 2px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--brand), var(--accent), var(--gold));
  opacity: 0.9;
}

.topbar-main {
  display: grid;
  gap: 18px;
  min-width: 0;
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 15px;
  min-width: 0;
}

.user-avatar {
  display: grid;
  place-items: center;
  width: 62px;
  height: 62px;
  flex: 0 0 auto;
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 16px;
  background:
    linear-gradient(150deg, rgba(255, 255, 255, 0.22), rgba(255, 255, 255, 0.08)),
    linear-gradient(135deg, rgba(24, 169, 87, 0.72), rgba(8, 115, 67, 0.35));
  color: #ffffff;
  font-weight: 900;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.24), 0 16px 34px rgba(0, 0, 0, 0.18);
}

.topbar h1 {
  margin: 3px 0 0;
  font-size: clamp(1.85rem, 2.5vw, 2.8rem);
  line-height: 1.05;
  letter-spacing: 0;
}

.eyebrow {
  margin: 0;
  color: #a8edbb;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.topbar-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
  align-self: center;
}

.app-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.app-nav button {
  min-height: 38px;
  border-radius: 999px;
  padding: 0 15px;
  background: rgba(255, 255, 255, 0.075);
  color: rgba(255, 255, 255, 0.78);
  font-size: 0.84rem;
  font-weight: 700;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.app-nav .active {
  background: #ffffff;
  color: var(--brand-deep);
  box-shadow: 0 12px 26px rgba(0, 0, 0, 0.16);
}

.primary,
.secondary,
.ghost,
.plain,
.mini-button {
  min-height: 42px;
  border-radius: 10px;
  padding: 0 14px;
  font-weight: 700;
  transition: transform 120ms ease, background 120ms ease;
}

.primary {
  background: linear-gradient(180deg, #72d34d, #19a558);
  color: white;
  box-shadow: 0 16px 30px rgba(25, 165, 88, 0.28);
}

.secondary {
  background: linear-gradient(180deg, #0d638c, var(--brand-deep));
  color: white;
}

.ghost {
  background: rgba(255, 255, 255, 0.1);
  color: white;
  border: 1px solid rgba(255, 255, 255, 0.18);
}

.plain,
.mini-button {
  background: #eef8f2;
  color: var(--brand-deep);
  border: 1px solid #d4eadc;
}

.mini-button {
  min-height: 32px;
  padding: 0 10px;
  font-size: 0.82rem;
}

.delete {
  background: #f4ded8;
  border-color: #efc7bf;
  color: var(--danger);
}

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

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

body.quotes-active .summary-strip {
  display: none;
}

body:not(.is-admin) .admin-only {
  display: none;
}

.summary-strip div,
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow-soft);
}

.summary-strip div {
  min-height: 116px;
  padding: 18px;
  display: grid;
  align-content: center;
  gap: 8px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background:
    linear-gradient(150deg, rgba(255, 255, 255, 0.97), rgba(245, 250, 248, 0.94)),
    #ffffff;
  position: relative;
  overflow: hidden;
}

.summary-strip div::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 5px;
  background: linear-gradient(180deg, var(--brand), var(--accent));
}

.summary-strip span,
.metric-grid span,
label,
dt,
.status,
.panel-heading span {
  color: var(--muted);
}

.summary-strip strong {
  font-size: clamp(1.35rem, 1.8vw, 1.85rem);
  color: var(--brand-deep);
  line-height: 1.05;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.content-grid,
.lead-layout,
.quote-layout,
.admin-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(360px, 0.8fr);
  gap: 18px;
  align-items: start;
}

.tracker-panel {
  grid-column: 1 / -1;
}

.panel {
  padding: 20px;
}

.panel-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
}

.panel h2 {
  margin: 0;
  font-size: 1.05rem;
  line-height: 1.2;
  color: var(--brand-deep);
}

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

.metric-grid div {
  min-height: 104px;
  display: grid;
  align-content: center;
  gap: 8px;
  padding: 15px;
  border: 1px solid #dce9ef;
  border-radius: 14px;
  background:
    linear-gradient(180deg, #ffffff, #f7fbfa);
  box-shadow: inset 0 1px 0 #ffffff;
}

.metric-grid strong {
  color: var(--brand-deep);
  font-size: 1.32rem;
}

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

.wide {
  grid-column: span 2;
}

label {
  display: grid;
  gap: 6px;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.01em;
}

input,
select,
textarea {
  width: 100%;
  min-width: 0;
  border: 1px solid #d8e4ea;
  border-radius: 10px;
  background: #fbfdfe;
  color: var(--ink);
  padding: 11px 12px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.9);
}

textarea {
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  outline: 3px solid rgba(20, 142, 70, 0.18);
  border-color: var(--brand);
}

.toggle-line {
  min-height: 44px;
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid #d8e4ea;
  border-radius: 10px;
  padding: 0 10px;
  background: #fbfdfe;
  color: var(--ink);
}

.toggle-line input {
  width: 18px;
  height: 18px;
}

.form-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 14px;
}

.lead-form-panel,
.leads-panel,
.table-panel,
.admin-panel,
.quote-form-panel,
.quote-preview-panel,
.saved-quotes-panel {
  grid-column: 1 / -1;
}

.quote-layout {
  grid-template-columns: 1fr;
}

.lead-list,
.calendar-list,
.archive-list,
.quote-list,
.admin-list {
  display: grid;
  gap: 12px;
}

.admin-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 110px 90px minmax(240px, auto);
  gap: 12px;
  align-items: center;
  padding: 14px;
  border: 1px solid #dce6ec;
  border-radius: 14px;
  background: #ffffff;
}

.admin-row-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
}

.admin-row-actions input {
  width: 150px;
  min-height: 34px;
  padding: 7px 9px;
}

.admin-row strong,
.admin-row span {
  display: block;
}

.admin-row span {
  color: var(--muted);
  font-size: 0.86rem;
}

.role-pill {
  justify-self: start;
  min-width: 86px;
  padding: 6px 10px;
  border-radius: 999px;
  background: #eef8f2;
  color: var(--brand-deep);
  font-size: 0.8rem;
  font-weight: 800;
  text-align: center;
  text-transform: capitalize;
}

.quote-command-bar {
  display: grid;
  grid-template-columns: 180px minmax(0, 1fr) auto;
  gap: 18px;
  align-items: center;
  margin-bottom: 18px;
  padding: 14px;
  border: 1px solid #d8e7df;
  border-radius: 14px;
  background: linear-gradient(135deg, #ffffff, #f4faf7);
}

.quote-command-bar img {
  width: 170px;
  max-width: 100%;
  height: auto;
}

.quote-command-bar strong,
.quote-command-bar span {
  display: block;
}

.quote-command-bar span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.9rem;
}

.quote-command-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.quote-style-preview {
  display: grid;
  grid-template-columns: 170px minmax(0, 1fr);
  gap: 14px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #ffffff;
}

.quote-style-preview img {
  width: 100%;
  max-height: 140px;
  object-fit: contain;
  border-radius: 10px;
  background: #f8fbfc;
}

.quote-style-preview strong,
.quote-style-preview span {
  display: block;
}

.quote-style-preview span {
  margin-top: 5px;
  color: var(--muted);
  font-size: 0.88rem;
}

.quote-customer-panel {
  margin-bottom: 18px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #ffffff;
}

.quote-customer-panel.is-hidden {
  display: none;
}

.compact-heading {
  margin-bottom: 12px;
}

.compact-heading h3 {
  margin: 0;
  color: var(--brand-deep);
}

.quote-items-panel {
  margin-top: 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #f8fbfc;
  overflow: hidden;
}

.quote-item-list {
  display: grid;
}

.quote-item-row {
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr) auto auto;
  gap: 12px;
  align-items: center;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
}

.quote-item-thumb {
  width: 92px;
  height: 72px;
  object-fit: contain;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #ffffff;
}

.quote-item-row:last-child {
  border-bottom: 0;
}

.quote-item-row strong,
.quote-item-row span {
  display: block;
}

.quote-item-row span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.86rem;
}

.quote-item-price {
  text-align: right;
  min-width: 140px;
}

.quote-item-price strong {
  color: var(--brand-deep);
}

.lead-card,
.calendar-item,
.archive-row {
  border: 1px solid #dce6ec;
  border-left: 5px solid var(--brand);
  border-radius: 14px;
  background:
    linear-gradient(180deg, #ffffff, #fbfdfe);
  padding: 14px;
  box-shadow: 0 10px 24px rgba(5, 22, 35, 0.06);
}

.lead-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: start;
}

.lead-card-title {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.lead-meta,
.calendar-meta,
.lead-notes {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.45;
}

.lead-notes {
  color: #344654;
}

.lead-card-actions {
  display: flex;
  gap: 6px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  border-radius: 999px;
  padding: 0 10px;
  font-size: 0.72rem;
  font-weight: 800;
  color: #ffffff;
  background: var(--brand-strong);
}

.status-sold {
  background: var(--brand);
}

.status-sns {
  background: var(--warning);
}

.status-call-back {
  background: var(--brand-strong);
}

.status-not-interested {
  background: var(--danger);
}

.calendar-item {
  display: grid;
  grid-template-columns: 130px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: start;
}

.calendar-date {
  display: grid;
  gap: 4px;
}

.calendar-date strong {
  color: var(--brand-deep);
}

.calendar-date span {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

.calendar-item.overdue {
  border-left-color: var(--danger);
}

.calendar-item.due-today {
  border-left-color: var(--warning);
}

.compact-list .calendar-item {
  grid-template-columns: 108px minmax(0, 1fr);
}

.compact-list .calendar-item .mini-button {
  display: none;
}

.archive-row {
  display: grid;
  grid-template-columns: 80px repeat(3, minmax(0, 1fr));
  gap: 10px;
  align-items: center;
}

.archive-row span {
  color: var(--muted);
  font-size: 0.86rem;
}

.quote-preview {
  border: 1px solid #dce6ec;
  border-radius: 18px;
  background: #ffffff;
  overflow: hidden;
}

.quote-document {
  padding: 20px;
}

.quote-order-form {
  color: #111111;
  background: #ffffff;
}

.order-form-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 260px;
  gap: 18px;
  align-items: start;
  margin-bottom: 14px;
}

.order-brand {
  text-align: center;
}

.order-logo-image {
  display: block;
  width: min(260px, 100%);
  height: auto;
  margin: 0 auto 8px;
}

.order-roof {
  width: 150px;
  height: 38px;
  margin: 0 auto -8px;
  border-top: 9px solid #75a843;
  border-left: 9px solid #75a843;
  transform: rotate(45deg) skew(-12deg, -12deg);
}

.order-logo {
  font-size: 2rem;
  font-weight: 900;
  color: #1979b9;
  line-height: 1;
}

.order-logo span {
  color: #78a844;
}

.order-brand strong {
  display: block;
  margin-top: 6px;
  font-size: 0.9rem;
}

.order-brand h2 {
  margin: 18px 0 0;
  color: #111111;
  font-size: 1.55rem;
  letter-spacing: 0.16em;
}

.order-contact {
  display: grid;
  gap: 4px;
  text-align: right;
  font-size: 0.92rem;
}

.order-contact strong {
  color: #111111;
}

.order-customer-grid,
.order-product-grid,
.order-bottom-grid {
  border: 2px solid #111111;
}

.order-customer-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border-bottom: 0;
}

.order-customer-grid div {
  min-height: 38px;
  display: grid;
  grid-template-columns: 160px minmax(0, 1fr);
  gap: 8px;
  align-items: center;
  padding: 7px 10px;
  border-bottom: 1px solid #111111;
}

.order-customer-grid div:nth-child(odd) {
  border-right: 1px solid #111111;
}

.order-customer-grid span,
.order-table-head,
.order-colour span,
.order-payment-table th {
  font-weight: 800;
}

.order-customer-grid strong {
  min-height: 22px;
  border-bottom: 1px solid #111111;
  font-weight: 500;
}

.order-product-grid {
  display: grid;
  grid-template-columns: 1fr 0.8fr 1.2fr 1.15fr 2.2fr;
  border-bottom: 0;
}

.order-product-grid > div {
  min-height: 52px;
  padding: 8px;
  border-right: 1px solid #111111;
  border-bottom: 1px solid #111111;
}

.order-product-grid > div:nth-child(5n) {
  border-right: 0;
}

.order-product-grid .large {
  grid-column: span 1;
}

.order-table-head {
  min-height: 34px;
  text-align: center;
  background: #f5f5f5;
}

.frame-design {
  white-space: pre-wrap;
}

.window-style-cell {
  display: grid;
  place-items: center;
}

.order-item-image {
  display: block;
  width: 112px;
  height: 82px;
  object-fit: contain;
  margin: 0 auto;
  border: 1px solid #dce6ec;
  border-radius: 8px;
  background: #ffffff;
}

.order-notes {
  grid-column: 1 / -1;
  border-right: 0 !important;
  min-height: 70px;
}

.order-colour {
  display: grid;
  gap: 6px;
  text-align: center;
}

.order-colour strong {
  font-weight: 500;
}

.order-bottom-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(280px, 0.75fr);
}

.order-terms {
  padding: 12px;
  border-right: 1px solid #111111;
}

.order-terms p {
  margin: 0 0 10px;
  line-height: 1.35;
}

.order-terms span {
  display: inline-block;
  min-width: 150px;
  border-bottom: 1px solid #111111;
}

.quote-total-table {
  width: 100%;
  min-width: 0;
  overflow: hidden;
  border: 0;
  border-radius: 0;
}

.quote-total-table th,
.quote-total-table td {
  padding: 12px 14px;
}

.quote-total-table td {
  text-align: right;
  font-weight: 800;
}

.order-payment-table th,
.order-payment-table td {
  border-color: #111111;
}

.quote-grand-total th,
.quote-grand-total td {
  background: #f5f5f5;
  color: #111111;
  font-size: 1.08rem;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 14px;
}

table {
  width: 100%;
  min-width: 1120px;
  border-collapse: collapse;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 12px 11px;
  text-align: left;
  vertical-align: middle;
}

th {
  color: var(--brand-deep);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  background: #f5faf8;
}

tbody tr:nth-child(even) {
  background: #fbfdfe;
}

.empty,
.empty-cell {
  color: var(--muted);
  padding: 12px 0;
}

.empty-cell {
  text-align: center;
}

.status {
  min-height: 22px;
  margin: 0 4px;
  font-size: 0.85rem;
  color: var(--muted);
}

.inline-status {
  min-height: 22px;
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 0.86rem;
}

@media (max-width: 1080px) {
  .content-grid,
  .lead-layout,
  .quote-layout {
    grid-template-columns: 1fr;
  }

  .metric-grid,
  .field-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .quote-form-panel,
  .quote-preview-panel {
    grid-column: 1;
  }
}

@media (max-width: 720px) {
  .portal-shell {
    width: min(100% - 20px, 1480px);
    padding: 10px 0 20px;
  }

  .topbar {
    display: grid;
  }

  .brand-lockup {
    align-items: flex-start;
  }

  .topbar-actions,
  .form-actions {
    justify-content: stretch;
  }

  .topbar-actions button,
  .form-actions button {
    flex: 1;
  }

  .summary-strip,
  .metric-grid,
  .field-grid,
  .quote-command-bar,
  .quote-style-preview,
  .calendar-item,
  .archive-row,
  .quote-item-row,
  .order-form-header,
  .order-customer-grid,
  .order-product-grid,
  .order-bottom-grid {
    grid-template-columns: 1fr;
  }

  .quote-item-price {
    text-align: left;
  }

  .quote-command-actions {
    justify-content: stretch;
  }

  .quote-command-actions button {
    flex: 1;
  }

  .wide {
    grid-column: auto;
  }

  .lead-card {
    grid-template-columns: 1fr;
  }
}
