:root {
    color-scheme: light;
    --bg: #ffffff;
    --panel: #ffffff;
    --ink: #111111;
    --muted: #737780;
    --line: #e8e8e8;
    --black: #111111;
    --card: #121212;
    --card-soft: #1c1c1c;
    --card-line: #2c2c2c;
    --card-text: #f3f4f6;
    --card-muted: #9ca3af;
    --gold: #c9a851;
    --blue: #5b8cff;
    --green: #35c28d;
    --danger: #ef4444;
    --shadow: 0 16px 42px rgba(17, 17, 17, .08);
}

* {
    box-sizing: border-box;
}

html {
    -webkit-text-size-adjust: 100%;
}

body {
    margin: 0;
    min-height: 100vh;
    background: var(--bg);
    color: var(--ink);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
}

button,
input,
textarea {
    font: inherit;
}

button {
    cursor: pointer;
}

.app-shell {
    width: min(1180px, 100%);
    margin: 0 auto;
    padding: 22px;
    padding-bottom: 112px;
}

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

.eyebrow {
    margin: 0 0 5px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 900;
    letter-spacing: .12em;
}

h1,
h2 {
    margin: 0;
    letter-spacing: 0;
}

h1 {
    font-size: clamp(28px, 4vw, 40px);
    line-height: 1.1;
}

h2 {
    font-size: 22px;
}

.metrics-panel {
    margin-bottom: 14px;
}

.metrics-toggle {
    width: 100%;
    display: grid;
    grid-template-columns: 1fr auto auto auto;
    align-items: center;
    gap: 12px;
    min-height: 52px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    color: var(--ink);
    padding: 0 16px;
    text-align: left;
    box-shadow: var(--shadow);
}

.metrics-title,
.metrics-more {
    color: var(--muted);
    font-size: 13px;
    font-weight: 900;
}

.metrics-toggle strong {
    font-size: 15px;
}

.metrics-toggle em {
    font-style: normal;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
    margin-top: 12px;
}

.metrics-panel.collapsed .stats-grid {
    display: none;
}

.stat-card {
    min-height: 100px;
    padding: 18px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    box-shadow: var(--shadow);
}

.stat-card span {
    display: block;
    color: var(--muted);
    font-size: 14px;
    margin-bottom: 12px;
}

.stat-card strong {
    display: block;
    color: var(--ink);
    font-size: 30px;
    line-height: 1.1;
}

.stat-card em {
    font-style: normal;
}

.stat-card.accent {
    border-color: transparent;
    background: var(--black);
}

.stat-card.accent span,
.stat-card.accent strong {
    color: #fff;
}

.list-panel {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    box-shadow: var(--shadow);
    overflow: hidden;
}

.toolbar,
.panel-head,
.modal-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.toolbar {
    padding: 18px;
    border-bottom: 1px solid var(--line);
    background: #fff;
}

.toolbar-note {
    margin: 0;
    color: var(--muted);
    font-size: 13px;
}

.tabs {
    display: flex;
    gap: 8px;
    padding: 12px 18px;
    border-bottom: 1px solid var(--line);
    background: #fafafa;
}

.tab {
    min-width: 92px;
    min-height: 38px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    color: #333;
    padding: 0 14px;
    font-weight: 900;
}

.tab.active {
    border-color: var(--black);
    background: var(--black);
    color: #fff;
}

label {
    display: block;
    margin-top: 16px;
}

label span {
    display: block;
    margin-bottom: 7px;
    color: #333;
    font-size: 14px;
    font-weight: 800;
}

input,
textarea {
    width: 100%;
    border: 1px solid #d9d9d9;
    border-radius: 8px;
    background: #fff;
    color: var(--ink);
    outline: none;
    transition: border-color .18s ease, box-shadow .18s ease;
}

input {
    height: 44px;
    padding: 0 12px;
}

textarea {
    resize: vertical;
    min-height: 112px;
    padding: 12px;
}

input:focus,
textarea:focus {
    border-color: var(--black);
    box-shadow: 0 0 0 3px rgba(17, 17, 17, .08);
}

.primary-btn,
.ghost-btn,
.mini-btn,
.icon-btn {
    border: 0;
    border-radius: 8px;
    min-height: 38px;
    padding: 0 14px;
    font-weight: 900;
}

.primary-btn {
    width: 100%;
    height: 46px;
    margin-top: 18px;
    background: var(--black);
    color: #fff;
}

.primary-btn.compact {
    width: auto;
    min-width: 112px;
    height: 42px;
    margin-top: 0;
}

.ghost-btn,
.mini-btn,
.icon-btn {
    border: 1px solid #d9d9d9;
    background: #fff;
    color: var(--black);
}

.icon-btn {
    width: 38px;
    padding: 0;
    font-size: 24px;
    line-height: 1;
}

.cards-wrap {
    padding: 14px;
    background: #fff;
}

.account-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
    gap: 12px;
}

.account-card {
    border: 1px solid #1f1f1f;
    border-radius: 8px;
    background:
        linear-gradient(135deg, rgba(255,255,255,.045), transparent 40%),
        var(--card);
    color: var(--card-text);
    padding: 12px;
    box-shadow: 0 16px 36px rgba(0, 0, 0, .16);
}

.card-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 10px;
}

.phone-line {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.phone-icon {
    position: relative;
    width: 12px;
    height: 18px;
    flex: 0 0 12px;
    border: 2px solid var(--card-text);
    border-radius: 3px;
}

.phone-icon::after {
    content: "";
    position: absolute;
    left: 4px;
    bottom: 2px;
    width: 3px;
    height: 3px;
    border-radius: 50%;
    background: var(--card-text);
}

.phone {
    color: #fff;
    font-size: 17px;
    font-weight: 950;
    word-break: break-all;
}

.status-pill {
    flex: 0 0 auto;
    min-height: 24px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid rgba(201, 168, 81, .45);
    border-radius: 7px;
    color: var(--gold);
    padding: 1px 7px;
    font-size: 12px;
    font-weight: 900;
}

.status-verified {
    border-color: rgba(53, 194, 141, .45);
    color: var(--green);
}

.status-secondary {
    border-color: rgba(91, 140, 255, .45);
    color: var(--blue);
}

.card-info {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px 12px;
}

.info-item {
    min-width: 0;
}

.info-item.note {
    grid-column: 2 / 4;
}

.info-label {
    display: block;
    margin-bottom: 3px;
    color: var(--card-muted);
    font-size: 12px;
    font-weight: 800;
}

.info-item strong {
    display: block;
    color: var(--card-text);
    font-size: 14px;
    line-height: 1.35;
    word-break: break-word;
}

.category-pill {
    width: fit-content;
    max-width: 100%;
    border: 1px solid #3a3a3a;
    border-radius: 7px;
    background: var(--card-soft);
    padding: 1px 7px;
}

.points {
    color: #fff;
    font-size: 16px !important;
    font-weight: 950;
}

.remark {
    white-space: pre-wrap;
}

.time {
    color: var(--card-text);
}

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

.account-card .mini-btn {
    border-color: #303030;
    background: #1b1b1b;
    min-height: 30px;
    padding: 0 10px;
    color: #fff;
}

.account-card .mini-btn.verify {
    border-color: #ffffff;
    background: #ffffff;
    color: #111111;
}

.account-card .mini-btn.undo {
    color: var(--gold);
}

.account-card .mini-btn.delete {
    color: var(--danger);
}

.empty-state {
    display: grid;
    place-items: center;
    min-height: 220px;
    color: var(--muted);
}

.fab-stack {
    position: fixed;
    right: 18px;
    bottom: calc(18px + env(safe-area-inset-bottom, 0px));
    z-index: 25;
    display: grid;
    gap: 12px;
}

.fab {
    position: relative;
    width: 54px;
    height: 54px;
    border: 0;
    border-radius: 999px;
    background: var(--black);
    color: #fff;
    box-shadow: 0 16px 38px rgba(0, 0, 0, .22);
}

.add-fab {
    font-size: 34px;
    line-height: 1;
}

.search-fab::before {
    content: "";
    position: absolute;
    left: 17px;
    top: 15px;
    width: 17px;
    height: 17px;
    border: 3px solid currentColor;
    border-radius: 50%;
}

.search-fab::after {
    content: "";
    position: absolute;
    left: 32px;
    top: 32px;
    width: 12px;
    height: 3px;
    border-radius: 999px;
    background: currentColor;
    transform: rotate(45deg);
    transform-origin: left center;
}

.entry-modal,
.search-modal,
.login-gate {
    position: fixed;
    inset: 0;
}

.entry-modal,
.search-modal {
    z-index: 18;
    display: grid;
    place-items: center;
    padding: 18px;
}

.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, .45);
    backdrop-filter: blur(6px);
}

.entry-card,
.search-card,
.login-card {
    position: relative;
    z-index: 1;
    width: min(620px, 100%);
    max-height: calc(100vh - 36px);
    overflow-y: auto;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    padding: 24px;
    box-shadow: 0 28px 90px rgba(0, 0, 0, .20);
}

.search-card,
.login-card {
    width: min(420px, 100%);
}

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

.modal-actions {
    justify-content: flex-end;
    margin-top: 18px;
}

.modal-actions .ghost-btn,
.modal-actions .primary-btn {
    min-width: 112px;
}

.login-gate {
    z-index: 30;
    display: grid;
    place-items: center;
    padding: 18px;
    background: #fff;
}

.login-card h2 {
    margin-bottom: 18px;
    font-size: 28px;
}

.login-card .primary-btn {
    margin-top: 14px;
}

.login-error {
    min-height: 22px;
    margin: 12px 0 0;
    color: var(--danger);
    font-size: 14px;
}

.toast {
    position: fixed;
    right: 22px;
    bottom: 22px;
    z-index: 40;
    max-width: min(360px, calc(100vw - 44px));
    padding: 13px 16px;
    border-radius: 8px;
    background: var(--black);
    color: #fff;
    box-shadow: 0 18px 42px rgba(0, 0, 0, .24);
    opacity: 0;
    transform: translateY(12px);
    pointer-events: none;
    transition: opacity .18s ease, transform .18s ease;
}

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

.hidden {
    display: none !important;
}

@media (max-width: 780px) {
    .app-shell {
        padding: 16px;
        padding-bottom: 104px;
    }

    h1 {
        font-size: 28px;
    }

    .metrics-toggle {
        grid-template-columns: 1fr auto;
        row-gap: 4px;
        min-height: 58px;
    }

    .metrics-toggle strong,
    .metrics-toggle > span:nth-child(3) {
        justify-self: start;
    }

    .metrics-more {
        grid-column: 2;
        grid-row: 1 / span 2;
        align-self: center;
    }

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

    .stat-card {
        min-height: 88px;
        padding: 15px;
    }

    .stat-card strong {
        font-size: 23px;
        word-break: break-all;
    }

    .toolbar {
        align-items: flex-start;
        flex-direction: column;
        padding: 16px;
    }

    .tabs {
        display: grid;
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 6px;
        padding: 10px;
    }

    .tab {
        min-width: 0;
        min-height: 42px;
        padding: 0 8px;
        font-size: 14px;
    }

    .cards-wrap {
        padding: 10px;
    }

    .account-grid {
        grid-template-columns: 1fr;
    }

    .account-card {
        padding: 12px;
    }

    .phone {
        font-size: 16px;
    }

    .card-info {
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 8px 10px;
    }

    .info-label {
        font-size: 11px;
    }

    .info-item strong {
        font-size: 13px;
    }

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

    .entry-card,
    .search-card {
        padding: 20px;
    }

    .modal-actions {
        flex-direction: column-reverse;
    }

    .modal-actions .ghost-btn,
    .modal-actions .primary-btn {
        width: 100%;
    }
}

@media (max-width: 420px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }
}
