:root {
  color-scheme: light;
  --bg: #f4f1f2;
  --panel: #ffffff;
  --panel-soft: #faf7f8;
  --ink: #120e0f;
  --muted: #70676a;
  --line: #e7dddf;
  --line-strong: #cdbfc2;
  --green: #b80000;
  --green-dark: #770000;
  --success: #15803d;
  --gold: #e05252;
  --gold-soft: #fff1f1;
  --navy: #0b0b0d;
  --navy-2: #120e0f;
  --blue: #a11212;
  --amber: #b86b10;
  --red: #b93838;
  --shadow: 0 22px 60px rgba(18, 14, 15, 0.12);
  --shadow-soft: 0 10px 28px rgba(18, 14, 15, 0.08);
  --radius: 8px;
  font-family: "Instrument Sans", Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  background:
    linear-gradient(180deg, #fffafa 0, #f4f1f2 360px),
    var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body.auth-locked {
  overflow: hidden;
}

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

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

button,
input,
select,
textarea {
  font: inherit;
  min-width: 0;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.58;
  transform: none !important;
  box-shadow: none !important;
}

svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
  flex: 0 0 auto;
}

.app-shell {
  min-height: 100vh;
}

.auth-gate {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 18px;
  background:
    radial-gradient(circle at 18% 20%, rgba(184, 0, 0, 0.28), transparent 34%),
    linear-gradient(135deg, #0b0b0d, #180e0f 58%, #0b0b0d);
}

.auth-card {
  width: min(460px, 100%);
  padding: 28px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--radius);
  background: rgba(18, 14, 15, 0.94);
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.36);
  color: #fff;
}

.auth-brand {
  margin-bottom: 24px;
}

.auth-form {
  display: grid;
  gap: 12px;
  margin-top: 16px;
}

.auth-copy {
  color: rgba(255, 255, 255, 0.68);
  line-height: 1.45;
}

.auth-error {
  min-height: 20px;
  margin-top: 12px;
  color: var(--red);
  font-size: 13px;
  font-weight: 800;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  height: 76px;
  padding: 0 26px;
  background: rgba(11, 11, 13, 0.96);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 16px 42px rgba(0, 0, 0, 0.26);
  backdrop-filter: blur(16px);
}

.session-box {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  min-width: 220px;
}

.session-box span {
  color: rgba(255, 255, 255, 0.72);
  font-size: 13px;
  font-weight: 800;
  overflow-wrap: anywhere;
}

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

.brand-logo {
  display: block;
  width: 88px;
  height: 42px;
  border-radius: var(--radius);
  background: #000;
  object-fit: cover;
  object-position: center;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.24);
}

.auth-brand .brand-logo {
  width: 122px;
  height: 58px;
}

.brand strong,
.brand span {
  display: block;
}

.brand strong {
  font-size: 16px;
  color: var(--ink);
}

.brand span {
  color: var(--muted);
  font-size: 12px;
  margin-top: 2px;
}

.auth-card .brand strong {
  color: #fff;
}

.auth-card .brand span {
  color: rgba(255, 255, 255, 0.66);
}

.auth-card label {
  color: rgba(255, 255, 255, 0.78);
}

.auth-card input {
  border-color: rgba(255, 255, 255, 0.16);
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}

.auth-card input:focus {
  border-color: #e05252;
  background: rgba(255, 255, 255, 0.12);
  box-shadow: 0 0 0 4px rgba(184, 0, 0, 0.22);
}

.topbar .brand strong {
  color: #fff;
}

.topbar .brand span {
  color: rgba(255, 255, 255, 0.66);
}

.tabs {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px;
  background: rgba(255, 255, 255, 0.09);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--radius);
}

.tab {
  min-width: 88px;
  height: 36px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: rgba(255, 255, 255, 0.7);
  font-weight: 700;
  transition: background 0.14s ease, color 0.14s ease;
}

.tab:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}

.tab.is-active {
  background: #fff;
  color: var(--navy);
  box-shadow: 0 8px 22px rgba(10, 16, 28, 0.16);
}

.tab.is-active:hover {
  color: var(--navy);
}

main {
  overflow-x: hidden;
  padding: 18px;
}

.view {
  display: none;
}

.view.is-visible {
  display: block;
}

.workspace-grid {
  display: grid;
  grid-template-columns: minmax(280px, 340px) minmax(620px, 1fr) minmax(520px, 640px);
  gap: 16px;
  align-items: start;
}

.workspace-grid > * {
  min-width: 0;
}

.input-panel,
.builder-panel,
.preview-panel,
.follow-main,
.automation-panel {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(255, 255, 255, 0.94)),
    var(--panel);
  border: 1px solid rgba(218, 198, 202, 0.72);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.input-panel,
.builder-panel,
.follow-main,
.automation-panel {
  padding: 20px;
}

.preview-panel {
  overflow: auto;
  background:
    linear-gradient(180deg, #fffafa, #f4f1f2);
}

.panel-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
  padding-bottom: 2px;
}

.panel-heading.inline {
  align-items: center;
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--green);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 23px;
  line-height: 1.15;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 0;
  font-size: 22px;
  line-height: 1.2;
  letter-spacing: 0;
}

h3 {
  margin-bottom: 0;
  font-size: 16px;
}

.voice-strip,
.actions-row,
.line-toolbar,
.preview-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
}

.voice-strip {
  margin-bottom: 12px;
  flex-wrap: wrap;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-soft);
}

.voice-state {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.voice-state.is-recording {
  color: var(--red);
}

.voice-help {
  margin-bottom: 12px;
  padding: 10px 12px;
  border: 1px solid #f0d8b2;
  border-radius: var(--radius);
  background: linear-gradient(180deg, #fffdf8, #fff7e9);
  color: #67440e;
  font-size: 13px;
  line-height: 1.4;
}

.voice-help a {
  display: inline-block;
  margin-top: 4px;
  padding: 2px 6px;
  border: 1px solid #eed3a9;
  border-radius: 5px;
  background: #fff;
  color: #27313f;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  text-decoration: none;
}

textarea,
input,
select {
  width: 100%;
  border: 1px solid #c8d2df;
  border-radius: 7px;
  background: #fbfcfe;
  color: var(--ink);
  outline: none;
  transition: border-color 0.16s ease, box-shadow 0.16s ease, background 0.16s ease;
}

textarea:focus,
input:focus,
select:focus {
  border-color: var(--green);
  background: #fff;
  box-shadow: 0 0 0 4px rgba(20, 120, 93, 0.12);
}

textarea {
  min-height: 260px;
  padding: 13px;
  resize: vertical;
  line-height: 1.45;
}

.brief-insight {
  display: grid;
  gap: 10px;
  margin-top: 12px;
  padding: 12px;
  border: 1px solid #d8e4ef;
  border-radius: var(--radius);
  background: linear-gradient(180deg, #ffffff, #f6f9fc);
  box-shadow: 0 8px 20px rgba(28, 38, 58, 0.06);
}

.brief-insight:empty {
  display: none;
}

.brief-insight-head,
.price-advisor-head,
.library-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.brief-insight-head span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.brief-detected-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.brief-detected-grid div {
  min-width: 0;
  padding: 8px;
  border: 1px solid #e3eaf2;
  border-radius: 7px;
  background: #fbfcfe;
}

.brief-detected-grid span,
.price-grid span,
.service-row span,
.service-row small {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.brief-detected-grid strong {
  display: block;
  margin-top: 3px;
  overflow-wrap: anywhere;
  font-size: 12px;
}

.brief-quality {
  padding: 8px 10px;
  border-radius: 7px;
  font-size: 12px;
  font-weight: 900;
}

.brief-quality.is-ready {
  background: #eaf8f1;
  color: var(--success);
}

.brief-quality.is-warning {
  background: #fff6e7;
  color: var(--amber);
}

.brief-quality.is-danger {
  background: #fff0f0;
  color: var(--red);
}

input,
select {
  height: 40px;
  padding: 0 10px;
}

label {
  display: grid;
  gap: 6px;
  min-width: 0;
  color: #3f4857;
  font-size: 12px;
  font-weight: 800;
}

.quick-examples {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin: 12px 0;
}

.quick-examples button {
  height: 36px;
  border: 1px solid #cfd8e5;
  border-radius: 7px;
  background: #fff;
  color: #364154;
  font-weight: 800;
  box-shadow: 0 2px 0 rgba(25, 32, 46, 0.03);
}

.quick-examples button:hover {
  border-color: var(--green);
  color: var(--green);
}

.primary-button,
.secondary-button,
.ghost-button,
.wide-button,
.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: 7px;
  font-weight: 800;
  white-space: nowrap;
  transition: transform 0.14s ease, box-shadow 0.14s ease, border-color 0.14s ease, background 0.14s ease, color 0.14s ease;
}

.primary-button,
.secondary-button,
.ghost-button,
.wide-button {
  min-height: 40px;
  padding: 0 13px;
}

.primary-button,
.wide-button {
  border: 1px solid var(--green);
  background: linear-gradient(180deg, #d40213, var(--green-dark));
  color: #fff;
  box-shadow: 0 12px 24px rgba(184, 0, 0, 0.22);
}

.primary-button:hover,
.wide-button:hover {
  background: linear-gradient(180deg, #e05252, #8f0000);
  transform: translateY(-1px);
  box-shadow: 0 15px 30px rgba(184, 0, 0, 0.28);
}

.secondary-button {
  border: 1px solid #c6d1df;
  background: #fff;
  color: #27313f;
  box-shadow: 0 8px 18px rgba(28, 38, 58, 0.06);
}

.secondary-button:hover,
.ghost-button:hover,
.icon-button:hover {
  border-color: var(--green);
  color: var(--green);
  transform: translateY(-1px);
}

.ghost-button {
  border: 1px solid transparent;
  background: transparent;
  color: #566174;
}

.topbar .ghost-button {
  color: rgba(255, 255, 255, 0.72);
}

.topbar .ghost-button:hover {
  border-color: rgba(255, 255, 255, 0.26);
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}

.wide-button {
  width: 100%;
}

.icon-button {
  width: 38px;
  height: 38px;
  border: 1px solid #cfd8e5;
  background: #fff;
  color: #3c4655;
  padding: 0;
  box-shadow: 0 8px 18px rgba(28, 38, 58, 0.06);
}

.hint {
  margin-top: 14px;
  padding: 12px;
  border: 1px solid #efd4d4;
  border-radius: var(--radius);
  background: linear-gradient(180deg, #fffafa, #fff1f1);
  color: #5f2020;
  font-size: 13px;
  line-height: 1.4;
}

.photo-box {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.photo-upload {
  position: relative;
  min-height: 40px;
  align-items: center;
  justify-items: center;
  padding: 10px;
  border: 1px dashed #b9c6d7;
  border-radius: var(--radius);
  background:
    linear-gradient(180deg, #ffffff, #f6f9fc);
  color: #344054;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.14s ease, background 0.14s ease, color 0.14s ease;
}

.photo-upload:hover {
  border-color: var(--green);
  background: #f8fffb;
  color: var(--green);
}

.photo-upload input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.photo-gallery {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.photo-thumb {
  position: relative;
  overflow: hidden;
  min-height: 76px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #f2f5f9;
  box-shadow: 0 8px 18px rgba(28, 38, 58, 0.07);
}

.photo-thumb img {
  display: block;
  width: 100%;
  height: 76px;
  object-fit: cover;
}

.photo-thumb button {
  position: absolute;
  top: 5px;
  right: 5px;
  width: 24px;
  height: 24px;
  border: 1px solid rgba(255, 255, 255, 0.75);
  border-radius: 999px;
  background: rgba(32, 36, 43, 0.72);
  color: #fff;
  font-weight: 900;
}

.photo-insights,
.check-panel {
  border: 1px solid #efd4d4;
  border-radius: var(--radius);
  background: linear-gradient(180deg, #fffafa, #fff1f1);
  color: #5f2020;
  font-size: 13px;
  line-height: 1.45;
}

.photo-insights {
  display: none;
  padding: 10px 12px;
}

.photo-insights:not(:empty) {
  display: block;
}

.check-panel {
  margin-top: 14px;
  padding: 12px;
}

.check-panel h3 {
  margin-bottom: 8px;
}

.check-panel ul {
  display: grid;
  gap: 6px;
  margin: 0;
  padding-left: 18px;
}

.check-panel li[data-level="danger"] {
  color: var(--red);
}

.check-panel li[data-level="warning"] {
  color: #835113;
}

.price-advisor,
.service-library-panel {
  display: grid;
  gap: 12px;
  margin-top: 14px;
  padding: 14px;
  border: 1px solid #d7e0eb;
  border-radius: var(--radius);
  background: linear-gradient(180deg, #ffffff, #f7fafc);
  box-shadow: 0 8px 22px rgba(28, 38, 58, 0.06);
}

.price-advisor:empty {
  display: none;
}

.price-advisor-head h3,
.library-head h3 {
  margin: 0;
}

.price-advisor-head > strong {
  min-width: 72px;
  padding: 8px 10px;
  border-radius: 999px;
  background: var(--navy);
  color: #fff;
  text-align: center;
  font-size: 15px;
}

.price-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.price-grid div {
  padding: 10px;
  border: 1px solid #e2e9f1;
  border-radius: 7px;
  background: #fbfcfe;
}

.price-grid strong {
  display: block;
  margin-top: 4px;
}

.price-alerts {
  display: grid;
  gap: 6px;
  margin: 0;
  padding-left: 18px;
  font-size: 13px;
}

.price-alerts li[data-level="danger"] {
  color: var(--red);
}

.price-alerts li[data-level="warning"] {
  color: var(--amber);
}

.price-ok {
  padding: 9px 10px;
  border-radius: 7px;
  background: #eaf8f1;
  color: var(--success);
  font-size: 13px;
  font-weight: 900;
}

.library-head {
  align-items: flex-end;
}

.library-head input {
  max-width: 260px;
}

.service-suggestions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.service-chip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 58px;
  padding: 10px;
  border: 1px solid #d7e0eb;
  border-radius: 7px;
  background: #fff;
  color: var(--ink);
  text-align: left;
  transition: border-color 0.14s ease, transform 0.14s ease, box-shadow 0.14s ease;
}

.service-chip:hover {
  border-color: var(--green);
  box-shadow: 0 10px 22px rgba(28, 38, 58, 0.08);
  transform: translateY(-1px);
}

.service-chip strong,
.service-chip small {
  display: block;
}

.service-chip small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
}

.service-chip > span:last-child {
  color: var(--green);
  font-size: 12px;
  font-weight: 900;
}

.form-grid,
.summary-grid,
.settings-grid,
.quote-options-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.span-2 {
  grid-column: span 2;
}

.line-toolbar {
  justify-content: space-between;
  margin: 18px 0 10px;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid rgba(197, 209, 224, 0.86);
  border-radius: var(--radius);
  background: #fff;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.85);
}

.quote-table {
  width: 100%;
  min-width: 760px;
  border-collapse: collapse;
  table-layout: fixed;
}

.quote-table th,
.quote-table td {
  border-bottom: 1px solid #e5ebf3;
  padding: 9px;
  text-align: left;
  vertical-align: middle;
}

.quote-table th {
  background: linear-gradient(180deg, #f7f9fc, #edf2f7);
  color: #4c5667;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

.quote-table tbody tr {
  transition: background 0.14s ease;
}

.quote-table tbody tr:hover {
  background: #fbfdfc;
}

.quote-table td:first-child {
  width: 40%;
}

.quote-table tr:last-child td {
  border-bottom: 0;
}

.quote-table input,
.quote-table select {
  height: 34px;
  min-width: 0;
}

.line-main {
  display: grid;
  gap: 6px;
}

.line-description {
  color: #596373;
  font-size: 12px;
}

.line-margin {
  color: #7a8493;
  font-size: 11px;
  font-weight: 800;
}

.remove-line {
  width: 34px;
  height: 34px;
  border: 1px solid #ecd1d1;
  border-radius: 7px;
  background: #fff8f8;
  color: var(--red);
  transition: border-color 0.14s ease, background 0.14s ease, transform 0.14s ease;
}

.remove-line:hover {
  border-color: var(--red);
  background: #fff1f1;
  transform: translateY(-1px);
}

.quote-options-grid {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.25fr) minmax(165px, 0.7fr);
  align-items: end;
  margin-top: 14px;
}

.toggle-label {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  padding: 0 10px;
  border: 1px solid #c8d2df;
  border-radius: 7px;
  background: #fbfcfe;
  color: #344054;
  white-space: normal;
  transition: border-color 0.16s ease, box-shadow 0.16s ease, background 0.16s ease;
}

.toggle-label:hover {
  border-color: var(--green);
  background: #fff;
  box-shadow: 0 0 0 4px rgba(20, 120, 93, 0.08);
}

.toggle-label input {
  flex: 0 0 auto;
  width: 16px;
  height: 16px;
  margin: 0;
  padding: 0;
}

.summary-grid {
  grid-template-columns: minmax(150px, 1fr) minmax(150px, 1fr) minmax(260px, 1.15fr);
  align-items: end;
  margin-top: 14px;
}

.totals {
  display: grid;
  gap: 5px;
  padding: 13px 14px;
  border: 1px solid #d4deeb;
  border-radius: var(--radius);
  background:
    linear-gradient(180deg, #ffffff, #f5f8fb);
  box-shadow: 0 10px 24px rgba(28, 38, 58, 0.07);
}

.totals div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.totals div:last-child {
  padding-top: 8px;
  border-top: 1px solid #dfe6ef;
  font-size: 18px;
}

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

.status-pill {
  min-width: 94px;
  padding: 7px 12px;
  border-radius: 999px;
  border: 1px solid rgba(47, 95, 167, 0.16);
  background: linear-gradient(180deg, #f5f8ff, #eaf2ff);
  color: var(--blue);
  text-align: center;
  font-size: 12px;
  font-weight: 900;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.78);
}

.status-pill.is-sent {
  border-color: rgba(184, 107, 16, 0.18);
  background: linear-gradient(180deg, #fffaf1, #fff0d9);
  color: var(--amber);
}

.status-pill.is-ready,
.status-pill.is-viewed,
.status-pill.is-reminded {
  background: linear-gradient(180deg, #f5f8ff, #eaf2ff);
  color: var(--blue);
}

.status-pill.is-accepted,
.status-pill.is-signed,
.status-pill.is-invoiced {
  border-color: rgba(21, 128, 61, 0.18);
  background: linear-gradient(180deg, #f3fbf7, #e4f6ed);
  color: var(--success);
}

.status-pill.is-refused,
.status-pill.is-expired {
  border-color: rgba(185, 56, 56, 0.18);
  background: linear-gradient(180deg, #fff6f6, #ffe9e9);
  color: var(--red);
}

.actions-row {
  flex-wrap: wrap;
  margin-top: 16px;
}

.preview-toolbar {
  justify-content: space-between;
  height: 58px;
  padding: 0 16px;
  border-bottom: 1px solid rgba(202, 213, 228, 0.8);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.94), rgba(246, 249, 252, 0.94));
  color: #283244;
  font-weight: 900;
}

.document-preview {
  overflow: auto;
  min-height: 700px;
  padding: 30px;
  background:
    linear-gradient(180deg, #f7f9fc, #edf2f7);
}

.al-document {
  width: min(860px, 100%);
  min-height: 980px;
  margin: 0 auto;
  padding: 28px 28px 34px;
  background: #fff;
  border: 1px solid rgba(209, 216, 226, 0.9);
  box-shadow: 0 18px 46px rgba(21, 25, 34, 0.12);
  color: #080808;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 17px;
  line-height: 1.28;
}

.al-head-box {
  width: min(520px, 100%);
  border: 1px solid #111;
  margin: 0 0 30px;
}

.al-head-box h2 {
  margin: 0;
  padding: 10px 22px 4px;
  color: #9a4f12;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 44px;
  font-weight: 500;
  line-height: 1;
}

.al-head-box div {
  padding: 3px 18px 5px;
  border-top: 1px solid #111;
  color: #556b2f;
  font-size: 24px;
}

.al-parties {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(220px, 0.72fr);
  gap: 44px;
  margin-bottom: 28px;
}

.al-company-lines,
.al-client-lines {
  font-size: 18px;
}

.al-company-lines {
  padding-bottom: 3px;
  border-bottom: 2px solid #111;
}

.al-job-title {
  margin: 0 -18px 22px;
  padding: 28px 52px;
  border: 1px solid #111;
  color: #9a4f12;
  font-size: 24px;
  text-align: center;
}

.al-lines {
  border: 1px solid #111;
  border-bottom: 0;
}

.al-section {
  position: relative;
  padding: 30px 42px 28px;
  border-bottom: 3px dotted #111;
}

.al-section-title {
  margin-bottom: 18px;
  color: #9a4f12;
  font-size: 24px;
}

.al-section-body {
  display: grid;
  gap: 7px;
  padding-right: 120px;
  font-size: 18px;
}

.al-section-price {
  position: absolute;
  right: 26px;
  bottom: 24px;
  min-width: 110px;
  text-align: right;
  font-size: 17px;
}

.al-final {
  min-height: 420px;
  padding: 34px 24px 28px;
  border: 1px solid #111;
  border-top: 0;
}

.al-total-pay {
  margin-bottom: 160px;
  text-align: right;
  font-size: 17px;
  letter-spacing: 0.02em;
}

.al-payment-grid,
.al-summary {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(300px, 0.78fr);
  gap: 32px;
  padding: 14px 0;
  border-top: 1px solid #111;
}

.al-payment-grid p,
.al-summary p,
.al-final p {
  margin: 0 0 10px;
}

.al-summary {
  min-height: 150px;
}

.al-signature {
  margin-top: 40px;
}

.al-received {
  margin-top: 150px;
}

.doc-head {
  display: flex;
  justify-content: space-between;
  gap: 30px;
  margin-bottom: 30px;
}

.doc-head h2 {
  font-size: 28px;
}

.doc-meta,
.doc-parties,
.doc-note {
  color: #535d6b;
  line-height: 1.5;
  font-size: 13px;
}

.doc-company strong,
.doc-client strong {
  display: block;
  color: var(--ink);
  font-size: 16px;
}

.doc-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  margin-bottom: 24px;
}

.doc-table {
  width: 100%;
  border-collapse: collapse;
  margin: 18px 0;
  font-size: 13px;
}

.doc-table th {
  background: #eff3f8;
  color: #3e4652;
}

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

.doc-table .money,
.doc-totals .money {
  text-align: right;
  white-space: nowrap;
}

.doc-line-description {
  margin-top: 3px;
  color: #697383;
  font-size: 12px;
  line-height: 1.35;
}

.doc-info-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 12px 0 4px;
}

.doc-info-grid div {
  padding: 9px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #f8fafc;
  color: #535d6b;
  font-size: 12px;
  line-height: 1.4;
}

.doc-info-grid strong {
  display: block;
  margin-bottom: 3px;
  color: var(--ink);
}

.doc-photo-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin: 12px 0;
}

.doc-photo-grid img {
  width: 100%;
  height: 92px;
  object-fit: cover;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.doc-totals {
  display: grid;
  justify-content: end;
  gap: 5px;
  margin-left: auto;
  width: min(320px, 100%);
}

.doc-totals div {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 20px;
  padding: 7px 0;
  border-bottom: 1px solid var(--line);
}

.doc-totals .grand {
  color: var(--ink);
  font-size: 18px;
  font-weight: 900;
}

.doc-sign {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 22px;
  margin-top: 28px;
}

.sign-box {
  min-height: 86px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  padding: 10px;
  color: var(--muted);
  font-size: 12px;
}

.follow-layout,
.settings-layout {
  max-width: 1180px;
  margin: 0 auto;
}

.follow-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 16px;
  align-items: start;
}

.record-list,
.reminder-list {
  display: grid;
  gap: 10px;
  margin-top: 16px;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-top: 16px;
}

.metric-card {
  position: relative;
  overflow: hidden;
  padding: 14px;
  border: 1px solid #d8e1ec;
  border-radius: var(--radius);
  background:
    linear-gradient(180deg, #ffffff, #f7fafc);
  box-shadow: var(--shadow-soft);
}

.metric-card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 3px;
  background: linear-gradient(90deg, #b80000, #e05252);
}

.metric-card span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.metric-card strong {
  display: block;
  margin-top: 7px;
  color: var(--ink);
  font-size: 23px;
  line-height: 1;
}

.filter-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 180px;
  gap: 10px;
  margin-top: 12px;
}

.record-card,
.reminder-card {
  display: grid;
  gap: 10px;
  padding: 15px;
  border: 1px solid #d7e0eb;
  border-radius: var(--radius);
  background: #fff;
  box-shadow: 0 8px 22px rgba(28, 38, 58, 0.06);
}

.record-card {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  transition: transform 0.14s ease, box-shadow 0.14s ease, border-color 0.14s ease;
}

.record-card:hover {
  border-color: #c4d0df;
  box-shadow: 0 14px 30px rgba(28, 38, 58, 0.1);
  transform: translateY(-1px);
}

.record-title {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}

.record-title strong {
  overflow-wrap: anywhere;
}

.record-meta {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

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

.mini-button {
  height: 34px;
  padding: 0 10px;
  border: 1px solid #c8d2df;
  border-radius: 7px;
  background: #fbfcfe;
  color: #354052;
  font-size: 12px;
  font-weight: 900;
  transition: border-color 0.14s ease, color 0.14s ease, transform 0.14s ease, box-shadow 0.14s ease;
}

.mini-button:hover {
  border-color: var(--green);
  color: var(--green);
  box-shadow: 0 8px 18px rgba(28, 38, 58, 0.07);
  transform: translateY(-1px);
}

.automation-panel h2 {
  margin-bottom: 16px;
}

.rule-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.reminder-card {
  background: linear-gradient(180deg, #fffdf8, #fff7e8);
  border-color: #efd6ae;
}

.settings-layout {
  display: grid;
  grid-template-columns: minmax(0, 920px);
  gap: 16px;
  justify-content: center;
}

.settings-grid textarea {
  min-height: 94px;
}

.service-editor-grid {
  margin-top: 16px;
}

.service-list {
  display: grid;
  gap: 8px;
  margin-top: 14px;
}

.service-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border: 1px solid #d7e0eb;
  border-radius: var(--radius);
  background: linear-gradient(180deg, #fff, #f7fafc);
  box-shadow: 0 8px 18px rgba(28, 38, 58, 0.05);
}

.service-row strong,
.service-row span,
.service-row small {
  overflow-wrap: anywhere;
}

.service-row span {
  margin-top: 4px;
}

.service-row small {
  margin-top: 3px;
  font-weight: 700;
}

.admin-panel .primary-button {
  margin-top: 12px;
}

.admin-edit-notice {
  margin: 12px 0;
  padding: 10px 12px;
  border: 1px solid #efd6ae;
  border-radius: var(--radius);
  background: linear-gradient(180deg, #fffdf8, #fff7e8);
  color: #67440e;
  font-size: 13px;
  font-weight: 800;
}

.user-list {
  display: grid;
  gap: 8px;
  margin-top: 16px;
}

.user-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  border: 1px solid #d7e0eb;
  border-radius: var(--radius);
  background:
    linear-gradient(180deg, #fff, #f7fafc);
  box-shadow: 0 8px 18px rgba(28, 38, 58, 0.05);
}

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

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

.user-row span {
  color: var(--muted);
  font-size: 12px;
}

.role-pill {
  padding: 5px 8px;
  border-radius: 999px;
  background: #eef4ff;
  color: var(--blue);
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 80;
  display: flex;
  align-items: center;
  gap: 12px;
  width: min(420px, calc(100vw - 32px));
  min-height: 56px;
  padding: 12px 16px;
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: 8px;
  background: rgba(11, 11, 13, 0.96);
  color: #fff;
  box-shadow: 0 22px 60px rgba(11, 11, 13, 0.26), 0 8px 18px rgba(11, 11, 13, 0.16);
  backdrop-filter: blur(14px);
  opacity: 0;
  transform: translate(-50%, 18px) scale(0.98);
  transition: opacity 0.2s ease, transform 0.2s ease;
  pointer-events: none;
}

.toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0) scale(1);
}

.toast-icon {
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 999px;
  background: var(--red);
  color: #fff;
  font-weight: 900;
  line-height: 1;
}

.toast-message {
  font-size: 14px;
  font-weight: 850;
  letter-spacing: 0;
}

.toast.is-success {
  background: linear-gradient(135deg, rgba(11, 11, 13, 0.98), rgba(48, 20, 20, 0.96));
}

.toast.is-success .toast-icon {
  background: linear-gradient(135deg, #b80000, #ef4444);
  box-shadow: 0 0 0 5px rgba(184, 0, 0, 0.16);
}

.toast.is-danger .toast-icon {
  background: #dc2626;
}

.toast.is-info .toast-icon {
  background: #64748b;
}

@media (max-width: 1680px) {
  .workspace-grid {
    grid-template-columns: minmax(280px, 360px) minmax(0, 1fr);
  }

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

  .document-preview {
    padding: 24px;
  }
}

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

@media (max-width: 820px) {
  .topbar {
    position: static;
    height: auto;
    align-items: stretch;
    flex-direction: column;
    padding: 14px;
  }

  .brand {
    min-width: 0;
  }

  .tabs {
    width: 100%;
  }

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

  .tab {
    flex: 1;
    min-width: 0;
  }

  main {
    padding: 10px;
  }

  .workspace-grid,
  .follow-layout {
    grid-template-columns: 1fr;
  }

  .form-grid,
  .summary-grid,
  .quote-options-grid,
  .brief-detected-grid,
  .price-grid,
  .service-suggestions,
  .al-parties,
  .al-payment-grid,
  .al-summary,
  .doc-grid,
  .doc-info-grid,
  .doc-sign,
  .rule-row,
  .dashboard-grid,
  .filter-row {
    grid-template-columns: 1fr;
  }

  .span-2 {
    grid-column: auto;
  }

  .document-preview {
    padding: 18px;
  }

  .al-document {
    padding: 18px;
  }

  .al-head-box h2 {
    font-size: 32px;
  }

  .al-job-title {
    margin-inline: 0;
    padding: 18px;
    font-size: 20px;
  }

  .al-section {
    padding: 22px 18px;
  }

  .al-section-body {
    padding-right: 0;
  }

  .al-section-price {
    position: static;
    margin-top: 14px;
  }

  .al-total-pay {
    margin-bottom: 60px;
  }

  .al-received {
    margin-top: 70px;
  }

  .doc-head {
    flex-direction: column;
  }

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

  .service-row {
    grid-template-columns: 1fr;
  }

  .library-head {
    align-items: stretch;
    flex-direction: column;
  }

  .library-head input {
    max-width: none;
  }

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

@media print {
  body {
    background: #fff;
  }

  .topbar,
  .input-panel,
  .builder-panel,
  .preview-toolbar,
  .toast {
    display: none !important;
  }

  main {
    padding: 0;
  }

  .workspace-grid,
  .view.is-visible {
    display: block;
  }

  .preview-panel {
    border: 0;
    box-shadow: none;
  }

  .document-preview {
    padding: 0;
    min-height: auto;
  }

  .al-document {
    padding: 0;
    border: 0;
    box-shadow: none;
  }
}
