* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: #04100a;
  color: #f4f8f5;
  font-family: Arial, Helvetica, sans-serif;
}

body:before {
  content: "";
  position: fixed;
  inset: 0;
  background: var(--company-watermark) center/70% no-repeat;
  opacity: .28;
  z-index: -1;
  pointer-events: none;
}

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  background: #030905;
  border-bottom: 1px solid var(--accent);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand img {
  width: 70px;
  height: 70px;
  object-fit: contain;
}

.brand h1 {
  margin: 0;
  font-size: 23px;
}

.brand p {
  margin: 3px 0;
  color: #d7dee2;
}

.user {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.user a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 32px;
  padding: 7px 11px;
  background: #d5d8d6;
  color: #0b6b3a;
  text-decoration: none;
  border: 1px solid #f4f8f5;
  border-radius: 4px;
  font-weight: bold;
  line-height: 1;
  box-shadow: inset 0 -1px 0 rgba(0, 0, 0, .18);
}

nav {
  background: #07160d;
  border-bottom: 1px solid var(--accent);
  padding: 8px 14px;
}

.nav-links {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  justify-content: center;
}

nav a,
.menu-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 32px;
  color: #0b6b3a;
  text-decoration: none;
  background: #d5d8d6;
  border: 1px solid #f4f8f5;
  padding: 7px 11px;
  border-radius: 4px;
  font-weight: bold;
  line-height: 1;
  box-shadow: inset 0 -1px 0 rgba(0, 0, 0, .18);
}

.menu-toggle {
  display: none;
  gap: 9px;
  cursor: pointer;
}

.menu-toggle-icon {
  display: inline-grid;
  gap: 4px;
  width: 20px;
  flex: 0 0 20px;
}

.menu-toggle-icon span {
  display: block;
  width: 20px;
  height: 2px;
  background: currentColor;
  border-radius: 99px;
}

.menu-toggle-text {
  margin-left: 0;
}

.nav-account-links {
  display: none;
}

nav a:hover,
nav a:focus,
.menu-toggle:hover,
.menu-toggle:focus,
.user a:hover,
.user a:focus {
  background: #f4f8f5;
  color: #064925;
  border-color: #7df0a8;
}

nav a:focus,
.menu-toggle:focus,
.user a:focus {
  outline: 2px solid rgba(125, 240, 168, .5);
  outline-offset: 2px;
}

main {
  padding: 20px;
  max-width: 1400px;
  margin: auto;
}

.panel,
.card {
  background: rgba(7, 26, 16, .92);
  border: 1px solid var(--accent);
  border-radius: 6px;
  padding: 14px;
  margin-bottom: 14px;
}

.cards {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}

.card b {
  display: block;
  font-size: 26px;
}

.card span {
  color: #d7dee2;
}

table {
  width: 100%;
  border-collapse: collapse;
  background: rgba(7, 26, 16, .92);
}

th {
  background: rgba(11, 107, 58, .45);
  color: #d7dee2;
  text-align: left;
}

th,
td {
  border-bottom: 1px solid rgba(255, 255, 255, .18);
  padding: 8px;
}

input,
select,
button {
  background: #0a1710;
  color: #f4f8f5;
  border: 1px solid var(--accent);
  border-radius: 4px;
  padding: 9px;
}

button,
.action-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 32px;
  padding: 7px 11px;
  background: #d5d8d6;
  color: #0b6b3a;
  text-decoration: none;
  border: 1px solid #f4f8f5;
  border-radius: 4px;
  cursor: pointer;
  font-weight: bold;
  line-height: 1;
  box-shadow: inset 0 -1px 0 rgba(0, 0, 0, .18);
}

button:hover,
button:focus,
.action-button:hover,
.action-button:focus {
  background: #f4f8f5;
  color: #064925;
  border-color: #7df0a8;
}

button:focus,
.action-button:focus {
  outline: 2px solid rgba(125, 240, 168, .5);
  outline-offset: 2px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.form-grid label {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.flash {
  padding: 10px;
  border-radius: 4px;
  margin-bottom: 10px;
}

.flash.success {
  background: var(--accent);
  color: #000;
}

.flash.error {
  background: #641d1d;
}

.login-body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-card {
  width: 390px;
  background: #071a10;
  border: 1px solid var(--accent);
  border-radius: 10px;
  padding: 25px;
}

.login-logo {
  width: 130px;
  display: block;
  margin: 0 auto 12px;
}

.login-card input {
  width: 100%;
  margin-top: 5px;
}

.login-card label {
  display: block;
  margin: 10px 0;
}

.login-primary {
  width: 100%;
  margin-top: 12px;
  padding: 13px 18px;
  background: #28c76f;
  border-color: #7df0a8;
  color: #021107;
  font-size: 17px;
  box-shadow: 0 0 0 1px rgba(125, 240, 168, .2), 0 10px 24px rgba(0, 0, 0, .32);
  text-transform: uppercase;
  letter-spacing: 0;
}

.login-primary:hover,
.login-primary:focus {
  background: #7df0a8;
  border-color: #d8ffe4;
  color: #021107;
  transform: translateY(-1px);
}

.login-primary:focus {
  outline: 3px solid rgba(125, 240, 168, .35);
  outline-offset: 2px;
}

.login-default {
  margin: 14px 0 0;
  padding: 10px 12px;
  background: #0a1710;
  border: 1px solid rgba(255, 255, 255, .22);
  border-radius: 4px;
  color: #d7dee2;
  text-align: center;
}

.action-links {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  align-items: center;
}

.contact-link {
  color: #7df0a8;
  font-weight: bold;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.contact-link:hover,
.contact-link:focus {
  color: #f4f8f5;
}

pre {
  white-space: pre-wrap;
  background: #06130b;
  border: 1px solid var(--accent);
  border-radius: 6px;
  padding: 12px;
}

.ai-help-widget {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 30;
}

.ai-help-bubble {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  background: var(--accent);
  color: #f4f8f5;
  border: 2px solid #d5d8d6;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  font-weight: bold;
  box-shadow: 0 12px 28px rgba(0, 0, 0, .35);
}

.ai-help-panel {
  position: absolute;
  right: 0;
  bottom: 66px;
  width: min(360px, calc(100vw - 28px));
  height: min(480px, calc(100vh - 120px));
  display: grid;
  grid-template-rows: auto 1fr auto;
  background: #07160d;
  border: 1px solid var(--accent);
  border-radius: 6px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, .48);
  overflow: hidden;
}

.ai-help-panel[hidden] {
  display: none;
}

.ai-help-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  background: #030905;
  border-bottom: 1px solid rgba(125, 240, 168, .35);
}

.ai-help-close {
  width: 34px;
  min-height: 34px;
  padding: 0;
  font-size: 20px;
}

.ai-help-messages {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px;
  overflow-y: auto;
}

.ai-help-message {
  max-width: 88%;
  padding: 9px 10px;
  border-radius: 6px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.ai-help-message.bot {
  align-self: flex-start;
  background: rgba(213, 216, 214, .12);
  border: 1px solid rgba(213, 216, 214, .28);
}

.ai-help-message.user {
  align-self: flex-end;
  background: #d5d8d6;
  color: #0b6b3a;
  font-weight: bold;
}

.ai-help-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  padding: 10px;
  border-top: 1px solid rgba(125, 240, 168, .35);
  background: #030905;
}

.ai-help-form input {
  min-width: 0;
}

textarea {
  background: #0a1710;
  color: #f4f8f5;
  border: 1px solid var(--accent);
  border-radius: 4px;
  padding: 9px;
  font-family: Arial, Helvetica, sans-serif;
  min-height: 120px;
}

.wide {
  grid-column: 1 / -1;
}

.mini-form {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  align-items: center;
}

.mini-form input,
.mini-form select {
  max-width: 160px;
}

.quote-type-picker {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

.file-cell {
  max-width: 220px;
  overflow-wrap: anywhere;
}

.quote-lines-table {
  table-layout: fixed;
}

.quote-lines-table th:first-child,
.quote-lines-table td:first-child {
  width: 38%;
}

.quote-lines-table th:nth-child(2),
.quote-lines-table td:nth-child(2),
.quote-lines-table th:nth-child(3),
.quote-lines-table td:nth-child(3) {
  width: 9%;
}

.quote-lines-table th:nth-child(4),
.quote-lines-table td:nth-child(4),
.quote-lines-table th:nth-child(5),
.quote-lines-table td:nth-child(5),
.quote-lines-table th:nth-child(6),
.quote-lines-table td:nth-child(6) {
  width: 12%;
}

.quote-lines-table th:last-child,
.quote-lines-table td:last-child {
  width: 8%;
}

.quote-lines-table input {
  width: 100%;
  min-width: 0;
}

.quote-lines-table .line-sell-total {
  font-weight: bold;
  color: #f4f8f5;
  white-space: nowrap;
}

.add-line-panel {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) 110px auto;
  gap: 8px;
  align-items: end;
}

.add-line-panel h3 {
  grid-column: 1 / -1;
  margin-bottom: 0;
}

.add-line-panel select,
.add-line-panel input {
  width: 100%;
}

.recent-quotes-table td:nth-child(2) {
  max-width: 320px;
  overflow-wrap: anywhere;
}

.website-requests-table td:nth-child(5),
.website-requests-table td:nth-child(7) {
  max-width: 320px;
  overflow-wrap: anywhere;
}

@media (max-width: 800px) {
  body:before {
    background-size: 110%;
    opacity: .16;
  }

  header {
    display: block;
  }

  .user {
    display: none;
  }

  .brand {
    align-items: flex-start;
  }

  .brand img {
    width: 58px;
    height: 58px;
  }

  .brand h1 {
    font-size: 18px;
  }

  .brand p {
    font-size: 13px;
  }

  .cards,
  .form-grid {
    grid-template-columns: 1fr;
  }

  main {
    padding: 10px;
  }

  table {
    display: block;
    overflow-x: auto;
    white-space: nowrap;
  }

  .mobile-card-table {
    display: grid;
    gap: 12px;
    overflow: visible;
    white-space: normal;
  }

  .mobile-card-table tbody {
    display: grid;
    gap: 12px;
  }

  .mobile-card-table tr {
    display: grid;
    gap: 8px;
    padding: 12px;
    background: rgba(3, 9, 5, .72);
    border: 1px solid rgba(125, 240, 168, .35);
    border-radius: 6px;
  }

  .mobile-card-table tr:first-child {
    display: none;
  }

  .mobile-card-table td {
    display: grid;
    grid-template-columns: minmax(86px, 34%) 1fr;
    gap: 10px;
    align-items: start;
    border-bottom: 1px solid rgba(255, 255, 255, .12);
    padding: 0 0 8px;
    min-width: 0;
  }

  .mobile-card-table td:last-child {
    border-bottom: 0;
    padding-bottom: 0;
  }

  .mobile-card-table td:before {
    content: attr(data-label);
    color: #d7dee2;
    font-size: 12px;
    font-weight: bold;
    text-transform: uppercase;
  }

  .mobile-card-table td[data-label="Create Quotes"],
  .mobile-card-table td[data-label="Actions"],
  .mobile-card-table td[data-label="Delete"] {
    grid-template-columns: 1fr;
  }

  .mobile-card-table td[data-label="Create Quotes"]:before,
  .mobile-card-table td[data-label="Actions"]:before,
  .mobile-card-table td[data-label="Delete"]:before {
    margin-bottom: -2px;
  }

  .measurements-table .mini-form {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .quote-type-picker {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
  }

  .quote-type-picker label {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    min-height: 40px;
    padding: 7px;
    border: 1px solid rgba(125, 240, 168, .35);
    border-radius: 4px;
    background: rgba(4, 16, 10, .75);
  }

  .quote-type-picker input {
    width: auto;
  }

  .measurements-table select,
  .measurements-table button,
  .measurements-table .action-button,
  .quotes-table .action-button,
  .recent-quotes-table .action-button {
    width: 100%;
  }

  .quotes-table .action-links,
  .recent-quotes-table .action-links {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 7px;
  }

  .recent-quotes-table td[data-label="Actions"] {
    grid-template-columns: 1fr;
  }

  .recent-quotes-table td[data-label="Actions"]:before {
    margin-bottom: -2px;
  }

  .website-requests-table .action-button {
    width: 100%;
  }

  .website-requests-table td[data-label="Customer"] {
    grid-template-columns: 1fr;
  }

  .quote-lines-table {
    table-layout: auto;
  }

  .quote-lines-table th,
  .quote-lines-table td {
    width: auto !important;
  }

  .quote-lines-table td[data-label="Item"],
  .quote-lines-table td[data-label="Remove"] {
    grid-template-columns: 1fr;
  }

  .quote-lines-table td[data-label="Item"]:before,
  .quote-lines-table td[data-label="Remove"]:before {
    margin-bottom: -2px;
  }

  .quote-lines-table .line-sell-total {
    text-align: right;
  }

  .quote-lines-table button {
    width: 100%;
  }

  .add-line-panel {
    grid-template-columns: 1fr;
  }

  .site-nav {
    padding: 0;
    border-bottom: 0;
    background: transparent;
  }

  .menu-toggle {
    position: fixed;
    right: 0;
    top: 12px;
    z-index: 41;
    display: inline-flex;
    width: auto;
    min-height: 44px;
    padding: 10px 12px;
    border-radius: 6px 0 0 6px;
    border-right: 0;
    box-shadow: 0 10px 24px rgba(0, 0, 0, .38);
  }

  .menu-toggle-text {
    display: none;
  }

  .nav-links {
    position: fixed;
    right: 0;
    top: 0;
    z-index: 40;
    display: grid;
    grid-template-columns: 1fr;
    gap: 7px;
    width: min(300px, 86vw);
    height: 100vh;
    padding: 68px 12px 16px 14px;
    background: #07160d;
    border-left: 1px solid var(--accent);
    box-shadow: -16px 0 40px rgba(0, 0, 0, .46);
    overflow-y: auto;
    transform: translateX(105%);
    transition: transform .2s ease;
  }

  .nav-links.is-open {
    transform: translateX(0);
  }

  .nav-links a {
    justify-content: flex-start;
    width: 100%;
  }

  .nav-account-links {
    display: grid;
    grid-template-columns: 1fr;
    gap: 7px;
    padding-top: 7px;
    border-top: 1px solid rgba(125, 240, 168, .35);
  }

  nav a,
  .menu-toggle,
  .user a,
  button,
  .action-button {
    min-height: 42px;
  }

  input,
  select,
  textarea {
    width: 100%;
    font-size: 16px;
  }

  .login-card {
    width: calc(100vw - 24px);
    padding: 18px;
  }

  .mini-form input,
  .mini-form select {
    max-width: none;
    flex: 1 1 180px;
  }

  .ai-help-widget {
    right: 12px;
    bottom: 12px;
  }

  .ai-help-panel {
    width: calc(100vw - 24px);
    height: min(440px, calc(100vh - 96px));
    bottom: 62px;
  }

  .ai-help-form {
    grid-template-columns: 1fr;
  }
}
