:root {
    --bg: #f6f7f4;
    --panel: #ffffff;
    --ink: #20231f;
    --muted: #687064;
    --line: #dfe4da;
    --green: #2f7d4f;
    --blue: #276b8f;
    --red: #b63e35;
    --shadow: 0 10px 28px rgba(31, 38, 29, 0.08);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans TC", Arial, sans-serif;
}

.app-shell {
    width: min(1180px, 100%);
    margin: 0 auto;
    padding: 18px 14px 88px;
}

.topbar,
.quick-links,
.toolbar,
.rule-head,
.rule-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.topbar {
    align-items: flex-start;
    margin-bottom: 16px;
}

.quick-links {
    flex-wrap: wrap;
    justify-content: flex-end;
}

.quick-links a,
.btn {
    min-height: 42px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    font-weight: 900;
    text-decoration: none;
}

.quick-links a {
    padding: 8px 11px;
    border: 1px solid var(--line);
    color: var(--green);
    background: var(--panel);
}

.eyebrow,
p {
    margin-top: 0;
}

.eyebrow {
    margin-bottom: 4px;
    color: var(--muted);
    font-size: 13px;
}

h1,
h2,
h3 {
    margin: 0;
}

h1 {
    font-size: 30px;
    line-height: 1.1;
}

h2 {
    font-size: 21px;
}

h3 {
    font-size: 18px;
}

.notice-card,
.rule-card {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
    box-shadow: var(--shadow);
}

.notice-card {
    display: grid;
    gap: 6px;
    margin-bottom: 14px;
    padding: 14px;
    border-left: 5px solid var(--blue);
}

.notice-card span {
    color: var(--muted);
    line-height: 1.5;
}

.toolbar {
    margin: 16px 0 12px;
}

.btn {
    border: 0;
    padding: 10px 14px;
    color: #fff;
    background: var(--green);
    cursor: pointer;
}

.btn.secondary {
    border: 1px solid var(--line);
    color: var(--ink);
    background: var(--panel);
}

.rule-grid {
    display: grid;
    gap: 12px;
}

.rule-card {
    display: grid;
    gap: 12px;
    padding: 14px;
}

.rule-card.inactive {
    opacity: 0.62;
}

.rule-head {
    align-items: flex-start;
}

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

.rule-form {
    display: grid;
    gap: 10px;
}

.rule-form label {
    display: grid;
    gap: 6px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 900;
}

.rule-form input,
.rule-form select {
    width: 100%;
    min-height: 44px;
    border: 1px solid #cfd8c8;
    border-radius: 8px;
    padding: 8px 10px;
    color: var(--ink);
    background: #fff;
    font: inherit;
    font-size: 16px;
    font-weight: 800;
}

.rule-actions {
    justify-content: flex-end;
}

.switch {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 900;
    cursor: pointer;
}

.switch input {
    position: absolute;
    opacity: 0;
}

.switch-ui {
    width: 48px;
    height: 28px;
    border-radius: 999px;
    background: #c8d0c4;
    transition: background 0.2s ease;
}

.switch-ui::after {
    content: "";
    display: block;
    width: 22px;
    height: 22px;
    margin: 3px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.22);
    transition: transform 0.2s ease;
}

.switch input:checked + .switch-ui {
    background: var(--green);
}

.switch input:checked + .switch-ui::after {
    transform: translateX(20px);
}

.empty-state {
    padding: 20px;
    border: 1px dashed var(--line);
    border-radius: 8px;
    color: var(--muted);
    background: var(--panel);
    text-align: center;
}

.toast {
    position: fixed;
    left: 50%;
    bottom: 22px;
    z-index: 50;
    transform: translateX(-50%) translateY(20px);
    max-width: min(420px, calc(100% - 28px));
    padding: 12px 14px;
    border-radius: 8px;
    color: #fff;
    background: rgba(31, 35, 31, 0.92);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.toast.is-visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

@media (min-width: 760px) {
    .rule-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

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

@media (min-width: 1080px) {
    .rule-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}
