/*
  Waste 4.0 compact UI foundation

  This file is the source of truth for new operational screens. Use these
  classes for new modules instead of copying older large modal/card/table
  styles or adding page-specific "compact pass" overrides.
*/

:root {
  --w4-fg: oklch(0.18 0.03 260);
  --w4-muted-fg: oklch(0.48 0.035 260);
  --w4-card: oklch(1 0 0);
  --w4-muted: oklch(0.965 0.006 260);
  --w4-border: oklch(0.90 0.012 260);
  --w4-border-strong: oklch(0.84 0.018 260);
  --w4-primary: oklch(0.58 0.22 280);
  --w4-primary-2: oklch(0.68 0.20 285);
  --w4-success: oklch(0.55 0.16 155);
  --w4-danger: oklch(0.55 0.20 25);
  --w4-radius-sm: 8px;
  --w4-radius-md: 10px;
  --w4-radius-lg: 12px;
  --w4-shadow-card:
    0 1px 2px oklch(0.20 0.03 260 / 0.04),
    0 10px 24px oklch(0.20 0.03 260 / 0.05);
  --w4-shadow-popover: 0 18px 48px oklch(0.20 0.03 260 / 0.18);
  --w4-field-height: 30px;
  --w4-row-padding-y: 6px;
  --w4-row-padding-x: 8px;
}

.w4-page,
.ui-compact {
  color: var(--w4-fg);
  font-size: 13px;
  line-height: 1.35;
}

.w4-page {
  padding: 0 14px 22px;
}

.w4-page-header,
.w4-toolbar,
.ui-compact-toolbar {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.w4-page-header {
  justify-content: space-between;
  margin-bottom: 10px;
}

.w4-title {
  color: var(--w4-fg);
  font-size: 24px;
  font-weight: 750;
  letter-spacing: 0;
  line-height: 1.08;
  margin: 0;
}

.w4-subtitle,
.w4-hint,
.ui-compact-hint {
  color: var(--w4-muted-fg);
  font-size: 12px;
  line-height: 1.35;
}

.w4-card,
.w4-panel,
.ui-compact-card {
  background: var(--w4-card);
  border: 1px solid var(--w4-border);
  border-radius: var(--w4-radius-lg);
  box-shadow: var(--w4-shadow-card);
  padding: 10px;
}

.w4-card-header,
.w4-panel-header {
  align-items: center;
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.w4-card-title,
.w4-panel-title {
  color: var(--w4-fg);
  font-size: 14px;
  font-weight: 750;
  line-height: 1.2;
  margin: 0;
}

.w4-grid {
  display: grid;
  gap: 10px;
}

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

.w4-grid--3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.w4-form-grid {
  display: grid;
  gap: 8px;
}

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

.w4-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.w4-label {
  color: var(--w4-muted-fg);
  font-size: 11.5px;
  font-weight: 700;
  line-height: 1.25;
}

.w4-input,
.w4-select,
.w4-textarea,
.ui-compact input:not([type="checkbox"]):not([type="radio"]),
.ui-compact select,
.ui-compact textarea {
  background: oklch(0.985 0.003 260);
  border: 1px solid var(--w4-border-strong);
  border-radius: 9px;
  box-sizing: border-box;
  color: var(--w4-fg);
  font: inherit;
  font-size: 12px;
  min-height: var(--w4-field-height);
  padding: 4px 9px;
  width: 100%;
}

.w4-textarea,
.ui-compact textarea {
  line-height: 1.4;
  min-height: 72px;
  resize: vertical;
}

.w4-input:focus,
.w4-select:focus,
.w4-textarea:focus,
.ui-compact input:not([type="checkbox"]):not([type="radio"]):focus,
.ui-compact select:focus,
.ui-compact textarea:focus {
  border-color: color-mix(in oklab, var(--w4-primary) 45%, var(--w4-border-strong));
  box-shadow: 0 0 0 3px color-mix(in oklab, var(--w4-primary) 16%, transparent);
  outline: none;
}

.w4-chip-btn,
.w4-btn,
.ui-compact-btn {
  align-items: center;
  background: #fcf9fa;
  border: 1px solid var(--w4-border-strong);
  border-radius: 10px;
  box-shadow:
    0 1px 2px oklch(0.20 0.03 260 / 0.04),
    0 4px 14px oklch(0.20 0.03 260 / 0.04);
  color: var(--w4-fg);
  cursor: pointer;
  display: inline-flex;
  font: inherit;
  font-size: 12px;
  font-weight: 650;
  gap: 6px;
  justify-content: center;
  min-height: 30px;
  padding: 0 10px;
  text-decoration: none;
  white-space: nowrap;
}

.w4-chip-btn:hover,
.w4-chip-btn:focus-visible,
.w4-btn:hover,
.w4-btn:focus-visible,
.ui-compact-btn:hover,
.ui-compact-btn:focus-visible {
  background: oklch(0.97 0.006 260);
  border-color: var(--w4-border-strong);
  color: var(--w4-fg);
}

.w4-action-btn,
.w4-btn--primary,
.ui-compact-btn--primary {
  background: linear-gradient(135deg, var(--w4-primary), var(--w4-primary-2));
  border: 0;
  color: #fff;
  font-weight: 750;
  box-shadow: 0 8px 20px oklch(0.55 0.22 280 / 0.22);
}

.w4-action-btn:hover,
.w4-action-btn:focus-visible,
.w4-btn--primary:hover,
.w4-btn--primary:focus-visible,
.ui-compact-btn--primary:hover,
.ui-compact-btn--primary:focus-visible {
  color: #fff;
  filter: brightness(1.04);
}

.w4-table-wrap,
.ui-compact-table-wrap {
  background: var(--w4-card);
  border: 1px solid var(--w4-border);
  border-radius: var(--w4-radius-lg);
  overflow: auto;
}

.w4-table,
.ui-compact-table {
  border-collapse: separate;
  border-spacing: 0;
  font-size: 12px;
  width: 100%;
}

.w4-table th,
.w4-table td,
.ui-compact-table th,
.ui-compact-table td {
  border-bottom: 1px solid var(--w4-border);
  color: var(--w4-fg);
  line-height: 1.28;
  padding: var(--w4-row-padding-y) var(--w4-row-padding-x);
  text-align: left;
  vertical-align: middle;
}

.w4-table th,
.ui-compact-table th {
  background: oklch(0.965 0.008 260);
  color: oklch(0.40 0.035 260);
  font-size: 10.5px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.w4-table tbody tr:last-child td,
.ui-compact-table tbody tr:last-child td {
  border-bottom: 0;
}

.w4-table tbody tr:hover td,
.ui-compact-table tbody tr:hover td {
  background: oklch(0.985 0.012 275);
}

.w4-badge,
.ui-compact-badge {
  align-items: center;
  background: var(--w4-muted);
  border: 1px solid var(--w4-border);
  border-radius: 999px;
  color: var(--w4-muted-fg);
  display: inline-flex;
  font-size: 11px;
  font-weight: 700;
  gap: 4px;
  min-height: 22px;
  padding: 0 8px;
  white-space: nowrap;
}

.w4-popover,
.ui-compact-popover {
  background: var(--w4-card);
  border: 1px solid var(--w4-border);
  border-radius: var(--w4-radius-lg);
  box-shadow: var(--w4-shadow-popover);
  color: var(--w4-fg);
  font-size: 12px;
  padding: 10px;
}

.w4-modal-backdrop,
.ui-compact-modal-backdrop {
  align-items: center;
  background: oklch(0.20 0.03 260 / 0.48);
  display: flex;
  inset: 0;
  justify-content: center;
  padding: 14px;
  position: fixed;
  z-index: 1000;
}

.w4-modal,
.ui-compact-modal {
  background: var(--w4-card);
  border: 1px solid var(--w4-border);
  border-radius: 16px;
  box-shadow: 0 24px 70px oklch(0.20 0.03 260 / 0.26);
  color: var(--w4-fg);
  display: flex;
  flex-direction: column;
  max-height: calc(100dvh - 28px);
  overflow: hidden;
  width: min(520px, calc(100vw - 28px));
}

.w4-modal-header,
.w4-modal-footer,
.ui-compact-modal-header,
.ui-compact-modal-footer {
  align-items: center;
  display: flex;
  gap: 8px;
  padding: 10px 13px;
}

.w4-modal-header,
.ui-compact-modal-header {
  border-bottom: 1px solid var(--w4-border);
  justify-content: space-between;
}

.w4-modal-footer,
.ui-compact-modal-footer {
  border-top: 1px solid var(--w4-border);
  justify-content: flex-end;
}

.w4-modal-title,
.ui-compact-modal-title {
  color: var(--w4-fg);
  font-size: 15px;
  font-weight: 750;
  line-height: 1.2;
  margin: 0;
}

.w4-modal-body,
.ui-compact-modal-body {
  display: flex;
  flex-direction: column;
  gap: 9px;
  overflow-y: auto;
  padding: 10px 13px;
}

.w4-modal-close,
.ui-compact-modal-close {
  align-items: center;
  appearance: none;
  background: rgba(148, 163, 184, 0.18);
  border: 0;
  border-radius: 999px;
  color: #374151;
  cursor: pointer;
  display: inline-flex;
  font-size: 20px;
  font-weight: 500;
  height: 30px;
  justify-content: center;
  line-height: 1;
  padding: 0;
  width: 30px;
}

.w4-modal-close:hover,
.w4-modal-close:focus-visible,
.ui-compact-modal-close:hover,
.ui-compact-modal-close:focus-visible {
  background: rgba(148, 163, 184, 0.32);
  color: #111827;
}

@media (max-width: 760px) {
  .w4-page {
    padding: 0 8px 18px;
  }

  .w4-grid--2,
  .w4-grid--3,
  .w4-form-grid--2 {
    grid-template-columns: 1fr;
  }

  .w4-title {
    font-size: 21px;
  }
}
