* { box-sizing: border-box; }

:root {
  --bg: #eef1f5;
  --surface: #ffffff;
  --surface-2: #f6f8fb;
  --border: #dfe3ea;
  --text: #1d2433;
  --muted: #5f6b7a;
  --primary: #1e3a5f;
  --primary-hover: #2a4c78;
  --danger: #b3261e;
  --shadow: 0 1px 2px rgba(23, 32, 48, 0.06), 0 1px 6px rgba(23, 32, 48, 0.06);
  --radius: 10px;
}

html, body { margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

.app-header { background: var(--primary); color: #fff; }
.header-inner {
  max-width: 960px;
  margin: 0 auto;
  padding: 20px 20px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.brand h1 { margin: 0; font-size: 24px; letter-spacing: 0.3px; }
.tagline { margin: 2px 0 0; color: #c7d3e3; font-size: 13px; }
.header-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.user-chip {
  font-size: 13px;
  color: #dfe9f5;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.18);
  padding: 5px 12px;
  border-radius: 999px;
}
.btn-header { border-color: rgba(255, 255, 255, 0.35); color: #fff; }
.btn-header:hover { background: rgba(255, 255, 255, 0.12); }

.container { max-width: 960px; margin: 0 auto; padding: 20px 20px 48px; }

.btn {
  font: inherit;
  font-size: 14px;
  padding: 8px 14px;
  border-radius: 8px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-ghost { background: transparent; border-color: var(--border); color: var(--text); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-danger { background: transparent; border-color: #f3c2bd; color: var(--danger); }
.btn-danger:hover { background: #fdf1f0; }
.btn-copy { background: #eef4ec; border-color: #cfe2cc; color: #2c6e2f; }
.btn-copy:hover { background: #e2efdf; }
.btn-copy.copied { background: #dff0dd; }
.btn-small { padding: 6px 10px; font-size: 13px; }

.toolbar {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
}
.search-row { display: flex; align-items: center; gap: 12px; }
#searchInput {
  flex: 1;
  font: inherit;
  font-size: 16px;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-2);
}
#searchInput:focus { outline: 2px solid #b7c9e2; border-color: var(--primary); background: #fff; }
.result-count { color: var(--muted); font-size: 13px; white-space: nowrap; }

.filter-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 14px; }
.pills { display: flex; gap: 8px; flex-wrap: wrap; }
.pill {
  font: inherit;
  font-size: 13px;
  padding: 6px 12px;
  border-radius: 999px;
  cursor: pointer;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--muted);
}
.pill:hover { border-color: #b9c6d6; color: var(--text); }
.pill.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.tag-filter { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
#tagSelect {
  font: inherit;
  font-size: 13px;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-2);
}

.results { margin-top: 18px; display: grid; gap: 12px; }
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 16px 12px;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.card:hover { border-color: #b9c6d6; box-shadow: 0 2px 8px rgba(23, 32, 48, 0.08); }
.card-header { margin-bottom: 8px; }
.card-title-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.card-title { margin: 0; font-size: 16px; }
.badge {
  flex: none;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  padding: 3px 9px;
  border-radius: 999px;
  color: #fff;
  white-space: nowrap;
}
.cat-returns { background: #2f6fdc; }
.cat-replacements { background: #2e9e5b; }
.cat-notes { background: #b8860b; }
.cat-internal { background: #7d5ba6; }

.card-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.tag {
  font-size: 12px;
  padding: 2px 8px;
  border-radius: 999px;
  cursor: pointer;
  background: #eef1f6;
  border: 1px solid #dde3ec;
  color: #43506b;
}
.tag:hover { background: #e2e9f4; }

.card-snippet { margin: 4px 0 0; color: var(--muted); font-size: 14px; }
.card-body {
  margin: 10px 0 0;
  padding: 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-family: inherit;
  font-size: 14px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
}
.card-actions { display: flex; gap: 8px; margin-top: 12px; }

.hidden { display: none !important; }
.empty { text-align: center; color: var(--muted); padding: 48px 0; }

.modal { position: fixed; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center; padding: 20px; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(23, 32, 48, 0.5); }
.modal-card {
  position: relative;
  background: var(--surface);
  border-radius: 12px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.25);
  width: 100%;
  max-width: 640px;
  max-height: 90vh;
  overflow-y: auto;
  padding: 24px;
}
.modal-card h2 { margin: 0 0 16px; font-size: 20px; }
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 5px; color: #39435a; }
.field input, .field select, .field textarea {
  width: 100%;
  font: inherit;
  font-size: 14px;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-2);
}
.field textarea { resize: vertical; min-height: 160px; line-height: 1.55; }
.field input:focus, .field select:focus, .field textarea:focus {
  outline: 2px solid #b7c9e2;
  border-color: var(--primary);
  background: #fff;
}
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.hint { font-size: 12px; color: var(--muted); margin: 5px 0 0; }
.form-error { color: var(--danger); font-size: 13px; margin: 0 0 10px; }
.modal-actions { display: flex; align-items: center; gap: 8px; margin-top: 6px; }
.modal-actions .spacer { flex: 1; }

/* Auth / login page */
.auth-body { background: var(--primary); }
.auth-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.auth-card {
  background: var(--surface);
  border-radius: 12px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.25);
  padding: 32px;
  width: 100%;
  max-width: 400px;
}
.auth-brand { margin: 0; font-size: 26px; color: var(--primary); }
.auth-sub { margin: 4px 0 24px; color: var(--muted); font-size: 13px; }
.auth-card .field label { color: var(--text); }
.btn-block { width: 100%; padding: 10px 14px; font-size: 15px; }

@media (max-width: 600px) {
  .auth-card { padding: 24px; }
}

@media (max-width: 600px) {
  .field-row { grid-template-columns: 1fr; }
  .header-inner { padding: 16px; }
  .search-row { flex-direction: column; align-items: stretch; }
  .filter-row { flex-direction: column; align-items: stretch; }
  .tag-filter { justify-content: space-between; }
  .card-actions { flex-wrap: wrap; }
}
