:root {
  --ink: #182027;
  --muted: #66737c;
  --line: #dce2e6;
  --paper: #f3f5f6;
  --panel: #ffffff;
  --field: #fbfcfd;
  --accent: #0b55b5;
  --accent-dark: #083f86;
  --deep: #202b34;
  --box-radius: 0;
  --box-gap: 16px;
  --soft-shadow: 0 10px 28px rgba(24, 32, 39, .08);
  --app-font: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  font-family: var(--app-font);
}

* { box-sizing: border-box; }

html {
  background: #ffffff;
}

body {
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(180deg, #ffffff 0%, #ffffff 22rem, #eef6ff 100%);
  font-family: var(--app-font);
}

body:not(.is-authenticated) .app-shell {
  display: none;
}

body.is-authenticated .auth-screen {
  display: none;
}

button,
input,
select,
textarea,
option,
optgroup {
  font-family: var(--app-font);
  font-size: inherit;
  line-height: inherit;
}

button {
  min-height: 42px;
  border: 0;
  border-radius: var(--box-radius);
  padding: 10px 15px;
  color: #fff;
  background: var(--deep);
  cursor: pointer;
  font-weight: 800;
}

button:hover { background: #31404c; }
button.ghost { color: var(--ink); background: #edf1f3; }
button.ghost:hover { background: #dfe6e9; }
button.small { min-height: 34px; padding: 7px 10px; font-size: 13px; }
button.danger { color: #8a1f11; background: #ffe8e4; }

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

.auth-card {
  width: min(100%, 430px);
  display: grid;
  justify-items: center;
  gap: 16px;
  padding: 30px;
  border: 1px solid rgba(220, 226, 230, .95);
  background: rgba(255, 255, 255, .96);
  box-shadow: var(--soft-shadow);
  text-align: center;
}

.auth-logo {
  width: min(170px, 44vw);
  height: auto;
}

.auth-card h1 {
  margin: 0 0 4px;
  font-size: 28px;
  line-height: 1.08;
  text-align: center;
}

.auth-card label,
.auth-card input,
.auth-card button,
.auth-message {
  width: 100%;
}

.auth-card label {
  color: var(--muted);
  text-align: left;
  font-weight: 800;
}

.auth-message {
  min-height: 20px;
  margin: 0;
  color: #8a1f11;
  font-weight: 900;
}

.session-pill {
  display: inline-flex;
  min-height: 42px;
  align-items: center;
  padding: 8px 12px;
  color: var(--accent-dark);
  background: #eef6ff;
  border: 1px solid #c9def6;
  font-size: 13px;
  font-weight: 900;
}

.app-shell {
  max-width: 1540px;
  margin: 0 auto;
  padding: 26px;
}

.topbar, fieldset, .side-panel section, .data-editor, .documents-head, .document, .mockup-panel {
  border: 1px solid rgba(220, 226, 230, .95);
  border-radius: var(--box-radius);
  background: rgba(255, 255, 255, .95);
  box-shadow: var(--soft-shadow);
}

.topbar {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 18px;
  align-items: center;
  margin-bottom: var(--box-gap);
  padding: 18px;
}

.brand-logo {
  display: block;
  width: clamp(70px, 8vw, 96px);
  height: auto;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent-dark);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: clamp(20px, 2vw, 28px);
  line-height: 1;
}

.subtitle {
  margin: 7px 0 0;
  color: var(--accent);
  font-size: 14px;
}

.topbar-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.main-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(360px, 410px);
  gap: var(--box-gap);
  align-items: start;
}

.quote-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(280px, 1fr));
  gap: var(--box-gap);
}

.mockup-panel {
  margin-bottom: var(--box-gap);
  padding: 18px;
}

.mockup-panel .section-head strong {
  color: var(--accent);
  font-size: 24px;
}

.mockup-stage {
  display: grid;
  grid-template-columns: minmax(240px, 1fr) minmax(220px, .8fr);
  gap: 18px;
  align-items: center;
  margin-top: 14px;
}

.mockup-card {
  display: grid;
  align-content: center;
  justify-items: start;
  min-height: 220px;
  aspect-ratio: 1.42 / 1;
  max-width: 520px;
  padding: 28px;
  color: var(--ink);
  background:
    linear-gradient(135deg, rgba(11, 85, 181, .08), rgba(255, 255, 255, .92)),
    repeating-linear-gradient(45deg, transparent, transparent 12px, rgba(11,85,181,.05) 12px, rgba(11,85,181,.05) 24px);
  border: 2px dashed rgba(11, 85, 181, .28);
  box-shadow: inset 0 0 0 14px rgba(255,255,255,.48), 0 16px 32px rgba(24, 32, 39, .1);
}

.mockup-card.has-image {
  background-position: center;
  background-size: cover;
}

.mockup-card span {
  display: grid;
  place-items: center;
  width: auto;
  height: 64px;
  min-width: 96px;
  margin-bottom: 28px;
  color: #fff;
  background: #fff;
  background: var(--accent);
  font-weight: 900;
  font-size: 18px;
  padding: 0 16px;
}

.mockup-card.has-image span {
  color: #ffffff;
  background: rgba(24, 32, 39, .72);
  backdrop-filter: blur(8px);
}

.mockup-card strong {
  max-width: 100%;
  overflow: hidden;
  font-size: 30px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mockup-card.has-image strong,
.mockup-card.has-image small {
  padding: 4px 8px;
  background: rgba(24, 32, 39, .68);
}

.mockup-card small {
  margin-top: 8px;
  opacity: .88;
  font-size: 14px;
}

.image-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  color: var(--muted);
  background: #f3f6f7;
  border: 1px solid var(--line);
}

.image-actions span {
  min-width: 0;
  overflow: hidden;
  font-size: 13px;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mockup-info dl {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 9px 14px;
  margin: 0;
}

.mockup-info dt {
  color: var(--accent);
  font-size: 12px;
  font-weight: 900;
}

.mockup-info dd {
  min-width: 0;
  margin: 0;
  overflow-wrap: anywhere;
  font-weight: 800;
}

fieldset {
  margin: 0;
  padding: 20px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.box-title {
  grid-column: 1 / -1;
  margin: 0 0 2px;
  font-size: 18px;
}

label {
  display: grid;
  gap: 7px;
  color: var(--accent);
  font-size: 13px;
  font-weight: 800;
}

label.wide { grid-column: 1 / -1; }

input, select, textarea {
  width: 100%;
  min-height: 46px;
  border: 1px solid #ccd5da;
  border-radius: var(--box-radius);
  padding: 10px 11px;
  color: var(--ink);
  background: #ffffff;
  outline: none;
  font-family: var(--app-font);
  font-weight: 800;
}

select,
select option,
select optgroup {
  color: var(--ink);
  background: #ffffff;
  font-family: var(--app-font);
  font-weight: 800;
}

textarea {
  resize: vertical;
  min-height: 132px;
  line-height: 1.45;
  font-family: var(--app-font);
  font-weight: 700;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(11, 85, 181, .12);
}

.side-panel {
  display: grid;
  gap: var(--box-gap);
}

.side-panel .result-card {
  display: block;
  padding: 22px;
  color: #fff;
  background: linear-gradient(145deg, #202b34, #0b55b5);
  border-color: #0b55b5;
}

.result-card p, .result-card span { margin: 0; opacity: .88; }
.result-card strong { display: block; margin: 8px 0; font-size: 42px; line-height: 1; }

.history, .breakdown { padding: 16px; }

.section-head, .documents-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.section-head h2, .breakdown h2, .documents-head h2 { margin: 0; color: var(--accent); }

.history ul {
  list-style: none;
  display: grid;
  gap: 6px;
  margin: 12px 0 0;
  padding: 0;
  max-height: 430px;
  overflow-y: auto;
  padding-right: 4px;
}

.history-search {
  margin-top: 12px;
}

.history li {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 6px 10px;
  align-items: center;
  border: 1px solid var(--line);
  padding: 8px;
  background: #fbfcfd;
}

.history-main {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.history-main strong {
  color: var(--accent);
  font-size: 13px;
}

.history-main span {
  min-width: 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-total {
  color: var(--ink);
  font-size: 13px;
  text-align: right;
}

.history-actions {
  grid-column: 1 / -1;
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.history-actions button {
  min-height: 28px;
  padding: 4px 8px;
  font-size: 11px;
}

.history-actions .document-action {
  background: var(--accent);
  border-color: var(--accent);
  color: #ffffff;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  padding: 14px;
}

.metrics div {
  display: grid;
  gap: 4px;
  background: #f3f6f7;
  padding: 12px;
}

.metrics span, .breakdown dt {
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
}

.metrics strong { font-size: 18px; }

.breakdown dl {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 9px 14px;
  margin: 14px 0 0;
}

.breakdown dd { margin: 0; font-weight: 900; text-align: right; }

.data-editor {
  display: none;
  margin-top: var(--box-gap);
  padding: 18px;
}

.data-editor.open { display: block; }

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

.data-tabs {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  margin-top: 14px;
  padding: 4px;
  background: #edf1f3;
}

.data-tab {
  min-height: 38px;
  color: var(--muted);
  background: transparent;
  white-space: nowrap;
}

.data-tab.active {
  color: var(--ink);
  background: #fff;
}

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

.data-table {
  width: 100%;
  min-width: 760px;
  border-collapse: collapse;
}

.data-table th, .data-table td {
  padding: 9px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

.data-table th {
  color: var(--muted);
  background: #f0f4f5;
  font-size: 12px;
  font-weight: 900;
}

.data-table input, .data-table select {
  min-height: 38px;
  padding: 8px;
  font-size: 13px;
}

.documents {
  display: grid;
  gap: var(--box-gap);
  margin-top: var(--box-gap);
}

.documents-head { padding: 16px 18px; box-shadow: none; }

.doc-tabs {
  display: flex;
  gap: 6px;
  padding: 4px;
  background: #edf1f3;
}

.doc-tab {
  min-height: 38px;
  color: var(--accent);
  background: transparent;
}

.doc-tab.active {
  color: var(--ink);
  background: #fff;
}

.document {
  display: none;
  padding: clamp(22px, 3vw, 34px);
  overflow-x: auto;
}

.document.active { display: block; }

.doc-header {
  display: flex;
  justify-content: space-between;
  gap: 20px;
}

.doc-contact {
  display: grid;
  gap: 3px;
  justify-items: end;
  color: var(--accent);
  font-size: 13px;
  text-align: right;
}

.doc-logo {
  width: min(75px, 18vw);
  height: auto;
  margin-bottom: 8px;
}

.doc-contact strong {
  font-size: 20px;
}

.document h2 { margin: 0; font-size: 28px; color: var(--accent); }
.document h3 { margin: 24px 0 8px; color: var(--accent); font-size: 14px; text-transform: uppercase; }

.document table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 22px;
  table-layout: fixed;
}

.document th, .document td {
  border: 1px solid var(--line);
  padding: 10px;
  text-align: left;
  overflow-wrap: anywhere;
}

.document th { background: #f0f4f5; }
.legal, .muted-line { margin-top: 32px; color: var(--accent); line-height: 1.5; }
.muted-line { margin-top: 0; }
.email { color: var(--accent); font-weight: 800; }

.work-grid {
  display: grid;
  grid-template-columns: 160px 1fr 160px 1fr;
  border: 1px solid var(--line);
  border-bottom: 0;
  margin: 12px 0 22px;
}

.work-grid span,
.work-grid strong {
  border-bottom: 1px solid var(--line);
  padding: 9px;
  overflow-wrap: anywhere;
}

.work-grid span {
  color: var(--accent);
  background: #f0f4f5;
}

.notes-title {
  margin-top: 28px;
  color: var(--accent);
  font-weight: 900;
}

@media (max-width: 1080px) {
  .main-grid { grid-template-columns: 1fr; }
}

@media (max-width: 760px) {
  .app-shell { padding: 14px; }
  .topbar { grid-template-columns: 1fr; }
  .topbar-actions { justify-content: stretch; }
  .topbar-actions button { flex: 1 1 46%; }
  .mockup-stage { grid-template-columns: 1fr; }
  .mockup-card { min-height: 190px; }
  .quote-form { grid-template-columns: 1fr; }
  fieldset { grid-template-columns: 1fr; padding: 16px; }
  input, select { font-size: 16px; }
  .metrics { grid-template-columns: 1fr; }
  .documents-head { align-items: stretch; flex-direction: column; }
  .doc-tabs { width: 100%; }
  .doc-tab { flex: 1; }
  .doc-header { flex-direction: column; }
  .doc-contact { text-align: left; }
  .work-grid { grid-template-columns: 1fr; }
}

@media print {
  body { background: #fff; }
  .topbar, .workspace, .side-panel, .documents-head { display: none; }
  .app-shell { padding: 0; max-width: none; }
  .document { border: 0; box-shadow: none; }
}
