:root {
    --background: #f3f7f4;
    --surface: #ffffff;
    --surface-soft: #f8fbf8;
    --text: #17251c;
    --muted: #6b7b70;
    --border: #d8e4da;
    --primary: #23804b;
    --primary-dark: #17663a;
    --primary-soft: #e8f5ec;
    --warning-soft: #fff8e9;
    --warning: #a66c10;
    --danger: #ba4343;
    --shadow: 0 18px 48px rgba(26, 69, 40, 0.09);
}

* { box-sizing: border-box; }
html { min-width: 320px; background: var(--background); }
body {
    min-height: 100vh;
    margin: 0;
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
        "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
    background: radial-gradient(circle at 8% 0%, rgba(35, 128, 75, .09), transparent 28rem),
        var(--background);
}
button, input, textarea, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
.hidden { display: none !important; }

.topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    min-height: 74px;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    padding: 12px clamp(18px, 4vw, 64px);
    border-bottom: 1px solid rgba(216, 228, 218, .92);
    background: rgba(255, 255, 255, .92);
    backdrop-filter: blur(18px);
}
.brand { display: flex; align-items: center; gap: 12px; color: var(--text); text-decoration: none; }
.brand-mark {
    display: grid;
    width: 44px;
    height: 44px;
    place-items: center;
    border-radius: 14px;
    color: #fff;
    font-weight: 800;
    background: linear-gradient(145deg, #33955c, #17663a);
    box-shadow: 0 9px 22px rgba(35, 128, 75, .22);
}
.brand strong, .brand small { display: block; }
.brand small { margin-top: 3px; color: var(--muted); font-size: 12px; }
.topbar-actions { display: flex; align-items: center; gap: 12px; }
.account-name { color: var(--muted); font-size: 14px; }

.page-shell { width: min(1440px, calc(100% - 36px)); margin: 30px auto 72px; }
.hero {
    display: flex;
    min-height: 190px;
    align-items: center;
    justify-content: space-between;
    gap: 28px;
    padding: clamp(28px, 4vw, 52px);
    border-radius: 28px;
    color: #fff;
    background: linear-gradient(118deg, #17663a, #2c9258);
    box-shadow: 0 22px 48px rgba(27, 102, 59, .2);
}
.hero h1 { margin: 10px 0 12px; font-size: clamp(28px, 3.6vw, 48px); line-height: 1.16; }
.hero p { max-width: 820px; margin: 0; color: rgba(255,255,255,.84); line-height: 1.8; }
.eyebrow { color: var(--primary); font-size: 12px; font-weight: 800; letter-spacing: .18em; }
.eyebrow.light { color: rgba(255,255,255,.78); }
.hero-button {
    min-width: 180px;
    min-height: 50px;
    padding: 0 22px;
    border: 1px solid rgba(255,255,255,.45);
    border-radius: 14px;
    color: #fff;
    font-weight: 800;
    background: rgba(255,255,255,.1);
    cursor: pointer;
}
.hero-button:hover { background: rgba(255,255,255,.18); }

.summary-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin: 20px 0; }
.summary-grid article {
    position: relative;
    min-height: 112px;
    padding: 22px;
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: 18px;
    background: var(--surface);
    box-shadow: 0 10px 28px rgba(29, 64, 40, .04);
}
.summary-grid article::after {
    position: absolute;
    width: 9px;
    height: 9px;
    top: 20px;
    right: 20px;
    border-radius: 50%;
    background: var(--primary);
    content: "";
}
.summary-grid span { display: block; margin-bottom: 10px; color: var(--muted); font-size: 13px; }
.summary-grid strong { font-size: 30px; }

.workspace-grid { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(320px, .8fr); gap: 20px; align-items: start; }
.panel {
    border: 1px solid var(--border);
    border-radius: 22px;
    background: var(--surface);
    box-shadow: var(--shadow);
}
.create-panel, .preview-panel { padding: clamp(20px, 3vw, 32px); }
.preview-panel { position: sticky; top: 94px; }
.panel-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 24px; }
.panel-heading h2 { margin: 5px 0 0; font-size: 23px; }
.step-badge {
    padding: 7px 11px;
    border-radius: 999px;
    color: var(--primary-dark);
    font-size: 12px;
    font-weight: 700;
    background: var(--primary-soft);
}

.form-grid { display: grid; gap: 16px; }
.two-columns { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.three-columns { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.field { display: grid; gap: 8px; margin-bottom: 18px; }
.field > span { font-size: 13px; font-weight: 750; }
.field small, .field-help { color: var(--muted); font-size: 12px; line-height: 1.65; }
.field input, .field textarea, .field select {
    width: 100%;
    min-height: 46px;
    padding: 11px 13px;
    border: 1px solid #cbdacc;
    border-radius: 12px;
    outline: none;
    color: var(--text);
    background: #fff;
    transition: border-color .16s ease, box-shadow .16s ease;
}
.field textarea { resize: vertical; line-height: 1.65; }
.field input:focus, .field textarea:focus, .field select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(35, 128, 75, .12);
}
.conditional-block, .target-block {
    margin: 2px 0 20px;
    padding: 18px;
    border: 1px solid #c9dfcf;
    border-radius: 16px;
    background: #f4faf6;
}
.conditional-block .field, .target-block .field { margin-bottom: 0; }
.schedule-fields { margin-bottom: 2px; }
.form-actions { display: flex; gap: 10px; margin-top: 8px; }

.primary-button, .secondary-button, .secondary-link, .primary-link {
    display: inline-flex;
    min-height: 44px;
    align-items: center;
    justify-content: center;
    padding: 0 17px;
    border-radius: 12px;
    font-weight: 750;
    text-decoration: none;
    cursor: pointer;
}
.primary-button, .primary-link { border: 1px solid var(--primary); color: #fff; background: var(--primary); }
.primary-button:hover, .primary-link:hover { background: var(--primary-dark); }
.secondary-button, .secondary-link { border: 1px solid var(--border); color: var(--text); background: #fff; }
.secondary-button:hover, .secondary-link:hover { border-color: #aec6b3; background: var(--surface-soft); }
button:disabled { opacity: .55; cursor: not-allowed; }
.wide { width: 100%; }

.empty-state { display: grid; min-height: 330px; place-items: center; align-content: center; text-align: center; }
.empty-state .empty-icon { display: grid; width: 58px; height: 58px; place-items: center; margin-bottom: 12px; border-radius: 18px; font-size: 25px; background: var(--primary-soft); }
.empty-state p { max-width: 300px; margin: 8px 0 0; color: var(--muted); font-size: 13px; line-height: 1.75; }
.preview-content dl { margin: 0; }
.preview-content dl > div { display: grid; grid-template-columns: 90px 1fr; gap: 12px; padding: 13px 0; border-bottom: 1px solid #edf1ed; }
.preview-content dt { color: var(--muted); font-size: 13px; }
.preview-content dd { margin: 0; overflow-wrap: anywhere; font-weight: 650; line-height: 1.55; }
.preview-warning { margin: 22px 0 16px; padding: 13px; border-radius: 12px; color: var(--warning); font-size: 12px; line-height: 1.65; background: var(--warning-soft); }

.list-panel { margin-top: 20px; padding: 26px; }
.list-heading { margin-bottom: 10px; }
.reminder-list { display: grid; gap: 12px; }
.reminder-card {
    display: grid;
    grid-template-columns: minmax(0, 1.5fr) minmax(180px, .7fr) minmax(160px, .6fr) auto;
    gap: 18px;
    align-items: center;
    padding: 18px;
    border: 1px solid #e1e9e2;
    border-radius: 15px;
    background: var(--surface-soft);
}
.reminder-main strong { display: block; margin-bottom: 7px; font-size: 16px; }
.reminder-main p { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.55; }
.reminder-meta span { display: block; color: var(--muted); font-size: 12px; }
.reminder-meta strong { display: block; margin-top: 5px; font-size: 13px; }
.status-pill { display: inline-flex; width: fit-content; padding: 6px 10px; border-radius: 999px; color: var(--primary-dark); font-size: 12px; font-weight: 750; background: var(--primary-soft); }
.status-pill.PAUSED { color: #7c661a; background: #fff5d9; }
.status-pill.CANCELLED, .status-pill.COMPLETED { color: #68736b; background: #edf1ee; }
.card-actions { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
.card-actions button { min-height: 36px; padding: 0 11px; border: 1px solid var(--border); border-radius: 9px; color: var(--text); background: #fff; cursor: pointer; }
.card-actions button.danger { color: var(--danger); border-color: #efcccc; }
.empty-list { padding: 44px 0; color: var(--muted); text-align: center; }

.auth-panel, .error-banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 18px;
    padding: 22px;
    border: 1px solid var(--border);
    border-radius: 18px;
    background: #fff;
}
.auth-panel h1 { margin: 5px 0; }
.auth-panel p { margin: 0; color: var(--muted); }
.error-banner { color: #8c3030; border-color: #efcaca; background: #fff5f5; }
.toast {
    position: fixed;
    z-index: 60;
    top: 92px;
    left: 50%;
    max-width: min(540px, calc(100vw - 32px));
    padding: 12px 18px;
    transform: translateX(-50%);
    border-radius: 12px;
    color: #fff;
    font-weight: 700;
    background: #1e3125;
    box-shadow: var(--shadow);
}
.toast.error { background: #ad3f3f; }

@media (max-width: 980px) {
    .summary-grid { grid-template-columns: repeat(2, 1fr); }
    .workspace-grid { grid-template-columns: 1fr; }
    .preview-panel { position: static; }
    .reminder-card { grid-template-columns: 1fr 1fr; }
    .card-actions { justify-content: flex-start; }
}

@media (max-width: 700px) {
    .topbar { min-height: 66px; padding: 10px 14px; }
    .brand small, .account-name { display: none; }
    .page-shell { width: min(100% - 20px, 1440px); margin-top: 14px; }
    .hero { min-height: unset; align-items: stretch; flex-direction: column; padding: 24px; border-radius: 20px; }
    .hero-button { width: 100%; }
    .summary-grid { gap: 10px; }
    .summary-grid article { min-height: 94px; padding: 17px; }
    .two-columns, .three-columns { grid-template-columns: 1fr; }
    .conditional-block .field, .target-block .field { margin-bottom: 14px; }
    .conditional-block .field:last-child, .target-block .field:last-child { margin-bottom: 0; }
    .create-panel, .preview-panel, .list-panel { padding: 18px; border-radius: 18px; }
    .panel-heading { align-items: flex-start; }
    .reminder-card { grid-template-columns: 1fr; gap: 12px; }
    .form-actions { flex-direction: column; }
    .form-actions button { width: 100%; }
}
