.page-head,
.detail-head,
.section-head {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 16px;
}

.page-head h1,
.detail-head h1,
.section-head h2,
.section-head h3 {
  margin: 0;
}

.page-head p,
.detail-head p,
.section-head p {
  margin: 6px 0 0;
  color: var(--color-text-muted);
}

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

.app-messages {
  width: 100%;
  display: grid;
  gap: 12px;
}

.app-message {
  padding: 14px 16px;
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  color: var(--color-text);
  box-shadow: var(--shadow-card);
}

.app-message--success {
  border-color: #bbf7d0;
  background: #f0fdf4;
  color: #166534;
}

.app-message--error {
  border-color: #fecaca;
  background: #fef2f2;
  color: #b91c1c;
}

.app-message--warning {
  border-color: #fcd34d;
  background: #fffbeb;
  color: #92400e;
}

.app-message--info {
  border-color: #bfdbfe;
  background: #eff6ff;
  color: #1d4ed8;
}

.card,
.detail-card,
.form-card,
.auth-card,
.table-card {
  width: 100%;
  min-width: 0;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
}

.app-page > * {
  width: 100%;
  min-width: 0;
  max-width: none;
}

.card,
.detail-card,
.form-card,
.auth-card {
  padding: 20px;
}

.table-card {
  padding: 20px 22px;
  overflow-x: auto;
}

.table-card--wide {
  overflow-x: visible;
}

.table-card table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

.table-card th,
.table-card td {
  padding: 12px 14px;
  text-align: left;
  vertical-align: top;
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;
  border-bottom: 1px solid var(--color-border);
}

.table-card th {
  background: var(--color-surface-soft);
  color: var(--color-text-muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.table-card tbody tr:hover {
  background: #fafafa;
}

.table-card tr:last-child td {
  border-bottom: 0;
}

.table-card .actions {
  justify-content: flex-end;
}

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  padding: 24px;
  color: var(--color-text-muted);
}

.empty-state__title {
  margin: 0;
  color: var(--color-text);
  font-size: 16px;
  font-weight: 800;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 10px;
  border-radius: 999px;
  border: 1px solid transparent;
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
}

.status-badge--success,
.status-badge.status-success {
  background: #ecfdf3;
  color: #027a48;
  border-color: #d1fadf;
}

.status-badge--warning,
.status-badge.status-warning {
  background: #fffaeb;
  color: #b54708;
  border-color: #fef0c7;
}

.status-badge--danger,
.status-badge.status-danger {
  background: #fef3f2;
  color: #b42318;
  border-color: #fecaca;
}

.status-badge--info,
.status-badge.status-info {
  background: #eff6ff;
  color: #1d4ed8;
  border-color: #dbeafe;
}

.status-badge--neutral,
.status-badge.status-neutral {
  background: #f3f4f6;
  color: #4b5563;
  border-color: #e5e7eb;
}

.status-badge--primary,
.status-badge.status-primary {
  background: var(--color-primary-soft);
  color: var(--color-primary-dark);
  border-color: rgba(109, 74, 255, 0.16);
}

.card-title {
  margin: 0 0 16px;
  font-size: 16px;
  font-weight: 700;
  color: var(--color-text);
}

.text-muted {
  margin: 0;
  color: var(--color-text-muted);
  font-size: 13px;
  line-height: 1.5;
}

.form-label {
  display: block;
  margin: 0 0 6px;
  font-size: 13px;
  font-weight: 500;
  color: #374151;
}

.form-input {
  width: 100%;
  min-height: 40px;
  padding: 0 12px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  font-size: 13px;
  color: var(--color-text);
}

.form-stack,
.driver-form {
  display: grid;
  gap: 14px;
  max-width: 520px;
}

.table-card .form-stack,
.table-card .driver-form {
  max-width: none;
}

.table {
  width: 100%;
  border-collapse: collapse;
}

.table th,
.table td {
  padding: 12px 14px;
  text-align: left;
  vertical-align: top;
  border-bottom: 1px solid var(--color-border);
  font-size: 13px;
}

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

.table tbody tr:hover {
  background: #fafafa;
}

.table tr:last-child td {
  border-bottom: 0;
}

.form-stack--wide,
.driver-form--wide {
  max-width: none;
}

.form-stack .form-field,
.driver-form .form-field {
  display: grid;
  gap: 6px;
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 4px;
  padding-top: 4px;
}

.form-stack > .primary-button,
.form-stack > .secondary-button,
.driver-form > .primary-button,
.driver-form > .secondary-button {
  justify-self: start;
  margin-top: 2px;
}

.page-head .actions {
  margin-left: auto;
}

.nav-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nav-group__label {
  padding: 8px 14px 2px;
  color: var(--color-text-soft);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.nav-subitem {
  display: flex;
  align-items: center;
  min-height: 36px;
  padding: 0 14px 0 22px;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  color: #4b5563;
  font-size: 13px;
  font-weight: 600;
}

.nav-subitem:hover {
  background: #f9fafb;
  color: var(--color-text);
}

.nav-subitem.active {
  background: var(--color-primary-soft);
  color: var(--color-primary-dark);
  border-color: rgba(109, 74, 255, 0.16);
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
  margin: 0;
}

.detail-grid div {
  padding: 14px;
  border: 1px solid var(--color-border);
  border-radius: 12px;
  background: var(--color-surface-soft);
}

.detail-grid dt {
  margin-bottom: 6px;
  color: var(--color-text-muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.detail-grid dd {
  margin: 0;
  font-weight: 700;
}

.form-card form,
.auth-card form {
  display: grid;
  gap: 14px;
}

.form-card form p,
.auth-card form p {
  display: grid;
  gap: 6px;
  margin: 0;
}

.form-card ul.errorlist,
.auth-card ul.errorlist {
  margin: 0;
  padding-left: 18px;
  color: var(--color-danger);
}

.form-errors {
  padding: 12px 14px;
  border-radius: 10px;
  background: #fef2f2;
  color: #b42318;
  border: 1px solid #fecaca;
  margin-bottom: 14px;
}

.auth-card {
  width: min(460px, 100%);
  margin: 0 auto;
}

.auth-note {
  margin: 0 0 16px;
  color: var(--color-text-muted);
}

.table-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.inline-form {
  display: inline-flex;
  margin: 0;
}

.inline-form button {
  min-height: 36px;
}

.segmented-control {
  display: inline-flex;
  padding: 4px;
  border: 1px solid var(--color-border);
  border-radius: 10px;
  background: #f9fafb;
  gap: 4px;
}

.segmented-control__item {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  padding: 0 14px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--color-text-muted);
  text-decoration: none;
}

.segmented-control__item.is-active {
  background: #fff;
  color: var(--color-text);
  box-shadow: var(--shadow-card);
}

.app-modal {
  border: none;
  border-radius: var(--radius-lg);
  padding: 0;
  width: min(96vw, 640px);
  max-height: 90vh;
  overflow: hidden;
  box-shadow: 0 20px 40px rgba(15, 23, 42, 0.18);
}

.app-modal--wide {
  width: min(96vw, 920px);
}

.app-modal::backdrop {
  background: rgba(17, 24, 39, 0.45);
}

.app-modal__inner {
  padding: 24px;
  max-height: 90vh;
  overflow: auto;
}

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

.icon-button {
  width: 36px;
  height: 36px;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  background: #fff;
  color: var(--color-text-muted);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}

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