:root {
  color-scheme: light;
  --ink: #172126;
  --muted: #60707a;
  --line: #d7e0e4;
  --paper: #f4f7f5;
  --panel: #ffffff;
  --accent: #0f766e;
  --highlight: #f59e0b;
  --danger: #b42318;
  --shadow: 0 18px 48px rgba(23, 33, 38, 0.12);
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(180deg, rgba(15, 118, 110, 0.08), transparent 38%),
    var(--paper);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

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

button {
  border: 0;
  cursor: pointer;
}

.is-hidden {
  display: none !important;
}

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

.auth-panel {
  width: min(440px, 100%);
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
}

.auth-copy,
.form-message {
  color: var(--muted);
  font-weight: 700;
}

.form-message {
  min-height: 20px;
  margin: 12px 0 0;
  color: var(--danger);
}

.app-shell {
  width: min(1520px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  padding: 24px;
}

.app-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

.app-shell.admin-mode {
  width: 100%;
  padding: 24px 32px;
}

.app-shell.admin-mode .workspace {
  grid-template-columns: 1fr;
}

.app-shell.admin-mode .controls {
  width: 100%;
}

.session-tools,
.template-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(360px, 440px) minmax(0, 1fr);
  gap: 24px;
  align-items: start;
}

.controls,
.preview-stage {
  min-width: 0;
}

.brand-line,
.preview-toolbar,
.panel-heading,
.repair-row,
.row-actions,
.toolbar-actions,
.session-tools {
  display: flex;
  align-items: center;
}

.brand-line,
.preview-toolbar,
.panel-heading {
  justify-content: space-between;
  gap: 16px;
}

.brand-line {
  margin-bottom: 16px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: 28px;
  line-height: 1.08;
}

h2 {
  font-size: 18px;
  line-height: 1.2;
}

.status-pill {
  flex: 0 0 auto;
  padding: 7px 10px;
  border: 1px solid rgba(15, 118, 110, 0.18);
  border-radius: 999px;
  color: #0b5f59;
  background: rgba(15, 118, 110, 0.1);
  font-size: 12px;
  font-weight: 800;
}

.panel {
  margin-bottom: 12px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.88);
  box-shadow: 0 8px 22px rgba(23, 33, 38, 0.06);
}

.panel h2 {
  margin-bottom: 12px;
}

.panel-heading h2 {
  margin: 0;
}

.field-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.field-grid.compact {
  grid-template-columns: 1fr 1fr;
}

label {
  display: grid;
  gap: 6px;
  margin-top: 12px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--ink);
  background: #fff;
  outline: none;
}

input {
  min-height: 42px;
  padding: 9px 11px;
}

select {
  min-height: 42px;
  padding: 9px 11px;
}

input[type="color"] {
  padding: 4px;
}

input[type="file"] {
  padding: 9px;
}

textarea {
  min-height: 94px;
  padding: 10px 12px;
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.14);
}

.repairs-list {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.repair-row {
  display: grid;
  grid-template-columns: minmax(120px, 0.8fr) minmax(140px, 1fr) 96px 92px 38px;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f9fbfa;
}

.repair-row input,
.repair-row select {
  min-height: 38px;
}

.repair-row .repair-title {
  min-width: 0;
}

.repair-row .repair-cost {
  min-width: 0;
}

.repair-customer-value {
  display: grid;
  align-items: center;
  min-height: 38px;
  padding: 0 10px;
  border: 1px solid rgba(15, 118, 110, 0.22);
  border-radius: 7px;
  color: var(--accent);
  background: rgba(15, 118, 110, 0.08);
  font-size: 13px;
  font-weight: 900;
}

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

.markup-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 82px;
  gap: 8px;
  align-items: center;
  margin-top: 0;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f9fbfa;
  text-transform: none;
}

.markup-row span {
  min-width: 0;
  color: var(--ink);
  font-size: 12px;
  font-weight: 900;
}

.markup-row input {
  min-height: 34px;
  padding: 7px 8px;
}

.repair-template-list {
  display: grid;
  gap: 10px;
  max-height: 560px;
  overflow: auto;
  padding-right: 4px;
}

.repair-template-row {
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f9fbfa;
}

.repair-template-row h3 {
  margin: 0;
  font-size: 14px;
}

.repair-template-row label {
  margin-top: 0;
}

.repair-template-row textarea {
  min-height: 62px;
}

.asset-grid {
  display: grid;
  gap: 10px;
}

.asset-row {
  display: grid;
  grid-template-columns: minmax(96px, 0.85fr) minmax(140px, 1fr) auto;
  gap: 8px;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f9fbfa;
}

.asset-row strong {
  display: block;
  font-size: 13px;
}

.asset-row span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.asset-row input[type="file"] {
  min-height: 38px;
  padding: 7px;
}

.asset-row button {
  min-height: 38px;
  padding: 0 10px;
  border-radius: 7px;
  color: #fff;
  background: var(--ink);
  font-weight: 800;
}

.icon-button,
.remove-repair {
  display: inline-grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 7px;
  color: #fff;
  background: var(--accent);
  font-size: 22px;
  font-weight: 900;
  line-height: 1;
}

.remove-repair {
  flex: 0 0 auto;
  color: var(--danger);
  background: rgba(180, 35, 24, 0.1);
  font-size: 18px;
}

.preview-stage {
  position: sticky;
  top: 24px;
}

.preview-toolbar {
  margin-bottom: 16px;
}

.preview-toolbar h2 {
  font-size: 24px;
}

.toolbar-actions {
  gap: 10px;
}

.toolbar-actions button {
  min-height: 42px;
  padding: 0 14px;
  border-radius: 7px;
  color: #fff;
  background: var(--ink);
  font-weight: 800;
}

.toolbar-actions button:first-child {
  background: var(--accent);
}

.primary-action,
#logoutButton,
#copySiteEmbed,
.template-actions button {
  min-height: 42px;
  margin-top: 12px;
  padding: 0 14px;
  border-radius: 7px;
  color: #fff;
  background: var(--accent);
  font-weight: 800;
}

#logoutButton,
#copySiteEmbed,
.template-actions button:last-child {
  background: var(--ink);
}

.admin-panel {
  border-color: rgba(15, 118, 110, 0.35);
}

.admin-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.admin-grid {
  display: grid;
  grid-template-columns: minmax(320px, 520px) minmax(320px, 520px);
  gap: 16px;
  align-items: start;
}

.admin-card {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f9fbfa;
}

.admin-card h3 {
  margin: 0 0 4px;
  font-size: 17px;
}

.user-table {
  display: grid;
  margin-top: 18px;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.user-table-row {
  display: grid;
  grid-template-columns: minmax(220px, 1.2fr) minmax(220px, 1.2fr) minmax(150px, 0.75fr) minmax(150px, 0.75fr) minmax(280px, 1fr);
  gap: 14px;
  align-items: center;
  min-width: 1040px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
}

.user-table-row:last-child {
  border-bottom: 0;
}

.user-table-head {
  color: var(--muted);
  background: #f4f7f5;
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.user-cell,
.domain-list {
  min-width: 0;
}

.user-cell span,
.user-cell small {
  display: block;
  color: var(--muted);
  font-weight: 700;
}

.domain-list {
  color: var(--muted);
  font-weight: 700;
}

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

.impersonate-button,
.secondary-action,
.danger-action,
#stopImpersonating {
  min-height: 38px;
  padding: 0 12px;
  border-radius: 7px;
  color: #fff;
  background: var(--accent);
  font-weight: 800;
}

.secondary-action {
  background: var(--ink);
}

.danger-action {
  background: var(--danger);
}

.canvas-frame {
  display: grid;
  place-items: center;
  min-height: 520px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(45deg, rgba(96, 112, 122, 0.08) 25%, transparent 25%),
    linear-gradient(-45deg, rgba(96, 112, 122, 0.08) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, rgba(96, 112, 122, 0.08) 75%),
    linear-gradient(-45deg, transparent 75%, rgba(96, 112, 122, 0.08) 75%);
  background-position:
    0 0,
    0 10px,
    10px -10px,
    -10px 0;
  background-size: 20px 20px;
  box-shadow: var(--shadow);
}

canvas {
  display: block;
  width: min(100%, 680px);
  height: auto;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 14px 36px rgba(23, 33, 38, 0.18);
}

.embed-output {
  margin-top: 16px;
}

.help-dialog {
  width: min(560px, calc(100vw - 32px));
  padding: 0;
  border: 0;
  border-radius: 8px;
  color: var(--ink);
  background: transparent;
}

.help-dialog::backdrop {
  background: rgba(5, 13, 18, 0.52);
}

.help-card {
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
}

.help-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.help-heading button {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 7px;
  color: #fff;
  background: var(--ink);
  font-weight: 900;
}

.help-card ol {
  margin: 0;
  padding-left: 22px;
}

.help-card li,
.help-card p {
  color: var(--muted);
  font-weight: 700;
  line-height: 1.45;
}

.help-card p {
  margin: 12px 0 0;
}

@media (max-width: 980px) {
  .app-shell {
    padding: 16px;
  }

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

  .preview-stage {
    position: static;
  }
}

@media (max-width: 560px) {
  .brand-line,
  .preview-toolbar,
  .app-topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .field-grid,
  .field-grid.compact {
    grid-template-columns: 1fr;
  }

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

  .repair-row .repair-cost,
  .repair-customer-value {
    width: 100%;
  }

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

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

  .toolbar-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    width: 100%;
  }
}
