:root {
  --bg: #eef2f5;
  --surface: #ffffff;
  --ink: #17202a;
  --muted: #667085;
  --line: #d8e0e8;
  --blue: #1f55d8;
  --blue-dark: #1742a8;
  --blue-ink: #153a8f;
  --orange: #ff8a00;
  --green: #19735a;
  --amber: #b7791f;
  --shadow: 0 18px 46px rgba(16, 24, 40, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: Arial, Helvetica, sans-serif;
  color: var(--ink);
  background: var(--bg);
}

button,
input,
select {
  font: inherit;
}

.app-shell {
  width: min(1440px, calc(100% - 28px));
  margin: 0 auto;
  padding: 18px 0 28px;
}

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

.login-card {
  display: grid;
  gap: 14px;
  width: min(420px, 100%);
  padding: 26px 24px 24px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.login-logo {
  width: min(250px, 82%);
  height: auto;
  margin-bottom: 4px;
}

.login-card input {
  width: 100%;
  min-height: 44px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  outline: none;
}

.login-card input:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(31, 78, 120, 0.14);
}

.login-error {
  margin: 0;
  color: #9f2f24;
  font-weight: 700;
}

.search-band {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

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

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

.brand-logo {
  width: 58px;
  height: 58px;
  object-fit: contain;
  flex: 0 0 auto;
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--blue-ink);
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: clamp(1.7rem, 3vw, 2.4rem);
  letter-spacing: 0;
}

.metric {
  padding: 8px 12px;
  border-radius: 6px;
  background: #f4f7ff;
  color: var(--blue);
  font-weight: 700;
  white-space: nowrap;
}

.global-search {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 124px;
  gap: 10px;
  margin-bottom: 14px;
}

.global-search input {
  height: 52px;
  padding: 0 18px;
  border: 2px solid #b9c7d5;
  border-radius: 999px;
  outline: none;
  font-size: 1.04rem;
  background: #fff;
}

.global-search input:focus,
.filters input:focus,
select:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(31, 78, 120, 0.14);
}

.search-mode {
  display: inline-grid;
  grid-template-columns: repeat(2, minmax(0, auto));
  gap: 6px;
  margin: -4px 0 14px;
  padding: 4px;
  border-radius: 8px;
  background: #edf3f8;
}

.mode-button {
  min-height: 34px;
  padding: 0 12px;
  color: var(--blue);
  background: transparent;
}

.mode-button:hover {
  background: #dbeaf5;
}

.mode-button.active {
  color: #fff;
  background: var(--blue);
}

.filters.is-muted {
  opacity: 0.6;
}

button {
  min-height: 42px;
  border: 0;
  border-radius: 6px;
  color: #fff;
  background: var(--blue);
  font-weight: 700;
  cursor: pointer;
}

button:hover {
  background: var(--blue-dark);
}

button.ghost {
  color: var(--blue);
  background: #eaf2f8;
}

button.ghost:hover {
  background: #dbeaf5;
}

button.danger {
  color: #fff;
  background: #9f2f24;
}

button.danger:hover {
  background: #7e241b;
}

.app-tabs {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 12px;
}

.tab-group,
.session-box {
  display: flex;
  align-items: center;
  gap: 8px;
}

.session-box span {
  color: var(--muted);
  font-weight: 700;
}

.session-box button {
  min-height: 38px;
  padding: 0 12px;
}

.tab-button {
  min-height: 40px;
  padding: 0 16px;
  color: var(--blue);
  background: #dfeaf2;
}

.tab-button.active {
  color: #fff;
  background: var(--blue);
}

.tab-page {
  display: none;
}

.tab-page.active {
  display: block;
}

.filters {
  display: grid;
  grid-template-columns: 1fr 1.2fr 0.55fr 1.2fr 0.55fr 100px 92px;
  gap: 10px;
  align-items: end;
}

label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

.filters input,
select {
  width: 100%;
  min-height: 42px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  outline: none;
  color: var(--ink);
  background: #fff;
}

.result-panel {
  margin-top: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.cart-panel {
  margin-top: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.quote-panel {
  margin-top: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.admin-panel {
  margin-top: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.cart-header,
.cart-total,
.quote-header,
.admin-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  background: #f8fafc;
}

.cart-header {
  border-bottom: 1px solid var(--line);
}

.quote-header {
  border-bottom: 1px solid var(--line);
}

.admin-header {
  border-bottom: 1px solid var(--line);
}

.cart-header strong,
.cart-header span,
.quote-header strong,
.quote-header span,
.admin-header strong,
.admin-header span {
  display: block;
}

.cart-header span,
.quote-header span,
.admin-header span {
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.88rem;
}

.cart-actions {
  display: flex;
  gap: 8px;
}

.cart-actions button {
  min-height: 38px;
  padding: 0 14px;
}

.cart-items {
  max-height: 260px;
  overflow: auto;
}

.quote-note-label {
  padding: 12px 14px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: #fbfdff;
}

.quote-note-label textarea {
  width: 100%;
  min-height: 74px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  outline: none;
  resize: vertical;
}

.quote-note-label textarea:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(31, 78, 120, 0.14);
}

.cart-row {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) 76px 112px 122px 82px;
  gap: 10px;
  align-items: center;
  padding: 10px 14px;
  border-bottom: 1px solid #edf1f5;
}

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

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

.cart-total {
  border-top: 1px solid var(--line);
  font-size: 1.05rem;
}

.admin-create {
  display: grid;
  grid-template-columns: minmax(160px, 1fr) minmax(160px, 1fr) 130px 132px;
  gap: 10px;
  align-items: end;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
}

.admin-create input,
.admin-user-row input {
  width: 100%;
  min-height: 38px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  outline: none;
}

.admin-users {
  max-height: calc(100vh - 230px);
  overflow: auto;
}

.admin-user-row {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) 190px 78px 70px 78px 108px;
  gap: 10px;
  align-items: center;
  padding: 10px 14px;
  border-bottom: 1px solid #edf1f5;
}

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

.admin-user-row strong {
  color: var(--blue);
}

.admin-user-row span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.84rem;
}

.quote-search {
  display: grid;
  grid-template-columns: 150px 92px 78px 148px;
  gap: 8px;
  align-items: center;
}

.quote-search input {
  min-height: 38px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  outline: none;
}

.quote-search button {
  min-height: 38px;
}

.quote-layout {
  display: grid;
  grid-template-columns: 1fr;
  min-height: 220px;
}

.quote-layout.has-detail {
  grid-template-columns: 340px minmax(0, 1fr);
}

.quote-list {
  background: #fbfdff;
  max-height: calc(100vh - 190px);
  overflow: auto;
}

.quote-layout.has-detail .quote-list {
  border-right: 1px solid var(--line);
}

.quote-card {
  display: block;
  width: 100%;
  min-height: auto;
  padding: 12px 14px;
  border-bottom: 1px solid #edf1f5;
  border-radius: 0;
  color: var(--ink);
  background: transparent;
  text-align: left;
}

.quote-card:hover {
  background: #eef6fc;
}

.quote-card.active {
  background: #e8f3fb;
}

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

.quote-card strong {
  color: var(--blue);
}

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

.quote-detail {
  padding: 14px;
  color: var(--muted);
}

.quote-detail-head,
.quote-detail-total {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.quote-detail-head {
  margin-bottom: 12px;
}

.quote-detail-head strong,
.quote-detail-head span {
  display: block;
}

.quote-detail-head strong {
  color: var(--ink);
}

.quote-detail-total {
  padding: 10px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  color: var(--ink);
}

.quote-note-view {
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}

.quote-note-view strong,
.quote-note-view span {
  display: block;
}

.quote-note-view strong {
  color: var(--ink);
}

.quote-note-view span {
  margin-top: 3px;
  color: var(--muted);
}

.pdf-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  padding: 0 12px;
  border-radius: 6px;
  color: #fff;
  background: var(--blue);
  font-weight: 700;
  text-decoration: none;
}

.pdf-choice-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(15, 23, 42, 0.36);
}

.pdf-choice {
  display: grid;
  gap: 10px;
  width: min(420px, 100%);
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.pdf-choice strong {
  font-size: 1.08rem;
}

.pdf-choice span {
  color: var(--muted);
}

.pdf-branch {
  margin-top: 4px;
}

.pdf-branch select {
  min-height: 40px;
}

.pdf-choice-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 4px;
}

.pdf-choice-actions .ghost {
  grid-column: span 2;
}

.quote-items {
  margin-top: 8px;
  max-height: 260px;
  overflow: auto;
}

.quote-item {
  padding: 9px 0;
  border-bottom: 1px solid #edf1f5;
}

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

.quote-item strong {
  color: var(--blue);
}

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

.result-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 58px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  background: #f8fafc;
}

.result-toolbar strong {
  display: block;
  margin-bottom: 2px;
}

.result-toolbar span {
  color: var(--muted);
  font-size: 0.88rem;
}

.result-toolbar select {
  width: 92px;
}

.table-wrap {
  position: relative;
  overflow: auto;
  max-height: calc(100vh - 260px);
}

table {
  width: 100%;
  min-width: 1240px;
  border-collapse: collapse;
  font-size: 0.9rem;
}

thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  padding: 10px 9px;
  color: #fff;
  background: var(--blue);
  text-align: left;
  white-space: nowrap;
}

tbody td {
  padding: 8px 9px;
  border-bottom: 1px solid #edf1f5;
  vertical-align: top;
}

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

tbody tr:hover {
  background: #fff6e8;
}

.code {
  color: var(--blue);
  font-weight: 700;
  white-space: nowrap;
}

.price {
  font-weight: 700;
  text-align: right;
  white-space: nowrap;
}

.stock {
  color: var(--green);
  font-weight: 700;
  text-align: right;
  white-space: nowrap;
}

.qty-input {
  width: 64px;
  min-height: 34px;
  padding: 0 7px;
  border: 1px solid var(--line);
  border-radius: 6px;
  text-align: right;
}

.mini-button,
.icon-button {
  min-height: 34px;
  padding: 0 10px;
  border-radius: 6px;
  font-size: 0.82rem;
}

.icon-button {
  color: var(--blue);
  background: #eaf2f8;
}

.cart-empty {
  padding: 18px 14px;
  color: var(--muted);
}

.empty {
  padding: 34px 16px;
  color: var(--muted);
  text-align: center;
}

[hidden] {
  display: none !important;
}

@media (max-width: 920px) {
  body {
    background: #e8eef3;
  }

  .app-shell {
    width: min(100% - 16px, 760px);
    padding: 10px 0 18px;
  }

  .app-tabs {
    align-items: stretch;
    flex-direction: column-reverse;
  }

  .tab-group {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .tab-button {
    width: 100%;
    padding: 0 8px;
  }

  .session-box {
    justify-content: flex-end;
  }

  .brand-row,
  .result-toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .brand-lockup {
    align-items: center;
  }

  .global-search,
  .filters,
  .cart-row,
  .admin-create,
  .admin-user-row,
  .quote-layout,
  .quote-search {
    grid-template-columns: 1fr;
  }

  .quote-header {
    align-items: stretch;
    flex-direction: column;
  }

  .quote-list {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .metric {
    width: fit-content;
  }

  .table-wrap {
    max-height: none;
  }
}

@media (max-width: 720px) {
  .search-band,
  .result-panel,
  .cart-panel,
  .quote-panel,
  .admin-panel {
    border-radius: 6px;
    box-shadow: 0 10px 28px rgba(16, 24, 40, 0.1);
  }

  .search-band {
    padding: 14px;
  }

  h1 {
    font-size: 1.6rem;
  }

  .brand-logo {
    width: 46px;
    height: 46px;
  }

  .login-logo {
    width: min(230px, 88%);
  }

  .eyebrow {
    font-size: 0.72rem;
  }

  .metric {
    padding: 7px 9px;
    font-size: 0.86rem;
    white-space: normal;
  }

  .global-search {
    grid-template-columns: 1fr;
  }

  .search-mode {
    width: 100%;
    grid-template-columns: 1fr 1fr;
  }

  .global-search input {
    height: 48px;
    padding: 0 14px;
    border-radius: 8px;
    font-size: 1rem;
  }

  .global-search button,
  .filters button,
  .cart-actions button,
  .quote-search button,
  .admin-create button {
    width: 100%;
  }

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

  .filters label:nth-child(2),
  .filters label:nth-child(4),
  .filters label:nth-child(5),
  .filters button {
    grid-column: span 2;
  }

  .cart-header,
  .cart-total {
    align-items: stretch;
    flex-direction: column;
  }

  .cart-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .cart-row {
    grid-template-columns: 1fr 82px;
    gap: 8px;
  }

  .cart-row > div,
  .cart-row .icon-button {
    grid-column: span 2;
  }

  .cart-row .price {
    text-align: left;
  }

  .quote-header,
  .quote-detail-head,
  .quote-detail-total,
  .admin-header {
    align-items: stretch;
    flex-direction: column;
  }

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

  .quote-search input,
  .quote-search .danger {
    grid-column: span 2;
  }

  .pdf-choice-actions {
    grid-template-columns: 1fr;
  }

  .pdf-choice-actions .ghost {
    grid-column: auto;
  }

  .quote-detail {
    padding: 12px;
  }

  .admin-create,
  .admin-user-row {
    grid-template-columns: 1fr;
  }

  .admin-users,
  .quote-list,
  .quote-items {
    max-height: none;
  }

  table,
  thead,
  tbody,
  tr,
  td {
    display: block;
  }

  table {
    min-width: 0;
    font-size: 0.9rem;
  }

  thead {
    display: none;
  }

  tbody {
    padding: 8px;
    background: #f8fafc;
  }

  tbody tr {
    margin-bottom: 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    overflow: hidden;
    background: #fff;
  }

  tbody tr:nth-child(even),
  tbody tr:hover {
    background: #fff;
  }

  tbody td {
    display: grid;
    grid-template-columns: 92px minmax(0, 1fr);
    gap: 10px;
    min-height: 38px;
    padding: 8px 10px;
    border-bottom: 1px solid #edf1f5;
  }

  tbody td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 0.78rem;
    font-weight: 700;
  }

  tbody td.row-action {
    display: block;
  }

  tbody td.row-action::before {
    content: "";
  }

  .mini-button {
    width: 100%;
  }

  .price,
  .stock {
    text-align: left;
  }

  .qty-input {
    width: 82px;
  }
}

@media (max-width: 460px) {
  .app-shell {
    width: min(100% - 10px, 440px);
  }

  .tab-group {
    grid-template-columns: 1fr;
  }

  .session-box {
    justify-content: space-between;
  }

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

  .filters label:nth-child(2),
  .filters label:nth-child(4),
  .filters label:nth-child(5),
  .filters button {
    grid-column: auto;
  }

  .cart-actions,
  .quote-search {
    grid-template-columns: 1fr;
  }

  .quote-search input,
  .quote-search .danger {
    grid-column: auto;
  }

  tbody td {
    grid-template-columns: 82px minmax(0, 1fr);
  }
}
