/*
  Operations (staff-only) pages. The operations layout loads only this file,
  not application.css: a plain, dense admin look with system fonts, tables and
  no customer-facing decoration. Every rule is scoped to body.ops because
  stylesheet_link_tag :app also loads this file on customer pages.
*/
.ops {
  --ops-ink: #1f2328;
  --ops-muted: #59636e;
  --ops-bg: #ffffff;
  --ops-subtle: #f6f8fa;
  --ops-line: #d1d9e0;
  --ops-accent: #0969da;
  --ops-danger: #cf222e;
  --ops-warn-bg: #fff8c5;
  --ops-ok-bg: #dafbe1;
  background: var(--ops-bg);
  color: var(--ops-ink);
  font: 14px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  margin: 0;
}
.ops *, .ops *::before, .ops *::after { box-sizing: border-box; }
.ops a { color: var(--ops-accent); text-decoration: none; }
.ops a:hover { text-decoration: underline; }
.ops h1 { font-size: 1.5rem; font-weight: 600; margin: 0; overflow-wrap: anywhere; }
.ops h2 { font-size: 1.1rem; font-weight: 600; margin: 0; }
.ops h3 { font-size: 0.95rem; font-weight: 600; margin: 0; }
.ops p { margin: 0.5rem 0; }
.ops code { background: var(--ops-subtle); border-radius: 4px; font-size: 0.85em; overflow-wrap: anywhere; padding: 0.1em 0.35em; }
.ops img { display: block; max-width: 100%; }
.ops :focus-visible { outline: 2px solid var(--ops-accent); outline-offset: 2px; }
.ops .hint { color: var(--ops-muted); max-width: 80ch; }

.ops .skip-link { background: var(--ops-ink); color: #fff; left: 1rem; padding: 0.5rem 0.75rem; position: absolute; top: 0.5rem; transform: translateY(-200%); z-index: 60; }
.ops .skip-link:focus { transform: none; }
.ops .visually-hidden { clip: rect(0 0 0 0); height: 1px; overflow: hidden; position: absolute; white-space: nowrap; width: 1px; }

.ops .button {
  align-items: center;
  background: var(--ops-subtle);
  border: 1px solid var(--ops-line);
  border-radius: 6px;
  color: var(--ops-ink);
  cursor: pointer;
  display: inline-flex;
  font: inherit;
  font-weight: 500;
  gap: 0.4rem;
  min-height: 32px;
  padding: 0.3rem 0.8rem;
  text-decoration: none;
  white-space: nowrap;
}
.ops .button:hover { background: #eff2f5; text-decoration: none; }
.ops .button-primary { background: #1f883d; border-color: #1a7f37; color: #fff; }
.ops .button-primary:hover { background: #1a7f37; }
.ops .button-danger { color: var(--ops-danger); }
.ops input:not([type="checkbox"]):not([type="radio"]):not([type="submit"]), .ops select, .ops textarea {
  background: var(--ops-bg);
  border: 1px solid var(--ops-line);
  border-radius: 6px;
  color: var(--ops-ink);
  font: inherit;
  min-height: 32px;
  padding: 0.3rem 0.5rem;
  width: 100%;
}

.ops .flash-stack { display: grid; gap: 0.5rem; max-width: min(480px, calc(100% - 2rem)); position: fixed; right: 1rem; top: 1rem; width: 100%; z-index: 50; }
.ops .flash { align-items: center; background: var(--ops-ok-bg); border: 1px solid var(--ops-line); border-radius: 6px; display: flex; gap: 1rem; justify-content: space-between; padding: 0.6rem 0.8rem; }
.ops .flash.alert { background: #ffebe9; }
.ops .flash button { background: none; border: 0; color: var(--ops-muted); cursor: pointer; font: inherit; }

.ops .operations-shell { margin: 0 auto; max-width: 1280px; padding: 0 1.5rem 4rem; }
.ops .operations-nav { align-items: center; border-bottom: 1px solid var(--ops-line); display: flex; gap: 1rem; justify-content: space-between; min-height: 56px; }
.ops .operations-nav nav { align-items: center; display: flex; flex-wrap: wrap; gap: 1.25rem; }
.ops .operations-nav nav a { color: var(--ops-ink); }
.ops .operations-nav nav a[aria-current="page"] { font-weight: 600; text-decoration: underline; text-underline-offset: 0.3em; }
.ops .operations-nav form { margin: 0; }
.ops .ops-brand { font-weight: 700; }
.ops .ops-brand span { color: var(--ops-muted); font-weight: 400; }
.ops .breadcrumb { margin: 1rem 0 0; }
.ops .operations-heading { align-items: flex-start; display: flex; flex-wrap: wrap; gap: 1rem; justify-content: space-between; padding: 1.25rem 0 1rem; }

.ops .metric-grid { border: 1px solid var(--ops-line); border-radius: 6px; display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); margin: 0 0 1.5rem; overflow: hidden; }
.ops .metric-grid div { border-left: 1px solid var(--ops-line); margin-left: -1px; padding: 0.6rem 0.9rem; }
.ops .metric-grid dt { color: var(--ops-muted); font-size: 0.8rem; }
.ops .metric-grid dd { font-size: 1.25rem; font-variant-numeric: tabular-nums; font-weight: 600; margin: 0; }

.ops .ops-section { margin-top: 2rem; }
.ops .list-heading { align-items: baseline; border-bottom: 1px solid var(--ops-line); display: flex; gap: 0.75rem; justify-content: space-between; margin: 1rem 0 0.5rem; padding-bottom: 0.4rem; }
.ops .list-heading > span { color: var(--ops-muted); font-variant-numeric: tabular-nums; }
.ops .inline-empty { color: var(--ops-muted); }
.ops .empty-state { border: 1px dashed var(--ops-line); border-radius: 6px; padding: 1.5rem; }
.ops .empty-state p { color: var(--ops-muted); margin-bottom: 0; }

.ops .table-wrap { overflow-x: auto; }
.ops .ops-table { border-collapse: collapse; width: 100%; }
.ops .ops-table th { background: var(--ops-subtle); color: var(--ops-muted); font-size: 0.8rem; font-weight: 600; text-align: left; white-space: nowrap; }
.ops .ops-table th, .ops .ops-table td { border-bottom: 1px solid var(--ops-line); padding: 0.45rem 0.6rem; vertical-align: top; }
.ops .ops-table tbody tr:hover { background: var(--ops-subtle); }
.ops .ops-table td:first-child { min-width: 12rem; }
.ops .ops-table .numeric { font-variant-numeric: tabular-nums; text-align: right; }
.ops .row-actions { white-space: nowrap; }
.ops .row-actions a + a { margin-left: 0.75rem; }

.ops .status-badge { background: var(--ops-subtle); border: 1px solid var(--ops-line); border-radius: 999px; display: inline-block; font-size: 0.75rem; padding: 0 0.5rem; white-space: nowrap; }
.ops .status-badge.ongoing { background: var(--ops-ok-bg); }
.ops .status-badge.finished { color: var(--ops-muted); }

.ops .facts { display: grid; gap: 0.5rem 1.5rem; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); margin: 0; }
.ops .facts dt { color: var(--ops-muted); font-size: 0.8rem; }
.ops .facts dd { margin: 0; overflow-wrap: anywhere; }
.ops .detail-facts { display: grid; gap: 1.5rem; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); margin-bottom: 1.5rem; }
.ops .copy-field-group { align-items: flex-end; display: flex; flex-wrap: wrap; gap: 0.5rem; margin: 0 0 0.75rem; }
.ops .copy-field { display: grid; flex: 1; gap: 0.2rem; }
.ops .copy-field span { color: var(--ops-muted); font-size: 0.8rem; }
/* Under its field, so it never reads as the row above's note. */
.ops .copy-field-warning { color: var(--ops-danger); flex-basis: 100%; font-size: 0.8rem; margin: 0; order: 1; }

.ops .recent-grid { display: grid; gap: 0.5rem; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); }
.ops .recent-item { border: 1px solid var(--ops-line); border-radius: 6px; overflow: hidden; }
.ops .recent-item img { aspect-ratio: 1; object-fit: cover; width: 100%; }
.ops .recent-item span { display: block; font-size: 0.75rem; overflow: hidden; padding: 0.25rem 0.4rem; text-overflow: ellipsis; white-space: nowrap; }

.ops .review-row { border-bottom: 1px solid var(--ops-line); display: grid; gap: 1rem 2rem; grid-template-columns: minmax(200px, 1fr) minmax(300px, 2fr) minmax(220px, 1fr); padding: 1rem 0; }
.ops .review-resolve { display: grid; gap: 0.4rem; }
.ops .review-resolve label { color: var(--ops-muted); font-size: 0.8rem; }
.ops .review-check { align-items: center; color: var(--ops-ink); display: flex; gap: 0.4rem; }
.ops .review-actions { display: grid; align-content: start; gap: 1rem; }
.ops .refund-form { display: grid; gap: 0.4rem; justify-items: start; }
.ops .refund-state { margin: 0 0 0.4rem; }
.ops .refund-failed { color: var(--ops-danger); }
.ops .purchase-times, .ops .purchase-ids { display: grid; gap: 0.25rem; margin: 0 0 0.4rem; }
.ops .purchase-times dt, .ops .purchase-ids dt { color: var(--ops-muted); font-size: 0.75rem; }
.ops .purchase-times dd, .ops .purchase-ids dd { margin: 0; }

.ops .operations-login { display: grid; min-height: 100dvh; padding: 1rem; place-items: center; }
.ops .login-card { border: 1px solid var(--ops-line); border-radius: 6px; max-width: 360px; padding: 1.5rem; width: 100%; }
.ops .login-form { display: grid; gap: 0.75rem; margin: 1rem 0; }
.ops .login-form label { display: grid; gap: 0.25rem; }

@media (max-width: 760px) {
  .ops .operations-shell { padding: 0 1rem 3rem; }
  .ops .detail-facts, .ops .review-row { grid-template-columns: 1fr; }
  .ops .copy-field-group { align-items: stretch; flex-direction: column; }
}

.ops .heading-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.ops .ops-form { display: grid; gap: 1rem; max-width: 720px; }
.ops .ops-form fieldset { border: 1px solid var(--ops-line); border-radius: 6px; display: grid; gap: 0.75rem; margin: 0; padding: 0.75rem 1rem 1rem; }
.ops .ops-form legend { font-weight: 600; padding: 0 0.25rem; }
.ops .ops-form .hint { font-size: 0.85rem; margin: 0; }
.ops .ops-form > .button { justify-self: start; }
.ops .field { display: grid; gap: 0.25rem; }
.ops .field label { font-weight: 500; }
.ops .field-row { display: grid; gap: 0.75rem; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.ops .has-error input, .ops .has-error select { border-color: var(--ops-danger); }
.ops fieldset.has-error { border-color: var(--ops-danger); }
.ops .form-errors { background: #ffebe9; border: 1px solid #ffcecb; border-radius: 6px; margin-bottom: 1rem; max-width: 720px; padding: 0.75rem 1rem; }
.ops .form-errors h2 { font-size: 0.95rem; }
.ops .form-errors ul { margin: 0.25rem 0 0; padding-left: 1.25rem; }
.ops .plan-options { display: grid; gap: 0.5rem; }
.ops .plan-option { align-items: flex-start; display: flex; gap: 0.5rem; }
.ops .plan-option input { margin-top: 0.3rem; }
.ops .plan-option > span { display: grid; }
.ops .plan-section { margin-bottom: 1.5rem; }
.ops .plan-section .facts { margin-bottom: 1rem; }
.ops .plan-form { max-width: none; }

.ops .ops-search { align-items: flex-end; display: flex; flex-wrap: wrap; gap: 0.5rem 0.75rem; margin: 0.75rem 0; }
.ops .ops-search .field { flex: 0 1 auto; }
.ops .ops-search .field:first-child { flex: 1 1 260px; }
.ops .status-badge.archived { background: #eaeef2; color: var(--ops-muted); }
.ops .status-badge + .status-badge { margin-left: 0.25rem; }
.ops .pager { align-items: center; display: flex; gap: 1rem; justify-content: center; padding: 0.75rem 0; }
.ops .pager span { color: var(--ops-muted); }
.ops .danger-zone { border: 1px solid #ffcecb; border-radius: 6px; display: grid; gap: 1rem; margin-top: 2rem; padding: 0.75rem 1rem 1rem; }
.ops .danger-zone h2 { color: var(--ops-danger); }
.ops .danger-zone form { display: grid; gap: 0.4rem; max-width: 520px; }
.ops .danger-zone h3 { margin-top: 0.25rem; }
