:root {
  --navy: #061857;
  --blue: #151f92;
  --ink: #071b47;
  --muted: #5c6e86;
  --line: #d3deeb;
  --soft: #f5f8fc;
  --white: #ffffff;
  --red: #d3102f;
  --green: #218c63;
  --amber: #f5b335;
  --steel: #eef2f7;
  --shadow: 0 18px 42px rgba(6, 24, 87, 0.11);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: linear-gradient(180deg, #f8fafc 0, #eef3f8 260px, #e7edf5 100%);
  color: var(--ink);
  font-family: Arial, Helvetica, sans-serif;
  letter-spacing: 0;
}

body::before {
  content: "";
  position: fixed;
  top: 0;
  left: 0;
  z-index: 50;
  width: 100%;
  height: 5px;
  background: var(--red);
}

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

.app-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: minmax(360px, 1fr) auto;
  align-items: center;
  gap: 20px;
  padding: 14px 22px;
  background: rgba(255, 255, 255, 0.96);
  border-bottom: 1px solid var(--line);
  box-shadow: 0 10px 26px rgba(6, 24, 87, 0.08);
  backdrop-filter: blur(10px);
}

.app-header h1,
.login-panel h1 {
  margin: 0;
  color: var(--navy);
  font-size: 30px;
  line-height: 1.1;
}

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

.brand-mark {
  flex: 0 0 auto;
  padding-right: 22px;
  border-right: 1px solid #dfe7f1;
}

.brand-title {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.wordmark {
  color: var(--blue);
  font-size: 26px;
  font-weight: 900;
  line-height: 1;
  white-space: nowrap;
}

.wordmark span {
  font-style: italic;
}

.wordmark em {
  color: var(--red);
  font-style: italic;
}

.header-subtitle {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.eyebrow,
.label-mini {
  display: block;
  margin: 0 0 5px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

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

.header-actions {
  justify-content: flex-end;
}

.button {
  display: inline-flex;
  min-height: 38px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 14px;
  border: 1px solid #cbd8e7;
  border-radius: 8px;
  background: var(--white);
  color: var(--blue);
  font-weight: 800;
  text-decoration: none;
  cursor: pointer;
  box-shadow: 0 8px 16px rgba(6, 24, 87, 0.06);
  transition: transform 140ms ease, box-shadow 140ms ease, border-color 140ms ease;
}

.button.primary {
  background: var(--blue);
  border-color: var(--blue);
  color: var(--white);
  box-shadow: 0 10px 20px rgba(21, 31, 146, 0.24);
}

.button.primary:hover,
.button.ghost:hover {
  transform: translateY(-1px);
}

.button.success {
  background: var(--green);
  border-color: var(--green);
  color: var(--white);
}

.button.warning {
  background: var(--amber);
  border-color: var(--amber);
  color: var(--ink);
}

.button.danger {
  background: var(--red);
  border-color: var(--red);
  color: var(--white);
}

.button.ghost {
  background: var(--white);
}

.operation-pill {
  display: inline-flex;
  min-height: 34px;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border: 1px solid #cfdbea;
  border-radius: 8px;
  background: #f6f9fd;
  color: var(--navy);
  font-size: 13px;
  font-weight: 900;
  white-space: nowrap;
}

.operation-pill::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: var(--red);
  box-shadow: 0 0 0 3px rgba(211, 16, 47, 0.12);
}

.button.subtle {
  background: #fff4f6;
  color: var(--red);
}

.button.small {
  min-height: 32px;
  padding: 6px 10px;
  font-size: 12px;
}

.button.disabled {
  pointer-events: none;
  opacity: 0.45;
}

.workflow-tabs {
  display: flex;
  gap: 8px;
  padding: 12px 20px;
  overflow-x: auto;
  background: var(--steel);
  border-bottom: 1px solid var(--line);
}

.workflow-tabs button {
  flex: 0 0 auto;
  min-height: 36px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--white);
  color: var(--ink);
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 8px 16px rgba(6, 24, 87, 0.04);
}

.workflow-tabs button.active {
  background: var(--blue);
  border-color: var(--blue);
  color: var(--white);
}

.config-warning {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 12px 20px;
  border-bottom: 1px solid #f1b8c3;
  border-top: 4px solid var(--red);
  background: #fff4f6;
  color: var(--ink);
  font-weight: 800;
}

.config-warning span {
  color: var(--muted);
  font-weight: 700;
}

.queue-summary {
  display: grid;
  grid-template-columns: repeat(6, minmax(120px, 1fr));
  gap: 12px;
  padding: 14px 20px;
  background: rgba(238, 243, 249, 0.92);
  border-bottom: 1px solid var(--line);
}

.queue-stat {
  display: flex;
  min-height: 48px;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 14px 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--white);
  color: var(--ink);
  cursor: pointer;
  box-shadow: var(--shadow);
  border-top: 4px solid var(--red);
}

.queue-stat span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.queue-stat strong {
  color: var(--navy);
  font-size: 28px;
  line-height: 1;
}

.desk-layout {
  display: grid;
  grid-template-columns: minmax(280px, 360px) minmax(0, 1fr);
  min-height: calc(100vh - 118px);
}

.quote-list-panel {
  border-right: 1px solid var(--line);
  background: #f8fbff;
  box-shadow: inset -1px 0 0 rgba(255, 255, 255, 0.8);
}

.panel-header {
  display: grid;
  gap: 10px;
  padding: 16px;
  border-bottom: 1px solid var(--line);
  background: var(--white);
  border-top: 4px solid var(--red);
}

.panel-header strong {
  color: var(--navy);
  font-size: 17px;
}

.panel-header input,
label input,
label select,
label textarea,
.section-title-input,
.charge-line input {
  width: 100%;
  min-height: 42px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdff;
  color: var(--ink);
  font-weight: 700;
  box-shadow: inset 0 1px 2px rgba(6, 24, 87, 0.04);
}

label textarea {
  min-height: 88px;
  resize: vertical;
}

label {
  display: grid;
  gap: 7px;
  color: var(--ink);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.quote-list {
  display: grid;
  gap: 8px;
  padding: 12px;
}

.quote-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  width: 100%;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--white);
  color: var(--ink);
  text-align: left;
  cursor: pointer;
  box-shadow: 0 10px 22px rgba(6, 24, 87, 0.06);
}

.quote-row.priority-urgent {
  border-color: #f1a8b4;
  box-shadow: inset 4px 0 0 var(--red);
}

.quote-row.priority-high {
  border-color: #f4c96f;
  box-shadow: inset 4px 0 0 var(--amber);
}

.quote-row.active {
  border-color: var(--blue);
  box-shadow: inset 4px 0 0 var(--blue);
}

.quote-row.priority-urgent.active {
  box-shadow: inset 4px 0 0 var(--red), 0 0 0 2px rgba(223, 22, 48, 0.12);
}

.quote-row.priority-high.active {
  box-shadow: inset 4px 0 0 var(--amber), 0 0 0 2px rgba(245, 179, 53, 0.18);
}

.quote-row strong,
.quote-row b {
  display: block;
  font-size: 14px;
  color: var(--navy);
}

.quote-row small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.quote-row-side {
  text-align: right;
}

.quote-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 7px;
}

.badge {
  display: inline-flex;
  min-height: 22px;
  align-items: center;
  padding: 3px 7px;
  border: 1px solid #dce7f5;
  border-radius: 999px;
  background: #f8fbff;
  color: var(--muted);
  font-size: 11px;
  font-style: normal;
  font-weight: 900;
  text-transform: uppercase;
}

.badge.urgent {
  border-color: #f1a8b4;
  background: #fff4f6;
  color: var(--red);
}

.badge.high {
  border-color: #f4c96f;
  background: #fff8e8;
  color: #875b00;
}

.badge.capacity {
  border-color: #b7d9cc;
  background: #eefaf5;
  color: var(--green);
}

.list-empty,
.empty-state,
.notice {
  margin: 16px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--white);
}

.empty-state h2 {
  margin: 0 0 8px;
}

.empty-state p {
  margin: 0;
  color: var(--muted);
}

.notice.error {
  border-color: #f1a8b4;
  background: #fff4f6;
  color: #9e1023;
}

.editor-panel {
  min-width: 0;
  padding: 18px;
}

.quote-editor {
  display: grid;
  gap: 14px;
}

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

.editor-strip > div,
.form-section,
.action-bar {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--white);
  box-shadow: var(--shadow);
  border-top: 4px solid var(--red);
}

.editor-strip > div {
  padding: 12px;
}

.editor-strip strong {
  color: var(--navy);
  font-size: 19px;
}

.form-section {
  display: grid;
  gap: 14px;
  padding: 16px;
}

.section-heading {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: baseline;
  padding-bottom: 10px;
  border-bottom: 1px solid #dce7f5;
}

.section-heading h2 {
  margin: 0;
  color: var(--navy);
  font-size: 19px;
}

.section-heading p {
  max-width: 680px;
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.field-grid {
  display: grid;
  gap: 14px;
}

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

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

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

.sections-area {
  display: grid;
  gap: 12px;
}

.charge-section {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid #dce7f5;
  border-radius: 8px;
  background: #f7faff;
  box-shadow: inset 4px 0 0 rgba(21, 31, 146, 0.12);
}

.charge-section-header {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto auto;
  gap: 8px;
}

.charge-lines {
  display: grid;
  gap: 8px;
}

.charge-line {
  display: grid;
  grid-template-columns: minmax(240px, 1fr) 160px auto;
  gap: 8px;
}

.action-bar {
  position: sticky;
  bottom: 0;
  z-index: 10;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding: 12px;
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(10px);
}

.login-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, #f8fafc, #e8eef7);
}

.login-shell {
  width: min(440px, calc(100vw - 32px));
}

.login-panel {
  display: grid;
  gap: 16px;
  padding: 26px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--white);
  box-shadow: var(--shadow);
  border-top: 5px solid var(--red);
}

.quote-preview-body {
  background: #dfe9f5;
}

.quote-preview {
  width: min(980px, calc(100vw - 32px));
  margin: 20px auto;
}

.quote-preview pre {
  margin: 16px 0 0;
  padding: 28px;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--white);
  color: var(--ink);
  font: 14px/1.5 "Courier New", Courier, monospace;
  white-space: pre-wrap;
}

.email-inbox-panel {
  display: grid;
  gap: 14px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--white);
  box-shadow: var(--shadow);
  border-top: 4px solid var(--red);
}

.email-list {
  display: grid;
  gap: 12px;
}

.email-card {
  display: grid;
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fbff;
}

.email-card-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
}

.email-card-header strong,
.email-card-header small {
  display: block;
}

.email-card-header small {
  margin-top: 4px;
  color: var(--muted);
  font-weight: 700;
}

.email-card pre {
  max-height: 260px;
  margin: 0;
  overflow: auto;
  padding: 12px;
  border: 1px solid #dce7f5;
  border-radius: 8px;
  background: var(--white);
  white-space: pre-wrap;
  font: 13px/1.45 Arial, Helvetica, sans-serif;
}

@media (max-width: 1180px) {
  .app-header {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .header-actions {
    justify-content: flex-start;
  }
}

@media (max-width: 1050px) {
  .desk-layout,
  .queue-summary,
  .field-grid.two,
  .field-grid.three,
  .field-grid.four,
  .editor-strip {
    grid-template-columns: 1fr;
  }

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

  .charge-section-header,
  .charge-line {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 720px) {
  .section-heading {
    align-items: stretch;
    flex-direction: column;
  }

  .app-header {
    position: static;
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .brand-block {
    align-items: flex-start;
    flex-direction: column;
    gap: 10px;
  }

  .brand-mark {
    padding-right: 0;
    border-right: 0;
  }

  .header-actions {
    justify-content: flex-start;
  }

  .editor-panel {
    padding: 10px;
  }
}
