﻿:root {
  color-scheme: light;
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-soft: #eef2f5;
  --line: #d6dde4;
  --text: #1c2733;
  --muted: #657487;
  --brand: #246b52;
  --brand-strong: #18533f;
  --accent: #c27a2c;
  --danger: #b93f3f;
  --shadow: 0 18px 45px rgba(31, 45, 61, 0.1);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, "Segoe UI", Arial, sans-serif;
  letter-spacing: 0;
}

.login-screen {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 20px;
}

.login-screen[hidden] {
  display: none;
}

.login-panel {
  display: grid;
  gap: 16px;
  width: min(390px, 100%);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
  padding: 24px;
}

.login-brand {
  color: var(--text);
  margin-bottom: 4px;
}

.login-error {
  border: 1px solid rgba(196, 57, 57, 0.32);
  border-radius: 8px;
  background: #fff3f3;
  color: #9d2525;
  padding: 10px 12px;
  font-size: 14px;
  font-weight: 700;
}

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

.password-field input {
  min-width: 0;
}

.app-shell[hidden] {
  display: none;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.primary-action,
.secondary-action,
.warning-action,
.success-action,
.danger-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  border: 0;
  border-radius: 8px;
  padding: 0 14px;
  font-weight: 700;
  text-decoration: none;
}

.primary-action {
  background: var(--brand);
  color: #fff;
}

.secondary-action {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--brand-strong);
}

.warning-action {
  background: var(--accent);
  color: #fff;
}

.success-action {
  background: var(--brand);
  color: #fff;
}

.danger-action {
  background: var(--danger);
  color: #fff;
}

.compact-action {
  min-height: 32px;
  padding: 0 10px;
  font-size: 13px;
}

td .secondary-action,
td .primary-action,
td .warning-action,
td .success-action,
td .danger-action {
  margin: 2px 4px 2px 0;
}

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 26px;
  border-radius: 999px;
  padding: 0 10px;
  background: #e6edf1;
  color: var(--brand-strong);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.badge.active {
  background: #dcece5;
  color: var(--brand-strong);
}

.badge.inactive,
.badge.warning {
  background: #fff2df;
  color: #94580d;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

.checkbox-field {
  grid-template-columns: auto 1fr;
  align-items: center;
  min-height: 40px;
}

.checkbox-field input {
  width: 18px;
  min-height: 18px;
}

input[type="checkbox"] {
  width: 18px;
  min-width: 18px;
  height: 18px;
  min-height: 18px;
  padding: 0;
  border: 0;
  border-radius: 3px;
  background: transparent;
  accent-color: var(--brand);
  cursor: pointer;
}

.permissions-panel {
  display: grid;
  gap: 10px;
}

.permissions-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.permissions-head h3 {
  margin: 0;
  color: var(--text);
  font-size: 14px;
}

.permissions-help {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.inline-control {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
}

.permissions-grid {
  display: grid;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: var(--surface-soft);
}

.permission-row {
  display: grid;
  grid-template-columns: minmax(90px, 1fr) repeat(9, minmax(34px, 48px));
  gap: 6px;
  align-items: center;
}

.permission-row strong,
.permission-row span {
  color: var(--text);
  font-size: 12px;
}

.permission-row.header span {
  color: var(--muted);
  font-weight: 700;
  text-align: center;
}

.permission-row label {
  display: grid;
  place-items: center;
}

.permission-row input {
  width: 18px;
  min-height: 18px;
}

.permission-row input:disabled {
  opacity: 0.45;
}

input,
select,
textarea {
  position: relative;
  z-index: 1;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
  color: var(--text);
  outline: none;
}

input,
select {
  min-height: 40px;
  padding: 0 11px;
}

textarea {
  min-height: 78px;
  padding: 10px 11px;
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(36, 107, 82, 0.15);
}

.autocomplete {
  position: relative;
}

.autocomplete-results {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  z-index: 12;
  max-height: 240px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.autocomplete-option {
  display: grid;
  gap: 3px;
  width: 100%;
  min-height: 52px;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  background: var(--surface);
  color: var(--text);
  padding: 9px 11px;
  text-align: left;
}

.autocomplete-option:hover,
.autocomplete-option:focus {
  background: var(--surface-soft);
}

.autocomplete-option span,
.autocomplete-empty {
  color: var(--muted);
  font-size: 12px;
}

.autocomplete-empty {
  padding: 12px;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 18px;
  align-items: start;
}

.dashboard-panel {
  display: grid;
  gap: 18px;
}

.table-wrap,
.editor,
.work-detail-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.table-wrap {
  overflow: auto;
  min-height: 360px;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 13px 14px;
  text-align: left;
  vertical-align: middle;
}

th {
  background: var(--surface-soft);
  color: #3d4c5d;
  font-size: 12px;
  text-transform: uppercase;
}

td {
  font-size: 14px;
}

.actions-col {
  width: 120px;
}

.selected-row {
  background: #f2f7f4;
}

.editor-backdrop,
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  background: rgba(24, 38, 34, 0.46);
  padding: 18px;
}

.editor-modal,
.modal {
  width: min(720px, calc(100vw - 28px));
  max-height: calc(100vh - 36px);
  overflow: auto;
  border: 1px solid rgba(150, 176, 166, 0.55);
  border-radius: 8px;
  background: linear-gradient(180deg, #ffffff 0%, #f8faf9 100%);
  box-shadow: 0 24px 70px rgba(18, 32, 28, 0.24);
}

.editor-modal {
  position: fixed;
  inset: 18px auto auto 50%;
  z-index: 31;
  display: grid;
  gap: 14px;
  transform: translateX(-50%);
  padding: 18px;
}

.editor.custom-field-layout,
.editor-modal.custom-field-layout {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.editor.custom-field-layout > .field-grid,
.editor-modal.custom-field-layout > .field-grid {
  grid-column: 1 / -1;
}

.editor-head,
.modal-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 14px;
}

.editor-head h2,
.modal-head h2 {
  margin: 0;
  color: var(--text);
  font-size: 20px;
}

.editor-head p,
.modal-head p {
  margin: 6px 0 0;
  color: var(--muted);
}

.icon-button {
  display: inline-grid;
  place-items: center;
  width: 34px;
  min-height: 34px;
  border: 0;
  border-radius: 8px;
  background: #eef3f5;
  color: var(--muted);
  font-weight: 800;
}

.field-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: start;
  gap: 10px;
}

.form-actions {
  position: sticky;
  bottom: -18px;
  z-index: 4;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin: 4px -18px -18px;
  border-top: 1px solid rgba(214, 221, 228, 0.9);
  background: rgba(248, 250, 249, 0.96);
  padding: 12px 18px;
}

.work-view-modal {
  width: min(1040px, calc(100vw - 28px));
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  gap: 12px;
  padding: 20px;
  overflow: hidden;
}

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 10px;
}

.tab-button {
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  padding: 0 12px;
  font-weight: 700;
}

.tab-button.active {
  border-color: var(--brand);
  background: #e8f2ed;
  color: var(--brand-strong);
}

.work-view-body {
  min-height: 420px;
  overflow: auto;
  padding-right: 4px;
}

.work-detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}

.work-detail-grid > div,
.detail-row,
.history-empty {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  padding: 11px;
}

.work-detail-grid strong {
  display: block;
  color: var(--text);
  font-size: 20px;
}

.work-detail-grid span,
.detail-row span {
  color: var(--muted);
  font-size: 12px;
}

.work-detail-section {
  display: grid;
  gap: 8px;
  margin-top: 16px;
}

.work-detail-section h3 {
  margin: 0;
  font-size: 15px;
}

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

.detail-row {
  display: grid;
  gap: 5px;
}

.detail-row strong {
  color: var(--text);
}

.work-view-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-bottom: 12px;
}

.upload-strip {
  display: grid;
  grid-template-columns: auto minmax(160px, 1fr) auto;
  gap: 10px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  padding: 10px;
}

.workshop-parts-form {
  display: grid;
  gap: 12px;
  border: 1px solid rgba(183, 204, 196, 0.8);
  border-radius: 8px;
  background: linear-gradient(180deg, #f5f9f7 0%, #edf4f1 100%);
  padding: 12px;
}

.workshop-inline-notice {
  border: 1px solid rgba(36, 107, 82, 0.22);
  border-radius: 8px;
  background: #e8f3ef;
  color: var(--brand-strong);
  padding: 10px 12px;
  font-weight: 700;
}

.workshop-cost-estimate {
  margin: 0;
  border: 1px solid rgba(36, 107, 82, 0.18);
  border-radius: 8px;
  background: #f8faf9;
  color: var(--muted);
  padding: 9px 11px;
  font-size: 13px;
  font-weight: 700;
}

.workshop-cost-estimate.warning {
  border-color: rgba(199, 61, 61, 0.35);
  background: #fff6f6;
  color: var(--danger);
}

.workshop-job-backdrop {
  z-index: 36;
  background: rgba(24, 38, 34, 0.36);
}

.workshop-job-editor-backdrop {
  z-index: 38;
  background: rgba(24, 38, 34, 0.42);
}

.workshop-job-modal {
  width: min(880px, calc(100vw - 36px));
  max-height: min(760px, calc(100vh - 36px));
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 12px;
  padding: 20px 22px 18px;
  overflow: hidden;
}

.workshop-job-detail-modal .modal-head {
  border-bottom: 1px solid rgba(214, 221, 228, 0.9);
  padding-bottom: 12px;
}

.workshop-job-detail-modal .modal-head h2 {
  font-size: 20px;
  line-height: 1.25;
}

.workshop-job-editor {
  width: min(860px, calc(100vw - 36px));
  max-height: min(680px, calc(100vh - 36px));
}

.workshop-job-body {
  display: grid;
  gap: 12px;
  min-height: 0;
  overflow: auto;
  overflow-x: hidden;
  padding-right: 4px;
}

.workshop-job-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  border: 1px solid rgba(214, 221, 228, 0.9);
  border-radius: 8px;
  background: #f8faf9;
  padding: 10px;
  margin-bottom: 0;
}

.workshop-job-actions .compact-action {
  min-height: 38px;
  padding: 0 12px;
}

.workshop-job-body .detail-list {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.workshop-job-detail-section {
  margin-top: 0;
}

.workshop-job-detail-section .detail-row {
  min-height: 74px;
  background: #f7faf9;
}

.workshop-job-parts-section {
  border-top: 1px solid rgba(214, 221, 228, 0.9);
  padding-top: 12px;
}

.workshop-job-parts-section .detail-row {
  background: #eef5f2;
}

.workshop-job-footer {
  position: sticky;
  bottom: -18px;
  z-index: 2;
  margin: 0 -22px -18px;
  border-top: 1px solid rgba(214, 221, 228, 0.9);
  background: rgba(248, 250, 249, 0.97);
  padding: 12px 22px;
}

.workshop-parts-grid {
  display: grid;
  grid-template-columns: minmax(180px, 1.2fr) minmax(180px, 1.1fr) minmax(110px, 0.55fr) minmax(180px, 1.1fr);
  gap: 10px;
}

.workshop-job-edit-form {
  min-height: 0;
  overflow: visible;
}

.workshop-job-edit-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.workshop-job-edit-grid label {
  min-width: 0;
}

.workshop-job-edit-grid textarea {
  min-height: 96px;
}

.workshop-job-edit-actions {
  position: sticky;
  bottom: -12px;
  z-index: 2;
  margin: 0 -12px -12px;
  border-top: 1px solid rgba(214, 221, 228, 0.9);
  background: rgba(248, 250, 249, 0.97);
  padding: 12px;
}

.workshop-parts-grid label {
  display: grid;
  gap: 6px;
}

.workshop-parts-grid span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.inline-form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.file-browser {
  display: grid;
  grid-template-columns: minmax(280px, 0.9fr) minmax(0, 1.1fr);
  gap: 14px;
  margin-top: 14px;
}

.selected-file-preview,
.file-preview-panel {
  display: grid;
  gap: 10px;
}

.file-preview-media {
  display: grid;
  min-height: 240px;
  place-items: center;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
}

.file-preview-media img {
  display: block;
  width: 100%;
  max-height: 340px;
  object-fit: contain;
}

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

.file-list-item {
  display: grid;
  gap: 4px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 10px;
  text-align: left;
}

.file-list-item.active,
.file-list-item.selected {
  border-color: var(--brand);
  background: #e8f2ed;
}

.file-list-item span,
.selected-file-preview p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.file-placeholder {
  display: grid;
  place-items: center;
  gap: 6px;
  color: var(--muted);
}

@media (max-width: 760px) {
  .workspace,
  .field-grid,
  .work-detail-grid,
  .workshop-job-body .detail-list,
  .file-browser,
  .upload-strip,
  .workshop-job-edit-grid,
  .workshop-parts-grid {
    grid-template-columns: 1fr;
  }

  .inline-form-actions {
    justify-content: stretch;
  }

  .inline-form-actions > button {
    width: 100%;
  }

  .editor-modal,
  .modal {
    width: calc(100vw - 20px);
    max-height: calc(100vh - 20px);
  }

  .editor.custom-field-layout,
  .editor-modal.custom-field-layout {
    grid-template-columns: 1fr;
  }
}

.contact-filter-fields {
  display: contents;
}
