:root {
  color-scheme: light;
  --bg: #eef2f5;
  --panel: #ffffff;
  --ink: #18212b;
  --muted: #65717d;
  --line: #cfd7df;
  --soft: #f5f7f9;
  --yellow: #ffdd00;
  --green: #116b49;
  --blue: #276aa3;
  --accent: #295e58;
  --accent-strong: #143c38;
  --danger: #8c2d21;
  font-family: Arial, Helvetica, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
}

button,
input,
select {
  font: inherit;
}

.shell {
  min-height: 100vh;
  padding: 18px;
}

.workspace {
  display: grid;
  grid-template-columns: 280px minmax(440px, 1fr) 430px;
  gap: 14px;
  min-height: calc(100vh - 36px);
}

.side-panel,
.form-panel,
.preview-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.side-panel,
.preview-panel {
  padding: 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 22px;
}

.session-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: -8px 0 18px;
  padding: 10px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
}

.session-bar span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 68px;
  height: 48px;
  border: 3px solid #111;
  border-radius: 7px;
  background: #fff;
  font-weight: 800;
}

h1 {
  margin: 0;
  font-size: 20px;
  line-height: 1.12;
}

p {
  margin: 0;
}

.brand p,
.notice,
.upload-card span {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

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

label,
.section-label {
  color: #33414f;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

input,
select {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  padding: 8px 10px;
}

input:focus,
select:focus,
button:focus {
  outline: 3px solid rgba(41, 94, 88, 0.18);
  outline-offset: 1px;
}

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

button {
  min-height: 40px;
  border: 1px solid var(--accent);
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  cursor: pointer;
}

button:hover {
  background: var(--accent-strong);
}

button:disabled {
  cursor: wait;
  opacity: 0.65;
}

.secondary {
  background: #fff;
  color: var(--accent-strong);
}

.secondary:hover {
  background: #eff5f3;
}

.compact {
  min-height: 34px;
  padding: 0 12px;
}

.icon-button {
  padding: 0;
  font-size: 20px;
}

.actions {
  display: grid;
  gap: 8px;
}

.notice {
  margin-top: 18px;
  padding: 12px;
  border-radius: 7px;
  background: var(--soft);
  border: 1px solid var(--line);
}

.notice strong {
  display: block;
  color: var(--danger);
  margin-bottom: 4px;
}

.form-panel {
  overflow: hidden;
}

.tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  border-bottom: 1px solid var(--line);
}

.tab {
  border: 0;
  border-right: 1px solid var(--line);
  border-radius: 0;
  background: #f8fafb;
  color: var(--muted);
}

.tab:last-child {
  border-right: 0;
}

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

.tab-panel {
  display: none;
  padding: 18px;
}

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

.grid {
  display: grid;
  gap: 12px;
}

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

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

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

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

.section-label {
  margin: 20px 0 10px;
  letter-spacing: 0;
}

.rows-editor {
  display: grid;
  gap: 10px;
}

.row-editor {
  display: grid;
  grid-template-columns: 112px 112px minmax(120px, 1.4fr) minmax(110px, 1fr) 82px 42px;
  gap: 8px;
  align-items: end;
  padding: 10px;
  background: var(--soft);
  border: 1px solid var(--line);
  border-radius: 7px;
}

.row-editor .field {
  margin: 0;
}

.remove-row {
  min-height: 38px;
  background: #fff;
  color: var(--danger);
  border-color: #d1aaa5;
}

.upload-card {
  display: grid;
  gap: 10px;
  min-height: 260px;
  padding: 14px;
  border: 1px dashed #aeb8c2;
  border-radius: 8px;
  background: #fbfcfd;
  cursor: pointer;
}

.upload-card input {
  min-height: 0;
  padding: 0;
  border: 0;
}

.upload-card img {
  width: 100%;
  height: 190px;
  object-fit: contain;
  border-radius: 6px;
  background: #fff;
  border: 1px solid var(--line);
}

.preview-panel {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  gap: 12px;
}

.preview-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
}

.preview-header button {
  min-height: 38px;
  padding: 0 12px;
}

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

.sign-svg-stage {
  width: 100%;
  aspect-ratio: 1.12;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  overflow: hidden;
}

.sign-svg-stage svg {
  display: block;
  width: 100%;
  height: 100%;
}

.doc-preview {
  display: grid;
  gap: 10px;
  align-content: start;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.mini-row {
  display: grid;
  grid-template-columns: 1.35fr 1fr;
  gap: 8px;
}

#miniPhoto,
#miniSign,
#miniRoute {
  display: grid;
  place-items: center;
  min-height: 86px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #eef2f4;
  color: var(--muted);
  overflow: hidden;
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  background-color: #fff;
  font-size: 13px;
}

#miniRoute {
  min-height: 118px;
}

#miniDistance {
  padding: 16px 0 4px;
  text-align: center;
  font-size: 12px;
}

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

.login-shell {
  width: min(100%, 420px);
}

.login-panel {
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 16px 48px rgba(24, 33, 43, 0.12);
}

.login-brand {
  margin-bottom: 26px;
}

.login-brand p {
  margin-top: 5px;
}

.login-form {
  display: grid;
}

.login-form button {
  width: 100%;
}

.login-error {
  min-height: 22px;
  margin: -2px 0 10px;
  color: var(--danger);
  font-size: 13px;
  line-height: 1.35;
}

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

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

@media (max-width: 820px) {
  .shell {
    padding: 10px;
  }

  .workspace,
  .grid.two,
  .grid.four,
  .grid.dimensions,
  .row-editor {
    grid-template-columns: 1fr;
  }

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

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