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

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  color: #1a1d21;
  background: #f7f8fa;
}

.page {
  max-width: 720px;
  margin: 0 auto;
  padding: 2rem 1rem 3rem;
}

.page-top {
  margin-bottom: 1rem;
}

.page-top-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem 1rem;
  margin-bottom: 0.35rem;
}

.page-top-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem 0.5rem;
}

.page--narrow {
  max-width: 400px;
}

.login-form .field {
  margin-bottom: 0.85rem;
}

.page-title {
  margin: 0;
  font-size: 1.35rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}

a.btn {
  text-decoration: none;
}

.btn--block {
  width: 100%;
  margin-bottom: 0;
}

.section-heading {
  margin: 0 0 0.75rem;
  font-size: 1rem;
  font-weight: 600;
}

.field-control {
  width: 100%;
  padding: 0.55rem 0.75rem;
  font: inherit;
  font-size: 0.9rem;
  border: 1px solid #d8dce2;
  border-radius: 6px;
  min-height: auto;
}

select.field-control {
  min-height: 2.35rem;
  background: #fff;
}

.field-control:focus {
  outline: none;
  border-color: #0a66c2;
  box-shadow: 0 0 0 2px rgba(10, 102, 194, 0.15);
}

.field-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.field--grow {
  flex: 1 1 12rem;
}

.field--narrow {
  flex: 0 1 8rem;
}

.form-error {
  margin: 0.5rem 0 0;
  font-size: 0.85rem;
  color: #b24020;
}

.cookie-form {
  padding-bottom: 1.25rem;
  margin-bottom: 1.25rem;
  border-bottom: 1px solid #e3e6ea;
}

.cookie-list-section .section-heading {
  margin: 0;
}

.cookie-list {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.cookie-card {
  border: 1px solid #e3e6ea;
  border-radius: 8px;
  padding: 0.75rem;
  background: #fafbfc;
}

.cookie-card-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
}

.cookie-label {
  display: block;
  font-size: 0.95rem;
}

.cookie-liat {
  display: block;
  font-size: 0.8rem;
  color: #7a8490;
  font-family: ui-monospace, Menlo, Consolas, monospace;
  margin-top: 0.15rem;
}

.badge {
  flex-shrink: 0;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: 0.2rem 0.45rem;
  border-radius: 4px;
  background: #e3e6ea;
  color: #3d444d;
}

.badge--active {
  background: #e8f5ee;
  color: #057642;
}

.badge--cooldown {
  background: #fff4e5;
  color: #b45309;
}

.badge--tier-premium {
  background: #e8f0fe;
  color: #1a56db;
}

.badge--tier-basic {
  background: #f3f4f6;
  color: #4b5563;
}

.tier-label.badge--tier-premium,
.tier-label.badge--tier-basic {
  font-size: 0.85em;
  font-weight: 600;
  padding: 0.15em 0.5em;
  border-radius: 4px;
  margin-left: 0.25rem;
}

.cookie-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  align-items: center;
}

.badge--dead {
  background: #fdf0ed;
  color: #b24020;
}

.cookie-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
  margin: 0 0 0.65rem;
  font-size: 0.8rem;
}

.cookie-stats dt {
  color: #7a8490;
  font-weight: 500;
}

.cookie-stats dd {
  margin: 0;
  color: #1a1d21;
}

.cookie-card-actions {
  display: flex;
  gap: 0.35rem;
}

.dialog {
  border: none;
  border-radius: 10px;
  padding: 0;
  max-width: min(420px, 92vw);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
}

.dialog::backdrop {
  background: rgba(0, 0, 0, 0.35);
}

.dialog-body {
  padding: 1.25rem;
}

.dialog-meta {
  margin: -0.35rem 0 1rem;
  font-size: 0.8rem;
  color: #7a8490;
  font-family: ui-monospace, Menlo, Consolas, monospace;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 1rem;
}

@media (max-width: 520px) {
  .cookie-stats {
    grid-template-columns: 1fr;
  }
}

.panel {
  background: #fff;
  border: 1px solid #e3e6ea;
  border-radius: 10px;
  padding: 1.5rem;
}

.panel-head {
  margin-bottom: 1.25rem;
}

.panel-head h1 {
  margin: 0 0 0.25rem;
  font-size: 1.35rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.panel-sub {
  margin: 0;
  font-size: 0.9rem;
  color: #5c6570;
}

.field {
  margin-bottom: 0.75rem;
}

.field-label {
  display: block;
  margin-bottom: 0.35rem;
  font-size: 0.85rem;
  font-weight: 500;
  color: #3d444d;
}

.field-input {
  width: 100%;
  padding: 0.65rem 0.75rem;
  font: inherit;
  font-size: 0.9rem;
  line-height: 1.45;
  color: inherit;
  background: #fff;
  border: 1px solid #d8dce2;
  border-radius: 6px;
  resize: vertical;
  min-height: 140px;
}

.field-input:focus {
  outline: none;
  border-color: #0a66c2;
  box-shadow: 0 0 0 2px rgba(10, 102, 194, 0.15);
}

.field-input::placeholder {
  color: #9aa3ad;
}

.meta-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem 1rem;
  margin-bottom: 1rem;
}

.meta-count {
  font-size: 0.85rem;
  color: #5c6570;
}

.meta-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.45rem 0.85rem;
  font: inherit;
  font-size: 0.875rem;
  font-weight: 500;
  line-height: 1.2;
  border-radius: 6px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn--primary {
  padding: 0.7rem 1rem;
  color: #fff;
  background: #0a66c2;
  border-color: #0a66c2;
}

.panel > .btn--primary.btn--block {
  margin-bottom: 1.5rem;
}

.btn--primary:hover:not(:disabled) {
  background: #004182;
  border-color: #004182;
}

.btn--ghost {
  color: #3d444d;
  background: transparent;
  border-color: #d8dce2;
}

.btn--ghost:hover:not(:disabled) {
  background: #f3f4f6;
  border-color: #c5cad2;
}

.btn--sm {
  padding: 0.35rem 0.65rem;
  font-size: 0.8rem;
}

.results {
  border-top: 1px solid #e3e6ea;
  padding-top: 1.25rem;
}

.results-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem 1rem;
  margin-bottom: 0.75rem;
}

.results-title {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
}

.results-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.results-body,
#results {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.scrape-progress {
  margin: 0;
  padding: 0.5rem 0.75rem;
  font-size: 0.85rem;
  font-weight: 500;
  color: #0a66c2;
  background: #eef3f8;
  border: 1px solid #d0e3f5;
  border-radius: 6px;
}

.results-empty {
  margin: 0;
  padding: 1.25rem;
  text-align: center;
  font-size: 0.9rem;
  color: #7a8490;
  background: #f9fafb;
  border: 1px dashed #e3e6ea;
  border-radius: 6px;
}

.result {
  border: 1px solid #e3e6ea;
  border-left: 3px solid #9aa3ad;
  border-radius: 6px;
  background: #fff;
  overflow: hidden;
}

.result--ok {
  border-left-color: #22c55e;
}

.result--err {
  border-left-color: #ef4444;
}

.result--queue {
  border-left-color: #c5cad2;
}

.result--queue.result--scraping {
  border-left-color: #0a66c2;
  background: #f8fbff;
}

.result--queue.result--pending {
  opacity: 0.92;
}

.result--queue.result--skipped {
  border-left-color: #d8dce2;
  opacity: 0.75;
}

.result-queue-body {
  padding: 0.65rem 0.75rem;
  font-size: 0.85rem;
  color: #7a8490;
}

.queue-status {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-weight: 500;
  color: #5c6570;
}

.result--scraping .queue-status {
  color: #0a66c2;
}

.spinner-inline {
  display: inline-block;
  width: 0.85em;
  height: 0.85em;
  border: 2px solid #c5daf0;
  border-top-color: #0a66c2;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.result-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.35rem 0.75rem;
  padding: 0.5rem 0.75rem;
  font-size: 0.8rem;
  background: #f9fafb;
  border-bottom: 1px solid #eef0f3;
}

.result-bar strong {
  font-weight: 600;
  color: #1a1d21;
}

.result-bar span {
  color: #5c6570;
  word-break: break-all;
}

.result-json {
  margin: 0;
  padding: 0.75rem;
  max-height: 280px;
  overflow: auto;
  font-family: ui-monospace, "Cascadia Code", "Source Code Pro", Menlo, Consolas, monospace;
  font-size: 0.78rem;
  line-height: 1.45;
  color: #2d333b;
  background: #f3f5f7;
  white-space: pre-wrap;
  word-break: break-word;
}

.result-foot {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  padding: 0.5rem 0.75rem;
  border-top: 1px solid #eef0f3;
}

.toast {
  position: fixed;
  bottom: 1.25rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
  max-width: min(90vw, 360px);
  padding: 0.6rem 1rem;
  font-size: 0.875rem;
  color: #fff;
  background: #1a1d21;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
  animation: toast-in 0.2s ease;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
}
