.button,
.icon-button {
  display: inline-flex;
  min-height: 36px;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
  border-radius: 8px;
  font-weight: 700;
  line-height: 1.2;
}

.button {
  gap: 7px;
  padding: 0 12px;
}

.button-primary {
  background: var(--color-accent);
  color: var(--color-accent-text);
}

.button-secondary {
  border-color: var(--color-border);
  background: var(--color-surface);
  color: var(--color-text);
}

.button-ghost {
  border-color: var(--color-border);
  background: transparent;
  color: var(--color-text);
}

.button-success {
  border-color: #15803d;
  background: #16a34a;
  color: #fff;
}

.button-danger {
  border-color: #b91c1c;
  background: #dc2626;
  color: #fff;
}

.icon-button {
  min-width: 38px;
  padding: 0 9px;
  border-color: var(--color-border);
  background: var(--color-surface);
  color: var(--color-text);
}

.action-icon {
  width: 36px;
  min-width: 36px;
  min-height: 36px;
  padding: 0;
  text-decoration: none;
}

.action-icon svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.action-danger {
  border-color: #f3b3ad;
  color: #b42318;
}

[data-theme="dark"] .action-danger {
  border-color: #7f2d27;
  color: #ffb4ad;
}

.app-theme-switch {
  display: inline-flex;
  min-height: 36px;
  align-items: center;
  gap: 6px;
  padding: 0 8px;
  border: 1px solid var(--color-border);
  border-radius: 999px;
  background: var(--color-surface);
  color: var(--color-text);
  cursor: pointer;
}

.app-theme-switch:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--color-accent) 35%, transparent);
  outline-offset: 2px;
}

.app-theme-icon {
  display: inline-grid;
  width: 18px;
  height: 18px;
  place-items: center;
  color: var(--color-muted);
  font-size: 14px;
  line-height: 1;
}

.app-theme-track {
  position: relative;
  display: inline-flex;
  width: 38px;
  height: 20px;
  align-items: center;
  border-radius: 999px;
  background: var(--color-bg-soft);
  box-shadow: inset 0 0 0 1px var(--color-border);
}

.app-theme-thumb {
  position: absolute;
  left: 3px;
  width: 14px;
  height: 14px;
  border-radius: 999px;
  background: var(--color-accent);
  box-shadow: 0 2px 6px rgba(15, 23, 42, 0.24);
  transition: transform 0.2s ease;
}

.app-theme-switch[data-theme-active="dark"] .app-theme-thumb {
  transform: translateX(18px);
}

.app-theme-switch[data-theme-active="light"] .app-theme-sun,
.app-theme-switch[data-theme-active="dark"] .app-theme-moon {
  color: var(--color-accent);
}

.topbar-panels {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.topbar-panel-wrapper {
  position: relative;
}

.topbar-panel-button {
  position: relative;
  display: inline-flex;
  min-height: 36px;
  align-items: center;
  gap: 7px;
  padding: 0 9px;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  background: var(--color-surface);
  color: var(--color-text);
  font-weight: 700;
}

.topbar-panel-icon {
  display: inline-grid;
  width: 18px;
  height: 18px;
  place-items: center;
  font-size: 15px;
  line-height: 1;
}

.topbar-panel-label {
  font-size: 13px;
}

.notification-badge,
.alert-badge,
.attendance-badge {
  display: inline-grid;
  min-width: 18px;
  height: 18px;
  place-items: center;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--color-bg-soft);
  color: var(--color-muted);
  font-size: 10px;
  font-weight: 800;
  line-height: 1;
}

.alert-badge {
  background: #fee2e2;
  color: #b91c1c;
}

[data-theme="dark"] .alert-badge {
  background: rgba(220, 38, 38, 0.22);
  color: #fecaca;
}

.topbar-floating-panel {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  z-index: 40;
  display: grid;
  width: min(360px, calc(100vw - 32px));
  gap: 14px;
  padding: 16px;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  background: var(--color-surface);
  box-shadow: var(--shadow-strong);
}

.topbar-floating-panel[hidden] {
  display: none;
}

.topbar-floating-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.topbar-floating-panel-header h2 {
  font-size: 16px;
}

.topbar-panel-empty {
  color: var(--color-muted);
  font-size: 14px;
}

.topbar-notification-list {
  display: grid;
  max-height: min(440px, calc(100vh - 160px));
  gap: 10px;
  overflow-y: auto;
  padding-right: 2px;
}

.topbar-notification-card {
  display: grid;
  gap: 8px;
  border: 1px solid var(--color-border);
  border-left: 4px solid var(--color-muted);
  border-radius: 8px;
  padding: 12px;
  background: var(--color-bg-soft);
}

.topbar-notification-unread {
  background: color-mix(in srgb, var(--color-primary) 8%, var(--color-bg-soft));
}

.topbar-notification-card-header,
.topbar-notification-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.topbar-notification-card p {
  margin: 0;
  font-size: 13px;
}

.topbar-notification-type {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 0 8px;
  border-radius: 999px;
  background: var(--color-surface);
  color: var(--color-text);
  font-size: 11px;
  font-weight: 800;
}

.topbar-notification-date {
  color: var(--color-muted);
  font-size: 12px;
  font-weight: 700;
}

.topbar-notification-card-info {
  border-left-color: #2563eb;
}

.topbar-notification-card-success {
  border-left-color: #16a34a;
}

.topbar-notification-card-warning,
.topbar-notification-card-approval_request {
  border-left-color: #f59e0b;
}

.topbar-notification-card-danger {
  border-left-color: #dc2626;
}

.topbar-notification-actions .button {
  min-height: 32px;
  padding: 0 10px;
  font-size: 12px;
}

.topbar-alert-list {
  display: grid;
  max-height: min(440px, calc(100vh - 160px));
  gap: 10px;
  overflow-y: auto;
  padding-right: 2px;
}

.topbar-alert-card {
  display: grid;
  gap: 8px;
  border: 1px solid var(--color-border);
  border-left: 4px solid var(--color-muted);
  border-radius: 8px;
  padding: 12px;
  background: var(--color-bg-soft);
}

.topbar-alert-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.topbar-alert-source,
.topbar-alert-date {
  color: var(--color-muted);
  font-size: 12px;
  font-weight: 700;
}

.topbar-alert-severity {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 0 8px;
  border-radius: 999px;
  background: var(--color-surface);
  color: var(--color-text);
  font-size: 11px;
  font-weight: 800;
}

.topbar-alert-card p {
  font-size: 13px;
}

.topbar-alert-card .button {
  width: fit-content;
  min-height: 34px;
}

.topbar-alert-card-critical {
  border-left-color: #dc2626;
}

.topbar-alert-card-urgent {
  border-left-color: #f97316;
}

.topbar-alert-card-warning {
  border-left-color: #f59e0b;
}

.topbar-alert-card-info {
  border-left-color: #2563eb;
}

.topbar-attendance-list {
  display: grid;
  max-height: min(460px, calc(100vh - 160px));
  gap: 10px;
  overflow-y: auto;
  padding-right: 2px;
}

.topbar-attendance-card {
  display: grid;
  gap: 8px;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: 12px;
  background: var(--color-bg-soft);
}

.topbar-attendance-card-header,
.topbar-attendance-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.topbar-attendance-client,
.topbar-attendance-occurrence {
  margin: 0;
}

.topbar-attendance-client {
  font-weight: 800;
}

.topbar-attendance-occurrence {
  color: var(--color-muted);
  font-size: 13px;
}

.topbar-attendance-meta {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 4px 10px;
  color: var(--color-muted);
  font-size: 12px;
}

.topbar-attendance-meta strong {
  color: var(--color-text);
}

.topbar-attendance-technician {
  display: grid;
  flex: 1 1 160px;
  min-width: 160px;
  gap: 4px;
  color: var(--color-muted);
  font-size: 12px;
  font-weight: 700;
}

.topbar-attendance-technician select {
  min-height: 38px;
  width: 100%;
}

.notification-panel,
.alert-panel,
.attendance-panel {
  min-height: 138px;
}

.alert-critical {
  border: 1px solid #dc2626;
  border-radius: 8px;
  padding: 10px;
  background: #fef2f2;
  color: #991b1b;
  font-weight: 700;
}

[data-theme="dark"] .alert-critical {
  background: rgba(127, 29, 29, 0.3);
  color: #fecaca;
}

.alert-blink {
  color: #dc2626;
}

.attendance-active {
  display: grid;
  gap: 8px;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: 10px;
  background: var(--color-bg-soft);
}

@media (prefers-reduced-motion: no-preference) {
  .alert-blink {
    animation: alert-blink 1.2s infinite;
  }
}

@keyframes alert-blink {
  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: 0.38;
  }
}

@media (max-width: 1120px) {
  .topbar-panel-label {
    display: none;
  }
}

@media (max-width: 720px) {
  .topbar-actions {
    gap: 8px;
  }

  .topbar-panels {
    flex: 1 1 auto;
    justify-content: space-between;
    gap: 8px;
  }

  .topbar-panel-button {
    min-width: 48px;
    min-height: 46px;
    padding: 0 10px;
    border-radius: 10px;
  }

  .topbar-panel-wrapper:nth-child(3) .topbar-panel-button {
    min-width: 56px;
    border-color: color-mix(in srgb, var(--color-accent) 48%, var(--color-border));
    background: color-mix(in srgb, var(--color-accent) 13%, var(--color-surface));
    box-shadow: 0 8px 18px rgb(0 0 0 / 0.12);
  }

  .topbar-panel-icon {
    width: 22px;
    height: 22px;
    font-size: 18px;
  }

  .topbar-panel-badge {
    position: absolute;
    top: -7px;
    right: -7px;
    min-width: 20px;
    height: 20px;
    border: 2px solid var(--color-surface);
    font-size: 10px;
  }

  .topbar-floating-panel {
    position: fixed;
    top: 104px;
    right: 10px;
    left: 10px;
    width: auto;
    max-height: calc(100dvh - 118px);
    overflow-y: auto;
    padding: 12px;
    border-radius: 10px;
  }

  .topbar-notification-list,
  .topbar-alert-list,
  .topbar-attendance-list {
    max-height: none;
    padding-right: 0;
  }

  .topbar-notification-card,
  .topbar-alert-card,
  .topbar-attendance-card {
    padding: 11px;
  }

  .topbar-notification-card-header,
  .topbar-notification-actions,
  .topbar-alert-card-header,
  .topbar-attendance-card-header,
  .topbar-attendance-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar-notification-actions .button,
  .topbar-alert-card .button,
  .topbar-attendance-actions .button {
    width: 100%;
    min-height: 44px;
    font-size: 14px;
  }

  .topbar-attendance-technician {
    width: 100%;
  }

  .topbar-attendance-actions .button-success {
    box-shadow: 0 8px 18px rgb(22 163 74 / 0.22);
  }

  .topbar-attendance-actions .button-danger {
    box-shadow: 0 8px 18px rgb(220 38 38 / 0.22);
  }

  .topbar-attendance-meta {
    grid-template-columns: 1fr;
    font-size: 13px;
  }

  .notification-badge,
  .alert-badge,
  .attendance-badge {
    min-width: 20px;
    height: 20px;
  }
}

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

.metric-card,
.panel {
  border: 1px solid var(--color-border);
  border-radius: 8px;
  background: var(--color-surface);
  box-shadow: var(--shadow-soft);
}

.metric-card {
  display: grid;
  gap: 6px;
  min-height: 112px;
  padding: 14px;
}

.metric-label,
.metric-note {
  color: var(--color-muted);
  font-size: 13px;
}

.metric-value {
  color: var(--color-text);
  font-size: 28px;
  line-height: 1;
}

.metric-card-warning {
  border-color: #f59e0b;
  background: #fffbeb;
}

.dashboard-header {
  margin-bottom: 16px;
}

.dashboard-module-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.dashboard-module-card,
.dashboard-summary-card,
.dashboard-quick-action {
  border: 1px solid var(--color-border);
  border-radius: 8px;
  background: var(--color-surface);
  box-shadow: var(--shadow-soft);
}

.dashboard-module-card {
  display: grid;
  min-height: 116px;
  gap: 8px;
  padding: 14px;
  color: var(--color-text);
  text-decoration: none;
  transition: border-color 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}

.dashboard-module-card:hover,
.dashboard-module-card:focus-visible,
.dashboard-quick-action:hover,
.dashboard-quick-action:focus-visible {
  border-color: color-mix(in srgb, var(--color-accent) 42%, var(--color-border));
  box-shadow: 0 12px 26px rgb(15 23 42 / 0.1);
  transform: translateY(-1px);
}

.dashboard-module-icon,
.dashboard-summary-icon,
.dashboard-quick-action span {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 8px;
  background: color-mix(in srgb, var(--color-accent) 12%, var(--color-surface));
  color: var(--color-accent);
  font-size: 12px;
  font-weight: 800;
}

.dashboard-module-card strong {
  font-size: 15px;
}

.dashboard-module-card > span:last-child {
  color: var(--color-muted);
  font-size: 12px;
  line-height: 1.35;
}

.dashboard-content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(260px, 340px);
  gap: 14px;
}

.dashboard-panel {
  padding: 16px;
}

.dashboard-operational-grid,
.dashboard-quick-actions {
  display: grid;
  gap: 10px;
}

.dashboard-operational-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.dashboard-summary-card {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  min-height: 78px;
  padding: 12px;
}

.dashboard-summary-card strong,
.dashboard-summary-card span,
.dashboard-quick-action strong {
  display: block;
}

.dashboard-summary-card strong {
  color: var(--color-text);
  font-size: 14px;
}

.dashboard-summary-card span {
  margin-top: 4px;
  color: var(--color-muted);
  font-size: 12px;
}

.dashboard-quick-action {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 46px;
  padding: 8px 10px;
  color: var(--color-text);
  text-decoration: none;
  transition: border-color 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}

.dashboard-quick-action span {
  width: 30px;
  height: 30px;
}

.dashboard-quick-action strong {
  font-size: 13px;
}

@media (max-width: 1180px) {
  .dashboard-module-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 860px) {
  .dashboard-module-grid,
  .dashboard-operational-grid,
  .dashboard-content-grid {
    grid-template-columns: 1fr;
  }
}

.stock-summary-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

.stock-summary-grid .metric-card {
  min-height: 86px;
  gap: 4px;
  padding: 12px 14px;
}

.stock-summary-grid .metric-value {
  font-size: 24px;
}

.stock-summary-grid .metric-label,
.stock-summary-grid .metric-note {
  font-size: 12px;
}

[data-theme="dark"] .metric-card-warning {
  border-color: #fbbf24;
  background: rgba(245, 158, 11, 0.12);
}

.panel {
  padding: 14px;
}

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

.panel-header p {
  margin-top: 4px;
  font-size: 13px;
}

.table-wrap {
  max-width: 100%;
  max-height: min(68vh, 720px);
  overflow-x: auto;
  overflow-y: auto;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  background: var(--color-surface);
  scrollbar-color: color-mix(in srgb, var(--color-accent) 44%, var(--color-border)) transparent;
  scrollbar-width: thin;
}

.table-wrap::-webkit-scrollbar {
  width: 7px;
  height: 7px;
}

.table-wrap::-webkit-scrollbar-track {
  background: transparent;
}

.table-wrap::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: color-mix(in srgb, var(--color-accent) 36%, var(--color-border));
}

.table-wrap::-webkit-scrollbar-thumb:hover {
  background: color-mix(in srgb, var(--color-accent) 58%, var(--color-border));
}

.data-table {
  width: 100%;
  min-width: 640px;
  border-collapse: collapse;
  background: var(--color-surface);
}

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

.data-table th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: color-mix(in srgb, var(--color-surface) 92%, var(--color-bg-soft));
  color: var(--color-muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  box-shadow: 0 1px 0 var(--color-border);
}

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

.data-table tbody tr:nth-child(even),
[data-table-style="zebra"] .data-table tbody tr:nth-child(even) {
  background: color-mix(in srgb, var(--color-bg-soft) 72%, transparent);
}

.data-table tbody tr:hover {
  background: color-mix(in srgb, var(--color-accent) 7%, var(--color-bg-soft));
}

.data-table td:last-child .table-actions,
.data-table td:last-child .stock-action-wrapper {
  justify-content: flex-end;
}

[data-table-style="compact"] .data-table th,
[data-table-style="compact"] .data-table td,
[data-density="compact"] .data-table th,
[data-density="compact"] .data-table td {
  padding: 7px 8px;
}

[data-theme="dark"] .data-table th {
  background: color-mix(in srgb, var(--color-surface) 88%, var(--color-bg));
}

[data-theme="dark"] .data-table tbody tr:nth-child(even) {
  background: color-mix(in srgb, var(--color-bg-soft) 58%, transparent);
}

[data-theme="dark"] .data-table tbody tr:hover {
  background: color-mix(in srgb, var(--color-accent) 10%, var(--color-bg-soft));
}

[data-density="compact"] .panel,
[data-density="compact"] .metric-card,
[data-density="compact"] .detail-grid div {
  padding: 12px;
}

[data-density="comfortable"] .panel,
[data-density="comfortable"] .metric-card,
[data-density="comfortable"] .detail-grid div {
  padding: 20px;
}

.empty-row td {
  color: var(--color-muted);
  text-align: center;
}

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

.appointment-empty {
  padding: 18px;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  color: var(--color-muted);
  text-align: center;
}

.appointment-card {
  display: grid;
  gap: 0;
  padding: 10px 10px 0;
  border: 1px solid var(--color-border);
  border-left: 4px solid #1d4ed8;
  border-radius: 8px;
  background: var(--color-surface);
  box-shadow: var(--shadow-soft);
}

.appointment-card-status-open {
  border-left-color: #1d4ed8;
}

.appointment-card-status-in_progress {
  border-left-color: #a16207;
}

.appointment-card-status-completed {
  border-left-color: #15803d;
}

.appointment-card-status-closed {
  border-left-color: #0f766e;
}

.appointment-card-status-cancelled {
  border-left-color: #b91c1c;
}

.service-order-status-open {
  border-left-color: #1d4ed8;
}

.service-order-status-in_progress {
  border-left-color: #a16207;
}

.service-order-status-awaiting_approval {
  border-left-color: #c2410c;
}

.service-order-status-awaiting_quote {
  border-left-color: #9a3412;
}

.service-order-status-external_repair {
  border-left-color: #7e22ce;
}

.service-order-status-completed {
  border-left-color: #15803d;
}

.service-order-status-closed {
  border-left-color: #64748b;
}

.service-order-status-cancelled {
  border-left-color: #b91c1c;
}

.appointment-card-main {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  align-items: start;
}

.appointment-card-title {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.appointment-card-title strong {
  color: var(--color-text);
  font-size: 15px;
}

.sequence-number-button {
  display: inline-flex;
  width: fit-content;
  border: 0;
  padding: 0;
  background: transparent;
  color: var(--color-text);
  cursor: pointer;
  font: inherit;
  font-size: 15px;
  font-weight: 700;
}

.sequence-number-button:hover,
.sequence-number-button:focus-visible {
  color: var(--color-primary);
  text-decoration: underline;
}

.sequence-number-heading {
  font-size: inherit;
}

.appointment-card-title span {
  color: var(--color-muted);
  font-size: 13px;
}

.appointment-card-controls {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.appointment-card-actions {
  gap: 8px;
}

.appointment-card-actions .action-icon {
  min-height: 34px;
  width: 38px;
  min-width: 38px;
}

.appointment-card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  padding: 8px 0;
  color: var(--color-muted);
  font-size: 13px;
}

.appointment-card-meta strong {
  color: var(--color-text);
}

.appointment-card-section {
  padding: 9px 0;
  border-top: 1px solid var(--color-border);
}

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

.appointment-card-section strong {
  color: var(--color-text);
}

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

.component-list span {
  padding: 10px 12px;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  color: var(--color-muted);
  background: var(--color-bg-soft);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: clamp(10px, 2vh, 18px);
  background: rgb(15 23 42 / 0.45);
  overflow: hidden;
}

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

.modal {
  display: grid;
  width: min(460px, 100%);
  max-height: min(88vh, 760px);
  grid-template-rows: auto minmax(0, 1fr) auto;
  overflow: hidden;
  border: 1px solid var(--color-border);
  border-radius: 10px;
  background: var(--color-surface);
  box-shadow: var(--shadow-strong);
}

.modal-wide {
  width: min(760px, 100%);
}

.modal-permissions {
  width: min(940px, 100%);
  max-height: min(92vh, 820px);
}

.modal-permissions .modal-body {
  padding: 10px 12px;
}

.modal-client {
  width: min(980px, 100%);
}

.modal-client .modal-header,
.modal-client .modal-footer {
  padding: 10px 12px;
}

.modal-client .modal-body {
  max-height: none;
  padding: 12px;
}

.modal-header,
.modal-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 14px;
  background: var(--color-surface);
}

.modal-header {
  border-bottom: 1px solid var(--color-border);
}

.modal-header h2 {
  margin: 0;
  color: var(--color-text);
  font-size: 17px;
  line-height: 1.25;
}

.modal-header .icon-button {
  flex: 0 0 auto;
  min-width: 34px;
  min-height: 34px;
}

.modal-body {
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  padding: 12px 14px;
  scrollbar-color: color-mix(in srgb, var(--color-accent) 44%, var(--color-border)) transparent;
  scrollbar-width: thin;
}

.modal-body::-webkit-scrollbar {
  width: 7px;
}

.modal-body::-webkit-scrollbar-track {
  background: transparent;
}

.modal-body::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: color-mix(in srgb, var(--color-accent) 36%, var(--color-border));
}

.modal-body::-webkit-scrollbar-thumb:hover {
  background: color-mix(in srgb, var(--color-accent) 58%, var(--color-border));
}

.modal-footer {
  flex-wrap: wrap;
  justify-content: flex-end;
  border-top: 1px solid var(--color-border);
}

.modal-footer-centered {
  gap: 18px;
  justify-content: center;
}

[data-theme="dark"] .modal-backdrop {
  background: rgb(0 0 0 / 0.62);
}

@media (max-width: 720px) {
  .modal-backdrop {
    align-items: stretch;
    padding: 8px;
  }

  .modal,
  .modal-wide,
  .modal-client {
    width: 100%;
    max-height: calc(100vh - 16px);
    max-height: calc(100dvh - 16px);
  }

  .modal-header,
  .modal-footer,
  .modal-client .modal-header,
  .modal-client .modal-footer {
    padding: 10px;
  }

  .modal-body,
  .modal-client .modal-body {
    padding: 10px;
  }

  .modal-footer .button {
    flex: 1 1 auto;
  }
}

.toast-region {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 60;
  display: grid;
  gap: 10px;
  width: min(360px, calc(100vw - 40px));
}

.toast {
  padding: 14px 16px;
  border: 1px solid var(--color-border);
  border-left: 4px solid var(--color-accent);
  border-radius: 8px;
  background: var(--color-surface);
  box-shadow: var(--shadow-strong);
}

.user-badge {
  display: inline-flex;
  min-height: 32px;
  align-items: center;
  padding: 0 10px;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  color: var(--color-accent);
  font-size: 13px;
  font-weight: 700;
}

.filter-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 10px 12px;
  align-items: end;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
  margin: -1px;
  white-space: nowrap;
}

.filter-shell {
  display: grid;
  gap: 8px;
  margin-bottom: 14px;
}

.filter-toolbar {
  display: flex;
  justify-content: flex-end;
}

.filter-toggle-button {
  min-width: 0;
}

.filter-toggle-button svg,
.filter-icon-action svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.filter-icon-action .filter-broom-icon {
  fill: currentColor;
  stroke: none;
}

.filter-panel {
  display: grid;
  grid-template-rows: 0fr;
  opacity: 0;
  transition: grid-template-rows 180ms ease, opacity 160ms ease;
}

.filter-panel.is-open {
  grid-template-rows: 1fr;
  opacity: 1;
}

.filter-panel-inner {
  min-height: 0;
  overflow: hidden;
}

.filter-panel:not(.is-open) .filter-panel-inner {
  visibility: hidden;
  pointer-events: none;
}

.filter-panel.is-open .filter-panel-inner {
  visibility: visible;
  pointer-events: auto;
}

.filter-panel .filter-grid {
  padding: 12px;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  background: var(--color-surface);
  box-shadow: var(--shadow-soft);
}

.filter-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.filter-icon-action {
  width: 38px;
  min-width: 38px;
  padding: 0;
}

.field {
  display: grid;
  gap: 5px;
}

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

.field-wide {
  grid-column: span 2;
}

.checkbox-row {
  display: flex;
  flex-wrap: wrap;
  gap: 7px 10px;
  min-height: 38px;
  align-items: center;
  padding: 7px 9px;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  background: var(--color-bg-soft);
}

.checkbox-inline {
  display: inline-flex;
  gap: 6px;
  align-items: center;
  color: var(--color-muted);
  font-size: 13px;
  font-weight: 600;
}

.checkbox-inline input {
  width: auto;
  min-height: auto;
  padding: 0;
}

.report-action-button {
  align-items: center;
  gap: 7px;
}

.report-visible-actions {
  align-items: center;
}

.report-visible-actions .report-action-button {
  min-height: 40px;
}

.report-action-button svg {
  width: 17px;
  height: 17px;
  flex: 0 0 auto;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

[data-report-preview-panel] .panel-header {
  align-items: center;
}

.report-preview-section {
  display: grid;
  gap: 10px;
  margin-bottom: 18px;
}

.report-preview-section h3 {
  margin: 0;
  color: var(--color-text);
  font-size: 15px;
}

.report-summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.report-metric-card {
  min-height: 78px;
  padding: 12px 14px;
}

.report-metric-card .metric-value {
  font-size: 21px;
}

.report-chart-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

.report-chart-card {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  background: var(--color-bg-soft);
}

.report-chart-card h3 {
  margin: 0;
  color: var(--color-text);
  font-size: 15px;
}

.report-chart-bars {
  display: grid;
  gap: 10px;
}

.report-chart-label {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  color: var(--color-muted);
  font-size: 13px;
}

.report-chart-label strong {
  color: var(--color-text);
}

.report-chart-track {
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--color-border);
}

.report-chart-track span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--color-accent);
}

.report-pie-layout {
  display: grid;
  grid-template-columns: 132px minmax(0, 1fr);
  gap: 14px;
  align-items: center;
}

.report-pie {
  width: 132px;
  aspect-ratio: 1;
  border: 1px solid var(--color-border);
  border-radius: 50%;
  box-shadow: inset 0 0 0 18px var(--color-surface);
}

.report-pie-legend {
  display: grid;
  gap: 8px;
}

.report-pie-legend span {
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--color-muted);
  font-size: 13px;
}

.report-pie-legend i {
  width: 10px;
  height: 10px;
  flex: 0 0 auto;
  border-radius: 50%;
}

.report-pie-legend strong {
  color: var(--color-text);
}

.field input {
  width: 100%;
  min-height: 38px;
  padding: 0 10px;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  background: var(--color-bg-soft);
  color: var(--color-text);
}

.field textarea {
  width: 100%;
  min-height: 92px;
  padding: 9px 10px;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  background: var(--color-bg-soft);
  color: var(--color-text);
  resize: vertical;
}

.field-error {
  color: #b42318;
  font-size: 13px;
}

.field-hint {
  color: var(--color-muted);
  font-size: 12px;
}

.form-message {
  margin-bottom: 12px;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 14px;
}

.form-message-error {
  border: 1px solid #f3b3ad;
  background: #fff1ef;
  color: #9f1f16;
}

.form-message-success {
  border: 1px solid #9bd8c9;
  background: #ecfdf7;
  color: #0b6b58;
}

[data-theme="dark"] .form-message-error {
  border-color: #7f2d27;
  background: #321714;
  color: #ffb4ad;
}

[data-theme="dark"] .form-message-success {
  border-color: #1f7a68;
  background: #102a25;
  color: #89f0d6;
}

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

.settings-form-section {
  grid-column: 1 / -1;
  padding-bottom: 4px;
}

.settings-form-section h3 {
  margin: 0;
  font-size: 16px;
}

.settings-form-section p {
  margin: 4px 0 0;
  color: var(--color-muted);
  font-size: 13px;
}

.settings-card {
  margin-bottom: 16px;
  padding: 14px;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  background: var(--color-bg-soft);
}

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

.backup-action-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 0;
}

.backup-action-form {
  grid-template-columns: minmax(0, 1fr);
  gap: 12px;
}

.backup-action-form .field,
.backup-action-form .form-actions {
  grid-column: 1 / -1;
}

.settings-theme-form input[type="color"] {
  width: 100%;
  min-height: 42px;
  padding: 4px;
}

.settings-password-form {
  max-width: 560px;
  grid-template-columns: minmax(0, 1fr);
}

.settings-password-form .field,
.settings-password-form .password-rules,
.settings-password-form .form-actions {
  grid-column: 1 / -1;
}

.password-rules {
  display: grid;
  gap: 6px;
  padding: 10px 12px;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  background: var(--color-bg-soft);
}

.password-control {
  position: relative;
  display: grid;
}

.password-control input {
  padding-right: 46px;
}

.password-toggle {
  position: absolute;
  top: 50%;
  right: 8px;
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--color-muted);
  cursor: pointer;
}

.password-toggle:hover,
.password-toggle:focus-visible,
.password-toggle[aria-pressed="true"] {
  background: color-mix(in srgb, var(--color-accent) 12%, transparent);
  color: var(--color-accent);
}

.password-rules span {
  color: var(--color-muted);
  font-size: 12px;
}

.password-rules span::before {
  content: "○";
  margin-right: 6px;
}

.password-rules span.is-valid {
  color: #16a34a;
}

.password-rules span.is-valid::before {
  content: "✓";
}

.password-rules span.is-invalid {
  color: var(--color-muted);
}

.client-form {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px 12px;
}

.client-form .field {
  gap: 5px;
}

.client-form .field label,
.client-form .field-error {
  font-size: 12px;
}

.client-form .field input,
.client-form .field select {
  min-height: 38px;
}

.form-actions,
.table-actions,
.check-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.form-actions,
.check-grid {
  grid-column: 1 / -1;
}

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

.status-badge {
  display: inline-flex;
  min-height: 24px;
  align-items: center;
  gap: 5px;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
  white-space: nowrap;
}

.status-badge:is(button, select) {
  border: 0;
  cursor: pointer;
}

select.status-badge {
  min-height: 24px;
  padding-right: 24px;
  font-family: inherit;
  text-align: left;
}

.status-badge::before {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  content: "";
}

.stock-item-name {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.stock-low-row {
  background: #fffbeb;
}

.stock-low-row td {
  border-bottom-color: #fde68a;
}

.stock-low-badge {
  background: #fef3c7;
  color: #92400e;
}

.vehicle-maintenance-status-scheduled {
  background: #dbeafe;
  color: #1d4ed8;
}

.vehicle-maintenance-status-in_progress {
  background: #fef3c7;
  color: #92400e;
}

.vehicle-maintenance-status-completed {
  background: #dcfce7;
  color: #166534;
}

.vehicle-maintenance-status-cancelled {
  background: #fee2e2;
  color: #b91c1c;
}

.vehicle-fuel-type-gasoline,
.vehicle-fuel-type-flex {
  background: #dbeafe;
  color: #1d4ed8;
}

.vehicle-fuel-type-ethanol {
  background: #dcfce7;
  color: #166534;
}

.vehicle-fuel-type-diesel {
  background: #fef3c7;
  color: #92400e;
}

.vehicle-fuel-type-electric {
  background: #e0e7ff;
  color: #3730a3;
}

.vehicle-fuel-type-other {
  background: #f1f5f9;
  color: #475569;
}

.financial-category-type-income {
  background: #dcfce7;
  color: #166534;
}

.financial-category-type-expense {
  background: #fee2e2;
  color: #b91c1c;
}

.financial-category-type-both {
  background: #dbeafe;
  color: #1d4ed8;
}

.financial-fee-status-pending {
  background: #fef3c7;
  color: #92400e;
}

.financial-fee-status-paid {
  background: #dcfce7;
  color: #166534;
}

.financial-fee-status-overdue {
  background: #fee2e2;
  color: #b91c1c;
}

.financial-fee-status-cancelled {
  background: #f1f5f9;
  color: #475569;
}

.financial-billed-yes {
  background: #dbeafe;
  color: #1d4ed8;
}

.financial-billed-no {
  background: #f1f5f9;
  color: #475569;
}

.employee-entry-type-salary {
  background: #dbeafe;
  color: #1d4ed8;
}

.employee-entry-type-advance,
.employee-entry-type-allowance {
  background: #fef3c7;
  color: #92400e;
}

.employee-entry-type-commission,
.employee-entry-type-bonus {
  background: #dcfce7;
  color: #166534;
}

.employee-entry-type-discount {
  background: #fee2e2;
  color: #b91c1c;
}

.employee-entry-type-vacation {
  background: #ede9fe;
  color: #6d28d9;
}

.employee-entry-type-other {
  background: #f1f5f9;
  color: #475569;
}

.employee-entry-status-pending {
  background: #fef3c7;
  color: #92400e;
}

.employee-entry-status-paid {
  background: #dcfce7;
  color: #166534;
}

.employee-entry-status-cancelled {
  background: #f1f5f9;
  color: #475569;
}

.account-receivable-type-service,
.account-receivable-status-pending {
  background: #dbeafe;
  color: #1d4ed8;
}

.account-receivable-type-sale,
.account-receivable-status-received {
  background: #dcfce7;
  color: #166534;
}

.account-receivable-type-extra_fee {
  background: #fef3c7;
  color: #92400e;
}

.account-receivable-type-reimbursement {
  background: #ede9fe;
  color: #6d28d9;
}

.account-receivable-type-other,
.account-receivable-status-cancelled {
  background: #f1f5f9;
  color: #475569;
}

.account-receivable-status-overdue {
  background: #fee2e2;
  color: #b91c1c;
}

.account-payable-type-supplier,
.account-payable-status-pending {
  background: #dbeafe;
  color: #1d4ed8;
}

.account-payable-type-utility {
  background: #fef3c7;
  color: #92400e;
}

.account-payable-type-tax,
.account-payable-status-overdue {
  background: #fee2e2;
  color: #b91c1c;
}

.account-payable-type-rent {
  background: #ede9fe;
  color: #6d28d9;
}

.account-payable-type-service,
.account-payable-status-paid {
  background: #dcfce7;
  color: #166534;
}

.account-payable-type-vehicle {
  background: #cffafe;
  color: #0e7490;
}

.account-payable-type-other,
.account-payable-status-cancelled {
  background: #f1f5f9;
  color: #475569;
}

.cash-flow-type-income,
.cash-flow-status-received,
.cash-flow-status-paid {
  background: #dcfce7;
  color: #166534;
}

.cash-flow-type-expense {
  background: #fee2e2;
  color: #b91c1c;
}

.stock-low-value {
  color: #b45309;
}

.stock-action-wrapper {
  position: relative;
  display: inline-flex;
}

.stock-action-menu {
  position: fixed;
  z-index: 1000;
  display: grid;
  width: 176px;
  padding: 6px;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  background: var(--color-surface);
  box-shadow: var(--shadow-soft);
}

.stock-action-menu[hidden] {
  display: none;
}

.stock-action-menu button,
.stock-action-menu a {
  display: flex;
  width: 100%;
  min-height: 34px;
  align-items: center;
  padding: 0 10px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--color-text);
  cursor: pointer;
  font: inherit;
  font-size: 13px;
  line-height: 1.2;
  text-decoration: none;
  text-align: left;
}

.stock-action-menu button:hover,
.stock-action-menu a:hover {
  background: var(--color-bg-soft);
}

.stock-action-menu button.is-danger,
.stock-action-menu a.is-danger {
  color: #dc2626;
}

[data-theme="dark"] .stock-low-row {
  background: rgba(245, 158, 11, 0.09);
}

[data-theme="dark"] .stock-low-row td {
  border-bottom-color: rgba(251, 191, 36, 0.28);
}

[data-theme="dark"] .stock-low-badge {
  background: rgba(251, 191, 36, 0.18);
  color: #fbbf24;
}

[data-theme="dark"] .vehicle-maintenance-status-scheduled {
  background: rgba(59, 130, 246, 0.18);
  color: #93c5fd;
}

[data-theme="dark"] .vehicle-maintenance-status-in_progress {
  background: rgba(251, 191, 36, 0.18);
  color: #fbbf24;
}

[data-theme="dark"] .vehicle-maintenance-status-completed {
  background: rgba(34, 197, 94, 0.18);
  color: #86efac;
}

[data-theme="dark"] .vehicle-maintenance-status-cancelled {
  background: rgba(239, 68, 68, 0.18);
  color: #fca5a5;
}

[data-theme="dark"] .vehicle-fuel-type-gasoline,
[data-theme="dark"] .vehicle-fuel-type-flex {
  background: rgba(59, 130, 246, 0.18);
  color: #93c5fd;
}

[data-theme="dark"] .vehicle-fuel-type-ethanol {
  background: rgba(34, 197, 94, 0.18);
  color: #86efac;
}

[data-theme="dark"] .vehicle-fuel-type-diesel {
  background: rgba(251, 191, 36, 0.18);
  color: #fbbf24;
}

[data-theme="dark"] .vehicle-fuel-type-electric {
  background: rgba(99, 102, 241, 0.2);
  color: #c4b5fd;
}

[data-theme="dark"] .vehicle-fuel-type-other {
  background: rgba(148, 163, 184, 0.18);
  color: #cbd5e1;
}

[data-theme="dark"] .financial-category-type-income {
  background: rgba(34, 197, 94, 0.18);
  color: #86efac;
}

[data-theme="dark"] .financial-category-type-expense {
  background: rgba(239, 68, 68, 0.18);
  color: #fca5a5;
}

[data-theme="dark"] .financial-category-type-both {
  background: rgba(59, 130, 246, 0.18);
  color: #93c5fd;
}

[data-theme="dark"] .financial-fee-status-pending {
  background: rgba(251, 191, 36, 0.18);
  color: #fbbf24;
}

[data-theme="dark"] .financial-fee-status-paid {
  background: rgba(34, 197, 94, 0.18);
  color: #86efac;
}

[data-theme="dark"] .financial-fee-status-overdue {
  background: rgba(239, 68, 68, 0.18);
  color: #fca5a5;
}

[data-theme="dark"] .financial-fee-status-cancelled,
[data-theme="dark"] .financial-billed-no {
  background: rgba(148, 163, 184, 0.18);
  color: #cbd5e1;
}

[data-theme="dark"] .financial-billed-yes {
  background: rgba(59, 130, 246, 0.18);
  color: #93c5fd;
}

[data-theme="dark"] .employee-entry-type-salary {
  background: rgba(59, 130, 246, 0.18);
  color: #93c5fd;
}

[data-theme="dark"] .employee-entry-type-advance,
[data-theme="dark"] .employee-entry-type-allowance,
[data-theme="dark"] .employee-entry-status-pending {
  background: rgba(251, 191, 36, 0.18);
  color: #fbbf24;
}

[data-theme="dark"] .employee-entry-type-commission,
[data-theme="dark"] .employee-entry-type-bonus,
[data-theme="dark"] .employee-entry-status-paid {
  background: rgba(34, 197, 94, 0.18);
  color: #86efac;
}

[data-theme="dark"] .employee-entry-type-discount {
  background: rgba(239, 68, 68, 0.18);
  color: #fca5a5;
}

[data-theme="dark"] .employee-entry-type-vacation {
  background: rgba(139, 92, 246, 0.18);
  color: #c4b5fd;
}

[data-theme="dark"] .employee-entry-type-other,
[data-theme="dark"] .employee-entry-status-cancelled {
  background: rgba(148, 163, 184, 0.18);
  color: #cbd5e1;
}

[data-theme="dark"] .account-receivable-type-service,
[data-theme="dark"] .account-receivable-status-pending {
  background: rgba(59, 130, 246, 0.18);
  color: #93c5fd;
}

[data-theme="dark"] .account-receivable-type-sale,
[data-theme="dark"] .account-receivable-status-received {
  background: rgba(34, 197, 94, 0.18);
  color: #86efac;
}

[data-theme="dark"] .account-receivable-type-extra_fee {
  background: rgba(251, 191, 36, 0.18);
  color: #fbbf24;
}

[data-theme="dark"] .account-receivable-type-reimbursement {
  background: rgba(139, 92, 246, 0.18);
  color: #c4b5fd;
}

[data-theme="dark"] .account-receivable-type-other,
[data-theme="dark"] .account-receivable-status-cancelled {
  background: rgba(148, 163, 184, 0.18);
  color: #cbd5e1;
}

[data-theme="dark"] .account-receivable-status-overdue {
  background: rgba(239, 68, 68, 0.18);
  color: #fca5a5;
}

[data-theme="dark"] .account-payable-type-supplier,
[data-theme="dark"] .account-payable-status-pending {
  background: rgba(59, 130, 246, 0.18);
  color: #93c5fd;
}

[data-theme="dark"] .account-payable-type-utility {
  background: rgba(251, 191, 36, 0.18);
  color: #fbbf24;
}

[data-theme="dark"] .account-payable-type-tax,
[data-theme="dark"] .account-payable-status-overdue {
  background: rgba(239, 68, 68, 0.18);
  color: #fca5a5;
}

[data-theme="dark"] .account-payable-type-rent {
  background: rgba(139, 92, 246, 0.18);
  color: #c4b5fd;
}

[data-theme="dark"] .account-payable-type-service,
[data-theme="dark"] .account-payable-status-paid {
  background: rgba(34, 197, 94, 0.18);
  color: #86efac;
}

[data-theme="dark"] .account-payable-type-vehicle {
  background: rgba(6, 182, 212, 0.18);
  color: #67e8f9;
}

[data-theme="dark"] .account-payable-type-other,
[data-theme="dark"] .account-payable-status-cancelled {
  background: rgba(148, 163, 184, 0.18);
  color: #cbd5e1;
}

[data-theme="dark"] .cash-flow-type-income,
[data-theme="dark"] .cash-flow-status-received,
[data-theme="dark"] .cash-flow-status-paid {
  background: rgba(34, 197, 94, 0.18);
  color: #86efac;
}

[data-theme="dark"] .cash-flow-type-expense {
  background: rgba(239, 68, 68, 0.18);
  color: #fca5a5;
}

[data-theme="dark"] .stock-low-value {
  color: #fbbf24;
}

.inline-edit-form {
  display: inline-flex;
  align-items: center;
}

.inline-edit-form select:not(.status-badge) {
  min-height: 32px;
  padding: 0 8px;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  background: var(--color-bg-soft);
  color: var(--color-text);
}

.appointment-status-open,
.priority-normal {
  background: #dbeafe;
  color: #1d4ed8;
}

.appointment-status-in_progress {
  background: #fef3c7;
  color: #a16207;
}

.appointment-status-completed,
.priority-low {
  background: #dcfce7;
  color: #15803d;
}

.appointment-status-closed {
  background: #ccfbf1;
  color: #0f766e;
}

.appointment-status-cancelled,
.service-order-status-badge-cancelled,
.priority-urgent {
  background: #fee2e2;
  color: #b91c1c;
}

.service-order-status-badge-open {
  background: #dbeafe;
  color: #1d4ed8;
}

.service-order-status-badge-in_progress {
  background: #fef3c7;
  color: #a16207;
}

.service-order-status-badge-awaiting_approval {
  background: #ffedd5;
  color: #c2410c;
}

.service-order-status-badge-awaiting_quote {
  background: #fed7aa;
  color: #9a3412;
}

.service-order-status-badge-external_repair {
  background: #f3e8ff;
  color: #7e22ce;
}

.service-order-status-badge-completed {
  background: #dcfce7;
  color: #15803d;
}

.service-order-status-badge-closed {
  background: #e2e8f0;
  color: #475569;
}

.priority-high {
  background: #fef3c7;
  color: #a16207;
}

[data-theme="dark"] .appointment-status-open,
[data-theme="dark"] .priority-normal {
  background: #172554;
  color: #93c5fd;
}

[data-theme="dark"] .appointment-status-in_progress {
  background: #422006;
  color: #fcd34d;
}

[data-theme="dark"] .appointment-status-completed,
[data-theme="dark"] .priority-low {
  background: #052e16;
  color: #86efac;
}

[data-theme="dark"] .appointment-status-closed {
  background: #134e4a;
  color: #99f6e4;
}

[data-theme="dark"] .appointment-status-cancelled,
[data-theme="dark"] .service-order-status-badge-cancelled,
[data-theme="dark"] .priority-urgent {
  background: #450a0a;
  color: #fca5a5;
}

[data-theme="dark"] .service-order-status-badge-open {
  background: #172554;
  color: #93c5fd;
}

[data-theme="dark"] .service-order-status-badge-in_progress {
  background: #422006;
  color: #fcd34d;
}

[data-theme="dark"] .service-order-status-badge-awaiting_approval {
  background: #431407;
  color: #fdba74;
}

[data-theme="dark"] .service-order-status-badge-awaiting_quote {
  background: #431407;
  color: #fb923c;
}

[data-theme="dark"] .service-order-status-badge-external_repair {
  background: #3b0764;
  color: #d8b4fe;
}

[data-theme="dark"] .service-order-status-badge-completed {
  background: #052e16;
  color: #86efac;
}

[data-theme="dark"] .service-order-status-badge-closed {
  background: #1e293b;
  color: #cbd5e1;
}

[data-theme="dark"] .priority-high {
  background: #422006;
  color: #fcd34d;
}

.service-order-checklist {
  margin: 0;
  padding: 12px;
  border: 1px solid var(--color-border);
  border-radius: 8px;
}

.service-order-checklist legend {
  padding: 0 6px;
  color: var(--color-text);
  font-weight: 800;
}

.service-order-checklist .check-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.service-order-checklist label {
  display: grid;
  gap: 6px;
}

.service-order-profile-grid {
  margin-top: 12px;
}

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

.service-order-create-actions select {
  min-height: 38px;
  padding: 0 12px;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  background: var(--color-bg-soft);
  color: var(--color-text);
}

.service-order-parts {
  display: grid;
  gap: 12px;
}

.service-order-parts-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.service-order-parts-header p {
  margin: 0;
}

.service-order-parts-list {
  display: grid;
  gap: 10px;
}

.service-order-part-row {
  display: grid;
  grid-template-columns: 150px minmax(180px, 1fr) minmax(180px, 1fr) 110px auto;
  gap: 10px;
  align-items: end;
  padding: 10px;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  background: var(--color-bg-soft);
}

.service-order-part-remove {
  margin-bottom: 2px;
}

.check-grid label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--color-muted);
  font-weight: 700;
}

.field select {
  width: 100%;
  min-height: 38px;
  padding: 0 10px;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  background: var(--color-bg-soft);
  color: var(--color-text);
}

.client-form .field input,
.client-form .field select {
  min-height: 38px;
}

.audit-table small {
  display: block;
  max-width: 280px;
  color: var(--color-muted);
  line-height: 1.4;
}

.pagination {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 12px;
}

.pagination [aria-disabled="true"] {
  opacity: 0.5;
  pointer-events: none;
}

.permission-form {
  display: grid;
  gap: 18px;
}

.modal-permissions .permission-form {
  gap: 10px;
}

.permission-group {
  display: grid;
  gap: 10px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--color-border);
}

.modal-permissions .permission-group {
  gap: 6px;
  padding-bottom: 8px;
}

.permission-group h3 {
  margin: 0;
  font-size: 15px;
}

.modal-permissions .permission-group h3 {
  font-size: 13px;
  line-height: 1.2;
}

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

.modal-permissions .permission-grid {
  grid-template-columns: repeat(auto-fit, minmax(185px, 1fr));
  gap: 6px;
}

.permission-grid label {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 4px 8px;
  padding: 10px;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  background: var(--color-bg-soft);
}

.modal-permissions .permission-grid label {
  gap: 2px 6px;
  padding: 6px 7px;
  border-radius: 6px;
  font-size: 12px;
  line-height: 1.25;
}

.modal-permissions .permission-grid input {
  margin-top: 1px;
}

.permission-grid small {
  grid-column: 2;
  color: var(--color-muted);
}

.modal-permissions .permission-grid small {
  overflow: hidden;
  font-size: 10px;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.modal-permissions .permission-form .form-actions {
  position: sticky;
  bottom: -10px;
  justify-content: flex-end;
  margin-top: 0;
  padding: 8px 0 2px;
  background: linear-gradient(180deg, transparent 0%, var(--color-surface) 26%);
}

.client-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.client-summary div,
.detail-grid div {
  display: grid;
  gap: 5px;
  padding: 10px;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  background: var(--color-bg-soft);
}

.client-summary strong,
.detail-grid strong {
  color: var(--color-text);
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.detail-grid span,
.placeholder-text {
  color: var(--color-muted);
}

.detail-span-2 {
  grid-column: span 2;
}

.network-card {
  display: grid;
  gap: 16px;
  padding: 16px;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  background: var(--color-bg-soft);
}

.network-detail-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.network-detail-grid div {
  background: var(--color-bg);
}

.tab-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tab-nav a,
.tab-nav .tab-disabled {
  display: inline-flex;
  min-height: 34px;
  align-items: center;
  padding: 0 10px;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  color: var(--color-text);
  text-decoration: none;
  background: var(--color-bg-soft);
}

.tab-nav .tab-disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.tab-nav a[aria-current="page"] {
  border-color: var(--color-accent);
  color: var(--color-accent);
}

.tab-panel {
  scroll-margin-top: 18px;
}

.email-server-stack {
  display: grid;
  gap: 8px;
}

.email-server-card {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  background: var(--color-bg-soft);
}

.email-server-card[hidden] {
  display: none;
}

.email-server-head,
.email-account-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.email-server-card h3 {
  margin: 2px 0;
  font-size: 18px;
}

.email-server-details {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.email-server-details div,
.email-account-card {
  border: 1px solid var(--color-border);
  border-radius: 8px;
  background: var(--color-surface);
}

.email-server-details div {
  display: grid;
  gap: 4px;
  padding: 8px 10px;
}

.email-server-details span,
.email-account-fields span,
.email-account-meta span {
  color: var(--color-muted);
  font-size: 12px;
}

.email-server-actions {
  justify-content: flex-end;
}

.status-switch {
  position: relative;
  flex: 0 0 auto;
  width: 42px;
  height: 24px;
  border-radius: 999px;
  background: #98a2b3;
  box-shadow: inset 0 0 0 1px rgb(0 0 0 / 0.12);
}

.status-switch::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 2px rgb(0 0 0 / 0.22);
  transition: transform 0.16s ease;
}

.status-switch.is-on {
  background: #16a34a;
}

.status-switch.is-on::after {
  transform: translateX(18px);
}

.email-compose {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  background: var(--color-bg-soft);
}

.email-compose input {
  border: 0;
  background: transparent;
}

.email-compose span {
  padding-right: 12px;
  color: var(--color-muted);
  font-weight: 700;
}

.email-list-filter {
  display: grid;
  gap: 6px;
  width: min(320px, 100%);
}

.email-list-filter label {
  color: var(--color-muted);
  font-size: 12px;
  font-weight: 700;
}

.email-list-filter input,
.email-account-table input,
.email-account-table select {
  width: 100%;
  min-height: 36px;
  padding: 0 10px;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  background: var(--color-bg-soft);
  color: var(--color-text);
}

.email-account-table {
  min-width: 760px;
}

.equipment-table {
  min-width: 820px;
}

.email-account-table .status-switch {
  display: inline-block;
  vertical-align: middle;
}

.status-switch-input {
  display: inline-flex;
  align-items: center;
  cursor: pointer;
}

.status-switch-input input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.status-switch-input input:disabled + .status-switch {
  cursor: default;
  opacity: 0.9;
}

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

.readonly-secret {
  width: 100%;
  min-height: 42px;
  padding: 0 12px;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  background: var(--color-bg-soft);
  color: var(--color-text);
}

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

  .backup-action-grid {
    grid-template-columns: 1fr;
  }

  .network-detail-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .report-summary-grid,
  .report-chart-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .button,
  .icon-button,
  .action-icon {
    min-height: 42px;
  }

  .table-wrap {
    max-height: calc(100dvh - 220px);
  }

  .data-table {
    min-width: 760px;
  }

  .filter-toolbar {
    justify-content: stretch;
  }

  .filter-toggle-button {
    width: 100%;
    min-height: 44px;
  }

  .filter-actions {
    align-items: stretch;
  }

  .filter-actions .button {
    flex: 1 1 44px;
    min-height: 44px;
  }

  .filter-icon-action {
    width: 44px;
    min-width: 44px;
  }

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

  .report-visible-actions,
  .report-visible-actions .report-action-button {
    width: 100%;
  }

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

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

  .pagination {
    align-items: stretch;
    flex-direction: column;
  }

  .permission-grid,
  .modal-permissions .permission-grid {
    grid-template-columns: 1fr;
  }

  [data-modal="topbar-attendance-finish-modal"] .modal {
    align-self: stretch;
  }

  [data-modal="topbar-attendance-finish-modal"] textarea {
    min-height: 150px;
    font-size: 16px;
  }

  .client-summary,
  .detail-grid,
  .email-server-details,
  .report-summary-grid,
  .report-chart-grid {
    grid-template-columns: 1fr;
  }

  .report-pie-layout {
    grid-template-columns: 1fr;
  }

  .service-order-parts-header {
    align-items: stretch;
    flex-direction: column;
  }

  .service-order-part-row {
    grid-template-columns: 1fr;
  }

  .detail-span-2 {
    grid-column: auto;
  }
}
