:root {
  color-scheme: light;
  --bg: #f6f7f8;
  --panel: #ffffff;
  --ink: #17202a;
  --muted: #637083;
  --line: #d7dde5;
  --accent: #176b87;
  --accent-strong: #0f4d64;
  --danger: #a73d3d;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Arial, Helvetica, sans-serif;
  font-size: 15px;
}

a {
  color: var(--accent-strong);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

.topbar {
  align-items: center;
  background: #ffffff;
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  min-height: 64px;
  padding: 0 28px;
}

.brand {
  color: var(--ink);
  font-size: 20px;
  font-weight: 700;
}

.page {
  margin: 0 auto;
  max-width: 1180px;
  padding: 28px;
}

.section-head {
  align-items: center;
  display: flex;
  gap: 20px;
  justify-content: space-between;
  margin-bottom: 24px;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 30px;
  line-height: 1.2;
}

h2 {
  font-size: 18px;
}

.section-head p,
.client-row p,
.empty p,
.row-actions {
  color: var(--muted);
  margin-top: 6px;
}

.button,
button.button {
  align-items: center;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink);
  cursor: pointer;
  display: inline-flex;
  font: inherit;
  min-height: 40px;
  padding: 8px 13px;
  text-decoration: none;
}

.button:hover {
  border-color: var(--accent);
  text-decoration: none;
}

.button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #ffffff;
}

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

.button.small {
  min-height: 34px;
  padding: 6px 10px;
}

.client-list {
  display: grid;
  gap: 12px;
}

.client-row,
.empty,
.flash,
.crm-form,
.audit-table-wrap {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.client-row {
  align-items: center;
  display: flex;
  gap: 18px;
  justify-content: space-between;
  padding: 18px;
}

.row-actions {
  align-items: center;
  display: flex;
  gap: 12px;
  white-space: nowrap;
}

.empty {
  padding: 32px;
  text-align: center;
}

.empty .button {
  margin-top: 18px;
}

.flash {
  border-color: #a4c7b8;
  margin-bottom: 18px;
  padding: 12px 16px;
}

.crm-form {
  padding: 22px;
}

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

.full {
  grid-column: 1 / -1;
}

label,
legend {
  color: #334155;
  font-weight: 700;
}

label {
  display: grid;
  gap: 8px;
}

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

legend {
  padding: 0 6px;
}

input,
textarea {
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink);
  font: inherit;
  min-height: 40px;
  padding: 9px 10px;
  width: 100%;
}

textarea {
  resize: vertical;
}

.repeat-list {
  display: grid;
  gap: 10px;
  margin-bottom: 12px;
}

.repeat-item {
  align-items: start;
  display: grid;
  gap: 8px;
  grid-template-columns: minmax(0, 1fr) 38px;
}

.icon-button {
  background: #fff7f7;
  border: 1px solid #efc6c6;
  border-radius: 6px;
  color: var(--danger);
  cursor: pointer;
  font-size: 22px;
  height: 40px;
  line-height: 1;
  width: 38px;
}

.file-field input[type="file"] {
  margin-top: 12px;
}

.file-list {
  display: grid;
  gap: 8px;
}

.file-row {
  align-items: center;
  border-bottom: 1px solid #edf0f4;
  display: grid;
  gap: 8px;
  grid-template-columns: auto auto minmax(0, 1fr);
  padding-bottom: 8px;
}

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

.form-actions {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  margin-top: 22px;
}

.audit-table-wrap {
  overflow-x: auto;
}

.audit-table {
  border-collapse: collapse;
  min-width: 980px;
  width: 100%;
}

.audit-table th,
.audit-table td {
  border-bottom: 1px solid var(--line);
  padding: 12px;
  text-align: left;
  vertical-align: top;
}

.audit-table th {
  background: #eef3f6;
  color: #334155;
}

pre {
  font-family: Consolas, "Courier New", monospace;
  margin: 0;
  max-width: 280px;
  white-space: pre-wrap;
}

@media (max-width: 760px) {
  .topbar,
  .section-head,
  .client-row,
  .row-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .page {
    padding: 18px;
  }

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