:root {
    --ink: #172033;
    --muted: #718096;
    --line: #e7ebf0;
    --canvas: #f5f7fa;
    --sidebar: #111827;
    --sidebar-muted: #9aa6b2;
    --accent: #2e6fda;
    --accent-soft: #eaf1ff;
    --success: #17865b;
}

* { box-sizing: border-box; }
body { background: var(--canvas); color: var(--ink); font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif; font-size: 14px; }
a { color: var(--accent); text-decoration: none; }
.app-shell { min-height: 100vh; display: flex; }
.sidebar { width: 232px; flex: 0 0 232px; background: var(--sidebar); color: #fff; padding: 22px 14px 16px; display: flex; flex-direction: column; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; letter-spacing: .02em; padding: 0 10px 28px; font-size: 16px; }
.brand-mark { width: 30px; height: 30px; border-radius: 8px; display: inline-flex; align-items: center; justify-content: center; background: #2e6fda; }
.sidebar-caption { text-transform: uppercase; font-size: 10px; color: #697586; letter-spacing: .12em; padding: 8px 12px 7px; }
.sidebar .nav-link { color: var(--sidebar-muted); display: flex; align-items: center; gap: 12px; padding: 9px 12px; border-radius: 6px; }
.sidebar .nav-link:hover, .sidebar .nav-link.active { color: #fff; background: rgba(255,255,255,.09); }
.sidebar .nav-link.active { box-shadow: inset 3px 0 0 var(--accent); }
.sidebar .nav-link i { width: 18px; font-size: 16px; }
.sidebar-foot { margin-top: auto; padding: 13px 12px 0; border-top: 1px solid rgba(255,255,255,.08); color: #7f8b99; font-size: 11px; }
.status-dot { width: 7px; height: 7px; display: inline-block; border-radius: 50%; background: #28b67a; margin-right: 7px; }
.main-content { flex: 1; min-width: 0; }
.topbar { min-height: 76px; background: #fff; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; padding: 15px 30px; }
.eyebrow { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .12em; }
.page-heading { font-size: 21px; line-height: 1.2; margin: 3px 0 0; font-weight: 700; }
.topbar-user { display: flex; align-items: center; gap: 10px; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); display: inline-flex; align-items: center; justify-content: center; font-weight: 700; }
.user-name { font-weight: 600; font-size: 13px; }
.user-role { color: var(--muted); font-size: 11px; margin-top: 1px; }
.btn-icon { width: 36px; height: 36px; display: inline-flex; align-items: center; justify-content: center; border: 1px solid var(--line); color: var(--muted); background: #fff; border-radius: 6px; }
.btn-icon:hover { color: var(--accent); border-color: #cbd8ef; background: var(--accent-soft); }
.content-wrap { max-width: 1500px; padding: 26px 30px 40px; margin: 0 auto; }
.page-footer { color: #a0a8b4; font-size: 11px; padding: 0 30px 18px; }
.section-title { font-size: 15px; font-weight: 700; margin: 0; }
.section-subtitle { color: var(--muted); font-size: 12px; margin-top: 5px; }
.panel { background: #fff; border: 1px solid var(--line); border-radius: 8px; }
.panel-header { padding: 18px 20px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; gap: 16px; }
.panel-body { padding: 20px; }
.shopify-page-heading { display: flex; justify-content: space-between; align-items: flex-end; gap: 20px; margin-bottom: 20px; }
.shopify-page-title-wrap { display: flex; align-items: center; gap: 13px; min-width: 0; }
.shopify-page-icon { width: 42px; height: 42px; display: inline-flex; align-items: center; justify-content: center; flex: 0 0 42px; border-radius: 10px; color: var(--accent); background: var(--accent-soft); font-size: 20px; }
.shopify-intro { display: flex; align-items: center; gap: 14px; padding: 14px 16px; margin-bottom: 16px; background: linear-gradient(90deg, #f9fbff, #fff); }
.shopify-intro-icon { width: 34px; height: 34px; display: inline-flex; align-items: center; justify-content: center; flex: 0 0 34px; border-radius: 8px; color: var(--accent); background: var(--accent-soft); }
.shopify-intro-copy { flex: 1; min-width: 0; }
.shopify-steps { margin-left: 0; margin-right: 0; }
.shopify-step { height: 100%; display: flex; align-items: flex-start; gap: 11px; padding: 14px 15px; background: #fff; border: 1px solid var(--line); border-radius: 8px; }
.shopify-step-number { width: 24px; height: 24px; display: inline-flex; align-items: center; justify-content: center; flex: 0 0 24px; border-radius: 50%; color: #fff; background: var(--accent); font-size: 11px; font-weight: 700; }
.shopify-store-list { padding: 4px 20px 10px; }
.shopify-store-item { display: grid; grid-template-columns: minmax(160px, 1.3fr) minmax(230px, 1.7fr) auto; gap: 18px; align-items: center; padding: 18px 0; }
.shopify-store-item + .shopify-store-item { border-top: 1px solid var(--line); }
.shopify-store-main { display: flex; align-items: center; gap: 11px; min-width: 0; }
.shopify-store-mark { width: 34px; height: 34px; display: inline-flex; align-items: center; justify-content: center; flex: 0 0 34px; border-radius: 8px; background: #f0f6ff; color: var(--accent); }
.shopify-store-meta { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; color: #465468; font-size: 12px; }
.shopify-store-meta > div { min-width: 0; }
.shopify-store-meta > div > span:last-child { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.shopify-meta-label { display: block; color: var(--muted); font-size: 10px; margin-bottom: 3px; }
.shopify-store-actions { display: flex; align-items: center; justify-content: flex-end; gap: 6px; white-space: nowrap; }
.shopify-form-panel { position: sticky; top: 18px; }
.shopify-form-divider { border-top: 1px solid var(--line); margin: 4px 0 16px; }
.shopify-scope-note { padding: 11px 12px; border-radius: 6px; background: #f8fafc; border: 1px solid var(--line); }
.shopify-oauth-box { padding: 14px; border: 1px solid #dce5f3; border-radius: 8px; background: linear-gradient(180deg, #fbfdff, #f8fbff); }
.shopify-advanced { border-top: 1px solid var(--line); padding-top: 14px; }
.shopify-advanced summary { color: var(--muted); cursor: pointer; }
.shopify-danger-zone { padding: 14px; border: 1px solid #f1c7cc; border-radius: 8px; background: #fff8f8; }
.workflow-builder { border: 1px solid var(--line); border-radius: 8px; padding: 16px; background: #fbfcfe; }
.workflow-builder-heading { display: flex; justify-content: space-between; align-items: flex-start; gap: 14px; }
.workflow-steps { display: grid; gap: 10px; }
.workflow-step-row { display: flex; align-items: flex-start; gap: 10px; padding: 11px; background: #fff; border: 1px solid var(--line); border-radius: 7px; }
.workflow-step-number { width: 26px; height: 26px; display: inline-flex; align-items: center; justify-content: center; flex: 0 0 26px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); font-size: 11px; font-weight: 700; }
.workflow-step-fields { flex: 1; min-width: 0; display: grid; gap: 8px; }
.workflow-step-options { display: grid; grid-template-columns: minmax(160px, .7fr) minmax(220px, 1.3fr); gap: 8px; align-items: center; }
.workflow-delay-label { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 12px; white-space: nowrap; }
.workflow-delay-label .form-control { width: 92px; }
.workflow-delay-label .form-select { width: auto; min-width: 76px; padding-right: 28px; }
.workflow-remove { flex: 0 0 auto; }
.workflow-send-note { padding: 11px 12px; background: #f8fafc; border: 1px solid var(--line); border-radius: 6px; color: var(--muted); font-size: 11px; line-height: 1.55; }
.metric { padding: 18px 20px; }
.metric-label { color: var(--muted); font-size: 12px; }
.metric-value { font-size: 28px; font-weight: 700; margin-top: 6px; line-height: 1; }
.metric-note { color: var(--muted); font-size: 11px; margin-top: 8px; }
.metric-icon { width: 38px; height: 38px; border-radius: 7px; display: inline-flex; align-items: center; justify-content: center; background: var(--accent-soft); color: var(--accent); font-size: 17px; }
.table { margin-bottom: 0; }
.table > :not(caption) > * > * { padding: 12px 14px; vertical-align: middle; border-color: var(--line); }
.table thead th { color: var(--muted); font-size: 11px; font-weight: 600; letter-spacing: .03em; white-space: nowrap; }
.table tbody td { font-size: 13px; }
.form-label { font-weight: 600; font-size: 12px; color: #465468; }
.form-control, .form-select { border-color: #d9e0e8; border-radius: 5px; font-size: 13px; padding: 9px 11px; }
.form-control:focus, .form-select:focus { border-color: #8fb1e9; box-shadow: 0 0 0 .2rem rgba(46,111,218,.12); }
.form-text { color: var(--muted); font-size: 11px; }
.btn { border-radius: 5px; font-size: 13px; }
.btn-primary { background: var(--accent); border-color: var(--accent); }
.btn-primary:hover { background: #245cb4; border-color: #245cb4; }
.badge-soft { color: #42607e; background: #eef3f7; font-weight: 600; }
.status-badge { font-size: 11px; font-weight: 600; padding: 5px 8px; border-radius: 4px; }
.status-sent, .status-delivered, .status-opened, .status-clicked { background: #e6f6ee; color: #17764f; }
.status-submitted, .status-queued, .status-provider_scheduled, .status-scheduled { background: #edf3ff; color: #3469b4; }
.status-delivery_delayed { background: #fff7e6; color: #9a6b16; }
.status-failed, .status-bounced, .status-complained, .status-suppressed, .status-canceled { background: #fff0f0; color: #b34a4a; }
.status-completed { background: #e6f6ee; color: #17764f; }
.status-partially_failed { background: #fff7e6; color: #9a6b16; }
.status-read { background: #f0f2f5; color: #677385; }
.auth-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; background: #f1f4f8; }
.auth-card { width: 100%; max-width: 430px; background: #fff; border: 1px solid var(--line); border-radius: 9px; padding: 34px; box-shadow: 0 16px 50px rgba(31, 48, 77, .07); }
.auth-brand { display: flex; align-items: center; gap: 10px; font-size: 19px; font-weight: 700; margin-bottom: 30px; }
.auth-title { font-size: 23px; font-weight: 700; margin-bottom: 6px; }
.auth-subtitle { color: var(--muted); font-size: 13px; margin-bottom: 25px; }
.empty-state { text-align: center; color: var(--muted); padding: 44px 20px; }
.empty-state i { display: block; font-size: 30px; margin-bottom: 10px; color: #b7c2d0; }
.code-like { font-family: Consolas, "Courier New", monospace; background: #f4f6f8; border-radius: 4px; padding: 2px 5px; font-size: 12px; }
.mail-variable-panel { padding: 12px; border: 1px solid #dce5f3; border-radius: 7px; background: #f8faff; }
.mail-variable-heading { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.mail-variable-heading > div { display: flex; flex-wrap: wrap; align-items: baseline; gap: 8px; }
.mail-variable-heading strong { color: #294d81; font-size: 12px; }
.mail-variable-heading small, .mail-variable-label { color: var(--muted); font-size: 11px; }
.mail-variable-picker { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.mail-variable-label { width: 100%; }
.mail-variable-chip { display: inline-flex; align-items: center; gap: 6px; padding: 5px 8px; border: 1px solid #d9e2f0; border-radius: 5px; background: #fff; cursor: pointer; }
.mail-variable-chip:hover { border-color: #91add7; background: #f2f7ff; }
.mail-variable-chip code { color: #315c9a; font-size: 11px; }
.mail-variable-chip span { color: #66758a; font-size: 10px; }
.mail-variable-description { margin-top: 8px; color: var(--muted); font-size: 10px; line-height: 1.6; }
.message-preview { max-height: 280px; overflow: auto; white-space: pre-wrap; background: #f8fafc; border: 1px solid var(--line); padding: 14px; border-radius: 5px; }
.message-tabs { margin-top: 4px; }
.message-tab-content { min-width: 0; }
.message-preview-frame { display: block; width: 100%; min-height: 420px; height: min(68vh, 760px); border: 1px solid var(--line); border-top: 0; background: #fff; }
.message-code { min-height: 420px; max-height: 760px; overflow: auto; margin: 0; padding: 16px; border: 1px solid var(--line); border-top: 0; background: #f8fafc; color: #26364d; font: 12px/1.65 Consolas, "Courier New", monospace; white-space: pre-wrap; overflow-wrap: anywhere; }
.message-attachments { padding: 10px 12px; background: #f8fafc; border: 1px solid var(--line); border-radius: 5px; }
.table-actions { white-space: nowrap; }
.quota-list { padding-top: 4px; padding-bottom: 4px; }
.quota-item { padding: 15px 0; }
.quota-item + .quota-item { border-top: 1px solid var(--line); }
.quota-state { display: inline-block; font-size: 10px; font-weight: 700; line-height: 1.2; padding: 5px 7px; border-radius: 4px; white-space: nowrap; }
.quota-ok { color: #17764f; background: #e6f6ee; }
.quota-warn { color: #9a6b16; background: #fff7e6; }
.quota-danger { color: #b34a4a; background: #fff0f0; }
.quota-grid span, .quota-foot, .quota-queue-note { color: var(--muted); font-size: 11px; }
.quota-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 10px; }
.quota-grid > div { min-width: 0; }
.quota-grid span, .quota-grid strong { display: block; }
.quota-grid strong { font-size: 12px; margin-top: 3px; }
.quota-foot { display: flex; justify-content: space-between; gap: 10px; margin-top: 10px; }
.quota-queue-note { margin-top: 4px; font-size: 10px; }
.template-preview-frame { display: block; width: 100%; min-height: 420px; height: min(62vh, 680px); border: 1px solid var(--line); background: #fff; }
.template-code-editor { min-height: 420px; font: 12px/1.65 Consolas, "Courier New", monospace; white-space: pre-wrap; }
.html-editor-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.visual-html-editor { min-height: 420px; padding: 16px; border: 1px solid var(--line); background: #fff; overflow: auto; outline: none; overflow-wrap: anywhere; }
.visual-html-editor:focus { border-color: #8fb1e9; box-shadow: 0 0 0 .2rem rgba(46,111,218,.12); }
.visual-html-editor img { max-width: 100%; height: auto; }
.template-preview-note { padding: 8px 10px; border: 1px solid var(--line); border-top: 0; color: var(--muted); background: #f8fafc; font-size: 11px; }
.shopify-product-picker { border: 1px solid #dce5f3; border-radius: 8px; padding: 13px; background: linear-gradient(180deg, #fbfdff, #f8fbff); }
.shopify-product-picker-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.shopify-product-picker-controls { display: grid; grid-template-columns: minmax(170px, .75fr) minmax(220px, 1.25fr); gap: 8px; margin-top: 11px; }
.shopify-product-picker-status { margin-top: 8px; }
.shopify-product-picker-empty { color: var(--muted); font-size: 12px; padding: 12px 0 2px; }
.shopify-product-results { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 9px; margin-top: 10px; max-height: 310px; overflow: auto; }
.shopify-product-card { display: block; min-width: 0; padding: 8px; border: 1px solid var(--line); border-radius: 7px; background: #fff; text-align: left; }
.shopify-product-card:hover, .shopify-product-card.selected { border-color: #8fb1e9; box-shadow: 0 0 0 2px rgba(46,111,218,.1); }
.shopify-product-card-image { width: 52px; height: 52px; flex: 0 0 52px; object-fit: cover; border-radius: 5px; background: #f1f4f8; }
.shopify-product-card-main { display: flex; align-items: center; gap: 9px; min-width: 0; }
.shopify-product-card-copy { display: block; min-width: 0; flex: 1; }
.shopify-product-card-title { display: block; font-size: 12px; font-weight: 600; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.shopify-product-card-meta { display: block; color: var(--muted); font-size: 11px; margin-top: 3px; }
.shopify-product-card-actions { display: flex; flex-wrap: wrap; gap: 4px; width: 100%; margin-top: 8px; }
.shopify-product-card-actions .btn { padding: 3px 6px; font-size: 10px; }
.recipient-sender-list { display: grid; gap: 7px; max-height: 220px; overflow: auto; padding: 1px; }
.recipient-sender-option { display: flex; align-items: center; gap: 9px; padding: 9px 10px; border: 1px solid var(--line); border-radius: 6px; cursor: pointer; }
.recipient-sender-option:has(input:checked) { border-color: #b6c9e8; background: #f7faff; }
.recipient-sender-option > span { display: grid; min-width: 0; }
.recipient-sender-option strong { font-size: 12px; font-weight: 600; }
.recipient-sender-option small { color: var(--muted); font-size: 10px; overflow-wrap: anywhere; }
.trigger-sender-notice { padding: 11px 12px; border: 1px solid #dce5f3; border-radius: 6px; background: #f7faff; }
.recipient-selection-summary { display: flex; align-items: baseline; gap: 5px; padding: 7px 11px; border-radius: 6px; color: #315c9a; background: var(--accent-soft); white-space: nowrap; }
.recipient-selection-summary strong { font-size: 16px; }
.recipient-selection-summary span { font-size: 11px; }
.recipient-group-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.recipient-group-chip { display: inline-flex; align-items: center; gap: 9px; max-width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: 7px; background: #fff; cursor: pointer; }
.recipient-group-chip:hover { border-color: #a9c0e5; background: #fbfdff; }
.recipient-group-chip:has(input:checked) { border-color: var(--accent); background: #f2f7ff; box-shadow: 0 0 0 1px rgba(46,111,218,.08); }
.recipient-group-chip input { width: 15px; height: 15px; margin: 0; flex: 0 0 15px; }
.recipient-group-chip-copy { display: grid; min-width: 0; }
.recipient-group-chip-copy strong { font-size: 12px; line-height: 1.35; overflow-wrap: anywhere; }
.recipient-group-chip-copy small { color: var(--muted); font-size: 9px; line-height: 1.25; }
.recipient-group-chip.is-shopify .recipient-group-chip-copy small { color: #198754; }
.recipient-group-count { min-width: 23px; padding: 2px 6px; border-radius: 10px; color: #5f6d7e; background: #f0f3f7; text-align: center; font-size: 10px; }
.recipient-list-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 9px; }
.recipient-list-filters { display: grid; grid-template-columns: minmax(220px, 1fr) minmax(190px, .72fr); gap: 8px; flex: 1; min-width: 0; }
.recipient-list-filters .input-group-text { color: var(--muted); background: #fff; border-color: #d9e0e8; }
.recipient-list-actions { display: flex; align-items: center; gap: 4px; white-space: nowrap; }
.recipient-contact-list { max-height: 350px; overflow: auto; border: 1px solid var(--line); border-radius: 6px; }
.recipient-contact-option { display: grid; grid-template-columns: 18px minmax(180px, .8fr) minmax(0, 1.2fr); align-items: center; gap: 10px; padding: 9px 11px; cursor: pointer; }
.recipient-contact-option + .recipient-contact-option { border-top: 1px solid #f0f2f5; }
.recipient-contact-option:hover { background: #f8faff; }
.recipient-contact-option[hidden], .recipient-empty-filter[hidden], #taskSenderPicker[hidden], #triggerSenderNotice[hidden] { display: none !important; }
#scheduledTimeFields[hidden] { display: none !important; }
.recipient-contact-copy { display: grid; min-width: 0; }
.recipient-contact-copy strong { font-size: 12px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.recipient-contact-copy small { color: var(--muted); font-size: 11px; overflow-wrap: anywhere; }
.recipient-contact-group-hint { display: flex; flex-wrap: wrap; gap: 4px; min-width: 0; }
.recipient-contact-group-hint .badge { font-size: 9px; font-weight: 500; color: #607084 !important; max-width: 100%; overflow-wrap: anywhere; white-space: normal; text-align: left; }
.recipient-contact-group-hint .text-bg-success { color: #167347 !important; background: #e8f6ef !important; }
.recipient-empty-filter { padding: 20px; color: var(--muted); text-align: center; font-size: 12px; }
@media (max-width: 991.98px) {
    .sidebar { position: fixed; z-index: 1040; inset: 0 auto 0 0; transform: translateX(-100%); transition: transform .2s ease; box-shadow: 10px 0 30px rgba(0,0,0,.15); }
    .sidebar.open { transform: translateX(0); }
    .topbar { padding: 14px 18px; }
    .content-wrap { padding: 20px 18px 32px; }
    .page-footer { padding: 0 18px 18px; }
    .shopify-form-panel { position: static; }
}
@media (max-width: 575.98px) {
    .auth-card { padding: 25px 20px; }
    .panel-header { align-items: flex-start; flex-direction: column; }
    .metric-value { font-size: 24px; }
    .quota-grid { gap: 5px; }
    .quota-foot { display: block; }
    .quota-foot span { display: block; margin-top: 3px; }
    .topbar-actions { gap: 8px; }
    .shopify-page-heading { align-items: flex-start; flex-direction: column; }
    .shopify-intro { align-items: flex-start; flex-wrap: wrap; }
    .shopify-intro .status-badge { margin-left: 48px; }
    .shopify-store-item { display: block; }
    .shopify-store-meta { grid-template-columns: repeat(2, minmax(0, 1fr)); margin: 13px 0; padding-left: 45px; }
    .shopify-store-actions { justify-content: flex-start; padding-left: 45px; }
    .workflow-builder-heading { display: block; }
    .workflow-builder-heading .badge { display: inline-block; margin-top: 8px; }
    .workflow-step-options { grid-template-columns: 1fr; }
    .shopify-product-picker-controls { grid-template-columns: 1fr; }
    .recipient-list-toolbar { align-items: stretch; flex-direction: column; }
    .recipient-list-actions { justify-content: flex-end; }
}
@media (max-width: 767.98px) {
    .recipient-contact-option { grid-template-columns: 18px minmax(0, 1fr); }
    .recipient-contact-group-hint { grid-column: 2; }
    .recipient-list-filters { grid-template-columns: 1fr; }
}
