:root {
  --bg: #20242b;
  --panel: #2b3038;
  --panel-2: #313743;
  --line: #4b515d;
  --line-soft: #3b414d;
  --text: #edf0f5;
  --muted: #b5bcc8;
  --green: #8ace2f;
  --amber: #f2a22d;
  --blue: #2bb3f3;
  --red: #f06b63;
  --sky: #35cbd8;
  --gold: #ffd23f;
  --violet: #8e7dff;
  --cyan: #1fd4cf;
  --slate: #9aa3af;
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  font-family: Tahoma, Verdana, Arial, sans-serif;
  background: #2a2e37;
  color: var(--text);
}

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

button {
  cursor: pointer;
}

input,
select,
textarea {
  width: 100%;
  min-height: 28px;
  padding: 4px 6px;
  border: 1px solid var(--line);
  background: #252a33;
  color: var(--text);
}

textarea {
  min-height: 66px;
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  outline: 1px solid #8ace2f;
  border-color: #8ace2f;
}

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

a {
  color: inherit;
  text-decoration: none;
}

.eyebrow {
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.primary,
.secondary,
.mini {
  border: 1px solid var(--line);
  background: #323844;
  color: var(--text);
  padding: 6px 8px;
}

.primary {
  background: #4b9c22;
  border-color: #4b9c22;
}

.secondary {
  background: #2a3038;
}

.mini {
  min-height: 26px;
  padding: 4px 7px;
  font-size: 11px;
}

.mini.success {
  background: #2f7025;
  border-color: #2f7025;
}

.mini.danger {
  background: #7d3a35;
  border-color: #7d3a35;
}

.cancelled-row {
  background: rgba(240, 107, 99, 0.08);
  color: var(--muted);
}

.cancelled-row td,
.cancelled-row th {
  color: var(--muted);
}

.block {
  width: 100%;
}

.flash {
  padding: 7px 10px;
  border: 1px solid var(--line);
  background: #2c313a;
  color: var(--text);
  font-size: 12px;
}

.flash-inline {
  margin: 8px 10px 0;
}

.flash.success {
  border-color: #4b9c22;
}

.flash.error {
  border-color: #a34f48;
}

.module-grid-ops,
.module-side-ops,
.ops-panel,
.form-panel,
.draft-table-shell,
.slip-card,
.slip-chipline,
.ticket-tags {
  min-width: 0;
}

.draft-mini-table {
  table-layout: fixed;
}

.draft-mini-table th,
.draft-mini-table td {
  white-space: normal;
  word-break: break-word;
}

.slip-chipline,
.ticket-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.slip-chipline span,
.ticket-tags span {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 2px 8px;
  border-radius: 999px;
}

.login-stage {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: #2a2e37;
}

.login-box {
  width: min(330px, 100%);
  padding: 14px;
  border: 1px solid var(--line);
  background: #2b3038;
  box-shadow: 0 10px 22px rgba(0, 0, 0, 0.25);
}

.login-box-compact {
  display: grid;
  gap: 10px;
}

.login-topline {
  font-size: 12px;
  color: #f3f4f8;
}

.login-title {
  font-size: 20px;
  font-weight: 700;
}

.compact-login-form,
.login-form {
  display: grid;
  gap: 10px;
}

.login-form label,
.entry-form label,
.toolbar-strip label {
  display: grid;
  gap: 4px;
  font-size: 11px;
  color: var(--muted);
}

.workbench {
  min-height: 100vh;
}

.compact-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 6px 10px;
  border-bottom: 1px solid var(--line);
  background: #252a33;
}

.header-left,
.compact-status {
  display: flex;
  align-items: center;
  gap: 10px;
}

.header-copy,
.compact-status div {
  display: grid;
  gap: 1px;
}

.header-copy strong {
  font-size: 14px;
}

.header-copy small,
.compact-status span {
  font-size: 11px;
  color: var(--muted);
}

.compact-shell-body {
  display: grid;
  grid-template-columns: 168px minmax(0, 1fr);
  min-height: calc(100vh - 43px);
}

.compact-sidebar {
  display: grid;
  grid-template-rows: 1fr auto;
  gap: 4px;
  border-right: 1px solid var(--line);
  background: #292e37;
  padding: 4px;
}

.sidebar-nav {
  display: grid;
  gap: 1px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  min-height: 28px;
  padding: 4px 5px;
  border: 0;
  text-align: left;
  background: transparent;
  color: var(--text);
}

.nav-item.active,
.nav-item:hover,
.nav-item-exit:hover {
  background: #343a45;
}

.nav-mark {
  width: 20px;
  height: 20px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  font-size: 10px;
  font-weight: 700;
  color: #14171c;
}

.nav-text {
  font-size: 11px;
  line-height: 1.15;
}

.tone-green { background: var(--green); }
.tone-amber { background: var(--amber); }
.tone-blue { background: var(--blue); color: #fff; }
.tone-red { background: var(--red); color: #fff; }
.tone-sky { background: var(--sky); }
.tone-gold { background: var(--gold); }
.tone-violet { background: var(--violet); color: #fff; }
.tone-cyan { background: var(--cyan); }
.tone-slate { background: var(--slate); color: #fff; }

.compact-content,
.content {
  padding: 0;
}

.module-main,
.panel-shell {
  display: grid;
  gap: 8px;
}

.module-main.standalone {
  gap: 8px;
}

.module-grid-ops {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 292px);
  gap: 4px;
  padding: 4px;
}

.module-side-ops {
  display: grid;
  align-content: start;
  gap: 4px;
  min-width: 0;
}

.panel-shell {
  padding: 5px;
  border: 1px solid var(--line);
  background: var(--panel);
  min-width: 0;
}

.panel-shell-tight {
  padding: 0;
  overflow: hidden;
}

.section-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.section-title-thin h2 {
  font-size: 14px;
}

.compact-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 11px;
  color: var(--muted);
}

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

.inline-actions.compact {
  gap: 5px;
}

.status-strip {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 4px 5px;
  background: #404756;
  border-bottom: 1px solid var(--line);
}

.ops-strip {
  background: #01300e;
  border-bottom-color: #2d7d35;
}

.status-main,
.status-side {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.ops-strip .status-main {
  color: #f2fff2;
  font-size: 11px;
  font-weight: 700;
}

.status-chip {
  padding: 2px 6px;
  border: 1px solid var(--line);
  background: #303641;
  font-size: 11px;
}

.status-chip-green {
  background: #4b9c22;
  border-color: #4b9c22;
  color: #fff;
}

.status-side span,
.status-side strong {
  font-size: 11px;
}

.matrix-scroll,
.table-scroll {
  overflow: auto;
  min-width: 0;
}

.matrix-scroll {
  overflow-anchor: none;
}

.matrix-table,
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 11px;
}

.matrix-table th,
.matrix-table td,
table th,
table td {
  border: 1px solid var(--line-soft);
  padding: 2px 4px;
  text-align: left;
  vertical-align: middle;
}

.matrix-table thead th,
table thead th {
  background: #353c47;
  position: sticky;
  top: 0;
  z-index: 1;
}

.matrix-table tbody th {
  background: #313742;
  position: sticky;
  left: 0;
  z-index: 1;
  min-width: 48px;
  width: 48px;
}

.compact-matrix th {
  font-size: 11px;
}

.matrix-cell {
  width: 22px;
  min-width: 22px;
  text-align: center;
  padding: 1px;
}

.draw-dot {
  width: 15px;
  height: 15px;
  display: inline-block;
  border: 1px solid #768092;
  background: transparent;
  padding: 0;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.draw-dot.is-open {
  border-color: #b7c6db;
}

.draw-dot.is-closed {
  border-color: #636c7a;
  background: #404654;
}

.draw-dot.is-selected {
  border-color: #9cf040;
  background: #79c92d;
  box-shadow: 0 0 0 1px rgba(156, 240, 64, 0.22);
}

.draw-dot:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.void-cell {
  background: #2a2f38;
}

.ops-panel {
  background: #01330f;
  border-color: #2d7d35;
}

.form-panel {
  gap: 10px;
}

.ops-footer {
  padding: 0 5px 5px;
  font-size: 11px;
  color: #e8ffe8;
  overflow-wrap: anywhere;
}

.draft-table-shell {
  padding: 0;
}

.draft-mini-table {
  font-size: 11px;
}

.draft-mini-table thead th,
.draft-mini-table tfoot td {
  background: #9fd9ec;
  color: #1b2028;
}

.draft-mini-table tbody td {
  background: #04310e;
  color: #f3fff3;
}

.draft-mini-table tbody tr.locked-row td {
  background: #12341c;
  color: #dcebdc;
}

.locked-row .ticket-tags span {
  border-color: #8aa78d;
  color: #cfe6cf;
}

.draft-mini-table tfoot td {
  text-align: right;
  font-weight: 700;
}

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

.draft-actions-shell {
  gap: 6px;
}

.draft-action-head {
  display: flex;
  align-items: center;
  gap: 10px;
}

.draft-action-head strong,
.draft-action-head small {
  display: block;
}

.draft-action-head small {
  color: var(--muted);
  font-size: 11px;
}

.draft-badge {
  width: 36px;
  height: 36px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 20px;
  color: #111;
  background: #ff9628;
}

.draft-actions-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
}

.draft-wide {
  width: 100%;
}

.entry-form,
.entry-grid,
.toolbar-strip,
.download-grid,
.two-col,
.settlement-strip,
.results-layout,
.results-side,
.results-stack,
.results-origin-grid {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.compact-form {
  gap: 4px;
}

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

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

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

.compact-entry-grid.secondary-grid {
  grid-template-columns: 110px repeat(3, minmax(0, 1fr));
}

.compact-entry-grid.tertiary-grid {
  grid-template-columns: 160px 180px minmax(0, 1fr);
}

.toggle-row {
  display: flex !important;
  align-items: center;
  gap: 6px;
  padding-top: 18px;
}

.toggle-row input {
  width: auto;
  min-height: auto;
}

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

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

.toolbar-strip {
  grid-template-columns: repeat(3, minmax(0, 180px)) auto;
  align-items: end;
}

.two-col {
  grid-template-columns: 1fr 1fr;
}

.slip-card {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  padding: 7px;
  border: 1px solid #d3d6dc;
  background: #f1f0eb;
  color: #111;
  font-family: "Courier New", monospace;
  font-size: 11px;
}

.slip-card-empty {
  width: 100%;
  border-color: var(--line);
  background: #2b3038;
  color: var(--muted);
  font-family: inherit;
}

.slip-empty-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--text);
}

.slip-head,
.slip-total,
.slip-line {
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

.slip-head small,
.slip-date small,
.slip-code {
  color: #555;
}

.slip-rule {
  border-top: 1px dashed #111;
  margin: 6px 0;
}

.slip-chipline {
  text-align: center;
  font-weight: 700;
  font-size: 10px;
}

.slip-line {
  padding: 1px 0;
}

.slip-empty {
  padding-top: 4px;
}

.slip-total {
  margin-top: 6px;
  padding-top: 5px;
  border-top: 1px solid #111;
  font-weight: 700;
}

.slip-code {
  margin-top: 6px;
  text-align: center;
  font-size: 10px;
}

.ticket-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  min-width: 0;
}

.ticket-tags span {
  padding: 2px 5px;
  background: #313743;
  border: 1px solid var(--line);
  color: var(--muted);
  overflow-wrap: anywhere;
}

.ticket-tags.big span {
  padding: 4px 7px;
}

.empty-cell,
.note-text {
  color: var(--muted);
}

.settlement-strip {
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 1px;
  border: 1px solid var(--line);
  background: var(--line);
}

.settlement-strip div {
  display: grid;
  gap: 2px;
  padding: 7px 6px;
  background: #313743;
  font-size: 11px;
}

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

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

.draw-chip {
  display: grid;
  gap: 2px;
  padding: 7px 8px;
  border: 1px solid var(--line);
  background: #313743;
  font-size: 11px;
}

.draw-chip strong {
  font-size: 12px;
}

.draw-chip span,
.draw-chip small {
  color: var(--muted);
}

.draw-chip-empty {
  opacity: 0.8;
}

.results-layout {
  grid-template-columns: minmax(0, 1fr) 284px;
  align-items: start;
}

.extract-page {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 248px;
  gap: 8px;
  align-items: start;
}

.extract-page > .toolbar-strip,
.extract-page > .extract-summary {
  grid-column: 1 / -1;
}

.extract-page > .extract-stack {
  grid-column: 1 / 2;
}

.extract-page > .results-side {
  grid-column: 2 / 3;
}

.results-side,
.results-stack {
  align-content: start;
}

.results-toolbar {
  grid-template-columns: minmax(180px, 1fr) auto auto;
  align-items: center;
}

.results-toolbar label {
  display: grid;
  gap: 3px;
  font-size: 11px;
}

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

.extract-stack {
  display: grid;
  gap: 8px;
}

.extract-group {
  gap: 6px;
}

.extract-group-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.extract-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.extract-card-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 5px;
}

.extract-card {
  display: grid;
  gap: 3px;
  padding: 7px;
  border: 1px solid var(--line);
  background: #313743;
  min-height: 72px;
}

.extract-card strong {
  font-size: 12px;
}

.extract-card span,
.extract-card small {
  color: var(--muted);
  font-size: 11px;
}

.extract-card div b {
  font-size: 14px;
}

.extract-card div small {
  margin-left: 6px;
}

.extract-summary {
  grid-template-columns: repeat(8, minmax(0, 1fr));
}

.result-card {
  display: grid;
  gap: 3px;
  padding: 7px;
  border: 1px solid var(--line);
  background: #313743;
  min-height: 74px;
}

.result-card strong {
  font-size: 12px;
}

.result-card span,
.result-card small {
  color: var(--muted);
  font-size: 11px;
}

.result-card div b {
  font-size: 14px;
}

.result-card div small {
  margin-left: 6px;
}

.result-card-empty {
  opacity: 0.8;
}

.results-origin-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1px;
  border: 1px solid var(--line);
  background: var(--line);
}

.results-origin-grid div {
  display: grid;
  gap: 2px;
  padding: 6px;
  background: #313743;
  font-size: 11px;
}

.results-origin-grid span {
  color: var(--muted);
}

.admin-draw-scroll {
  max-height: 420px;
}

.results-meta-list {
  display: grid;
  gap: 6px;
  font-size: 11px;
}

.results-meta-list strong {
  color: #fff;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 72px;
  padding: 2px 6px;
  border: 1px solid var(--line);
  background: #303641;
  color: #fff;
  font-size: 10px;
  text-transform: uppercase;
}

.status-pill.ok {
  background: #2f7025;
  border-color: #2f7025;
}

.status-pill.pending {
  background: #915f18;
  border-color: #915f18;
}

.status-pill.manual {
  background: #6f3d72;
  border-color: #6f3d72;
}

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

.download-card {
  display: grid;
  place-items: center;
  min-height: 58px;
  border: 1px solid var(--line);
  background: #2c313a;
  font-size: 12px;
}

@media (max-width: 1180px) {
  .draw-chip-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .compact-shell-body,
  .two-col,
  .module-grid-ops,
  .results-layout {
    grid-template-columns: 1fr;
  }

  .compact-sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

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

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

  .compact-entry-grid,
  .redoblona-grid,
  .compact-entry-grid.secondary-grid,
  .compact-entry-grid.tertiary-grid,
  .settlement-strip,
  .download-grid,
  .draw-chip-grid {
    grid-template-columns: 1fr 1fr;
  }

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

@media (max-width: 720px) {
  .compact-header,
  .section-title,
  .status-strip {
    display: grid;
    grid-template-columns: 1fr;
  }

  .compact-content,
  .compact-sidebar,
  .panel-shell {
    padding: 8px;
  }

  .toolbar-strip,
  .compact-entry-grid,
  .redoblona-grid,
  .compact-entry-grid.secondary-grid,
  .compact-entry-grid.tertiary-grid,
  .settlement-strip,
  .download-grid,
  .draw-chip-grid,
  .results-card-grid {
    grid-template-columns: 1fr;
  }

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