:root {
  --bg: #edf8f5;
  --panel: #ffffff;
  --panel-soft: #f7fffc;
  --ink: #18202f;
  --muted: #657084;
  --line: #cfe3dc;
  --accent: #0f8f79;
  --accent-strong: #087367;
  --blue: #2457d6;
  --red: #c51f2d;
  --amber: #e58a12;
  --green: #1f9d55;
  --sun: #facc15;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background:
    radial-gradient(circle at 12% 0%, rgba(34, 197, 94, .18), transparent 28%),
    radial-gradient(circle at 92% 8%, rgba(250, 204, 21, .18), transparent 24%),
    linear-gradient(135deg, #edf8f5 0%, #f4f8ff 52%, #fff7ed 100%);
  color: var(--ink);
  font: 15px/1.45 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

a { color: inherit; text-decoration: none; }
input, select, textarea, button { font: inherit; }

input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  padding: 10px 11px;
}

input:not([type="hidden"]):not([type="checkbox"]):not([type="radio"]):not([type="file"]):not([type="color"]),
select {
  min-height: 42px;
}

input[type="color"] {
  min-height: 42px;
  height: 42px;
  padding: 4px;
}

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

input[readonly], textarea[readonly], select:disabled {
  background: #f8fafc;
  color: #475569;
}
.date-input-wrap {
  display: block;
  width: 100%;
  margin-top: 5px;
  position: relative;
}

label .date-input-wrap input[data-date-input] {
  margin-top: 0;
  cursor: pointer;
}

.date-input-wrap.is-readonly input[data-date-input] {
  cursor: default;
}

.date-popover {
  position: fixed;
  z-index: 32;
  padding: 10px;
  border: 1px solid #b7eadf;
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  box-shadow: 0 18px 42px rgba(15, 23, 42, .20);
}

.date-popover[hidden] {
  display: none;
}

.date-cal-head {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr) 36px;
  gap: 8px;
  align-items: center;
  margin-bottom: 10px;
}

.date-cal-head strong {
  text-align: center;
  font-size: 14px;
}

.date-nav,
.date-day,
.date-text-button {
  border: 1px solid transparent;
  border-radius: 6px;
  background: #f8fafc;
  color: var(--ink);
  min-height: 34px;
  padding: 0;
}

.date-nav:hover,
.date-day:hover,
.date-text-button:hover {
  border-color: var(--accent);
  background: linear-gradient(180deg, #dff5f1, #c8efe8);
  color: var(--accent-strong);
  box-shadow: 0 10px 24px rgba(15, 143, 121, .18);
}

.date-weekdays,
.date-days {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 5px;
}

.date-weekdays {
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-align: center;
  text-transform: uppercase;
}

.date-day,
.date-day-spacer {
  min-width: 0;
  min-height: 34px;
}

.date-day.today {
  border-color: #facc15;
  background: #fff7d6;
}

.date-day.selected {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.date-cal-footer {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  border-top: 1px solid var(--line);
  margin-top: 10px;
  padding-top: 10px;
}

.date-text-button {
  padding: 0 11px;
  font-size: 13px;
  font-weight: 800;
}
.topbar {
  min-height: 84px;
  padding: 18px clamp(16px, 3vw, 34px);
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid rgba(15, 143, 121, .2);
  background:
    linear-gradient(90deg, rgba(255,255,255,.96), rgba(232,255,248,.96) 48%, rgba(255,247,221,.96));
  box-shadow: 0 10px 28px rgba(15, 118, 110, .10);
  position: relative;
}

.topbar::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 4px;
  background: linear-gradient(90deg, #2445c7, #2bb7f0, #38bdf8, #4ade80, #facc15, #fb923c, #ef4444);
}

.topbar-main {
  display: flex;
  align-items: center;
  gap: clamp(16px, 3vw, 34px);
  min-width: 0;
  flex-wrap: wrap;
}

.module-nav {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.module-link {
  border: 2px solid #b7eadf;
  border-radius: 8px;
  background: linear-gradient(180deg, #ffffff, #eefaf7);
  color: #164e45;
  min-height: 48px;
  padding: 12px 18px;
  font-size: 15px;
  font-weight: 900;
  line-height: 1.1;
  box-shadow: 0 8px 20px rgba(15, 87, 78, .11);
}

.module-link:hover {
  border-color: #8bd6ce;
  color: var(--accent-strong);
}

.module-link.active {
  border-color: var(--accent);
  background: linear-gradient(180deg, #dff5f1, #c8efe8);
  color: var(--accent-strong);
  box-shadow: 0 10px 24px rgba(15, 143, 121, .18);
}

.module-link.disabled {
  cursor: not-allowed;
  opacity: .55;
  background: #f8fafc;
  box-shadow: none;
}
.brand-head {
  display: flex;
  align-items: center;
  gap: 18px;
  min-width: 0;
}

.brand-logo {
  width: clamp(150px, 18vw, 230px);
  height: 72px;
  object-fit: contain;
  object-position: left center;
  flex: 0 0 auto;
}

.eyebrow {
  margin: 0 0 3px;
  color: var(--accent);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .08em;
  font-weight: 700;
}

h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: 28px; }
h2 { margin: 8px 0 0; font-size: 26px; line-height: 1.15; }
h3 { margin-bottom: 10px; font-size: 14px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }

.button, button {
  border: 0;
  border-radius: 6px;
  background: var(--ink);
  color: #fff;
  padding: 10px 14px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-weight: 700;
}

.button.ghost {
  background: #eef2f7;
  color: var(--ink);
}

.button.danger {
  background: #fee2e2;
  color: var(--red);
}

.full { width: 100%; }

.session {
  display: flex;
  align-items: center;
  gap: 12px;
}

.register-layout {
  display: grid;
  gap: 16px;
  padding: 18px clamp(16px, 3vw, 34px) 34px;
}

.panel {
  background: linear-gradient(180deg, #ffffff, var(--panel-soft));
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 12px 30px rgba(15, 87, 78, .08);
}

.register-toolbar {
  padding: 14px;
}

.filters {
  display: grid;
  gap: 10px;
}

.search-row {
  display: grid;
  grid-template-columns: 1fr 44px;
  gap: 8px;
}

.icon-button {
  padding: 0;
  font-size: 22px;
}

.filter-grid, .date-grid {
  display: grid;
  grid-template-columns: 1fr 220px 190px;
  gap: 8px;
  align-items: center;
}

.filter-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.print-button {
  background: #eef8f4;
  color: var(--accent-strong);
  border: 1px solid #b7eadf;
}

.checkline {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  min-height: 42px;
}

.checkline input {
  width: auto;
}

.new-contract {
  border-top: 1px solid var(--line);
  padding-top: 12px;
  margin-top: 12px;
}

.new-contract summary {
  cursor: pointer;
  font-weight: 800;
}

.create-form {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.bills-create-form {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  align-items: start;
}

.bills-create-form > label {
  display: grid;
  align-content: start;
  min-width: 0;
}

.create-form textarea,
.create-form .tag-picker,
.create-form .dropzone,
.create-form .full {
  grid-column: 1 / -1;
}

.tag-picker,
.tag-editor {
  display: grid;
  gap: 10px;
}

.tag-picker {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
  padding: 12px;
}

.tag-custom-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
}

.table-panel {
  overflow: hidden;
}

.table-scroll {
  overflow-x: auto;
}

.contracts-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 1280px;
  table-layout: fixed;
}

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

.contracts-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f8fafc;
  color: #334155;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .05em;
}

.contracts-table tbody tr {
  cursor: pointer;
}

.contracts-table tbody tr.category-mark {
  box-shadow: inset 4px 0 0 var(--category-color);
}

.contracts-table tbody tr:hover,
.contracts-table tbody tr.selected {
  background: #eef8f6;
}

.contracts-table tbody tr.category-mark:hover,
.contracts-table tbody tr.category-mark.selected {
  background: linear-gradient(90deg, var(--category-soft), #eef8f6 48%);
}

.contracts-table td {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.contracts-table th,
.contracts-table td {
  position: relative;
}

.contracts-table th:nth-child(1),
.contracts-table td:nth-child(1) { width: 190px; min-width: 190px; }
.contracts-table th:nth-child(2),
.contracts-table td:nth-child(2) { width: 240px; min-width: 240px; }
.contracts-table th:nth-child(3),
.contracts-table td:nth-child(3) { width: 130px; min-width: 130px; }
.contracts-table th:nth-child(4),
.contracts-table td:nth-child(4) { width: 150px; min-width: 150px; }
.contracts-table th:nth-child(5),
.contracts-table td:nth-child(5),
.contracts-table th:nth-child(6),
.contracts-table td:nth-child(6) { width: 120px; min-width: 120px; }
.contracts-table th:nth-child(7),
.contracts-table td:nth-child(7) { width: 130px; min-width: 130px; }
.contracts-table th:nth-child(8),
.contracts-table td:nth-child(8) { width: 190px; min-width: 190px; }
.contracts-table th:nth-child(9),
.contracts-table td:nth-child(9) { width: 130px; min-width: 130px; }

.column-resizer {
  position: absolute;
  top: 0;
  right: -4px;
  width: 9px;
  height: 100%;
  cursor: col-resize;
  touch-action: none;
  z-index: 3;
}

.column-resizer::after {
  content: '';
  position: absolute;
  top: 9px;
  bottom: 9px;
  left: 4px;
  border-left: 1px solid transparent;
}

.column-resizer:hover::after,
.contracts-table th.is-resizing .column-resizer::after {
  border-color: #2563eb;
}

.tags-cell {
  min-width: 190px;
  white-space: normal;
}

.tags-cell .tag-chip-list {
  max-height: 68px;
  overflow: hidden;
}

.category-badge {
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  border: 1px solid var(--category-strong);
  border-radius: 999px;
  background: var(--category-soft);
  color: var(--category-color);
  padding: 5px 9px;
  font-size: 12px;
  font-weight: 800;
  line-height: 1.2;
  white-space: nowrap;
}

.detail-badges {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.tag-chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-width: 0;
}

.tag-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid #cbd5e1;
  border-radius: 999px;
  background: #f8fafc;
  color: #334155;
  min-height: 30px;
  padding: 5px 10px;
  font-size: 12px;
  font-weight: 800;
  line-height: 1.1;
}

.tag-chip:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.tag-chip.fixed {
  background: #f8fafc;
}

.tag-chip.custom {
  border-color: #fed7aa;
  background: #fff7ed;
  color: #9a3412;
}

.tag-chip.selected {
  border-color: #8bd6ce;
  background: #dff5f1;
  color: var(--accent);
}

.tag-chip.custom.selected {
  border-color: #fdba74;
  background: #ffedd5;
  color: #9a3412;
}

.tag-chip[disabled] {
  cursor: default;
  opacity: .9;
}

.tag-chip[disabled]:hover {
  border-color: #cbd5e1;
  color: #334155;
}

.tag-chip.selected[disabled]:hover {
  border-color: #8bd6ce;
  color: var(--accent);
}

.tag-chip.custom.selected[disabled]:hover {
  border-color: #fdba74;
  color: #9a3412;
}

.tag-empty {
  color: var(--muted);
  font-size: 13px;
}

.pill {
  border-radius: 999px;
  padding: 5px 9px;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.pill.ok { background: #dcfce7; color: var(--green); }
.pill.warning { background: #fef3c7; color: var(--amber); }
.pill.danger { background: #fee2e2; color: var(--red); }
.pill.neutral { background: #e5e7eb; color: #374151; }

.detail-panel {
  position: fixed;
  top: 0;
  right: 0;
  z-index: 12;
  width: min(760px, calc(100vw - 34px));
  height: 100vh;
  padding: clamp(18px, 3vw, 30px);
  border-radius: 8px 0 0 8px;
  overflow-y: auto;
  box-shadow: -18px 0 38px rgba(15, 23, 42, .18);
  transform: translateX(105%);
  transition: transform .22s ease;
}

.detail-panel.open {
  transform: translateX(0);
}

.detail-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 22px;
}

.detail-actions {
  display: flex;
  align-items: flex-start;
  justify-content: flex-end;
}

.detail-safe-actions {
  display: flex;
  justify-content: flex-end;
  width: 100%;
}

.detail-safe-actions .button {
  min-width: 92px;
}

.detail-management-actions {
  max-width: 380px;
  margin-left: auto;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  padding: 12px;
  border: 1px solid #f1c9c9;
  border-radius: 8px;
  background: #fffafa;
}

.detail-management-actions .button {
  width: 100%;
  min-height: 40px;
  padding-inline: 12px;
  white-space: nowrap;
}

.detail-management-actions .button.ghost {
  border: 1px solid #cbd5e1;
  background: #f8fafc;
}

.detail-management-actions .button.danger {
  border: 1px solid #fecaca;
}

.meta-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 22px;
}

label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

label input, label select {
  margin-top: 5px;
  color: var(--ink);
  font-weight: 500;
}

.form-field {
  display: grid;
  align-content: start;
  gap: 5px;
  min-width: 0;
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  line-height: 1.25;
}

.form-field > input,
.form-field > select,
.form-field > textarea,
.form-field > .date-input-wrap {
  margin-top: 0;
}

.form-field > input,
.form-field > select,
.form-field > textarea {
  color: var(--ink);
  font-weight: 500;
}

.form-field > textarea {
  min-height: 112px;
}

.create-form > .form-field,
.user-create-form > .form-field,
.stack-form > .form-field {
  align-self: end;
}

.color-field input[type="color"] {
  width: 100%;
  min-width: 72px;
}

.checkline input,
.inline-check input {
  margin-top: 0;
}

.detail-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(260px, 380px);
  gap: 16px;
  align-items: start;
}

.section-line {
  border-top: 1px solid var(--line);
  padding-top: 18px;
  margin-top: 18px;
}

.wide-input {
  max-width: 760px;
}

.notice-box {
  margin-top: 18px;
  padding: 14px;
  border: 1px solid #b7eadf;
  border-radius: 7px;
  background: #ecfdf5;
  display: grid;
  gap: 4px;
}

.empty {
  color: var(--muted);
  padding: 18px;
}

.dropzone {
  min-height: 92px;
  border: 1px dashed #94a3b8;
  border-radius: 8px;
  background: #f8fafc;
  display: grid;
  place-items: center;
  padding: 18px;
  text-align: center;
  color: #475569;
  cursor: pointer;
  position: relative;
}

.dropzone input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}
.upload-limit-note {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
  pointer-events: none;
}

.dropzone.dragging,
.dropzone.has-files,
.dropzone.saving {
  border-color: var(--accent);
  background: #ecfdf5;
  color: var(--accent);
}

.document-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 12px;
  margin-top: 12px;
}

.document-card {
  color: var(--ink);
  background: linear-gradient(180deg, #ffffff, #f8fffc);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px;
  display: grid;
  gap: 8px;
  text-align: left;
  min-width: 0;
  position: relative;
}

.document-card:hover {
  border-color: var(--accent);
}
.document-card.is-current {
  border-color: #f59e0b;
  box-shadow: inset 0 0 0 1px #fbbf24;
}

.document-current-badge {
  position: absolute;
  top: 8px;
  left: 8px;
  z-index: 2;
  border-radius: 999px;
  background: #fef3c7;
  color: #92400e;
  border: 1px solid #fde68a;
  padding: 5px 9px;
  font-size: 12px;
  font-weight: 900;
}

.document-current-toggle {
  margin: 0;
  padding: 6px 0 0;
  color: #334155;
  font-size: 13px;
}

.document-description {
  width: 100%;
  min-height: 62px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px;
  font: inherit;
  font-size: 13px;
  line-height: 1.35;
}

.document-description:focus {
  border-color: var(--accent);
  outline: 3px solid rgba(14, 165, 164, .14);
}

.document-description-text {
  margin: 0;
  color: #475569;
  font-size: 13px;
  line-height: 1.35;
  white-space: normal;
}

.doc-delete {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 30px;
  height: 30px;
  padding: 0;
  border-radius: 999px;
  background: #fee2e2;
  color: var(--red);
  z-index: 2;
}

.document-card strong,
.document-card small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.document-card small {
  color: var(--muted);
}

.thumb {
  height: 128px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f8fafc;
  display: grid;
  place-items: center;
  overflow: hidden;
  position: relative;
}

.thumb img,
.thumb embed,
.thumb iframe {
  width: 100%;
  height: 100%;
  border: 0;
  object-fit: contain;
  pointer-events: none;
  position: relative;
  z-index: 0;
}

.file-icon {
  font-weight: 900;
  color: var(--muted);
}

.preview-modal {
  position: fixed;
  inset: 0;
  z-index: 20;
  background: rgba(15, 23, 42, .58);
  padding: 24px;
  display: grid;
  place-items: center;
}

.preview-modal[hidden] {
  display: none;
}

.preview-dialog {
  width: min(1100px, 100%);
  height: min(820px, calc(100vh - 48px));
  background: #fff;
  border-radius: 8px;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  overflow: hidden;
}

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

.preview-dialog footer {
  border-top: 1px solid var(--line);
  border-bottom: 0;
  justify-content: flex-end;
}

.preview-body {
  background: #f1f5f9;
  display: grid;
  place-items: center;
  min-height: 0;
}

.preview-body img,
.preview-body iframe {
  width: 100%;
  height: 100%;
  border: 0;
  object-fit: contain;
}

.preview-body p {
  max-width: 560px;
  padding: 24px;
  color: var(--muted);
  text-align: center;
}

.rich-shell {
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
}

.rich-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px;
  border-bottom: 1px solid var(--line);
  background: #f8fafc;
}

.rich-toolbar button {
  width: 38px;
  min-height: 34px;
  padding: 0;
  background: #e2e8f0;
  color: var(--ink);
}

.rich-color {
  width: 42px;
  min-height: 34px;
  border-radius: 6px;
  background: #e2e8f0;
  color: var(--ink);
  display: inline-grid;
  place-items: center;
  position: relative;
  font-size: 14px;
  font-weight: 900;
  cursor: pointer;
}

.rich-color.highlight {
  background: #fef3c7;
}

.rich-color input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.rich-editor {
  min-height: 150px;
  padding: 12px;
  outline: 0;
}

.rich-editor[contenteditable="false"] {
  background: #f8fafc;
  color: #475569;
}

.rich-editor p,
.rich-editor ul,
.rich-editor ol {
  margin-top: 0;
}

.audit-form {
  display: grid;
  gap: 8px;
  margin-bottom: 14px;
}

.audit-form textarea {
  min-height: 78px;
}

.audit-list {
  display: grid;
  gap: 10px;
}

.audit-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fff;
}

.audit-item.auto {
  background: #f8fafc;
}

.audit-item header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: baseline;
  margin-bottom: 8px;
}

.audit-item header span {
  color: var(--muted);
  font-size: 12px;
}

.audit-item p {
  margin-bottom: 0;
}

.audit-item del {
  color: var(--red);
}

.audit-item ins {
  color: var(--green);
  text-decoration: none;
  font-weight: 700;
}

.audit-note {
  min-height: 76px;
}

.saving {
  outline: 2px solid #fbbf24;
}

.saved {
  outline: 2px solid #22c55e;
}

.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
}

.login-box {
  width: min(420px, 100%);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 24px;
  display: grid;
  gap: 14px;
}

.login-logo {
  width: min(300px, 100%);
  max-height: 160px;
  object-fit: contain;
  justify-self: center;
  margin-bottom: 4px;
}

.settings-layout {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  padding: 18px clamp(16px, 3vw, 34px) 34px;
}

.settings-panel {
  padding: 22px;
}

.wide-settings {
  grid-column: 1 / -1;
}

.user-create-form {
  display: grid;
  grid-template-columns: minmax(150px, 1fr) minmax(260px, 1.7fr) minmax(170px, 1fr) minmax(170px, 1fr) auto;
  gap: 10px;
  align-items: end;
  margin: 18px 0;
}

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

.users-table {
  width: 100%;
  min-width: 1040px;
  border-collapse: collapse;
}

.users-table th,
.users-table td {
  border-top: 1px solid var(--line);
  padding: 10px;
  text-align: left;
}

.users-table th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .05em;
}

.users-table th:nth-child(2),
.users-table td:nth-child(2) {
  min-width: 300px;
}

.users-table th:nth-child(1),
.users-table td:nth-child(1),
.users-table th:nth-child(4),
.users-table td:nth-child(4) {
  min-width: 190px;
}

.stack-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 80px auto;
  gap: 10px;
  align-items: end;
  margin: 18px 0;
}

.tag-settings-form,
.mail-test-form {
  grid-template-columns: minmax(0, 1fr) auto;
}

.recipient-form {
  grid-template-columns: minmax(160px, .8fr) minmax(240px, 1.2fr) auto;
}

.stack-form .button,
.user-create-form .button {
  align-self: end;
  min-height: 42px;
}

.settings-tags {
  padding-top: 4px;
}

.editable-list {
  display: grid;
  gap: 10px;
}

.editable-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  border-top: 1px solid var(--line);
  padding-top: 10px;
}

.inline-settings-form {
  display: grid;
  gap: 8px;
  align-items: center;
}

.category-inline-form {
  grid-template-columns: auto minmax(0, 1fr) 72px auto;
}

.tag-inline-form {
  grid-template-columns: minmax(0, 1fr) auto auto;
}

.inline-check {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  white-space: nowrap;
}

.inline-check input {
  width: auto;
  margin: 0;
}

.simple-list {
  display: grid;
  gap: 10px;
}

.simple-list > div {
  display: flex;
  align-items: center;
  gap: 10px;
  justify-content: space-between;
  border-top: 1px solid var(--line);
  padding-top: 10px;
}

.color-dot {
  width: 14px;
  height: 14px;
  border-radius: 999px;
  background: var(--dot);
  display: inline-block;
  flex: 0 0 auto;
}

.alert {
  background: #fee2e2;
  color: var(--red);
  padding: 10px;
  border-radius: 6px;
}

.success {
  background: #dcfce7;
  color: var(--green);
  padding: 10px;
  border-radius: 6px;
}

@media (max-width: 980px) {
  .filter-grid,
  .meta-grid,
  .detail-grid,
  .settings-layout {
    grid-template-columns: 1fr;
  }

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

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

@media (max-width: 620px) {
  .topbar, .detail-head {
    display: grid;
  }

  .topbar-main {
    display: grid;
    gap: 12px;
  }

  .module-nav {
    width: 100%;
  }

  .module-link {
    min-height: 42px;
    padding: 10px 12px;
    font-size: 13px;
  }

  .brand-head {
    align-items: flex-start;
    gap: 12px;
  }

  .brand-logo {
    width: 132px;
    height: 58px;
  }

  .session {
    flex-wrap: wrap;
    justify-content: flex-start;
  }

  .create-form,
  .stack-form,
  .tag-custom-row,
  .editable-row,
  .category-inline-form,
  .tag-inline-form,
  .user-create-form {
    grid-template-columns: 1fr;
  }

  .preview-modal {
    padding: 10px;
  }

  .detail-panel {
    width: calc(100vw - 10px);
  }

  .detail-actions {
    width: 100%;
    min-width: 0;
    align-items: stretch;
  }

  .detail-safe-actions {
    justify-content: flex-start;
  }
}

.detail-bottom-actions {
  border-color: #fecaca;
  background: #fffafa;
}

.detail-bottom-actions .detail-management-actions {
  margin-top: 10px;
}