/* ККН-Поток: веб-загрузка актов — спокойная, понятная тема */
:root {
  --bg: #f4f6fa;
  --surface: #ffffff;
  --text: #1a2332;
  --muted: #5c6b7f;
  --accent: #1e6b5c;
  --accent-hover: #165a4d;
  --border: #dce3ed;
  --danger: #b42318;
  --success: #0d6b4a;
  --warn: #9a6700;
  --radius: 12px;
  --shadow: 0 4px 24px rgba(26, 35, 50, 0.08);
  --font: "Segoe UI", system-ui, -apple-system, sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.55;
  color: var(--text);
  background: var(--bg);
}

a {
  color: var(--accent);
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}

.wrap {
  max-width: 720px;
  margin: 0 auto;
  padding: 1.5rem 1.25rem 3rem;
}

.wrap-wide {
  max-width: 1100px;
}

.wrap-control-monitor {
  max-width: min(100%, calc(100vw - 2.5rem));
}

.table-scroll {
  overflow-x: auto;
  margin: 0 -0.25rem;
}

table.data-tight {
  font-size: 0.92rem;
}

table.data-tight th,
table.data-tight td {
  padding: 0.4rem 0.5rem;
  vertical-align: top;
}

.break-all {
  word-break: break-all;
}

.mono {
  font-family: ui-monospace, Consolas, monospace;
  font-size: 0.88em;
}

tr.muted-row td {
  color: var(--muted);
  font-size: 0.88rem;
  padding-top: 0.15rem;
  border-top: none;
}

header.site {
  background: linear-gradient(135deg, #1e6b5c 0%, #2a8f7a 100%);
  color: #fff;
  padding: 1.75rem 1.25rem;
  box-shadow: var(--shadow);
}

header.site h1 {
  margin: 0 0 0.35rem;
  font-size: 1.45rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}

header.site p {
  margin: 0;
  opacity: 0.92;
  font-size: 0.95rem;
}

.card {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  padding: 1.5rem 1.35rem;
  margin-top: 1.25rem;
}

.card h2 {
  margin: 0 0 0.75rem;
  font-size: 1.15rem;
  font-weight: 600;
}

/* Спойлер на /monitor: блок «Отправки через сайт» */
details.card-spoiler > summary.card-spoiler-summary {
  cursor: pointer;
  list-style: none;
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--text);
  user-select: none;
}

details.card-spoiler > summary.card-spoiler-summary::-webkit-details-marker {
  display: none;
}

details.card-spoiler > summary.card-spoiler-summary::after {
  content: " ▶";
  font-size: 0.75em;
  color: var(--muted);
  font-weight: 400;
}

details.card-spoiler[open] > summary.card-spoiler-summary::after {
  content: " ▼";
}

details.card-spoiler[open] > summary.card-spoiler-summary {
  margin-bottom: 0.75rem;
  padding-bottom: 0.65rem;
  border-bottom: 1px solid var(--border);
}

.card-spoiler-body {
  margin-top: 0.25rem;
}

.card-spoiler-actions {
  margin-bottom: 0.85rem;
}

.muted {
  color: var(--muted);
  font-size: 0.92rem;
}

.steps {
  margin: 0;
  padding-left: 1.25rem;
  color: var(--muted);
  font-size: 0.95rem;
}

.steps li {
  margin-bottom: 0.35rem;
}

.profile-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.profile-list li {
  margin-bottom: 0.65rem;
}

.profile-list a {
  display: block;
  padding: 1rem 1.1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-weight: 500;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.profile-list a:hover {
  border-color: var(--accent);
  box-shadow: 0 2px 12px rgba(30, 107, 92, 0.12);
  text-decoration: none;
}

.profile-list .desc {
  display: block;
  font-weight: 400;
  font-size: 0.88rem;
  color: var(--muted);
  margin-top: 0.35rem;
}

.upload-notice {
  margin: 0 0 1.25rem;
  padding: 1.15rem 1.25rem;
  border-radius: var(--radius);
  border: 2px solid var(--accent);
  background: #eef8f5;
}

.upload-notice-lead {
  margin: 0 0 0.65rem;
  font-size: 1.45rem;
  font-weight: 700;
  line-height: 1.25;
  color: var(--accent);
}

.upload-notice-sub,
.upload-notice-warn,
.upload-notice-forbidden {
  margin: 0.45rem 0 0;
  font-size: 1.05rem;
  line-height: 1.45;
  color: var(--text);
}

.upload-notice-forbidden {
  color: var(--danger);
  font-weight: 600;
}

.upload-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 1.75rem 1rem;
  text-align: center;
  background: #fafbfd;
  margin-top: 0.5rem;
}

.upload-zone input[type="file"] {
  margin-top: 0.75rem;
  max-width: 100%;
}

.btn {
  display: inline-block;
  margin-top: 1rem;
  padding: 0.65rem 1.35rem;
  font-size: 1rem;
  font-family: inherit;
  font-weight: 600;
  color: #fff;
  background: var(--accent);
  border: none;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.15s;
}

.btn:hover {
  background: var(--accent-hover);
}

.btn-secondary {
  background: var(--muted);
}
.btn-secondary:hover {
  background: #4a5768;
}

.flash {
  padding: 0.85rem 1rem;
  border-radius: 10px;
  margin-bottom: 1rem;
  font-size: 0.95rem;
}

.flash.error {
  background: #fde8e6;
  color: var(--danger);
  border: 1px solid #f5c4be;
}

.flash.ok {
  background: #e6f5ef;
  color: var(--success);
  border: 1px solid #b8e0cc;
}

table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
}

table.data th,
table.data td {
  text-align: left;
  padding: 0.45rem 0.65rem;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

table.data th {
  width: 38%;
  color: var(--muted);
  font-weight: 500;
}

table.data-edit .field-input {
  width: 100%;
  max-width: 22rem;
  font: inherit;
  padding: 0.4rem 0.55rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
}

table.data-edit .field-input:focus {
  outline: 2px solid rgba(30, 107, 92, 0.35);
  border-color: var(--accent);
}

.btn:disabled,
.btn[aria-busy="true"] {
  opacity: 0.72;
  cursor: wait;
  pointer-events: none;
}

.badge {
  display: inline-block;
  padding: 0.2rem 0.55rem;
  border-radius: 6px;
  font-size: 0.82rem;
  font-weight: 600;
}

.badge.ok {
  background: #d4ede4;
  color: var(--success);
}

.badge.err {
  background: #fde8e6;
  color: var(--danger);
}

.badge.wait {
  background: #fff4d6;
  color: var(--warn);
}

table.control-months th,
table.control-months td {
  white-space: nowrap;
}

table.control-months td.cm-subject-cell,
table.control-months th.cm-subject-head {
  white-space: normal;
}

.cm-subject-form {
  display: flex;
  gap: 0.25rem;
  align-items: center;
  max-width: 11rem;
}

.cm-subject-input {
  flex: 1 1 auto;
  min-width: 0;
  max-width: 9rem;
  font-size: 0.86rem;
  padding: 0.3rem 0.4rem;
}

.cm-subject-save {
  flex: 0 0 auto;
  margin-top: 0;
  padding: 0.2rem 0.45rem;
  font-size: 0.85rem;
  line-height: 1.2;
}

table.control-months .cm-idx-col {
  width: 2.5ch;
  min-width: 2.5ch;
  max-width: 2.5ch;
  padding-left: 0.2rem;
  padding-right: 0.35rem;
  text-align: right;
}

table.control-months th.cm-pending-act-col,
table.control-months td.cm-pending-act {
  min-width: 16rem;
  max-width: 22rem;
}

.cm-pending-act {
  overflow: hidden;
  text-overflow: ellipsis;
}

.cm-months-col {
  padding: 0.3rem 0.35rem !important;
  vertical-align: middle !important;
}

.cm-months-head {
  font-size: 0.72rem;
  color: var(--muted);
  text-align: center;
  margin-bottom: 0.15rem;
}

.cm-month-labels {
  display: grid;
  grid-template-columns: repeat(12, 1.5rem);
  gap: 1px;
  font-size: 0.58rem;
  color: var(--muted);
  text-align: center;
  line-height: 1;
}

.cm-month-labels span:nth-child(10),
.cm-month-labels span:nth-child(11),
.cm-month-labels span:nth-child(12) {
  font-size: 0.5rem;
}

.cm-months-grid {
  display: grid;
  grid-template-columns: repeat(12, 1.5rem);
  gap: 1px;
}

.cm-month-item {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 1.35rem;
  border-radius: 3px;
  text-align: center;
}

.cm-month-icon {
  font-size: 0.82rem;
  line-height: 1;
}

.cm-month-item.cm-in_progress {
  background: #e8f1ff;
}

.cm-cell {
  text-align: center;
  min-width: 4.4rem;
}

.cm-status-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  flex-wrap: wrap;
}

.cm-inline-form {
  display: inline;
  margin: 0;
}

.cm-publish-btn {
  margin-top: 0;
  padding: 0.15rem 0.45rem;
  font-size: 0.72rem;
  line-height: 1.2;
  white-space: nowrap;
}

.cm-none {
  color: var(--muted);
}

.cm-in_progress {
  background: #e8f1ff;
  color: #1a4a8a;
  font-weight: 600;
}

.cm-in_control {
  background: #fff4d6;
  color: #7a5300;
  font-weight: 600;
}

.cm-posted {
  color: var(--text);
}

.cm-errors {
  background: #fde8e6;
  color: var(--danger);
  font-weight: 600;
}

.cm-link {
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  cursor: pointer;
  text-decoration: underline;
  padding: 0;
}

.cm-legend {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin: 0.2rem 0 0.85rem;
}

.cm-legend-item {
  display: inline-block;
  padding: 0.2rem 0.55rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  font-size: 0.86rem;
}

#cm-reason-dialog {
  width: min(760px, 94vw);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem;
}

.cm-progress {
  margin-top: 0.9rem;
  padding: 0.75rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fafbfd;
}

.cm-progress-head {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  align-items: center;
  margin-bottom: 0.35rem;
}

.cm-progress-bar {
  width: 100%;
  height: 10px;
  background: #e8edf5;
  border-radius: 999px;
  overflow: hidden;
}

.cm-progress-fill {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, #1e6b5c, #2a8f7a);
  transition: width 0.35s ease;
}

#cm-progress-detail {
  margin-top: 0.25rem;
}

.lines-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
  margin-top: 0.5rem;
}

.lines-table th,
.lines-table td {
  padding: 0.4rem 0.5rem;
  border: 1px solid var(--border);
}

.lines-table th {
  background: #f0f3f8;
  font-weight: 600;
}

.batch-table td:first-child {
  word-break: break-word;
  max-width: 12rem;
}

.log-heading {
  font-size: 0.9rem;
  font-weight: 600;
  margin: 1rem 0 0.35rem;
  color: var(--text);
}

.actions {
  margin-top: 1.25rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
}

.checkbox-row {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  margin-top: 1rem;
  font-size: 0.92rem;
  color: var(--muted);
}

.checkbox-row input {
  margin-top: 0.25rem;
}

.result-box {
  padding: 1.25rem;
  border-radius: var(--radius);
  margin-top: 1rem;
}

.result-box.success {
  background: #e8f5ef;
  border: 1px solid #9fd4b8;
}

.result-box.fail {
  background: #fdecea;
  border: 1px solid #f0b4ad;
}

pre.log {
  background: #1a2332;
  color: #e8ecf1;
  padding: 1rem;
  border-radius: 8px;
  overflow-x: auto;
  font-size: 0.78rem;
  line-height: 1.45;
  max-height: 280px;
}

footer.note {
  margin-top: 2rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
  font-size: 0.85rem;
  color: var(--muted);
}

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: rgba(0, 0, 0, 0.45);
}

.modal-box {
  width: min(100%, 28rem);
  padding: 1.25rem 1.35rem;
  border-radius: 10px;
  background: var(--card, #fff);
  border: 1px solid var(--warn);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.18);
}

@media (min-width: 640px) {
  .wrap {
    padding: 2rem 1.5rem 4rem;
  }
  header.site h1 {
    font-size: 1.6rem;
  }
}
