:root {
  --bg: #f4f6f8;
  --card: #ffffff;
  --text: #1f2937;
  --title: #111827;
  --muted: #6b7280;
  --border: #e5e7eb;
  --border-strong: #d1d5db;
  --accent: #2563eb;
  --accent-dark: #1d4ed8;
  --danger: #dc2626;
  --danger-dark: #b91c1c;
  --success: #047857;
  --error-bg: #fef2f2;
  --error-border: #fecaca;
  --success-bg: #ecfdf5;
  --success-border: #bbf7d0;
  --control-bg: #ffffff;
  --readonly-bg: #f3f4f6;
  --radius-lg: 12px;
  --radius-md: 10px;
  --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.06);
  --shadow-md: 0 2px 7px rgba(15, 23, 42, 0.07);
  --focus-ring: 0 0 0 2px rgba(37, 99, 235, 0.14);
  --page-max-width: 1000px;
  --page-margin: 0 auto;
  --page-padding: 24px;
}

* {
  box-sizing: border-box;
}

html {
  background: var(--bg);
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  max-width: var(--page-max-width);
  margin: var(--page-margin);
  padding: var(--page-padding);
  font-family: Arial, sans-serif;
  font-size: 16px;
  line-height: 1.45;
  background: var(--bg);
  color: var(--text);
}

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

button {
  -webkit-tap-highlight-color: transparent;
}

.hidden {
  display: none !important;
}

/* Layout */
.app,
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

.app {
  width: 100%;
  margin: 0 auto;
  overflow: hidden;
}

.card {
  padding: 24px;
}

.header,
.top-bar {
  display: flex;
  align-items: center;
  gap: 12px;
}

.header {
  position: relative;
  top: auto;
  z-index: 10;
  padding: 24px 24px 18px;
  background: var(--card);
  border-bottom: 1px solid var(--border);
}

.top-bar {
  margin-bottom: 20px;
}

.content {
  padding: 20px 18px 30px;
}

h1,
.header h1,
#formTitle {
  color: var(--title);
  font-size: 24px;
  line-height: 1.2;
  font-weight: 700;
}

.header h1,
#formTitle {
  margin: 0;
}

/* Back button */
.back-button {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--title);
  cursor: pointer;
}

.back-button:hover {
  background: rgba(17, 24, 39, 0.06);
}

.back-icon {
  width: 34px;
  height: 34px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Status blocks */
.status,
.loading,
.empty-list,
.empty-list-message {
  padding: 18px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--muted);
  font-size: 15px;
  line-height: 1.45;
}

.empty-list {
  text-align: center;
  border-style: dashed;
}

.status.error,
.inline-error,
.form-message.error {
  color: var(--danger-dark);
  border-color: var(--error-border);
  background: var(--error-bg);
}

.inline-error {
  padding: 12px 14px;
  border: 1px solid var(--error-border);
  border-radius: var(--radius-md);
  line-height: 1.45;
}

.form-message {
  display: none;
  padding: 12px;
  border-radius: var(--radius-md);
  background: var(--card);
  border: 1px solid var(--border);
  font-size: 14px;
  line-height: 1.4;
}

.form-message.success,
.form-message.error {
  display: block;
}

.form-message.success {
  color: var(--success);
  border-color: var(--success-border);
  background: var(--success-bg);
}

/* Buttons */
.actions,
.posts-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.actions {
  margin-bottom: 24px;
}

.primary-button,
.main-button,
.secondary-button,
.danger-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  border-radius: var(--radius-md);
  cursor: pointer;
  font-size: 16px;
  font-weight: 700;
  line-height: 1.2;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.primary-button,
.main-button {
  padding: 11px 20px;
  border: none;
  background: var(--accent);
  color: #ffffff;
}

.primary-button:hover:not(:disabled),
.main-button:hover:not(:disabled) {
  background: var(--accent-dark);
}

.secondary-button {
  padding: 10px 16px;
  border: 1px solid var(--border-strong);
  background: #ffffff;
  color: var(--accent);
}

.secondary-button:hover:not(:disabled) {
  background: #f3f4f6;
}

.danger-button {
  padding: 11px 20px;
  border: none;
  background: var(--danger);
  color: #ffffff;
}

.danger-button:hover:not(:disabled) {
  background: var(--danger-dark);
}

.primary-button:disabled,
.main-button:disabled,
.secondary-button:disabled,
.danger-button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* Simple forms */
.form-row {
  margin-bottom: 20px;
}

label {
  display: block;
  margin-bottom: 8px;
  color: #374151;
  font-size: 16px;
  line-height: 1.3;
  font-weight: 700;
}

textarea,
.list-search-input,
.employee-search-input {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  background: var(--control-bg);
  color: var(--text);
  font-size: 16px;
  line-height: 1.45;
}

textarea {
  padding: 12px 14px;
  resize: vertical;
}

textarea:focus,
.list-search-input:focus,
.employee-search-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: var(--focus-ring);
}

textarea[readonly] {
  background: var(--readonly-bg);
  color: #374151;
}

#emergencyText {
  min-height: 180px;
}

#pointsText {
  min-height: 140px;
  background: var(--readonly-bg);
  color: #374151;
}

#pointsContainer {
  margin-top: 24px;
}

.hint {
  margin-top: 8px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

/* Employee pages */
.employee-list,
.employee-form,
.points-column,
.points-per-point-list {
  display: flex;
  flex-direction: column;
}

.employee-list {
  gap: 10px;
}

.employee-card {
  width: 100%;
  text-align: left;
  border: 1px solid #d9dde3;
  background: var(--card);
  border-radius: var(--radius-md);
  padding: 16px 18px;
  color: var(--text);
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: background 0.15s ease, border-color 0.15s ease;
}

.employee-card:hover {
  background: #f9fafb;
  border-color: #cbd5e1;
}

.employee-card:active {
  transform: translateY(1px);
}

.employee-name {
  color: var(--title);
  font-size: 21px;
  line-height: 1.3;
  font-weight: 700;
}

.employee-destination {
  color: var(--muted);
  font-size: 19px;
  line-height: 1.4;
  overflow-wrap: anywhere;
  margin-top: 8px;
}

.employee-form {
  gap: 14px;
}

.field {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px;
}

.field label {
  margin-bottom: 7px;
  font-size: 20px;
}

.field input,
.field textarea {
  width: 100%;
  min-width: 0;
  border: none;
  outline: none;
  padding: 0;
  background: transparent;
  color: var(--text);
  font-size: 22px;
  line-height: 1.45;
  resize: vertical;
}

.field textarea {
  min-height: 56px;
}

.readonly-field input,
.readonly-field textarea {
  padding: 12px 14px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  background: var(--readonly-bg);
  color: #374151;
  cursor: default;
}

.readonly-field textarea {
  min-height: 88px;
}

.editable-field {
  border-color: #bfdbfe;
}

.editable-field:focus-within {
  border-color: var(--accent);
  box-shadow: var(--focus-ring);
}

.editable-field input,
.number-field input[type="number"] {
  border-bottom: 1px solid var(--border);
  padding-bottom: 6px;
}

.employee-form .actions {
  gap: 10px;
  margin-top: 4px;
}

.employee-form .primary-button {
  width: 100%;
}

.employee-form .danger-button {
  flex: 0 0 auto;
}

.actions-split .primary-button {
  flex: 1 1 auto;
}

.list-toolbar {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 10px;
  margin-bottom: 20px;
}

.list-toolbar-actions {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 10px;
}

.toolbar-add-button {
  width: auto;
}

.list-search {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.list-search-label {
  color: #374151;
  font-size: 15px;
  line-height: 1.3;
  font-weight: 700;
}

.list-search-input,
.employee-search-input {
  min-height: 46px;
  padding: 10px 13px;
}

.combo {
  position: relative;
}

.combo-input-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.combo-input-row input {
  flex: 1;
  min-width: 0;
}

.combo-input-readonly {
  cursor: default;
}

.combo-toggle {
  flex: 0 0 auto;
  width: 42px;
  height: 40px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  background: #ffffff;
  color: var(--muted);
  cursor: pointer;
  font-size: 15px;
}

.combo-toggle:hover {
  background: #f3f4f6;
}

.combo-dropdown {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 6px);
  z-index: 50;
  max-height: 240px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.14);
}

.combo-option {
  padding: 12px;
  border-bottom: 1px solid var(--border);
  font-size: 16px;
  line-height: 1.35;
  cursor: pointer;
}

.combo-option:last-child {
  border-bottom: none;
}

.combo-option:hover {
  background: #f3f4f6;
}

.combo-option-empty {
  color: var(--muted);
  cursor: default;
}

.combo-option-empty:hover {
  background: #ffffff;
}

.combo-option-clear {
  color: var(--danger-dark);
}

/* Emergency pages */
.per-point-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.per-point-button {
  width: 44px;
  height: 40px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  background: var(--control-bg);
  color: var(--text);
  cursor: pointer;
  font-size: 16px;
  font-weight: 700;
}

.per-point-button:hover:not(:disabled) {
  background: #f3f4f6;
  color: var(--text);
}

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

.per-point-button:disabled {
  opacity: 0.65;
  cursor: default;
}

.per-point-stepper {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  max-width: 100%;
}

.per-point-stepper-input {
  width: 54px;
  height: 40px;
  min-width: 0;
  padding: 6px 8px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  background: var(--control-bg);
  color: var(--text);
  font-size: 16px;
  font-weight: 700;
  line-height: 1.2;
  text-align: center;
  outline: none;
}

.per-point-stepper-input:focus {
  border-color: var(--accent);
  box-shadow: var(--focus-ring);
}

.per-point-stepper-input:disabled {
  opacity: 0.65;
  cursor: default;
}

.per-point-stepper-input[type='number'] {
  appearance: textfield;
  -moz-appearance: textfield;
}

.per-point-stepper-input::-webkit-outer-spin-button,
.per-point-stepper-input::-webkit-inner-spin-button {
  margin: 0;
  -webkit-appearance: none;
}

.list-header {
  display: grid;
  grid-template-columns: 180px minmax(0, 1fr) 180px;
  gap: 16px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

.emergency-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.emergency-row {
  display: grid;
  grid-template-columns: 180px minmax(0, 1fr) 180px;
  gap: 16px;
  align-items: start;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--card);
  color: var(--text);
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: background 0.15s ease, border-color 0.15s ease;
}

.emergency-row:hover {
  background: #f9fafb;
  border-color: #cbd5e1;
}

.emergency-row > * {
  min-width: 0;
  overflow-wrap: anywhere;
}

.emergency-id {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  word-break: break-word;
}

.points-column {
  gap: 4px;
  white-space: normal;
}

.point-line {
  line-height: 1.4;
}

.points-per-point-list {
  gap: 10px;
}

.point-per-point-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--card);
}

.point-per-point-name {
  min-width: 0;
  overflow-wrap: anywhere;
  color: var(--text);
}

.point-per-point-buttons {
  flex-wrap: nowrap;
}

.posts-container {
  padding-top: 24px;
  border-top: 1px solid var(--border);
}

.posts-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.posts-header h2 {
  margin: 0;
  color: var(--title);
  font-size: 16px;
  line-height: 1.25;
}

.posts-actions {
  justify-content: flex-end;
}

.posts-table-wrapper {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.posts-table {
  width: max-content;
  min-width: 100%;
  border-collapse: collapse;
  background: var(--card);
  table-layout: auto;
}

.posts-table th,
.posts-table td {
  padding: 11px 12px;
  border: 1px solid var(--border);
  text-align: left;
  font-size: 14px;
  line-height: 1.4;
  white-space: nowrap;
  overflow-wrap: normal;
  word-break: normal;
}

.posts-table th {
  background: #f9fafb;
  color: var(--muted);
  font-weight: 700;
}


@media (max-width: 560px) {
  body {
    --page-margin: 0;
    --page-padding: 7px;
    max-width: none;
    font-size: 20px;
    line-height: 1.55;
  }

  .app {
    min-height: 100svh;
    border: none;
    border-radius: 0;
    box-shadow: none;
    background: var(--bg);
  }

  .card {
    padding: 10px;
    border-radius: 15px;
    border-color: var(--border-strong);
    box-shadow: var(--shadow-md);
  }

  .header {
    position: sticky;
    top: 0;
    z-index: 20;
    padding: 7px;
  }

  .content {
    padding: 10px;
  }

  h1,
  .header h1,
  #formTitle {
    font-size: 18px;
    line-height: 1.15;
    letter-spacing: -0.015em;
    padding: 7px;
  }

  .back-button {
    width: 26px;
    height: 26px;
  }

  .back-icon {
    width: 26px;
    height: 26px;
  }

  .status,
  .loading,
  .empty-list,
  .empty-list-message,
  .inline-error {
    padding: 20px;
    border-radius: 16px;
    font-size: 20px;
    line-height: 1.5;
  }

  .actions,
  .actions-split,
  .posts-actions {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }

  .primary-button,
  .main-button,
  .secondary-button,
  .danger-button,
  .toolbar-add-button {
    width: 100%;
    border-radius: 12px;
    font-size: 16px;
  }

  .card .main-button,
  .card .secondary-button,
  .card .danger-button {
    font-size: 16px;
  }

  label {
    margin-bottom: 13px;
    font-size: 16px;
    line-height: 1.3;
    letter-spacing: -0.01em;
  }

  textarea {
    padding: 10px;
    border-radius: 16px;
    font-size: 18px;
    line-height: 1.42;
    letter-spacing: -0.015em;
  }

  #emergencyText {
    min-height: 160px;
  }

  .form-row {
    margin-bottom: 26px;
  }

  .employee-card {
    border-radius: 12px;
    border-color: var(--border-strong);
    box-shadow: var(--shadow-md);
  }

  .employee-name {
    font-size: 16px;
    line-height: 1.15;
    letter-spacing: -0.02em;
  }

  .employee-destination {
    font-size: 15px;
    line-height: 1.32;
  }

  .employee-form {
    gap: 20px;
  }

  .field {
    border-radius: 18px;
    border-color: var(--border-strong);
  }

  .field label {
    margin-bottom: 12px;
    font-size: 16px;
  }

  .field input,
  .field textarea {
    font-size: 18px;
    line-height: 1.45;
  }

  .field textarea {
    min-height: 100px;
  }

  .hint {
    margin-top: 12px;
    font-size: 16px;
  }

  .list-toolbar-actions {
    justify-content: stretch;
  }

  .list-search-label {
    font-size: 16px;
  }

  .list-search-input,
  .employee-search-input {
    border-radius: 12px;
    padding: 13px 16px;
    font-size: 15px;
  }

  .combo-input-row {
    gap: 12px;
  }

  .combo-toggle {
    width: 35px;
    height: 35px;
    border-radius: 10px;
    font-size: 22px;
  }

.combo-dropdown {
  position: static;
  max-height: 430px;
  margin-top: 8px;
  border-radius: 12px;
}

  .combo-option {
    padding: 22px;
    font-size: 18px;
    line-height: 1.3;
  }

  .per-point-buttons,
  .per-point-stepper {
    gap: 5px;
  }

  .per-point-button {
    width: 35px;
    height: 35px;
    border-radius: 7px;
    font-size: 18px;
  }

  .per-point-stepper-input {
    width: 45px;
    height: 35px;
    border-radius: 7px;
    font-size: 18px;
  }

  #listContent,
  .posts-table-wrapper {
    width: 100%;
    overflow-x: auto;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 12px;
  }

  #listContent {
    display: grid;
    grid-template-columns: max-content max-content minmax(110px, max-content);
    column-gap: 10px;
    row-gap: 14px;
    align-items: start;
  }

  .list-header,
  .emergency-row {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: subgrid;
    width: max-content;
    min-width: 100%;
    margin-inline: 0;
  }

  .emergency-list {
    display: contents;
  }

  .list-header {
    padding: 16px 18px;
    font-size: 16px;
    line-height: 1.2;
    white-space: nowrap;
    align-items: end;
  }

  .list-header > *,
  .emergency-row > * {
    min-width: max-content;
    overflow-wrap: normal;
    word-break: normal;
  }

  .list-header > :nth-child(1),
  .emergency-row > :nth-child(1)
   {
    text-align: center;
  }

  .list-header > :nth-child(2),
  .list-header > :nth-child(3),
  .emergency-row > :nth-child(2),
  .emergency-row > :nth-child(3) 
  {
    text-align: left;
  }

  .list-header > :nth-child(3) {
    min-width: 110px;
    max-width: 110px;
    white-space: normal;
    overflow-wrap: anywhere;
    word-break: normal;
  }

  .emergency-row {
    padding: 22px 18px;
    border-radius: 18px;
    border-color: var(--border-strong);
    font-size: 32px;
    line-height: 1.24;
    letter-spacing: -0.02em;
    box-shadow: var(--shadow-md);
  }

  .emergency-id,
  .emergency-row > :nth-child(1),
  .emergency-row > :nth-child(3) {
    font-size: 18px;
    line-height: 1.24;
  }

  .emergency-row > :nth-child(3) {
    min-width: 110px;
    width: max-content;
    white-space: nowrap;
  }

  .points-column {
    gap: 10px;
    text-align: left;
  }

  .point-line {
    white-space: nowrap;
    overflow-wrap: normal;
    word-break: normal;
  }

  .point-line,
  .point-per-point-name {
    font-size: 18px;
    line-height: 1.24;
    letter-spacing: -0.02em;
    align-content: center;
  }

  .point-per-point-row {
    align-items: stretch;
    gap: 7px;
    padding: 7px;
    border-radius: 10px;
  }

  .point-per-point-row .per-point-stepper {
    width: 100%;
  }

  .point-per-point-buttons {
  justify-content: flex-start;
  }


  .posts-header {
    align-items: stretch;
    flex-direction: column;
    gap: 16px;
  }

  .posts-header h2 {
    font-size: 16px;
    line-height: 1.15;
    letter-spacing: -0.02em;
  }

  .posts-table {
    width: max-content;
    min-width: 100%;
    table-layout: auto;
  }

  .posts-table th,
  .posts-table td {
    padding: 18px 20px;
    font-size: 18px;
    line-height: 1.35;
    white-space: nowrap;
    overflow-wrap: normal;
    word-break: normal;
  }

  .posts-table th {
    font-size: 16px;
    line-height: 1.25;
    white-space: nowrap;
  }
}
