@import url("https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=Manrope:wght@600;700;800&display=swap");

:root {
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --secondary: #14b8a6;
  --accent: #f59e0b;
  --surface: #f8fafc;
  --surface-card: #ffffff;
  --text: #0f172a;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --success: #16a34a;
  --warning: #d97706;
  --danger: #dc2626;
  --shadow-sm: 0 4px 16px rgba(15, 23, 42, .05);
  --radius-sm: 8px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --font-body: Inter, sans-serif;
  --font-heading: Manrope, sans-serif;
}
body[data-theme="dark"] {
  --surface: #0b1120; --surface-card: #111827; --text: #f8fafc;
  --text-muted: #94a3b8; --border: #334155; --primary: #3b82f6;
  --primary-hover: #60a5fa; --shadow-sm: 0 4px 16px rgba(0,0,0,.2);
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--surface); color: var(--text); font: 400 14px/1.5 var(--font-body); }
a { color: inherit; text-decoration: none; }
.app-shell { min-height: 100vh; display: flex; }
.sidebar { width: 248px; position: fixed; inset: 0 auto 0 0; padding: 26px 16px; display: flex; flex-direction: column; background: var(--surface-card); border-right: 1px solid var(--border); }
.brand { display: flex; align-items: center; gap: 10px; padding: 0 10px 28px; font: 800 22px var(--font-heading); letter-spacing: -.8px; }
.brand span span { color: var(--primary); }
.brand-mark { width: 32px; height: 32px; }
.nav { display: grid; gap: 6px; }
.nav-link { color: var(--text-muted); display: flex; align-items: center; gap: 10px; padding: 11px 12px; border-radius: var(--radius-md); font-weight: 600; transition: .16s ease; }
.nav-link:hover, .nav-link.active { color: var(--primary); background: rgba(37,99,235,.09); }
.sidebar-bottom { margin-top: auto; padding: 8px; }
.theme-toggle { border: 0; background: transparent; color: var(--text-muted); cursor: pointer; padding: 8px; font: 500 13px var(--font-body); }
.main-content { width: min(1280px, calc(100% - 248px)); margin-left: 248px; padding: 42px clamp(24px, 4vw, 56px); }
.page-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 24px; margin-bottom: 28px; }
.eyebrow { margin: 0 0 5px; color: var(--primary); font-size: 11px; font-weight: 700; letter-spacing: .1em; }
h1,h2 { font-family: var(--font-heading); letter-spacing: -.04em; }
h1 { margin: 0; font-size: clamp(28px, 3vw, 38px); line-height: 1.15; }
h2 { margin: 0 0 4px; font-size: 18px; }
.page-subtitle,.section-heading p,.danger-zone p { margin: 7px 0 0; color: var(--text-muted); }
.back-link { display: inline-block; margin-bottom: 14px; color: var(--text-muted); font-weight: 600; }
.back-link:hover { color: var(--primary); }
.card { background: var(--surface-card); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); }
.btn { min-height: 42px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 10px 15px; border: 1px solid transparent; border-radius: var(--radius-md); cursor: pointer; font: 600 14px var(--font-body); transition: .16s ease; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover:not(:disabled) { background: var(--primary-hover); }
.btn-secondary { color: var(--text); background: var(--surface-card); border-color: var(--border); }
.btn-secondary:hover:not(:disabled) { background: var(--surface); }
.btn-danger { background: var(--danger); color: #fff; }
.toolbar { display: flex; align-items: end; gap: 16px; padding: 16px; margin-bottom: 20px; }
.filter-group { display: grid; gap: 5px; min-width: 170px; }
.filter-grow { flex: 1; }
.filter-group label { color: var(--text-muted); font-size: 12px; font-weight: 600; }
.input, select { width: 100%; min-height: 42px; padding: 10px 12px; color: var(--text); background: var(--surface-card); border: 1px solid var(--border); border-radius: var(--radius-md); outline: none; font: 400 14px var(--font-body); }
.input:focus,select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,.12); }
.tag-input { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; width: 100%; min-height: 42px; padding: 6px 8px; box-sizing: border-box; color: var(--text); background: var(--surface-card); border: 1px solid var(--border); border-radius: var(--radius-md); }
.tag-input:focus-within { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,.12); }
.tag-input-chips { display: contents; }
.tag-chip { display: inline-flex; align-items: center; gap: 4px; padding: 4px 6px 4px 10px; background: var(--surface); border-radius: var(--radius-sm); font-size: 13px; font-weight: 600; color: var(--text); white-space: nowrap; }
.tag-chip-remove { border: none; background: transparent; color: var(--text-muted); cursor: pointer; font-size: 15px; line-height: 1; padding: 0 2px; }
.tag-chip-remove:hover { color: var(--text); }
.tag-input-text { flex: 1 1 120px; min-width: 120px; border: none; outline: none; background: transparent; color: var(--text); font: 400 14px var(--font-body); padding: 4px 2px; }
.toolbar-count { padding-bottom: 11px; color: var(--text-muted); white-space: nowrap; font-size: 13px; }
.auth-shell { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.auth-card { width: 100%; max-width: 380px; padding: 32px; display: grid; gap: 20px; }
.auth-card .brand { justify-content: center; padding: 0 0 4px; }
.auth-switch { margin: 0; text-align: center; color: var(--text-muted); font-size: 13px; }
.auth-switch a { color: var(--primary); font-weight: 600; }
.user-info { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px; margin-bottom: 4px; }
.user-info span { color: var(--text-muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-info .btn { min-height: 30px; padding: 4px 10px; font-size: 12px; }
.search-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(310px, 1fr)); gap: 16px; }
.search-card { padding: 20px; display: grid; gap: 17px; }
.search-card-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.search-card h2 { font-size: 20px; }
.card-kicker { margin: 3px 0 0; color: var(--text-muted); }
.badge { display: inline-flex; align-items: center; justify-content: center; padding: 4px 9px; border-radius: 999px; font-size: 12px; font-weight: 700; white-space: nowrap; }
.badge-active { background: #dcfce7; color: #166534; }
.badge-renewal { background: #fef3c7; color: #92400e; }
.badge-expired { background: #fee2e2; color: #991b1b; }
.badge-paused { background: #e2e8f0; color: #475569; }
.meta-row,.criteria { color: var(--text-muted); font-size: 13px; }
.criteria { padding: 11px; background: var(--surface); border-radius: var(--radius-sm); }
.criteria strong { display: block; margin-bottom: 2px; color: var(--text); font-size: 12px; }
.price-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.price-item { padding: 10px; background: var(--surface); border-radius: var(--radius-sm); }
.price-item span { display: block; color: var(--text-muted); font-size: 11px; }
.price-item strong { font-size: 15px; }
.card-footer { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding-top: 3px; border-top: 1px solid var(--border); }
.card-footer small { color: var(--text-muted); }
.detail-layout { display: grid; gap: 16px; max-width: 940px; }
.form-section { padding: 24px; }
.section-heading { margin-bottom: 20px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.form-grid label { display: grid; gap: 6px; color: var(--text); font-size: 13px; font-weight: 600; }
.field-full { grid-column: 1 / -1; }
.check-label { display: flex !important; align-items: center; gap: 9px; min-height: 42px; font-weight: 500 !important; }
.checkbox { width: 17px; height: 17px; accent-color: var(--primary); }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; }
.form-message { min-height: 20px; margin: 0; color: var(--success); font-weight: 600; }
.form-message.error { color: var(--danger); }
.header-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 9px; justify-content: flex-end; }
.danger-zone { max-width: 940px; margin-top: 28px; padding: 22px 24px; display: flex; align-items: center; justify-content: space-between; gap: 20px; border-color: rgba(220,38,38,.3); }
.notice { max-width: 940px; margin: -8px 0 18px; padding: 12px 14px; border-radius: var(--radius-md); background: #fef3c7; color: #92400e; }
.ai-options { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.ai-option { text-align: left; }
.link-button { border: none; background: none; padding: 0; color: var(--primary); font: 600 13px var(--font-body); cursor: pointer; text-decoration: underline; }
.hidden { display: none; }
.loading-card,.empty-card { padding: 32px; color: var(--text-muted); text-align: center; }
@media (max-width: 820px) {
  .sidebar { position: static; width: 100%; height: auto; padding: 14px 18px; flex-direction: row; align-items: center; }
  .brand { padding: 0; margin-right: auto; }
  .nav { display: flex; gap: 2px; }
  .nav-link { padding: 8px; font-size: 0; }
  .nav-link span { font-size: 18px; }
  .sidebar-bottom { margin: 0; padding: 0; }
  .theme-toggle span { display: none; }
  .app-shell { display: block; }
  .main-content { width: 100%; margin: 0; padding: 28px 18px; }
  .page-header { flex-direction: column; }
  .toolbar { align-items: stretch; flex-direction: column; }
  .toolbar-count { padding: 0; }
  .header-actions { justify-content: flex-start; }
}
@media (max-width: 560px) {
  .form-grid { grid-template-columns: 1fr; }
  .field-full { grid-column: auto; }
  .price-grid { grid-template-columns: 1fr; }
  .card-footer,.danger-zone { align-items: stretch; flex-direction: column; }
  .danger-zone .btn { width: 100%; }
}


.nav-count {
  display: inline-flex;
  min-width: 18px;
  height: 18px;
  align-items: center;
  justify-content: center;
  padding: 0 5px;
  margin-left: auto;
  color: #fff;
  background: var(--danger);
  border-radius: 999px;
  font-size: 10px;
  font-weight: 700;
}
.alerts-list { display: grid; gap: 12px; }
.alert-card {
  padding: 18px 20px;
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 16px;
  align-items: start;
}
.alert-card.unread { border-left: 4px solid var(--primary); }
.alert-icon {
  width: 40px; height: 40px;
  display: grid; place-items: center;
  background: var(--surface);
  border-radius: 12px;
  color: var(--primary);
  font-size: 20px;
}
.alert-card.gem .alert-icon { color: var(--accent); background: #fff7ed; }
.alert-main { min-width: 0; }
.alert-title-row { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.alert-title-row h2 { margin: 0; font-size: 17px; overflow-wrap: anywhere; }
.alert-meta { margin: 5px 0 0; color: var(--text-muted); font-size: 13px; }
.alert-detail { margin: 10px 0 0; color: var(--text-muted); font-size: 13px; }
.alert-detail strong { color: var(--text); }
.alert-actions { display: flex; flex-direction: column; align-items: flex-end; gap: 8px; min-width: 140px; }
.alert-price { color: var(--text); font: 800 20px var(--font-heading); white-space: nowrap; }
.alert-time { color: var(--text-muted); font-size: 12px; white-space: nowrap; }
.badge-gem { background: #fef3c7; color: #92400e; }
.badge-deal { background: #dbeafe; color: #1d4ed8; }
.read-state { color: var(--text-muted); font-size: 12px; font-weight: 600; }
@media (max-width: 680px) {
  .alert-card { grid-template-columns: auto 1fr; }
  .alert-actions { grid-column: 1 / -1; flex-direction: row; align-items: center; justify-content: space-between; }
}

.admin-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; margin-bottom: 20px; }
.stat-card { padding: 20px; display: grid; gap: 4px; }
.stat-label { margin: 0; color: var(--text-muted); font-size: 13px; font-weight: 600; }
.stat-value { margin: 2px 0 0; font: 800 34px var(--font-heading); letter-spacing: -.03em; }
.stat-trend { min-height: 40px; margin-top: 6px; color: var(--primary); }
.stat-trend svg { display: block; width: 100%; height: 40px; overflow: visible; }
.stat-caption { margin: 4px 0 0; color: var(--text-muted); font-size: 12px; }
.admin-shortcuts { padding: 24px; }
.shortcut-grid { display: flex; flex-wrap: wrap; gap: 10px; }
@media (max-width: 560px) {
  .shortcut-grid { flex-direction: column; }
  .shortcut-grid .btn { width: 100%; }
}
