:root {
    --bg: #f6f7f4;
    --panel: #ffffff;
    --ink: #20231f;
    --muted: #687064;
    --line: #dfe4da;
    --green: #2f7d4f;
    --blue: #276b8f;
    --red: #b63e35;
    --amber: #c68a21;
    --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;
}

body.is-modal-open {
    overflow: hidden;
}

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

.topbar,
.quick-links,
.section-head,
.sub-head,
.editor-head,
.editor-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,
.category-panel,
.customer-card,
.form-section,
.repeat-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.55;
}

.toolbar {
    display: grid;
    gap: 10px;
    margin-bottom: 14px;
}

.search-box,
label {
    display: grid;
    gap: 7px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 800;
}

.radio-group {
    display: grid;
    gap: 9px;
    margin: 0;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #f7f8f4;
}

.radio-group legend {
    padding: 0 4px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 900;
}

.radio-group label {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--ink);
}

.radio-group input {
    width: 18px;
    min-height: 18px;
    accent-color: var(--green);
}

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

input,
select,
textarea {
    width: 100%;
    min-height: 44px;
    padding: 10px 11px;
    border: 1px solid #cbd4c4;
    border-radius: 8px;
    background: #ffffff;
    color: var(--ink);
}

textarea {
    resize: vertical;
}

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

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

.btn.compact {
    min-height: 38px;
}

.category-panel {
    display: grid;
    gap: 12px;
    margin-bottom: 24px;
    padding: 14px;
}

.category-form,
.form-grid,
.contact-grid,
.repeat-grid {
    display: grid;
    gap: 10px;
}

.category-strip {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.category-pill,
.metric-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 34px;
    padding: 6px 9px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #f7f8f4;
    color: var(--ink);
    font-size: 13px;
    font-weight: 900;
}

.category-pill {
    border: 1px solid var(--line);
    cursor: pointer;
}

.category-pill small {
    color: var(--muted);
    font-size: 11px;
}

.category-pill:hover,
.category-pill.is-editing {
    border-color: var(--green);
    color: var(--green);
    background: #eef5ea;
}

.customers-section {
    display: grid;
    gap: 10px;
}

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

.customer-card {
    display: grid;
    gap: 12px;
    padding: 16px;
    border-top: 4px solid var(--green);
}

.card-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}

.customer-card h3 {
    font-size: 21px;
}

.tag {
    padding: 6px 9px;
    border-radius: 8px;
    background: #eef2ea;
    color: var(--green);
    font-size: 12px;
    font-weight: 900;
    white-space: nowrap;
}

.meta-grid {
    display: grid;
    gap: 8px;
    margin: 0;
}

.meta-grid div {
    display: grid;
    gap: 2px;
    padding: 10px;
    border-radius: 8px;
    background: #f7f8f4;
}

.meta-grid dt {
    color: var(--muted);
    font-size: 12px;
    font-weight: 900;
}

.meta-grid dd {
    margin: 0;
    font-weight: 800;
    overflow-wrap: anywhere;
}

.metric-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.metric-pill strong {
    color: var(--blue);
}

.empty-state {
    padding: 16px;
    border: 1px dashed #c9d0c2;
    border-radius: 8px;
    color: var(--muted);
    background: #fafbf8;
    text-align: center;
}

.modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 10;
    padding: 12px;
    overflow: auto;
    background: rgba(20, 26, 20, 0.48);
}

.customer-editor {
    width: min(980px, 100%);
    margin: 0 auto;
    border-radius: 8px;
    background: var(--bg);
    box-shadow: 0 18px 60px rgba(0, 0, 0, 0.24);
}

.editor-head {
    position: sticky;
    top: 0;
    z-index: 1;
    padding: 14px;
    border-bottom: 1px solid var(--line);
    background: var(--panel);
    border-radius: 8px 8px 0 0;
}

.icon-btn,
.remove-row {
    width: 38px;
    height: 38px;
    border: 0;
    border-radius: 8px;
    background: #f3e4df;
    color: var(--red);
    font-size: 22px;
    font-weight: 900;
    cursor: pointer;
}

.editor-form {
    display: grid;
    gap: 14px;
    padding: 14px;
}

.form-section {
    display: grid;
    gap: 12px;
    padding: 14px;
    box-shadow: none;
}

.repeat-list {
    display: grid;
    gap: 10px;
}

.repeat-card {
    display: grid;
    gap: 10px;
    padding: 12px;
    box-shadow: none;
    background: #fbfcf9;
}

.repeat-card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.repeat-card-title {
    color: var(--ink);
    font-weight: 900;
}

.check-line {
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 44px;
    color: var(--muted);
    font-weight: 900;
}

.check-line input {
    width: 18px;
    min-height: 18px;
}

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

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

@media (min-width: 720px) {
    .toolbar,
    .category-form {
        grid-template-columns: 1fr auto;
        align-items: end;
    }

    .category-form {
        grid-template-columns: 1fr 180px auto;
    }

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

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

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

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

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

@media (min-width: 1020px) {
    .app-shell {
        width: min(1280px, 100%);
    }

    .customer-grid {
        grid-template-columns: 1fr;
        gap: 8px;
    }

    .customer-card {
        grid-template-columns: minmax(230px, 1.15fr) minmax(360px, 1.75fr) minmax(260px, 1fr) 112px;
        align-items: center;
        gap: 14px;
        padding: 12px 14px;
        border-top: 0;
        border-left: 4px solid var(--green);
    }

    .customer-card h3 {
        font-size: 18px;
    }

    .customer-card .eyebrow {
        margin-bottom: 2px;
    }

    .customer-card .tag {
        align-self: flex-start;
    }

    .card-head {
        align-items: center;
        justify-content: flex-start;
    }

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

    .meta-grid div {
        min-height: 58px;
        padding: 8px;
    }

    .meta-grid dd {
        font-size: 13px;
        line-height: 1.25;
    }

    .metric-row {
        justify-content: flex-start;
        gap: 6px;
    }

    .metric-pill {
        min-height: 30px;
        padding: 5px 8px;
        font-size: 12px;
    }

    .customer-card > .btn {
        min-height: 38px;
        padding-inline: 10px;
    }

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

/* Full-screen editor, Trello-style: close left, title center area, spacer right. */
.modal-backdrop {
    padding: 0;
}

.modal-backdrop[hidden] {
    display: none;
}

.customer-editor {
    width: 100%;
    min-height: 100vh;
    min-height: 100dvh;
    margin: 0;
    border-radius: 0;
    box-shadow: none;
}

.editor-head {
    z-index: 2;
    display: grid;
    grid-template-columns: 44px minmax(0, 1fr) 44px;
    min-height: 68px;
    padding: 10px 12px;
    border-radius: 0;
}

.editor-title {
    min-width: 0;
}

.editor-head-spacer {
    display: block;
    width: 42px;
    height: 42px;
}

.editor-head .icon-btn {
    width: 42px;
    height: 42px;
}

.editor-form {
    width: min(980px, 100%);
    margin: 0 auto;
    padding: 14px 14px 28px;
}

.field-hint {
    margin: 6px 0 12px;
    color: #687267;
    font-size: 14px;
    line-height: 1.5;
}
