:root {
  color-scheme: light dark;
  --bg: #f4f6fb;
  --card-bg: #fff;
  --text: #1c1f23;
  --muted: #6c7685;
  --primary: #2563eb;
  --primary-dark: #1e3fa9;
  --danger: #dc2626;
  --border: #d8dce3;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Segoe UI", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.5rem 2rem;
  background: #0f172a;
  color: #fff;
}

.app-header h1 {
  margin: 0;
  font-size: 1.5rem;
}

.app-main {
  padding: 1.5rem;
  max-width: 1200px;
  margin: 0 auto;
}

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.cards-ops {
  grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
}

.cards-admin {
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
}

.card {
  background: var(--card-bg);
  border-radius: 1rem;
  padding: 1.25rem;
  box-shadow: 0 20px 50px rgba(15, 23, 42, 0.08);
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.card h2,
.card h3 {
  margin: 0;
}

form {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

textarea {
  border-radius: 0.5rem;
  border: 1px solid var(--border);
  padding: 0.65rem 0.75rem;
  font-size: 1rem;
  font-family: inherit;
  resize: vertical;
}

label {
  font-size: 0.9rem;
  color: var(--muted);
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

input,
select {
  border-radius: 0.5rem;
  border: 1px solid var(--border);
  padding: 0.65rem 0.75rem;
  font-size: 1rem;
  font-family: inherit;
}

select {
  cursor: pointer;
  background: var(--card-bg);
}

button {
  border: none;
  border-radius: 0.5rem;
  padding: 0.65rem 0.9rem;
  font-size: 1rem;
  background: var(--primary);
  color: #fff;
  cursor: pointer;
  transition: background 0.2s ease;
}

button:hover {
  background: var(--primary-dark);
}

button.secondary {
  background: #1f2937;
}

button.danger {
  background: var(--danger);
}

.button-row {
  display: flex;
  gap: 0.5rem;
}

.data-panels {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 1.5rem;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}

.table-wrapper {
  overflow-x: auto;
  max-height: 420px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
}

th,
td {
  padding: 0.5rem 0.75rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

th {
  font-weight: 600;
  color: var(--muted);
}

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

.search-results {
  margin-top: 0.5rem;
  text-align: left;
  max-height: 180px;
  overflow-y: auto;
}

.search-hit {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.35rem 0;
  border-bottom: 1px solid var(--border);
}

.link-btn {
  background: none;
  border: none;
  color: var(--primary);
  cursor: pointer;
  padding: 0;
  font-size: 0.9rem;
}

.table-actions {
  display: flex;
  gap: 0.5rem;
}

.hint {
  color: var(--muted);
  font-size: 0.85rem;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 1.5rem;
  transform: translateX(-50%);
  padding: 0.75rem 1.25rem;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.9);
  color: #fff;
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.2);
}

.toast.error {
  background: var(--danger);
}

.hidden {
  display: none !important;
}

.modal {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
}

.modal-card {
  position: relative;
  width: min(480px, calc(100% - 2rem));
  background: var(--card-bg);
  border-radius: 1rem;
  padding: 1.5rem;
  box-shadow: 0 20px 60px rgba(15, 23, 42, 0.3);
  z-index: 1001;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.icon-btn {
  border: none;
  background: transparent;
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  color: var(--muted);
}

.split {
  display: flex;
  gap: 1rem;
}

.split label {
  flex: 1;
}

@media (max-width: 640px) {
  .app-header {
    flex-direction: column;
    gap: 0.75rem;
  }

  .button-row {
    flex-direction: column;
  }

  .split {
    flex-direction: column;
  }

  .cards-ops,
  .cards-admin {
    grid-template-columns: 1fr;
  }
}

