/* shop-reply — minimal, friendly, Shopify-admin-familiar (BUILD_SPEC §11).
   Mobile-first responsive; system fonts; one green accent; cards. */

:root {
  --bg: #f6f6f7;
  --surface: #ffffff;
  --border: #e1e3e5;
  --text: #202223;
  --text-subdued: #6d7175;
  --accent: #008060;
  --accent-hover: #006e52;
  --critical: #d72c0d;
  --warning-bg: #fff5ea;
  --warning-border: #e1b878;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(0,0,0,.05), 0 1px 4px rgba(0,0,0,.04);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
        "Helvetica Neue", Arial, sans-serif;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* --- layout --- */
.topnav {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 4px;
  padding: 0 12px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  position: sticky; top: 0; z-index: 10;
}
.topnav .brand {
  font-weight: 700; color: var(--text); padding: 14px 10px 14px 4px;
  white-space: nowrap;
}
.topnav .brand .dot { color: var(--accent); }
.topnav a.nav-link {
  color: var(--text-subdued); padding: 14px 10px; white-space: nowrap;
  border-bottom: 2px solid transparent; font-weight: 500;
}
.topnav a.nav-link:hover { color: var(--text); text-decoration: none; }
.topnav a.nav-link.active { color: var(--text); border-bottom-color: var(--accent); }
.topnav .spacer { flex: 1; }
.topnav form { margin: 0; }

.container { max-width: 960px; margin: 0 auto; padding: 16px 12px 64px; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  margin-bottom: 16px;
}
.card h2 { margin: 0 0 4px; font-size: 16px; }
.card .sub { color: var(--text-subdued); font-size: 13px; margin: 0 0 12px; }

/* --- flash messages --- */
.flash {
  background: #effaf5; border: 1px solid #b3dcc8; color: #054f31;
  padding: 10px 14px; border-radius: var(--radius); margin-bottom: 14px;
  font-size: 14px;
}

/* --- forms & buttons --- */
label { display: block; font-weight: 600; font-size: 13px; margin: 12px 0 4px; }
label .hint { font-weight: 400; color: var(--text-subdued); }
input[type=text], input[type=email], input[type=password], input[type=url],
select, textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #8c9196;
  border-radius: 8px;
  font: inherit;
  background: var(--surface);
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--accent); outline-offset: 1px; border-color: var(--accent);
}
textarea { min-height: 110px; resize: vertical; }

.btn {
  display: inline-block;
  background: var(--accent); color: #fff;
  border: none; border-radius: 8px;
  padding: 10px 18px; font: inherit; font-weight: 600;
  cursor: pointer;
  min-height: 42px; /* touch-friendly */
}
.btn:hover { background: var(--accent-hover); }
.btn.secondary {
  background: var(--surface); color: var(--text);
  border: 1px solid #8c9196;
}
.btn.secondary:hover { background: #f1f2f3; }
.btn.danger { background: #fff; color: var(--critical); border: 1px solid var(--critical); }
.btn.small { padding: 6px 12px; min-height: 34px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: default; }

.inline-form { display: inline; }
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }
.row > div { flex: 1; min-width: 180px; }
.actions-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }

/* --- badges --- */
.badge {
  display: inline-block; font-size: 12px; font-weight: 600;
  border-radius: 999px; padding: 2px 10px; white-space: nowrap;
}
.badge.new { background: #eaf4ff; color: #1f5199; }
.badge.drafted { background: #fff1e3; color: #8a5100; }
.badge.sent { background: #effaf5; color: #054f31; }
.badge.closed { background: #f1f2f3; color: var(--text-subdued); }
.badge.flagged { background: #fff0ed; color: var(--critical); }
.badge.verified { background: #effaf5; color: #054f31; }
.badge.pending { background: #fff1e3; color: #8a5100; }
.badge.none { background: #f1f2f3; color: var(--text-subdued); }

/* --- ticket list --- */
.ticket-list { display: flex; flex-direction: column; gap: 8px; }
.ticket-item {
  display: block; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 12px 14px; color: var(--text);
}
.ticket-item:hover { text-decoration: none; border-color: var(--accent); }
.ticket-item .line1 { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.ticket-item .subject { font-weight: 600; flex: 1; min-width: 160px; }
.ticket-item .meta { color: var(--text-subdued); font-size: 13px; margin-top: 2px; }

.filterbar { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.filterbar a {
  padding: 6px 12px; border-radius: 999px; font-size: 13px; font-weight: 600;
  background: var(--surface); border: 1px solid var(--border); color: var(--text-subdued);
}
.filterbar a.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.filterbar a:hover { text-decoration: none; }

/* --- thread --- */
.msg { border: 1px solid var(--border); border-radius: var(--radius);
       padding: 12px 14px; margin-bottom: 10px; background: var(--surface); }
.msg.out { background: #f3faf7; border-color: #b3dcc8; }
.msg .who { font-size: 13px; font-weight: 700; margin-bottom: 6px; }
.msg .who .when { font-weight: 400; color: var(--text-subdued); }
.msg .body { overflow-wrap: anywhere; }
.msg .body img { max-width: 100%; height: auto; }
.msg .attachments { margin-top: 8px; font-size: 13px; }

.action-box {
  background: var(--warning-bg); border: 1px solid var(--warning-border);
  border-radius: var(--radius); padding: 12px 14px; margin: 12px 0; font-size: 14px;
}
.action-box strong { display: block; margin-bottom: 4px; }

.tracking { font-size: 13px; color: var(--text-subdued); margin-top: 6px; }

/* --- editor (Quill) --- */
.editor-wrap { background: var(--surface); border-radius: 8px; }
#editor { min-height: 160px; background: var(--surface); border-radius: 0 0 8px 8px; }
.ql-toolbar { border-radius: 8px 8px 0 0; }
.ql-container { font: inherit; border-radius: 0 0 8px 8px; }

/* --- tables / dns records --- */
.dns-record {
  background: #f6f6f7; border: 1px dashed var(--border); border-radius: 8px;
  padding: 10px 12px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12.5px; overflow-x: auto; white-space: pre-wrap; word-break: break-all;
  margin: 6px 0 12px;
}

.kb-source { display: flex; align-items: center; gap: 10px; padding: 10px 0;
             border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.kb-source:last-child { border-bottom: none; }
.kb-source .title { flex: 1; min-width: 200px; font-weight: 600; }
.kb-source .meta { color: var(--text-subdued); font-size: 13px; }

.empty {
  text-align: center; color: var(--text-subdued); padding: 36px 16px;
}
.empty .big { font-size: 34px; margin-bottom: 6px; }

.auth-page { max-width: 400px; margin: 8vh auto 0; padding: 0 14px; }
.auth-page .brand { text-align: center; font-size: 22px; font-weight: 800;
                    margin-bottom: 18px; }
.auth-page .brand .dot { color: var(--accent); }

details.adder { border: 1px solid var(--border); border-radius: var(--radius);
                margin-bottom: 10px; background: var(--surface); }
details.adder summary { padding: 12px 14px; font-weight: 600; cursor: pointer; }
details.adder .inner { padding: 0 14px 14px; }

/* --- tabs (inbox settings) --- */
.tabs { display: flex; gap: 2px; margin: 8px -16px 0; padding: 0 16px;
        overflow-x: auto; }
.tabs a {
  padding: 10px 14px; font-weight: 600; font-size: 14px;
  color: var(--text-subdued); border-bottom: 2px solid transparent;
  white-space: nowrap;
}
.tabs a:hover { color: var(--text); text-decoration: none; }
.tabs a.active { color: var(--text); border-bottom-color: var(--accent); }

/* --- activation checklist --- */
.checklist { background: #f3faf7; border-color: #b3dcc8; }
.check-items { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; }
.check-item {
  display: flex; align-items: center; gap: 10px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 8px; padding: 10px 12px; color: var(--text); font-weight: 500;
}
.check-item:hover { border-color: var(--accent); text-decoration: none; }
.check-item.done { color: var(--text-subdued); text-decoration: line-through; }
.check-item.done:hover { text-decoration: line-through; }
.check-item .tick { font-size: 15px; min-width: 22px; text-align: center; }

/* --- setup wizard --- */
.wizard { max-width: 620px; margin: 0 auto; }
.wizard-progress { display: flex; align-items: center; justify-content: center;
                   gap: 0; margin: 6px 0 16px; }
.wizard-progress .dot {
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--surface); border: 2px solid var(--border);
  color: var(--text-subdued); font-weight: 700; font-size: 13px;
  display: flex; align-items: center; justify-content: center;
}
.wizard-progress .dot.on { background: var(--accent); border-color: var(--accent);
                           color: #fff; }
.wizard-progress .bar { width: 48px; height: 2px; background: var(--border); }

/* --- wizard welcome --- */
.how-steps { display: flex; flex-direction: column; gap: 8px; max-width: 460px;
             margin: 0 auto; }
.how-step {
  display: flex; gap: 12px; align-items: flex-start;
  background: #f6f6f7; border-radius: 8px; padding: 12px; font-size: 14px;
  font-weight: 600;
}
.how-step .num {
  flex: 0 0 auto; width: 24px; height: 24px; border-radius: 50%;
  background: var(--accent); color: #fff; font-size: 13px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}
.how-step .sub { font-weight: 400; }

/* numbered setup steps (Shopify connect, etc.) */
.setup-steps { margin: 6px 0 16px; padding-left: 22px; }
.setup-steps li { margin-bottom: 10px; line-height: 1.55; }
.setup-steps .dns-record { margin: 8px 0 6px; }

/* helper text under an input */
.field-note { font-size: 12.5px; color: var(--text-subdued); margin: 5px 0 0; }

/* equal-width, TOP-aligned field columns (labels/inputs line up even when
   helper text under one field wraps to 2 lines) */
.field-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 4px 14px; align-items: start; margin-top: 4px;
}
.field-grid > div > label:first-child { margin-top: 0; }
@media (max-width: 640px) { .field-grid { grid-template-columns: 1fr; } }

/* live status box (distinct from info boxes) */
.status-box {
  display: flex; gap: 12px; align-items: flex-start;
  background: #fff8ec; border: 1px solid #f0d9a8; border-left: 4px solid #e0a92e;
  border-radius: 8px; padding: 12px 14px; font-size: 14px; margin: 14px 0;
}
.status-box .pulse {
  flex: 0 0 auto; width: 10px; height: 10px; border-radius: 50%;
  background: #e0a92e; margin-top: 5px; position: relative;
}
.status-box .pulse::after {
  content: ""; position: absolute; inset: -4px; border-radius: 50%;
  border: 2px solid #e0a92e; opacity: .6;
  animation: status-pulse 1.6s ease-out infinite;
}
@keyframes status-pulse {
  0% { transform: scale(.5); opacity: .7; }
  100% { transform: scale(1.7); opacity: 0; }
}
.status-box.done {
  background: #effaf5; border-color: #b3dcc8; border-left-color: var(--accent);
}
.status-box.done .pulse { background: var(--accent); }
.status-box.done .pulse::after { display: none; }

/* inbox address (handle) field */
.handle-field {
  display: flex; align-items: stretch; gap: 0; margin: 4px 0 6px;
  border: 1px solid #8c9196; border-radius: 8px; overflow: hidden;
  background: var(--surface); flex-wrap: wrap;
}
.handle-field input {
  flex: 1 1 140px; min-width: 120px; border: none; border-radius: 0;
  padding: 10px 12px; outline: none;
}
.handle-field input:focus { outline: none; }
.handle-field:focus-within { outline: 2px solid var(--accent); outline-offset: 1px;
                             border-color: var(--accent); }
.handle-field .suffix {
  display: flex; align-items: center; padding: 0 10px; color: var(--text-subdued);
  background: #f6f6f7; font-size: 14px; white-space: nowrap;
}
.handle-field .btn { border-radius: 0; min-height: auto; }

/* setup sub-steps */
.setup-label {
  font-weight: 700; font-size: 14px; margin: 18px 0 8px;
}
.setup-list {
  list-style: none; padding: 0; margin: 0;
  display: flex; flex-direction: column; gap: 8px;
}
.setup-list li {
  background: #f6f6f7; border-radius: 8px; padding: 10px 12px;
  font-size: 14px; color: var(--text-subdued); line-height: 1.5;
}
.setup-list li strong { color: var(--text); }

/* brand-voice generator */
.voicegen {
  background: #f3faf7; border: 1px solid #b3dcc8; border-radius: var(--radius);
  padding: 12px 14px; margin-bottom: 14px;
}
.voicegen label { margin-top: 0; }
.voicegen .sub { margin: 6px 0 0; }

/* step count + required/optional pills */
.step-count {
  font-size: 12px; font-weight: 700; letter-spacing: .04em;
  text-transform: uppercase; color: var(--accent); margin-bottom: 4px;
}
.req, .opt {
  font-size: 11px; font-weight: 700; border-radius: 999px;
  padding: 2px 8px; vertical-align: middle; margin-left: 4px;
  text-transform: uppercase; letter-spacing: .03em;
}
.req { background: #eaf4ff; color: #1f5199; }
.opt { background: #f1f2f3; color: var(--text-subdued); }

/* --- settings hub --- */
.hub-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.hub-card {
  display: flex; gap: 12px; align-items: flex-start;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 16px; color: var(--text);
}
a.hub-card:hover { border-color: var(--accent); text-decoration: none; }
.hub-card .hub-icon { font-size: 22px; }
.hub-card p { margin: 2px 0 0; }

/* --- mobile --- */
@media (max-width: 640px) {
  .container { padding: 12px 8px 80px; }
  .card { padding: 13px; }
  .row { flex-direction: column; }
  .row > div { min-width: 0; }
  .btn { width: 100%; text-align: center; }
  .btn.small, .filterbar .btn { width: auto; }
  .actions-row .btn { width: 100%; }
  .ql-toolbar { overflow-x: auto; white-space: nowrap; }
  .hub-grid { grid-template-columns: 1fr; }
  .wizard-progress .bar { width: 28px; }
}
