/* ==========================================================================
   Forms, wizards, settings rows, viewers and split workspaces.
   Everything here is shared by every generated screen, so a form in Finance
   and a form in HR are the same object — same label position, same control
   height, same footer. Nothing bespoke, nothing drifting.
   ========================================================================== */

/* ------------------------------------------------------------- fieldsets --- */
.fset { margin-bottom: var(--gap); }
.fset:last-child { margin-bottom: 0; }
.fset-head {
  display: flex; align-items: baseline; gap: 10px;
  padding-bottom: 10px; margin-bottom: 15px;
  border-bottom: 1px solid var(--border);
}
.fset-title { font-size: var(--fs-h3); font-weight: 600; color: var(--text); }
.fset-note  { font-size: var(--fs-xs); color: var(--text-3); }

.fgrid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 15px 18px; }
.fgrid.one   { grid-template-columns: minmax(0, 1fr); }
.fgrid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.fgrid > .wide { grid-column: 1 / -1; }

/* ---------------------------------------------------------------- field --- */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > label {
  font-size: var(--fs-xs); font-weight: 600; color: var(--text-2);
  display: flex; align-items: center; gap: 6px;
}
.field > label .req { color: var(--danger); font-weight: 700; }
.field .hint { font-size: var(--fs-xs); color: var(--text-3); }

.ctl {
  height: 36px; padding: 0 12px; width: 100%;
  border: 1px solid var(--border-strong); border-radius: var(--r-sm);
  background: var(--surface); color: var(--text);
  font: inherit; font-size: var(--fs-sm);
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
textarea.ctl { height: auto; min-height: 76px; padding: 9px 12px; resize: vertical; line-height: 1.5; }
select.ctl { cursor: pointer; appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--text-3) 50%),
                    linear-gradient(135deg, var(--text-3) 50%, transparent 50%);
  background-position: calc(100% - 16px) 15px, calc(100% - 11px) 15px;
  background-size: 5px 5px, 5px 5px; background-repeat: no-repeat; padding-right: 30px; }
.ctl:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-100); }
.ctl:disabled, .ctl[readonly] { background: var(--surface-2); color: var(--text-2); cursor: not-allowed; }
.ctl.num { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }

/* a control with a fixed unit or currency shoulder */
.ctl-wrap { position: relative; display: flex; align-items: center; }
.ctl-wrap .adorn {
  position: absolute; right: 12px; font-size: var(--fs-xs); color: var(--text-3);
  pointer-events: none; font-weight: 600;
}
.ctl-wrap .adorn.left { left: 12px; right: auto; }
.ctl-wrap .adorn.left ~ .ctl { padding-left: 30px; }

/* ---------------------------------------------------------------- switch --- */
.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; }
.switch > input { position: absolute; opacity: 0; pointer-events: none; }
.switch .track {
  width: 38px; height: 22px; border-radius: var(--r-pill); background: var(--border-strong);
  position: relative; transition: background var(--t-fast); flex: none;
}
.switch .track::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px;
  border-radius: 50%; background: #fff; box-shadow: var(--sh-xs);
  transition: transform var(--t-fast);
}
.switch > input:checked + .track { background: var(--accent); }
.switch > input:checked + .track::after { transform: translateX(16px); }
.switch > input:focus-visible + .track { box-shadow: 0 0 0 3px var(--accent-100); }

/* one setting per row: what it is on the left, the control on the right */
.setrow {
  display: flex; align-items: center; gap: 18px; padding: 13px 0;
  border-top: 1px solid var(--border);
}
.setrow:first-child { border-top: 0; padding-top: 0; }
.setrow .sr-main { flex: 1; min-width: 0; }
.setrow .sr-name { font-size: var(--fs-body); font-weight: 600; color: var(--text); }
.setrow .sr-note { font-size: var(--fs-xs); color: var(--text-3); margin-top: 2px; }
.setrow .sr-ctl { flex: none; min-width: 0; }
.setrow .sr-ctl .ctl { width: 210px; }

/* --------------------------------------------------------------- footer --- */
.form-foot {
  display: flex; align-items: center; gap: 10px;
  margin-top: var(--gap); padding-top: 15px; border-top: 1px solid var(--border);
}
.form-foot .spacer { flex: 1; }
.form-foot .note { font-size: var(--fs-xs); color: var(--text-3); }

/* -------------------------------------------------------------- stepper --- */
.stepper { display: flex; gap: 8px; margin-bottom: var(--gap); flex-wrap: wrap; }
.step {
  display: flex; align-items: center; gap: 9px; padding: 9px 14px;
  border-radius: var(--r-md); background: var(--surface); box-shadow: var(--sh-xs);
  font-size: var(--fs-sm); color: var(--text-3); font-weight: 500; flex: 1; min-width: 158px;
}
.step .sn {
  width: 22px; height: 22px; border-radius: 50%; flex: none;
  display: grid; place-items: center; font-size: var(--fs-xs); font-weight: 700;
  background: var(--surface-sunken); color: var(--text-3);
}
.step.done { color: var(--text-2); }
.step.done .sn { background: var(--success-bg); color: var(--success); }
.step.now { color: var(--text); box-shadow: 0 0 0 1.5px var(--accent), var(--sh-sm); }
.step.now .sn { background: var(--accent); color: #fff; }

/* --------------------------------------------------------------- viewer --- */
.viewer { display: grid; grid-template-columns: minmax(0, 1fr) 292px; gap: var(--gap); }
.doc-sheet {
  background: #fff; border-radius: var(--r-md); box-shadow: var(--sh-sm);
  padding: 34px 38px; min-height: 460px; position: relative; overflow: hidden;
}
.doc-sheet::before {
  content: ""; position: absolute; inset: 0 0 auto 0; height: 4px; background: var(--grad-mesh);
}
.doc-head { display: flex; align-items: flex-start; gap: 16px; margin-bottom: 26px; }
.doc-logo { width: 40px; height: 40px; border-radius: var(--r-sm); object-fit: contain; }
.doc-co { font-size: var(--fs-h2); font-weight: 700; color: var(--text); letter-spacing: -.3px; }
.doc-addr { font-size: var(--fs-xs); color: var(--text-3); margin-top: 2px; line-height: 1.55; }
.doc-kind {
  margin-left: auto; text-align: right;
  font-size: var(--fs-label); font-weight: 700; letter-spacing: .11em;
  text-transform: uppercase; color: var(--accent-700);
}
.doc-rule { height: 1px; background: var(--border); margin: 20px 0; }
.doc-sign { display: flex; gap: 46px; margin-top: 46px; }
.doc-sign > div { flex: 1; border-top: 1px solid var(--text-3); padding-top: 7px;
                  font-size: var(--fs-xs); color: var(--text-3); }
.doc-watermark {
  position: absolute; right: -18px; bottom: 14px;
  font-size: 62px; font-weight: 800; letter-spacing: -2px;
  color: var(--surface-2); pointer-events: none; user-select: none;
}

/* ------------------------------------------------------ split workspace --- */
.worksplit { display: grid; grid-template-columns: 322px minmax(0, 1fr); gap: var(--gap); align-items: start; }
.queue { max-height: 640px; overflow-y: auto; }
.queue-item {
  display: block; padding: 11px 12px; border-radius: var(--r-sm);
  border-left: 3px solid transparent; cursor: pointer;
  transition: background var(--t-fast);
}
.queue-item + .queue-item { box-shadow: inset 0 1px 0 var(--border); }
.queue-item:hover { background: var(--surface-hover); }
.queue-item.is-on { background: var(--accent-50); border-left-color: var(--accent); }
.queue-item .qi-top { display: flex; align-items: center; gap: 8px; }
.queue-item .qi-code { font-size: var(--fs-xs); font-weight: 700; color: var(--accent-700);
                       font-variant-numeric: tabular-nums; }
.queue-item .qi-name { font-size: var(--fs-sm); font-weight: 600; color: var(--text);
                       margin-top: 3px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.queue-item .qi-sub { font-size: var(--fs-xs); color: var(--text-3); margin-top: 2px; }

/* ------------------------------------------------------ module directory --- */
.dir-group { margin-bottom: 22px; }
.dir-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(232px, 1fr)); gap: 10px; }
.dir-card {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px;
  background: var(--surface); border-radius: var(--r-md); box-shadow: var(--sh-xs);
  transition: transform var(--t-fast), box-shadow var(--t-fast);
  min-width: 0;
}
.dir-card:hover { transform: translateY(-1px); box-shadow: var(--sh-sm); }
.dir-card .ic { width: 15px; height: 15px; color: var(--mod, var(--accent)); flex: none; }
.dir-card .dc-main { min-width: 0; flex: 1; }
/* both are spans inside one flex child, so they must be told to stack —
   otherwise the name and the id run together as "Finance OverviewFIN-001" */
.dir-card .dc-name { display: block; font-size: var(--fs-sm); font-weight: 600; color: var(--text);
                     overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dir-card .dc-id { display: block; font-size: var(--fs-label); color: var(--text-3);
                   font-variant-numeric: tabular-nums; letter-spacing: .04em; margin-top: 1px; }
.dir-card .dc-tag { font-size: var(--fs-label); font-weight: 700; letter-spacing: .06em;
                    text-transform: uppercase; color: var(--text-3); flex: none; }

@media (max-width: 1099px) {
  .viewer, .worksplit { grid-template-columns: minmax(0, 1fr); }
  .queue { max-height: 300px; }
}
@media (max-width: 767px) {
  .fgrid, .fgrid.three { grid-template-columns: minmax(0, 1fr); }
  .setrow { flex-direction: column; align-items: stretch; gap: 9px; }
  .setrow .sr-ctl .ctl { width: 100%; }
  .doc-sheet { padding: 20px 18px; }
  .doc-head { flex-wrap: wrap; }
  .doc-kind { margin-left: 0; text-align: left; width: 100%; }
  .form-foot { flex-wrap: wrap; }
}
