:root {
  color-scheme: light;
  --app-bg: #f8fafc;
  --app-text: #0f172a;
  --app-muted: #64748b;
  --bg-gradient: rgba(59, 130, 246, 0.25);
  font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
  line-height: 1.6;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: radial-gradient(circle at top, var(--bg-gradient, rgba(59, 130, 246, 0.25)), transparent 45%), var(--app-bg);
  color: var(--app-text);
  padding: 2rem;
}

.bg-glass {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 1.5rem;
  box-shadow: 0 18px 45px rgba(15, 23, 42, 0.08);
}

.hidden {
  display: none !important;
}

.list-group-item-action {
  border-radius: 0.75rem;
}

.list-group-item-action + .list-group-item-action {
  margin-top: 0.35rem;
}

.status-badge {
  display: inline-flex;
  border-radius: 999px;
  padding: 0.25rem 0.85rem;
  font-weight: 600;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.status-pending {
  background: rgba(251, 191, 36, 0.2);
  color: #92400e;
}

.status-approved {
  background: rgba(34, 197, 94, 0.2);
  color: #166534;
}

.status-rejected {
  background: rgba(239, 68, 68, 0.2);
  color: #7f1d1d;
}

.status-expired {
  background: rgba(244, 63, 94, 0.18);
  color: #9f1239;
}

.status-draft {
  background: rgba(148, 163, 184, 0.3);
  color: #0f172a;
}

.status-sent {
  background: rgba(59, 130, 246, 0.2);
  color: #1d4ed8;
}

.status-changes,
.status-changes-requested {
  background: rgba(249, 115, 22, 0.2);
  color: #7c2d12;
}

.status-cancelled {
  background: rgba(15, 23, 42, 0.12);
  color: #334155;
}

.contact-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.contact-pill {
  border-radius: 0.75rem;
  padding: 0.75rem 1rem;
  background: #fff;
  border: 1px solid #e5e7eb;
}

.form-label {
  font-weight: 600;
  color: var(--app-text);
}

.text-muted {
  color: var(--app-muted) !important;
}

.app-card {
  border: 1px solid #e2e8f0;
  border-radius: 1.5rem;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 12px 30px rgba(15, 23, 42, 0.08);
}

.app-subcard {
  border: 1px solid #e2e8f0;
  border-radius: 1.25rem;
  background: #f8fafc;
}

.app-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  border-radius: 999px;
  padding: 0.35rem 0.75rem;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.app-chip-neutral {
  background: #e2e8f0;
  color: #334155;
}

.app-chip-brand {
  background: var(--brand-primary-soft, rgba(21, 112, 239, 0.12));
  color: var(--brand-primary-dark, #175cd3);
}

.app-label {
  display: block;
  margin-bottom: 0.45rem;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: #334155;
}

.app-hint {
  margin-top: 0.45rem;
  font-size: 0.8rem;
  color: #64748b;
}

.app-input,
.app-select,
.app-textarea {
  width: 100%;
  border: 1px solid #cbd5e1;
  border-radius: 1rem;
  background: #fff;
  color: #0f172a;
  padding: 0.72rem 0.95rem;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background-color 0.15s ease;
}

.app-input:focus,
.app-select:focus,
.app-textarea:focus {
  outline: none;
  border-color: var(--brand-primary, #1570ef);
  box-shadow: 0 0 0 4px var(--brand-primary-soft, rgba(21, 112, 239, 0.12));
}

.app-input-sm,
.app-select-sm,
.app-textarea-sm {
  border-radius: 0.9rem;
  padding: 0.58rem 0.8rem;
  font-size: 0.92rem;
}

.app-textarea {
  min-height: 7rem;
  resize: vertical;
}

.app-textarea-sm {
  min-height: 4.5rem;
}

.app-button,
.app-button-secondary,
.app-button-danger,
.app-button-ghost {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  border-radius: 999px;
  border: 1px solid transparent;
  padding: 0.72rem 1.15rem;
  font-size: 0.92rem;
  font-weight: 700;
  text-decoration: none;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease, opacity 0.15s ease, box-shadow 0.15s ease;
  cursor: pointer;
}

.app-button {
  background: var(--brand-primary, #1570ef);
  color: #fff;
  box-shadow: 0 10px 25px rgba(21, 112, 239, 0.18);
}

.app-button:hover,
.app-button:focus-visible {
  background: var(--brand-primary-dark, #175cd3);
  color: #fff;
}

.app-button-secondary {
  border-color: #cbd5e1;
  background: #fff;
  color: #334155;
}

.app-button-secondary:hover,
.app-button-secondary:focus-visible {
  border-color: #94a3b8;
  background: #f8fafc;
  color: #0f172a;
}

.app-button-danger {
  border-color: #be123c;
  background: #e11d48;
  color: #fff;
  box-shadow: 0 10px 25px rgba(225, 29, 72, 0.2);
}

.app-button-danger:hover,
.app-button-danger:focus-visible {
  border-color: #9f1239;
  background: #be123c;
  color: #fff;
}

.app-button-ghost {
  border-color: transparent;
  background: transparent;
  color: #475569;
  box-shadow: none;
}

.app-button-ghost:hover,
.app-button-ghost:focus-visible {
  background: #f8fafc;
  color: #0f172a;
}

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

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

.app-table th,
.app-table td {
  padding: 0.9rem 1rem;
  border-bottom: 1px solid #e2e8f0;
  vertical-align: top;
}

.app-table th {
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #64748b;
}

.quote-grid-spacer {
  display: none;
}

.items-form-first {
  order: 1;
}

.items-list-after {
  order: 2;
}

.app-modal {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100dvh;
  max-height: 100dvh;
  padding: 0.75rem 1.25rem;
  overflow: auto;
  overscroll-behavior: contain;
  background: rgba(15, 23, 42, 0.62);
  backdrop-filter: blur(6px);
}

.app-modal[aria-hidden="true"] {
  display: none !important;
}

.app-modal-panel {
  width: min(100%, 64rem);
  max-height: calc(100% - 1.5rem);
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
  border: 1px solid rgba(226, 232, 240, 0.9);
  border-radius: 1.75rem;
  background: rgba(255, 255, 255, 0.98);
  box-shadow: 0 32px 80px rgba(15, 23, 42, 0.25);
  margin: 0 auto;
}

.app-modal-panel > form {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

.app-modal-panel.app-modal-panel-sm {
  width: min(100%, 32rem);
}

.app-modal-header,
.app-modal-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.5rem 1.75rem;
}

.app-modal-header {
  border-bottom: 1px solid #e2e8f0;
}

.app-modal-footer {
  border-top: 1px solid #e2e8f0;
  flex-wrap: wrap;
}

.app-modal-body {
  padding: 1.5rem 1.75rem;
  overflow: auto;
  flex: 1 1 auto;
  min-height: 0;
  max-height: min(68dvh, 44rem);
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

html.app-modal-open,
body.app-modal-open {
  overflow: hidden;
}

#toastContainer {
  pointer-events: none;
}

@media (max-width: 768px) {
  body {
    padding: 1.5rem 1rem;
  }

  .app-modal {
    padding: 0.5rem 0.75rem;
  }

  .app-modal-panel {
    max-height: calc(100% - 1rem);
  }

  .app-modal-body {
    max-height: 62dvh;
  }

  .app-modal-header,
  .app-modal-body,
  .app-modal-footer {
    padding-inline: 1rem;
  }
}

@media (min-width: 768px) {
  .quote-grid-spacer {
    display: block;
    grid-column: span 2 / span 2;
  }
}
