:root {
  color-scheme: light;
  --bg: #eef3f7;
  --panel: #ffffff;
  --surface: #f7f9fb;
  --text: #17212b;
  --muted: #6d7885;
  --line: #d9e0e7;
  --accent: #2f7cf6;
  --accent-dark: #1e63d6;
  --ok: #1f9d55;
  --warn: #9a6a00;
  --error: #c93b31;
  font-family: Arial, Helvetica, sans-serif;
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
}

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

.workspace {
  width: min(100%, 1520px);
  min-height: calc(100vh - 24px);
  margin: 0 auto;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: visible;
}

.topbar {
  display: grid;
  grid-template-columns: minmax(230px, 1fr) auto;
  gap: 14px;
  align-items: center;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 22px;
  line-height: 1.2;
  font-weight: 700;
}

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

p {
  margin-top: 5px;
  color: var(--muted);
  font-size: 13px;
}

.sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
}

.main-tabs,
.product-tabs {
  display: flex;
  gap: 6px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.main-tab,
.product-tab {
  min-height: 34px;
  padding: 0 12px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}

.main-tab.is-active,
.product-tab.is-active {
  background: #ffffff;
  color: var(--accent);
  box-shadow: 0 1px 2px rgba(25, 40, 60, 0.08);
}

.status {
  min-height: 36px;
  padding: 10px 12px;
  border-radius: 6px;
  background: #eef3f8;
  color: var(--muted);
  font-size: 13px;
  text-align: right;
}

.status[data-type="busy"] {
  background: #fff7df;
  color: var(--warn);
}

.status[data-type="ok"] {
  background: #e8f7ef;
  color: var(--ok);
}

.status[data-type="error"] {
  background: #fdecea;
  color: var(--error);
}

.view,
.product-form {
  display: none;
}

.product-form:not(.is-active) {
  display: none !important;
}

.view.is-active,
.product-form.is-active {
  display: block;
}

.config-grid.product-form.is-active {
  display: grid;
}

.doc-layout {
  display: grid;
  grid-template-columns: 310px minmax(0, 1fr);
  gap: 16px;
  padding: 18px;
}

.generator-panel,
.documents-panel,
.settings-panel {
  min-width: 0;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.generator-panel {
  display: grid;
  align-content: start;
  gap: 12px;
}

.google-connect {
  display: grid;
  grid-template-columns: 1fr;
  gap: 6px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.google-connect .secondary-action {
  width: 100%;
  min-height: 34px;
}

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

.documents-panel {
  min-height: 380px;
}

.settings-layout {
  padding: 18px;
}

.settings-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 14px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.settings-tab {
  min-height: 34px;
  padding: 0 12px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
}

.settings-tab.is-active {
  background: #ffffff;
  color: var(--accent);
  box-shadow: 0 1px 2px rgba(25, 40, 60, 0.08);
}

.settings-grid {
  display: grid;
  gap: 14px;
  margin-top: 16px;
}

.settings-card {
  min-width: 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.settings-card h3 {
  margin: 0 0 10px;
  font-size: 16px;
}

.settings-save {
  margin-top: 14px;
}

.settings-note {
  margin-top: 8px;
}

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

.small-action {
  min-height: 32px;
  padding: 0 12px;
  font-size: 12px;
}

.template-card {
  background: #ffffff;
}

.template-settings {
  display: grid;
  gap: 6px;
  margin: 12px 0;
}

.template-setting-row {
  display: grid;
  grid-template-columns:
    minmax(240px, 1.1fr)
    minmax(180px, 0.8fr)
    minmax(160px, 0.72fr)
    minmax(145px, 0.65fr)
    64px;
  gap: 8px;
  align-items: center;
  min-height: 38px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.directory-status {
  padding: 8px 10px;
  border: 1px solid #cfe0f3;
  border-radius: 8px;
  background: #f3f8ff;
  color: #456174;
  font-size: 12px;
}

.directory-status.is-warning {
  border-color: #ead49a;
  background: #fff8e8;
  color: var(--warn);
}

.template-main {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.template-enabled {
  display: flex;
  gap: 8px;
  align-items: center;
  min-width: 0;
  font-size: 13px;
  font-weight: 700;
}

.template-enabled input {
  width: 16px;
  min-width: 16px;
  min-height: 16px;
}

.template-enabled span,
.template-meta {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.template-meta {
  color: var(--muted);
  font-size: 12px;
}

.template-setting-row input[data-template-field="googleDocId"],
.template-setting-row input[data-template-field="allowedUserIds"],
.template-setting-row input[data-template-field="allowedDepartmentIds"] {
  min-height: 30px;
  padding: 5px 8px;
  font-size: 12px;
}

.access-picker {
  position: relative;
  min-width: 0;
}

.access-picker summary {
  overflow: hidden;
  min-height: 30px;
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #ffffff;
  color: var(--text);
  cursor: pointer;
  font-size: 12px;
  font-weight: 700;
  list-style: none;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.access-picker summary::-webkit-details-marker {
  display: none;
}

.access-picker[open] summary {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px rgba(47, 124, 246, 0.12);
}

.access-options {
  position: absolute;
  z-index: 20;
  top: calc(100% + 4px);
  left: 0;
  width: min(320px, 82vw);
  max-height: 280px;
  overflow: auto;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 12px 30px rgba(23, 33, 43, 0.14);
}

.access-search {
  position: sticky;
  z-index: 1;
  top: 0;
  min-height: 30px;
  margin-bottom: 5px;
  padding: 5px 8px;
  background: #ffffff;
  font-size: 12px;
}

.access-hint,
.access-empty {
  padding: 5px 7px;
  color: var(--muted);
  font-size: 11px;
}

.access-empty {
  text-align: center;
}

.access-option {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  padding: 7px;
  border-radius: 6px;
  cursor: pointer;
}

.access-option:hover {
  background: var(--surface);
}

.access-option input {
  width: 15px;
  min-width: 15px;
  min-height: 15px;
  margin-top: 2px;
}

.access-option span {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.access-option strong,
.access-option small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.access-option strong {
  font-size: 12px;
}

.access-option small {
  color: var(--muted);
  font-size: 11px;
}

.template-setting-row a {
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  text-decoration: none;
}

.generation-log-list,
.variable-reference {
  display: grid;
  gap: 6px;
  margin-top: 12px;
}

.log-search {
  display: block;
  margin-top: 12px;
}

.generation-log-row,
.empty-log,
.variable-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-left-width: 4px;
  border-radius: 8px;
  background: #ffffff;
}

.generation-log-row.is-ok {
  border-left-color: var(--ok);
}

.generation-log-row.is-error {
  border-left-color: var(--error);
}

.generation-log-row strong,
.variable-row code {
  font-size: 12px;
}

.generation-log-row small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 11px;
}

.generation-log-row a {
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  text-decoration: none;
}

.empty-log {
  grid-template-columns: 1fr;
  border-left-width: 1px;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}

.variable-row {
  grid-template-columns: minmax(220px, 0.45fr) minmax(0, 1fr);
  border-left-width: 1px;
}

.variable-row code {
  overflow: hidden;
  padding: 5px 7px;
  border-radius: 6px;
  background: #edf3fa;
  color: #284763;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.variable-row span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.section-head,
.draft-head,
.product-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.document-list {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.document-card,
.empty-docs {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 70px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.document-card > div:first-child {
  min-width: 0;
}

.document-card strong,
.document-card p {
  overflow: hidden;
  text-overflow: ellipsis;
}

.empty-docs {
  justify-content: center;
  color: var(--muted);
  font-size: 14px;
}

.doc-actions,
.actions {
  display: flex;
  align-items: center;
  gap: 6px;
  justify-content: flex-end;
  width: auto;
  white-space: nowrap;
}

.product-toolbar {
  padding: 14px 18px 0;
  align-items: center;
}

.config-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  padding: 16px 18px;
}

.basket-controls {
  display: grid;
  grid-template-columns: minmax(150px, 220px) auto auto auto;
  gap: 8px;
  align-items: center;
}

.toolbar-select {
  display: block;
}

.basket-controls select,
.basket-controls button {
  min-height: 34px;
  height: 34px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 700;
}

.toolbar-icon-action {
  display: inline-grid;
  place-items: center;
  width: 34px;
  min-width: 34px;
  padding: 0;
  border: 1px solid var(--line);
  background: #ffffff;
  color: #536170;
  cursor: pointer;
}

.toolbar-icon-action svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.9;
}

.toolbar-icon-action:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: #eef5ff;
}

.basket-controls select {
  padding: 0 34px 0 12px;
  border: 1px solid var(--line);
  background-color: #ffffff;
  color: var(--text);
}

.entry-table {
  margin: 14px 18px 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.panel-line {
  grid-template-columns:
    minmax(80px, 0.8fr)
    minmax(100px, 1fr)
    minmax(68px, 0.66fr)
    minmax(68px, 0.66fr)
    minmax(68px, 0.66fr)
    minmax(76px, 0.74fr)
    minmax(76px, 0.74fr)
    minmax(86px, 0.84fr)
    minmax(86px, 0.84fr)
    minmax(68px, 0.64fr)
    minmax(68px, 0.64fr)
    minmax(104px, 0.86fr)
    92px;
  gap: 6px;
  align-items: stretch;
  padding: 0;
}

.panel-line.product-form.is-active,
.simple-line.product-form.is-active {
  display: grid;
}

.simple-line {
  grid-template-columns:
    minmax(280px, 1.8fr)
    minmax(86px, 0.72fr)
    minmax(72px, 0.58fr)
    minmax(86px, 0.72fr)
    minmax(118px, 0.9fr)
    92px;
  gap: 6px;
  align-items: stretch;
  padding: 0;
}

.simple-line[data-simple-type="shaped"] {
  grid-template-columns:
    minmax(230px, 1.5fr)
    minmax(90px, 0.64fr)
    minmax(74px, 0.52fr)
    minmax(78px, 0.54fr)
    minmax(70px, 0.48fr)
    minmax(86px, 0.62fr)
    minmax(118px, 0.82fr)
    92px;
}

.simple-line .wide-field {
  grid-column: auto;
}

.panel-line label,
.simple-line label {
  display: grid;
  grid-template-rows: auto 1fr;
  min-width: 0;
}

.panel-line label > span,
.simple-line label > span {
  min-height: 32px;
  margin-bottom: 0;
  padding: 8px 8px 6px;
  background: var(--surface);
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  line-height: 1.15;
}

.panel-line input,
.panel-line select,
.simple-line input,
.simple-line select {
  min-height: 32px;
  margin: 8px 0 10px;
  padding: 5px 7px;
  font-size: 12px;
}

.line-submit {
  min-height: 32px;
  margin: 40px 8px 10px 0;
  padding: 0 10px;
}

.simple-line .submit {
  margin: 40px 8px 10px 0;
}

label,
fieldset {
  min-width: 0;
}

label > span,
legend,
.preview > span {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.2;
}

input,
select,
textarea {
  width: 100%;
  min-height: 38px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #ffffff;
  color: var(--text);
  font: inherit;
  font-size: 14px;
}

textarea {
  resize: vertical;
}

fieldset {
  margin: 0;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-bottom: 8px;
}

.segmented label {
  display: flex;
  gap: 6px;
  align-items: center;
  min-height: 30px;
  padding: 5px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 12px;
}

.segmented input {
  width: auto;
  min-height: 0;
}

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

.preview {
  grid-column: span 3;
  min-height: 74px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.preview strong {
  display: block;
  font-size: 14px;
  line-height: 1.45;
  font-weight: 700;
}

.submit,
.primary-action,
.secondary-action,
.save {
  min-height: 40px;
  padding: 0 16px;
  border: 0;
  border-radius: 6px;
  color: #ffffff;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
}

.submit,
.primary-action {
  align-self: end;
  background: var(--accent);
}

.submit:hover,
.primary-action:hover {
  background: var(--accent-dark);
}

.product-form .submit {
  width: 100%;
  min-height: 32px;
  padding: 0 10px;
  background: var(--ok);
}

.product-form .submit:hover {
  background: #168548;
}

.secondary-action {
  background: #5d6b7a;
}

.save {
  background: var(--ok);
}

.save:disabled {
  cursor: not-allowed;
  background: #c8d2dc;
}

.draft {
  padding: 0 18px 22px;
}

.draft-head {
  padding: 16px 0 12px;
  border-top: 1px solid var(--line);
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

table {
  width: 100%;
  min-width: 1120px;
  table-layout: fixed;
  border-collapse: collapse;
  background: #ffffff;
}

th:nth-child(2),
td:nth-child(2) {
  width: 92px;
}

th:nth-child(3),
td:nth-child(3) {
  width: 98px;
}

th:nth-child(4),
td:nth-child(4) {
  width: 104px;
}

th:nth-child(5),
td:nth-child(5) {
  width: 126px;
}

th:nth-child(6),
td:nth-child(6) {
  width: 112px;
}

th,
td {
  padding: 8px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
  font-size: 13px;
}

th {
  color: var(--muted);
  font-weight: 700;
  background: var(--surface);
}

td strong {
  display: block;
  max-width: 680px;
  font-weight: 700;
  line-height: 1.35;
}

.panel-edit-grid {
  display: grid;
  grid-template-columns:
    minmax(76px, 0.8fr)
    minmax(98px, 1fr)
    minmax(70px, 0.7fr)
    minmax(70px, 0.7fr)
    minmax(70px, 0.7fr)
    minmax(80px, 0.8fr)
    minmax(80px, 0.8fr)
    minmax(86px, 0.86fr)
    minmax(86px, 0.86fr);
  gap: 5px;
  min-width: 0;
}

.params-heading,
.panel-summary-grid,
.simple-param-grid {
  display: grid;
  grid-template-columns:
    minmax(76px, 0.8fr)
    minmax(98px, 1fr)
    minmax(70px, 0.7fr)
    minmax(70px, 0.7fr)
    minmax(70px, 0.7fr)
    minmax(80px, 0.8fr)
    minmax(80px, 0.8fr)
    minmax(86px, 0.86fr)
    minmax(86px, 0.86fr);
  gap: 5px;
  align-items: center;
  min-width: 0;
}

.params-heading span {
  overflow: hidden;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.15;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.panel-summary-grid span {
  overflow: hidden;
  min-height: 30px;
  padding: 7px 7px;
  border: 1px solid #e4eaf0;
  border-radius: 6px;
  background: #f8fafc;
  color: var(--text);
  font-size: 12px;
  font-weight: 700;
  line-height: 14px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.metric-pill,
.tax-pill {
  display: block;
  overflow: hidden;
  min-height: 30px;
  padding: 7px 8px;
  border: 1px solid #e4eaf0;
  border-radius: 6px;
  background: #f8fafc;
  color: var(--text);
  font-size: 12px;
  font-weight: 700;
  line-height: 14px;
  text-align: right;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tax-pill {
  color: #536170;
  text-align: center;
}

.simple-param-grid {
  grid-template-columns: minmax(260px, 1fr) 70px repeat(7, minmax(0, 0.01fr));
}

.params-heading.is-simple {
  grid-template-columns: minmax(260px, 1fr) 70px repeat(7, minmax(0, 0.01fr));
}

.params-heading.is-shaped,
.simple-param-grid.shaped-param-grid {
  grid-template-columns:
    minmax(145px, 0.82fr)
    minmax(250px, 1.28fr)
    minmax(92px, 0.58fr)
    minmax(74px, 0.44fr)
    70px
    repeat(4, minmax(0, 0.01fr));
}

.simple-param-grid span,
.simple-param-grid input,
.simple-param-grid select {
  overflow: hidden;
  min-height: 30px;
  padding: 7px 7px;
  border: 1px solid #e4eaf0;
  border-radius: 6px;
  background: #f8fafc;
  color: var(--text);
  font-size: 12px;
  font-weight: 700;
  line-height: 14px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.simple-param-grid input {
  width: 100%;
  font-weight: 400;
}

.simple-param-grid select {
  width: 100%;
  font-weight: 400;
}

.param-control {
  display: block;
  min-width: 0;
  min-height: 30px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f8fafc;
}

.param-control:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px rgba(47, 124, 246, 0.22);
}

.panel-edit-grid .param-control select,
.panel-edit-grid .param-control input,
.simple-edit-grid input,
.cell-input {
  min-height: 28px;
  padding: 4px 6px;
  font-size: 11px;
}

.tax-input {
  text-align: left;
}

.panel-edit-grid .param-control select,
.panel-edit-grid .param-control input {
  width: 100%;
  min-height: 28px;
  padding: 4px 18px 4px 6px;
  border: 0;
  border-radius: 0;
  background-color: transparent;
  font-weight: 700;
  line-height: 22px;
}

.panel-edit-grid .param-control select:focus,
.panel-edit-grid .param-control input:focus {
  outline: none;
}

.simple-edit-grid {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) 72px;
  gap: 6px;
}

.cell-input {
  width: 100%;
  min-width: 0;
  font-weight: 700;
  text-align: right;
}

.spec-totals {
  display: grid;
  justify-content: end;
  padding: 18px 18px 20px;
  background: #ffffff;
}

.spec-totals dl {
  width: min(100%, 430px);
  margin: 0;
  color: var(--muted);
}

.spec-totals dl > div {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 34px;
  align-items: center;
  min-height: 30px;
}

.spec-totals dt,
.spec-totals dd {
  margin: 0;
  font-size: 15px;
}

.spec-totals dt {
  text-align: right;
}

.spec-totals dd {
  min-width: 120px;
  text-align: right;
}

.discount-row dt,
.discount-row dd {
  color: #78a22f;
}

.grand-total {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 34px;
  align-items: baseline;
  width: min(100%, 430px);
  margin-top: 14px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
  color: #5c6673;
}

.grand-total span,
.grand-total strong {
  font-size: 24px;
  line-height: 1.2;
  font-weight: 700;
}

.grand-total span {
  text-align: right;
}

.grand-total strong {
  min-width: 150px;
  text-align: right;
}

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

.empty-row td {
  color: var(--muted);
  text-align: center;
}

.actions button,
.doc-actions button,
.doc-actions select,
.dialog-actions select,
dialog button {
  min-height: 30px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #ffffff;
  color: var(--text);
  cursor: pointer;
  font-size: 12px;
}

.doc-actions select,
.dialog-actions select {
  width: 72px;
  background: #ffffff;
}

.actions button:hover,
.doc-actions button:hover,
dialog button:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.doc-actions button:disabled,
.doc-actions select:disabled,
.dialog-actions button:disabled,
.dialog-actions select:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.actions {
  width: 96px;
}

.actions .edit-action,
.actions .icon-action {
  display: inline-grid;
  place-items: center;
  width: 30px;
  min-width: 30px;
  min-height: 30px;
  padding: 0;
  color: #536170;
  line-height: 1;
}

.actions .icon-action svg {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.actions .edit-action:hover,
.actions .icon-action.copy:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: #eef5ff;
}

.actions .icon-action.danger:hover {
  border-color: var(--error);
  color: var(--error);
  background: #fff1f0;
}

dialog {
  width: min(1360px, calc(100vw - 24px));
  height: calc(100vh - 16px);
  height: calc(100dvh - 16px);
  max-height: calc(100vh - 16px);
  max-height: calc(100dvh - 16px);
  margin: 8px auto;
  border: 0;
  border-radius: 10px;
  padding: 0;
  overflow: hidden;
  box-shadow: 0 20px 70px rgba(15, 32, 56, 0.28);
}

dialog::backdrop {
  background: rgba(15, 32, 56, 0.42);
}

.document-dialog {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  height: 100%;
  min-height: 0;
  max-height: 100%;
}

.document-dialog header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px;
  border-bottom: 1px solid var(--line);
}

.dialog-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: flex-end;
}

.google-editor {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  min-height: 0;
  background: #eef3f7;
}

.google-editor iframe {
  width: 100%;
  height: 100%;
  min-height: 0;
  border: 0;
  background: #ffffff;
}

.google-editor p {
  margin: 0;
  padding: 8px 14px;
  border-top: 1px solid var(--line);
  background: #ffffff;
  color: var(--muted);
  font-size: 12px;
}

#documentEditor {
  min-height: 0;
  border: 0;
  border-radius: 0;
  padding: 18px;
  font-family: Arial, Helvetica, sans-serif;
  line-height: 1.5;
  resize: none;
}

[hidden] {
  display: none !important;
}

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

  .status {
    text-align: left;
  }

  .doc-layout {
    grid-template-columns: 1fr;
  }

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

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

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

  .basket-controls {
    grid-template-columns: minmax(180px, 1fr) auto auto;
  }

  .preview,
  .wide-field {
    grid-column: span 2;
  }
}

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

  .workspace {
    min-height: 100vh;
    border: 0;
    border-radius: 0;
  }

  .main-tabs,
  .product-tabs,
  .product-toolbar,
  .basket-controls,
  .draft-head,
  .document-card {
    align-items: stretch;
    flex-direction: column;
  }

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

  .panel-line {
    grid-template-columns: 1fr;
  }

  .simple-line {
    grid-template-columns: 1fr;
  }

  .basket-controls {
    grid-template-columns: 1fr;
  }

  .preview,
  .wide-field {
    grid-column: span 1;
  }
}
