:root {
    --bg: #0b1220;
    --panel: #121c31;
    --panel-soft: #182540;
    --line: rgba(151, 173, 214, 0.18);
    --text: #ebf2ff;
    --muted: #8ea3c8;
    --accent: #3dd9d6;
    --accent-2: #60a5fa;
    --success: #22c55e;
    --danger: #f87171;
    --warning: #f59e0b;
    --shadow: 0 20px 50px rgba(0, 0, 0, 0.25);
    --radius: 18px;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: "PingFang SC", "Noto Sans SC", "Helvetica Neue", sans-serif;
    background:
        radial-gradient(circle at top right, rgba(61, 217, 214, 0.16), transparent 28%),
        radial-gradient(circle at bottom left, rgba(96, 165, 250, 0.12), transparent 24%),
        var(--bg);
    color: var(--text);
}

a {
    color: inherit;
    text-decoration: none;
}

.layout {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 244px;
    padding: 32px 20px;
    border-right: 1px solid var(--line);
    background: rgba(8, 15, 29, 0.7);
    backdrop-filter: blur(12px);
}

.brand {
    margin-bottom: 28px;
}

.brand h1 {
    margin: 0 0 6px;
    font-size: 22px;
}

.brand p,
.subtle {
    margin: 0;
    color: var(--muted);
    font-size: 13px;
}

.nav {
    display: grid;
    gap: 10px;
    margin-top: 24px;
}

.nav-group {
    display: grid;
    gap: 8px;
}

.nav-group + .nav-group {
    margin-top: 8px;
    padding-top: 14px;
    border-top: 1px solid rgba(151, 173, 214, 0.12);
}

.nav-group-title {
    padding: 0 14px;
    font-size: 12px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--muted);
}

.nav a {
    padding: 12px 14px;
    border-radius: 14px;
    color: var(--muted);
    transition: all 0.2s ease;
}

.nav-button {
    width: 100%;
    padding: 12px 14px;
    border-radius: 14px;
    border: 0;
    background: transparent;
    color: var(--muted);
    text-align: left;
    cursor: pointer;
    transition: all 0.2s ease;
}

.nav a:hover,
.nav a.active,
.nav-button:hover {
    background: rgba(61, 217, 214, 0.12);
    color: var(--text);
}

.main {
    flex: 1;
    padding: 32px;
}

.message-stack {
    display: grid;
    gap: 12px;
    margin-bottom: 18px;
}

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    margin-bottom: 24px;
}

.page-title {
    margin: 0;
    font-size: 28px;
}

.actions-wrap {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.segmented-control {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px;
    border-radius: 999px;
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.04);
}

.segmented-item {
    padding: 10px 16px;
    border-radius: 999px;
    color: var(--muted);
    font-size: 13px;
    transition: all 0.2s ease;
}

.segmented-item:hover,
.segmented-item.active {
    background: rgba(61, 217, 214, 0.14);
    color: var(--text);
}

.grid {
    display: grid;
    gap: 16px;
}

.grid-4 {
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

.grid-2 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.card {
    background: linear-gradient(180deg, rgba(24, 37, 64, 0.9), rgba(11, 18, 32, 0.95));
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 20px;
}

.info-grid {
    display: grid;
    gap: 14px;
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.info-item {
    padding: 16px;
    border-radius: 16px;
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.03);
    display: grid;
    gap: 8px;
}

.info-label {
    font-size: 12px;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--muted);
}

.info-value {
    font-size: 24px;
    font-weight: 700;
}

.path-text {
    word-break: break-all;
    line-height: 1.5;
    font-size: 12px;
}

.trend-grid {
    display: grid;
    gap: 16px;
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.trend-card {
    padding: 18px;
    border-radius: 16px;
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.03);
}

.trend-title {
    margin-bottom: 14px;
    font-size: 15px;
    font-weight: 700;
}

.trend-chart {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 10px;
    align-items: end;
    min-height: 180px;
}

.trend-bar-group {
    display: grid;
    gap: 8px;
    justify-items: center;
}

.trend-bar {
    width: 100%;
    min-height: 28px;
    border-radius: 12px 12px 6px 6px;
    background: linear-gradient(180deg, rgba(34, 197, 94, 0.95), rgba(34, 197, 94, 0.32));
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding-top: 8px;
}

.trend-bar.accent {
    background: linear-gradient(180deg, rgba(61, 217, 214, 0.95), rgba(61, 217, 214, 0.28));
}

.trend-bar.warning {
    background: linear-gradient(180deg, rgba(245, 158, 11, 0.95), rgba(245, 158, 11, 0.28));
}

.trend-bar.danger {
    background: linear-gradient(180deg, rgba(248, 113, 113, 0.95), rgba(248, 113, 113, 0.28));
}

.trend-bar-value {
    font-size: 12px;
    font-weight: 700;
    color: #08111d;
}

.trend-bar-label {
    font-size: 12px;
    color: var(--muted);
}

.stat-label {
    color: var(--muted);
    font-size: 13px;
}

.stat-value {
    margin-top: 10px;
    font-size: 30px;
    font-weight: 700;
}

.card-title {
    margin: 0 0 16px;
    font-size: 18px;
}

.table-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 16px;
}

.bulk-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 18px;
    padding: 16px 18px;
    border-radius: 16px;
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.03);
}

.bulk-toolbar-info {
    display: grid;
    gap: 6px;
}

.bulk-toolbar-title {
    font-size: 15px;
    font-weight: 700;
}

.bulk-export-select {
    min-width: 140px;
}

.delivery-template-panel {
    padding: 18px;
    border-radius: 16px;
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.03);
}

.template-guide {
    display: grid;
    gap: 12px;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    margin-bottom: 18px;
}

.template-guide-item,
.template-card {
    padding: 18px;
    border-radius: 16px;
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.025);
}

.template-guide-item {
    display: flex;
    gap: 14px;
    align-items: flex-start;
}

.template-guide-step {
    width: 32px;
    height: 32px;
    border-radius: 999px;
    background: rgba(61, 217, 214, 0.16);
    color: var(--text);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    flex-shrink: 0;
}

.template-guide-title {
    margin-bottom: 6px;
    font-size: 15px;
    font-weight: 700;
}

.delivery-template-layout {
    display: grid;
    gap: 18px;
    grid-template-columns: minmax(320px, 420px) minmax(0, 1fr);
    align-items: start;
}

.delivery-template-sidebar,
.delivery-template-main {
    display: grid;
    gap: 18px;
}

.template-card-header,
.template-preview-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
    margin-bottom: 16px;
}

.template-card-title {
    margin-bottom: 6px;
}

.delivery-template-form-grid {
    grid-template-columns: 1fr;
}

.template-variable-list {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.template-variable-list code {
    display: inline-flex;
    align-items: center;
    min-height: 34px;
    padding: 8px 12px;
    border-radius: 999px;
    border: 1px solid rgba(151, 173, 214, 0.2);
    background: rgba(255, 255, 255, 0.04);
    color: #d9e8ff;
    font-size: 12px;
}

.template-visual-preview {
    display: grid;
    gap: 14px;
}

.template-preview-tabs {
    display: inline-flex;
    flex-wrap: wrap;
    gap: 8px;
}

.template-preview-tab {
    padding: 10px 14px;
    border-radius: 999px;
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.04);
    color: var(--muted);
    cursor: pointer;
    transition: all 0.2s ease;
}

.template-preview-tab.active {
    background: rgba(61, 217, 214, 0.14);
    border-color: rgba(61, 217, 214, 0.24);
    color: var(--text);
}

.template-preview-scene {
    position: relative;
}

.template-preview-surface {
    display: none;
}

.template-preview-surface.active {
    display: block;
}

.preview-phone-shell,
.preview-email-shell,
.preview-market-shell,
.preview-wechat-shell {
    border-radius: 20px;
    border: 1px solid var(--line);
    overflow: hidden;
    background: rgba(7, 12, 24, 0.96);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.preview-phone-topbar,
.preview-email-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 16px;
    border-bottom: 1px solid rgba(151, 173, 214, 0.12);
    background: rgba(255, 255, 255, 0.03);
}

.preview-phone-body {
    display: flex;
    justify-content: flex-end;
    padding: 18px;
    min-height: 200px;
    background:
        radial-gradient(circle at top left, rgba(61, 217, 214, 0.08), transparent 28%),
        rgba(5, 10, 22, 0.94);
}

.preview-phone-bubble,
.preview-market-bubble {
    max-width: min(520px, 100%);
    padding: 16px 18px;
    border-radius: 18px 18px 6px 18px;
    white-space: pre-wrap;
    line-height: 1.72;
    word-break: break-word;
}

.preview-phone-bubble {
    background: linear-gradient(180deg, rgba(61, 217, 214, 0.95), rgba(96, 165, 250, 0.92));
    color: #07111d;
    font-weight: 500;
}

.preview-wechat-shell {
    background: #111b21;
    border-color: rgba(84, 101, 111, 0.45);
}

.preview-wechat-topbar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: #202c33;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.preview-wechat-back,
.preview-wechat-actions {
    width: 28px;
    color: #d1d7db;
    text-align: center;
    font-size: 18px;
    flex-shrink: 0;
}

.preview-wechat-title-group {
    flex: 1;
    min-width: 0;
}

.preview-wechat-title {
    font-weight: 700;
    color: #f4f7fa;
}

.preview-wechat-subtitle-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 2px;
    flex-wrap: wrap;
}

.preview-wechat-subtitle {
    color: #91a1ac;
    font-size: 12px;
}

.preview-wechat-store-badge {
    display: inline-flex;
    align-items: center;
    min-height: 22px;
    padding: 0 8px;
    border-radius: 999px;
    background: rgba(37, 211, 102, 0.16);
    color: #b7f7cb;
    font-size: 11px;
    font-weight: 700;
}

.preview-wechat-body {
    display: grid;
    gap: 16px;
    padding: 18px 16px;
    background:
        radial-gradient(circle at top right, rgba(37, 211, 102, 0.08), transparent 26%),
        #0b141a;
}

.preview-wechat-incoming,
.preview-wechat-outgoing {
    display: flex;
    gap: 10px;
    align-items: flex-end;
}

.preview-wechat-outgoing {
    justify-content: flex-end;
}

.preview-wechat-avatar {
    width: 34px;
    height: 34px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.08);
    color: #dbe8ef;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 700;
    flex-shrink: 0;
}

.preview-wechat-avatar-brand {
    background: rgba(37, 211, 102, 0.22);
    color: #d6ffe6;
}

.preview-wechat-message-block {
    display: grid;
    gap: 6px;
    justify-items: start;
}

.preview-wechat-message-block-out {
    justify-items: end;
}

.preview-wechat-meta {
    padding: 0 4px;
    color: #8ea3ad;
    font-size: 12px;
}

.preview-wechat-meta-out {
    color: #9fe5ba;
}

.preview-wechat-message {
    max-width: min(520px, 100%);
    padding: 14px 16px;
    border-radius: 16px;
    line-height: 1.72;
    white-space: pre-wrap;
    word-break: break-word;
}

.preview-wechat-message-in {
    background: #202c33;
    color: #e9edef;
    border-bottom-left-radius: 6px;
}

.preview-wechat-message-out {
    background: #005c4b;
    color: #eafff8;
    border-bottom-right-radius: 6px;
}

.preview-email-card {
    padding: 20px;
    display: grid;
    gap: 12px;
    background:
        radial-gradient(circle at top right, rgba(96, 165, 250, 0.08), transparent 24%),
        rgba(12, 19, 34, 0.94);
}

.preview-email-subject {
    font-size: 20px;
    font-weight: 700;
}

.preview-email-recipient {
    padding: 12px 14px;
    border-radius: 14px;
    border: 1px solid rgba(96, 165, 250, 0.18);
    background: rgba(96, 165, 250, 0.08);
    color: #dbeafe;
    font-size: 13px;
}

.preview-email-meta {
    color: var(--muted);
    font-size: 13px;
}

.preview-email-content {
    padding: 18px;
    border-radius: 16px;
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.03);
    white-space: pre-wrap;
    line-height: 1.8;
    word-break: break-word;
}

.preview-email-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.preview-email-button {
    display: inline-flex;
    align-items: center;
    min-height: 36px;
    padding: 0 14px;
    border-radius: 999px;
    border: 1px solid rgba(151, 173, 214, 0.18);
    background: rgba(255, 255, 255, 0.03);
    color: var(--text);
    font-size: 13px;
}

.preview-email-button-primary {
    background: linear-gradient(135deg, rgba(96, 165, 250, 0.95), rgba(59, 130, 246, 0.88));
    border-color: rgba(96, 165, 250, 0.3);
    color: #08111d;
    font-weight: 700;
}

.preview-market-shell {
    padding: 18px;
}

.preview-market-header {
    display: flex;
    gap: 12px;
    align-items: center;
    margin-bottom: 16px;
}

.preview-market-avatar {
    width: 42px;
    height: 42px;
    border-radius: 999px;
    background: linear-gradient(180deg, rgba(245, 158, 11, 0.95), rgba(249, 115, 22, 0.9));
    color: #1a1105;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
}

.preview-market-avatar-xianyu {
    background: linear-gradient(180deg, rgba(245, 158, 11, 0.95), rgba(249, 115, 22, 0.9));
    color: #1a1105;
}

.preview-market-avatar-taobao {
    background: linear-gradient(180deg, rgba(251, 146, 60, 0.96), rgba(239, 68, 68, 0.9));
    color: #fff2e8;
}

.preview-market-title {
    font-size: 15px;
    font-weight: 700;
}

.preview-market-title-row {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 4px;
}

.preview-market-bubble {
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 18px 18px 18px 8px;
}

.preview-market-store-badge {
    display: inline-flex;
    align-items: center;
    min-height: 22px;
    padding: 0 8px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 700;
}

.preview-market-store-badge-xianyu {
    background: rgba(245, 158, 11, 0.16);
    color: #ffe3bc;
}

.preview-market-shell-xianyu {
    background:
        radial-gradient(circle at top left, rgba(245, 158, 11, 0.12), transparent 28%),
        rgba(10, 16, 30, 0.98);
}

.preview-market-header-xianyu {
    border-bottom: 1px solid rgba(245, 158, 11, 0.14);
    padding-bottom: 14px;
}

.preview-market-bubble-xianyu {
    background: rgba(255, 247, 237, 0.08);
    border-color: rgba(245, 158, 11, 0.16);
}

.preview-market-store-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 0 16px;
}

.preview-market-store-row-xianyu {
    border-bottom: 1px dashed rgba(245, 158, 11, 0.16);
    margin-bottom: 14px;
}

.preview-market-store-avatar {
    width: 38px;
    height: 38px;
    border-radius: 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 800;
    flex-shrink: 0;
}

.preview-market-store-avatar-xianyu {
    background: linear-gradient(180deg, rgba(245, 158, 11, 0.95), rgba(234, 88, 12, 0.92));
    color: #fff5e6;
}

.preview-market-store-name {
    font-size: 14px;
    font-weight: 700;
    margin-bottom: 4px;
}

.preview-market-shell-taobao {
    background:
        radial-gradient(circle at top right, rgba(239, 68, 68, 0.12), transparent 28%),
        rgba(19, 14, 19, 0.98);
}

.preview-market-header-taobao {
    border-bottom: 1px solid rgba(251, 146, 60, 0.16);
    padding-bottom: 14px;
}

.preview-market-bubble-taobao {
    background: rgba(127, 29, 29, 0.14);
    border-color: rgba(251, 146, 60, 0.18);
}

.preview-market-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 14px;
}

.preview-market-button {
    display: inline-flex;
    align-items: center;
    min-height: 36px;
    padding: 0 14px;
    border-radius: 999px;
    font-size: 13px;
    border: 1px solid transparent;
}

.preview-market-button-xianyu-primary {
    background: rgba(245, 158, 11, 0.18);
    border-color: rgba(245, 158, 11, 0.26);
    color: #fde7c4;
}

.preview-market-button-xianyu-secondary {
    background: rgba(255, 255, 255, 0.04);
    border-color: rgba(255, 255, 255, 0.08);
    color: var(--text);
}

.preview-market-button-taobao-primary {
    background: linear-gradient(135deg, rgba(251, 146, 60, 0.96), rgba(239, 68, 68, 0.9));
    border-color: rgba(251, 146, 60, 0.26);
    color: #fff7ed;
    font-weight: 700;
}

.preview-market-button-taobao-secondary {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(251, 146, 60, 0.16);
    color: #ffe4d1;
}

.variable-hint {
    padding: 12px 14px;
    border-radius: 14px;
    border: 1px dashed rgba(151, 173, 214, 0.2);
    background: rgba(255, 255, 255, 0.02);
    color: var(--muted);
    font-size: 13px;
    line-height: 1.6;
}

.template-output {
    min-height: 220px;
    line-height: 1.7;
    font-family: "SFMono-Regular", "Menlo", monospace;
    background: rgba(7, 12, 24, 0.96);
}

.template-editor {
    min-height: 220px;
    line-height: 1.7;
    font-family: "SFMono-Regular", "Menlo", monospace;
    background: rgba(10, 17, 30, 0.96);
}

.template-editor,
.template-output {
    white-space: pre-wrap;
}

.import-preview-panel {
    padding: 16px;
    border-radius: 16px;
    border: 1px solid rgba(245, 158, 11, 0.28);
    background: rgba(245, 158, 11, 0.08);
}

.import-result-panel {
    padding: 16px;
    border-radius: 16px;
    border: 1px solid rgba(34, 197, 94, 0.28);
    background: rgba(34, 197, 94, 0.08);
}

.import-history-panel {
    padding: 16px;
    border-radius: 16px;
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.02);
}

.import-preview-title {
    margin-bottom: 6px;
}

.import-preview-grid {
    display: grid;
    gap: 12px;
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.import-preview-metric {
    display: grid;
    gap: 6px;
    padding: 12px 14px;
    border-radius: 14px;
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.03);
}

.import-preview-label {
    font-size: 12px;
    color: var(--muted);
}

.import-preview-list ul {
    margin: 8px 0 0;
    padding-left: 18px;
}

.import-preview-list li {
    margin-bottom: 6px;
}

.import-history-list {
    display: grid;
    gap: 12px;
}

.import-history-item {
    padding: 14px;
    border-radius: 14px;
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.03);
}

.import-history-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 10px 16px;
    margin-bottom: 10px;
    color: var(--muted);
    font-size: 12px;
}

.import-history-title {
    margin: 0 0 8px;
    font-size: 15px;
}

.import-history-summary {
    display: grid;
    gap: 6px;
    margin-bottom: 8px;
}

.import-history-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.table-wrap {
    overflow: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th,
td {
    padding: 12px 10px;
    border-bottom: 1px solid var(--line);
    text-align: left;
    font-size: 14px;
    vertical-align: top;
}

th {
    color: var(--muted);
    font-weight: 500;
}

.checkbox-col {
    width: 44px;
}

.table-checkbox {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: var(--accent);
}

form {
    margin: 0;
}

.form-grid {
    display: grid;
    gap: 16px;
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.filter-grid {
    display: grid;
    gap: 16px;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    margin-bottom: 18px;
}

.field {
    display: grid;
    gap: 8px;
}

.field.full {
    grid-column: 1 / -1;
}

label {
    font-size: 13px;
    color: var(--muted);
}

input,
select,
textarea,
button {
    font: inherit;
}

input,
select,
textarea {
    width: 100%;
    padding: 12px 14px;
    border-radius: 14px;
    border: 1px solid rgba(151, 173, 214, 0.18);
    background: rgba(12, 19, 34, 0.9);
    color: var(--text);
}

textarea {
    min-height: 108px;
    resize: vertical;
}

.actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.filter-actions {
    display: flex;
    gap: 10px;
    align-items: end;
    flex-wrap: wrap;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 11px 16px;
    border-radius: 14px;
    border: 1px solid transparent;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease, opacity 0.2s ease;
}

.btn:hover {
    transform: translateY(-1px);
}

.btn:disabled,
.nav-button:disabled {
    cursor: not-allowed;
    opacity: 0.66;
    transform: none;
}

.btn.is-static {
    pointer-events: none;
}

.btn.is-disabled {
    opacity: 0.52;
}

.btn.is-loading::after,
.nav-button.is-loading::after {
    content: "";
    width: 12px;
    height: 12px;
    border-radius: 999px;
    border: 2px solid currentColor;
    border-right-color: transparent;
    animation: spin 0.7s linear infinite;
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    color: #08111d;
    font-weight: 700;
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.04);
    border-color: var(--line);
    color: var(--text);
}

.btn-danger {
    background: rgba(248, 113, 113, 0.14);
    border-color: rgba(248, 113, 113, 0.3);
    color: #fecaca;
}

.badge {
    display: inline-flex;
    align-items: center;
    padding: 6px 10px;
    border-radius: 999px;
    font-size: 12px;
    border: 1px solid transparent;
}

.badge.active {
    color: #bbf7d0;
    background: rgba(34, 197, 94, 0.12);
    border-color: rgba(34, 197, 94, 0.26);
}

.badge.used {
    color: #dbeafe;
    background: rgba(96, 165, 250, 0.12);
    border-color: rgba(96, 165, 250, 0.26);
}

.badge.expired,
.badge.disabled,
.badge.blocked {
    color: #fecaca;
    background: rgba(248, 113, 113, 0.12);
    border-color: rgba(248, 113, 113, 0.26);
}

.message {
    padding: 14px 16px;
    border-radius: 14px;
    border: 1px solid transparent;
    font-size: 14px;
}

.message-title {
    margin-bottom: 4px;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.message.success {
    background: rgba(34, 197, 94, 0.12);
    border-color: rgba(34, 197, 94, 0.24);
    color: #bbf7d0;
}

.message.error {
    background: rgba(248, 113, 113, 0.12);
    border-color: rgba(248, 113, 113, 0.24);
    color: #fecaca;
}

.hero-center,
.login-shell {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
}

.login-card,
.download-card {
    width: min(760px, 100%);
    padding: 28px;
}

.login-card {
    max-width: 460px;
}

.mono {
    font-family: "SFMono-Regular", "Menlo", "Consolas", monospace;
    letter-spacing: 0.08em;
}

.muted-box {
    padding: 14px;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--line);
}

.empty-state {
    display: grid;
    gap: 8px;
    padding: 24px;
    border-radius: 16px;
    border: 1px dashed rgba(151, 173, 214, 0.22);
    background: rgba(255, 255, 255, 0.03);
}

.empty-state.compact {
    padding: 18px;
}

.empty-state-title {
    font-size: 18px;
    font-weight: 700;
}

.empty-state-text {
    color: var(--muted);
    line-height: 1.6;
}

.toast-region {
    position: fixed;
    top: 18px;
    right: 18px;
    z-index: 1000;
    display: grid;
    gap: 10px;
    width: min(360px, calc(100vw - 24px));
}

.toast {
    padding: 14px 16px;
    border-radius: 14px;
    border: 1px solid var(--line);
    background: rgba(18, 28, 49, 0.96);
    color: var(--text);
    box-shadow: var(--shadow);
    opacity: 0;
    transform: translateY(-8px);
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.toast.show {
    opacity: 1;
    transform: translateY(0);
}

.toast.success {
    border-color: rgba(34, 197, 94, 0.28);
}

.toast.error {
    border-color: rgba(248, 113, 113, 0.3);
}

.section-gap {
    margin-top: 18px;
}

.pagination-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    margin-top: 18px;
    flex-wrap: wrap;
}

.pagination-summary {
    color: var(--muted);
    font-size: 13px;
}

.pagination-actions {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}

.hidden-download-frame {
    width: 0;
    height: 0;
    border: 0;
    position: absolute;
    left: -9999px;
}

.checkbox-group {
    display: flex;
    flex-wrap: wrap;
    gap: 12px 18px;
}

.checkbox-inline {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--text);
}

.code-block {
    background: #0f172a;
    color: #e2e8f0;
    border-radius: 14px;
    padding: 14px 16px;
    overflow-x: auto;
}

.code-block pre {
    margin: 0;
    white-space: pre-wrap;
    word-break: break-word;
}

.secret-panel {
    min-width: 220px;
}

.secret-panel summary {
    cursor: pointer;
    color: var(--accent);
    list-style: none;
}

.secret-panel summary::-webkit-details-marker {
    display: none;
}

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

@media (max-width: 960px) {
    .layout {
        display: block;
    }

    .sidebar {
        width: 100%;
        border-right: 0;
        border-bottom: 1px solid var(--line);
    }

    .main {
        padding: 20px;
    }

    .sidebar {
        padding: 20px 16px;
    }

    .nav {
        gap: 14px;
    }

    .nav a,
    .nav-button {
        padding: 14px 16px;
    }

    .card {
        padding: 16px;
    }

    .page-title {
        font-size: 24px;
    }

    th,
    td {
        padding: 10px 8px;
        font-size: 13px;
    }


    .grid-4,
    .grid-2,
    .info-grid,
    .trend-grid,
    .template-guide,
    .form-grid,
    .filter-grid {
        grid-template-columns: 1fr;
    }

    .delivery-template-layout {
        grid-template-columns: 1fr;
    }

    .bulk-toolbar,
    .table-header,
    .template-card-header,
    .template-preview-header,
    .topbar,
    .pagination-bar {
        flex-direction: column;
        align-items: stretch;
    }

    .actions-wrap {
        justify-content: stretch;
    }

    .segmented-control {
        width: 100%;
        justify-content: space-between;
    }

    .segmented-item {
        flex: 1;
        text-align: center;
    }

    .template-preview-tabs {
        display: grid;
        grid-template-columns: 1fr;
    }

    .preview-phone-body,
    .preview-email-card,
    .preview-market-shell {
        padding: 14px;
    }
}
