* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, "Segoe UI", Roboto, "PingFang SC", "Microsoft YaHei", sans-serif;
    background: #f0f4ff;
    color: #1a2332;
    padding: 12px;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: flex-start;
}

.app-container {
    max-width: 1400px;
    width: 100%;
    background: #ffffff;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(79, 110, 247, 0.10);
    padding: 20px 16px 28px;
}

.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 20px;
    padding-bottom: 14px;
    border-bottom: 2px solid #f0f4ff;
}
.header-left {
    display: flex;
    align-items: center;
    gap: 8px;
}
.header-left .logo {
    font-size: 24px;
}
.header-left h1 {
    font-size: 20px;
    font-weight: 700;
    background: linear-gradient(135deg, #4F6EF7, #6C8AFF);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}
.header-left .sub {
    font-size: 12px;
    color: #5185d6;
    margin-left: 4px;
    -webkit-text-fill-color: #5185d6;
    font-weight: 400;
}
.stats {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
}
.stats .stat-item {
    display: flex;
    align-items: baseline;
    gap: 4px;
    font-size: 12px;
    color: #6b7a8f;
}
.stats .stat-item .num {
    font-size: 16px;
    font-weight: 700;
    color: #1a2332;
}
.stats .stat-item .num.blue { color: #4F6EF7; }
.stats .stat-item .num.green { color: #2ecc71; }
.stats .stat-item .num.orange { color: #f39c12; }

.toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 10px 12px;
    margin-bottom: 12px;
    padding: 14px 14px;
    background: #f8faff;
    border-radius: 12px;
    border: 1px solid #eef3fc;
    align-items: center;
}
.filter-group {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 10px;
    align-items: center;
    flex: 1 1 auto;
}
.filter-group label {
    font-size: 13px;
    font-weight: 500;
    color: #3d4e66;
    display: flex;
    align-items: center;
    gap: 4px;
}
.filter-group select,
.filter-group input[type="text"] {
    padding: 4px 10px;
    border-radius: 6px;
    border: 1.5px solid #dce4ef;
    background: #fff;
    font-size: 13px;
    color: #1a2332;
    outline: none;
    height: 34px;
    transition: border 0.2s;
}
.filter-group select {
    min-width: 80px;
    cursor: pointer;
}
.filter-group input[type="text"] {
    min-width: 120px;
}
.filter-group select:focus,
.filter-group input[type="text"]:focus {
    border-color: #4F6EF7;
    box-shadow: 0 0 0 3px rgba(79, 110, 247, 0.12);
}
.btn-reset {
    padding: 4px 14px;
    border-radius: 6px;
    border: 1.5px solid #dce4ef;
    background: #fff;
    font-size: 13px;
    color: #4d5f77;
    cursor: pointer;
    height: 34px;
    display: flex;
    align-items: center;
    gap: 4px;
    transition: background 0.2s;
}
.btn-reset:hover {
    background: #f0f4ff;
}
.action-group {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-left: auto;
}

.btn {
    padding: 6px 16px;
    border-radius: 6px;
    border: none;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    height: 34px;
    white-space: nowrap;
}
.btn-primary {
    background: #4F6EF7;
    color: #fff;
    box-shadow: 0 4px 12px rgba(79, 110, 247, 0.30);
}
.btn-primary:hover {
    background: #3d5ce0;
    transform: translateY(-1px);
}
.btn-success {
    background: #2ecc71;
    color: #fff;
    box-shadow: 0 4px 12px rgba(46, 204, 113, 0.30);
}
.btn-success:hover {
    background: #27ae60;
    transform: translateY(-1px);
}
.btn-warning {
    background: #f39c12;
    color: #fff;
    box-shadow: 0 4px 12px rgba(243, 156, 18, 0.30);
}
.btn-warning:hover {
    background: #d68910;
    transform: translateY(-1px);
}
.btn-danger {
    background: #e74c3c;
    color: #fff;
    box-shadow: 0 4px 12px rgba(231, 76, 60, 0.25);
}
.btn-danger:hover {
    background: #c0392b;
    transform: translateY(-1px);
}
.btn-cancel {
    background: #f0f4ff;
    color: #3d4e66;
}
.btn-cancel:hover {
    background: #e4eaf7;
}
.btn-add-row {
    background: #e8edfe;
    color: #4F6EF7;
    border: 1px solid #d0d9f5;
}
.btn-add-row:hover {
    background: #dce4fc;
}
.btn-sm {
    padding: 2px 10px;
    height: 26px;
    font-size: 12px;
}
.btn-close-detail {
    background: #eef3fc;
    color: #3d4e66;
}
.btn-close-detail:hover {
    background: #dce4ef;
}
.btn-outline {
    background: transparent;
    color: #4d5f77;
    border: 1.5px solid #dce4ef;
}
.btn-outline:hover {
    background: #f0f4ff;
    border-color: #b8c9e0;
}

.apply-btn-area {
    text-align: center;
    padding: 20px 0 16px;
    margin-bottom: 8px;
}
.btn-apply {
    font-size: 18px;
    padding: 12px 48px;
    height: auto;
    border-radius: 12px;
    background: linear-gradient(135deg, #4F6EF7, #6C8AFF);
    box-shadow: 0 6px 24px rgba(79, 110, 247, 0.35);
}
.btn-apply:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 32px rgba(79, 110, 247, 0.45);
}
.apply-hint {
    color: #8a9bb5;
    font-size: 13px;
    margin-top: 8px;
}

.list-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    flex-wrap: wrap;
    gap: 6px;
}
.list-header h2 {
    font-size: 16px;
    font-weight: 600;
    color: #1a2332;
}
.list-header .count-badge {
    background: #eef3fc;
    padding: 2px 14px;
    border-radius: 30px;
    font-size: 12px;
    color: #4d5f77;
}

.table-wrapper {
    overflow-x: auto;
    border-radius: 10px;
    border: 1px solid #e0e7f0;
    -webkit-overflow-scrolling: touch;
}
table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    min-width: 700px;
}
thead {
    background: #f8faff;
    border-bottom: 2px solid #d0dce8;
}
thead th {
    padding: 10px 12px;
    text-align: left;
    font-weight: 600;
    color: #2c3e50;
    font-size: 12px;
    white-space: nowrap;
    border-bottom: 2px solid #c0cfe0;
}
tbody tr {
    border-bottom: 3px solid #e4eaf2;
    transition: background 0.15s;
}
tbody tr:hover {
    background: #f5f8ff;
}
tbody td {
    padding: 12px 12px;
    vertical-align: middle;
    color: #1a2332;
    border-right: 1px solid #edf2f8;
    word-break: break-word;
    line-height: 1.5;
}
tbody td:last-child {
    border-right: none;
}

.td-name {
    font-weight: 600;
    color: #1a2b3c;
    cursor: pointer;
    transition: color 0.2s;
}
.td-name:hover {
    color: #4F6EF7;
    text-decoration: underline;
}
.td-name .click-hint {
    font-weight: 400;
    font-size: 11px;
    color: #8a9bb5;
    margin-left: 4px;
}

.td-business-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.business-item {
    display: flex;
    flex-direction: column;
    gap: 2px;
    font-size: 13px;
    line-height: 1.6;
    padding: 4px 0;
    border-bottom: 1px dashed #eef3fc;
}
.business-item:last-child {
    border-bottom: none;
}
.business-name {
    font-weight: 600;
    color: #4F6EF7;
}
.business-note {
    color: #5a6b7e;
    font-size: 12.5px;
    white-space: pre-wrap !important;
    word-break: break-word !important;
    overflow-wrap: break-word !important;
    line-height: 1.6;
    padding-left: 2px;
    display: block;
    max-width: 100%;
}

.tag-region {
    background: #e3f5ec;
    color: #1a8a5a;
    padding: 2px 10px;
    border-radius: 30px;
    font-size: 11px;
    display: inline-block;
    white-space: normal;
    word-break: break-word;
    max-width: 100%;
}
.phone-link {
    color: #4F6EF7;
    text-decoration: none;
    font-weight: 500;
    font-size: 13px;
}
.phone-link:hover {
    text-decoration: underline;
}
.status-badge {
    padding: 2px 10px;
    border-radius: 30px;
    font-size: 11px;
    display: inline-block;
}
.status-pending {
    background: #fff3cd;
    color: #856404;
}
.status-approved {
    background: #d4edda;
    color: #155724;
}

.empty-state {
    text-align: center;
    padding: 32px 16px;
    color: #8a9bb5;
}
.empty-state .empty-icon {
    font-size: 36px;
    display: block;
    margin-bottom: 8px;
}
.empty-state p {
    font-size: 14px;
}

.highlight {
    background: #ffeb3b;
    padding: 0 2px;
    border-radius: 2px;
}

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.50);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 999;
    padding: 16px;
    animation: fadeIn 0.25s ease;
}
.modal-overlay.active {
    display: flex;
}
@keyframes fadeIn {
    from { opacity: 0; transform: scale(0.96); }
    to { opacity: 1; transform: scale(1); }
}
.modal {
    background: #ffffff;
    border-radius: 16px;
    max-width: 720px;
    width: 100%;
    padding: 24px 20px 24px;
    box-shadow: 0 30px 80px rgba(0, 0, 0, 0.25);
    animation: slideUp 0.3s ease;
    max-height: 95vh;
    overflow-y: auto;
}
@keyframes slideUp {
    from { opacity: 0; transform: translateY(30px) scale(0.97); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}
.modal .modal-title {
    font-size: 18px;
    font-weight: 700;
    color: #1a2332;
    margin-bottom: 4px;
}
.modal .modal-desc {
    font-size: 13px;
    color: #6b7a8f;
    margin-bottom: 18px;
}
.modal .form-group {
    margin-bottom: 14px;
}
.modal .form-group label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: #3d4e66;
    margin-bottom: 4px;
}
.modal .form-group label .required {
    color: #e74c3c;
    margin-left: 2px;
}
.modal .form-group input,
.modal .form-group select {
    width: 100%;
    padding: 8px 12px;
    border-radius: 8px;
    border: 1.5px solid #dce4ef;
    font-size: 14px;
    color: #1a2332;
    outline: none;
    background: #fff;
    transition: border 0.2s;
}
.modal .form-group input:focus,
.modal .form-group select:focus {
    border-color: #4F6EF7;
    box-shadow: 0 0 0 3px rgba(79, 110, 247, 0.12);
}
.modal .form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}
.modal .business-entry {
    display: flex;
    gap: 8px;
    align-items: flex-start;
    margin-bottom: 6px;
    flex-wrap: wrap;
    background: #f8faff;
    padding: 6px 10px;
    border-radius: 8px;
    border: 1px solid #eef3fc;
}
.modal .business-entry input,
.modal .business-entry textarea {
    flex: 1;
    min-width: 80px;
    padding: 5px 8px;
    border-radius: 6px;
    border: 1.5px solid #dce4ef;
    font-size: 14px;
    font-family: inherit;
    outline: none;
    background: #fff;
    transition: border 0.2s;
}
.modal .business-entry input:focus,
.modal .business-entry textarea:focus {
    border-color: #4F6EF7;
    box-shadow: 0 0 0 3px rgba(79, 110, 247, 0.12);
}
.modal .business-entry textarea {
    resize: none;
    overflow: hidden;
    min-height: 34px;
    line-height: 1.5;
}
.modal .business-entry .btn-remove {
    background: transparent;
    border: none;
    color: #e74c3c;
    font-size: 18px;
    cursor: pointer;
    padding: 0 4px;
    align-self: center;
}
.modal .business-entry .btn-remove:hover {
    color: #c0392b;
}
.modal .modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 18px;
    padding-top: 14px;
    border-top: 1px solid #f0f4ff;
}
.modal .modal-actions .btn {
    min-width: 70px;
    justify-content: center;
}

.detail-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    padding-bottom: 16px;
    border-bottom: 2px solid #f0f4ff;
}
.detail-title {
    font-size: 22px;
    font-weight: 700;
    color: #1a2332;
}
.detail-close {
    background: #f0f4ff;
    border: none;
    font-size: 22px;
    cursor: pointer;
    color: #6b7a8f;
    padding: 4px 12px;
    border-radius: 8px;
    transition: background 0.2s;
    line-height: 1.4;
}
.detail-close:hover {
    background: #dce4ef;
}
.detail-info {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px 20px;
    padding: 16px 0 12px;
    font-size: 14px;
}
.detail-info .info-item {
    display: flex;
    gap: 6px;
}
.detail-info .info-label {
    color: #8a9bb5;
    font-weight: 500;
    min-width: 56px;
}
.detail-info .info-value {
    color: #1a2332;
    word-break: break-word;
}
.detail-info .info-value a {
    color: #4F6EF7;
    text-decoration: none;
}
.detail-info .info-value a:hover {
    text-decoration: underline;
}
.detail-business-section {
    padding-top: 14px;
    border-top: 1px solid #eef3fc;
}
.detail-business-section .section-title {
    font-weight: 600;
    font-size: 15px;
    color: #1a2332;
    margin-bottom: 12px;
}
.detail-business-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.detail-business-item {
    background: #f8faff;
    padding: 10px 14px;
    border-radius: 10px;
    border: 1px solid #eef3fc;
}
.detail-business-item .biz-name {
    font-weight: 600;
    color: #4F6EF7;
    font-size: 14px;
}
.detail-business-item .biz-note {
    color: #5a6b7e;
    font-size: 13px;
    white-space: pre-wrap;
    word-break: break-word;
    line-height: 1.6;
    margin-top: 4px;
    display: block;
    padding-left: 2px;
}
.detail-business-item .biz-note:empty {
    display: none;
}
.detail-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid #f0f4ff;
}

.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-width: 320px;
    width: 100%;
}
.toast {
    padding: 12px 16px;
    border-radius: 10px;
    background: #1a2332;
    color: #fff;
    font-size: 13px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.18);
    animation: toastIn 0.4s ease;
    display: flex;
    align-items: center;
    gap: 8px;
}
.toast.success {
    background: #2ecc71;
}
.toast.error {
    background: #e74c3c;
}
.toast.info {
    background: #4F6EF7;
}
@keyframes toastIn {
    from { opacity: 0; transform: translateX(40px); }
    to { opacity: 1; transform: translateX(0); }
}

@media (max-width: 768px) {
    body {
        padding: 6px;
    }
    .app-container {
        padding: 12px 8px 18px;
        border-radius: 14px;
    }

    .header {
        flex-direction: column;
        align-items: flex-start;
        gap: 6px;
    }
    .header-left h1 {
        font-size: 17px;
    }
    .stats {
        width: 100%;
        justify-content: space-around;
    }
    .stats .stat-item {
        font-size: 11px;
    }
    .stats .stat-item .num {
        font-size: 14px;
    }

    .toolbar {
        flex-direction: column;
        align-items: stretch;
        padding: 12px;
        gap: 8px;
    }
    .filter-group {
        flex-direction: column;
        align-items: stretch;
        gap: 6px;
    }
    .filter-group label {
        font-size: 12px;
        flex-wrap: wrap;
        align-items: center;
    }
    .filter-group select,
    .filter-group input[type="text"] {
        width: 100%;
        min-width: unset;
        height: 38px;
        font-size: 15px;
    }
    .btn-reset {
        height: 38px;
        font-size: 14px;
        justify-content: center;
    }
    .action-group {
        margin-left: 0;
        justify-content: stretch;
    }
    .action-group .btn {
        flex: 1;
        justify-content: center;
        height: 38px;
        font-size: 14px;
    }

    .btn-apply {
        font-size: 16px;
        padding: 10px 32px;
        width: 100%;
        justify-content: center;
    }
    .apply-hint {
        font-size: 12px;
    }

    .list-header h2 {
        font-size: 14px;
    }
    .list-header .count-badge {
        font-size: 11px;
    }

    .table-wrapper {
        border-radius: 8px;
    }
    table {
        min-width: 460px;
        font-size: 12px;
        table-layout: fixed;
    }
    thead th:nth-child(1) { width: 10%; }
    thead th:nth-child(2) { width: 8%; }
    thead th:nth-child(3) { width: 10%; }
    thead th:nth-child(4) { width: 42%; }
    thead th:nth-child(5) { width: 10%; }
    thead th:nth-child(6) { width: 20%; text-align: right; }

    thead th {
        padding: 6px 6px;
        font-size: 10px;
        white-space: nowrap;
    }
    tbody td {
        padding: 8px 6px;
        font-size: 11px;
        line-height: 1.5;
        word-break: break-word;
    }

    .td-name {
        font-size: 11px;
    }
    .td-name .click-hint {
        font-size: 9px;
    }

    .business-item {
        font-size: 11px;
        gap: 1px;
        padding: 2px 0;
    }
    .business-name {
        font-size: 11px;
    }
    .business-note {
        font-size: 10.5px;
        padding-left: 0;
        white-space: pre-wrap !important;
        word-break: break-word !important;
        overflow-wrap: break-word !important;
        max-width: 100% !important;
        display: block !important;
    }

    .tag-region {
        font-size: 9px;
        padding: 1px 6px;
        white-space: normal !important;
        word-break: break-word !important;
        max-width: 100%;
    }

    .btn-sm {
        padding: 1px 6px;
        height: 24px;
        font-size: 11px;
    }
    .phone-link {
        font-size: 11px;
    }

    .modal {
        padding: 14px 12px;
    }
    .modal .form-row {
        grid-template-columns: 1fr;
        gap: 8px;
    }
    .modal .business-entry {
        flex-direction: column;
        align-items: stretch;
    }
    .modal .business-entry .btn-remove {
        align-self: flex-end;
    }
    .modal .modal-title {
        font-size: 16px;
    }
    .modal .modal-desc {
        font-size: 12px;
    }
    .modal .form-group input,
    .modal .form-group select,
    .modal .business-entry input,
    .modal .business-entry textarea {
        font-size: 15px;
    }
    .modal .business-entry textarea {
        min-height: 60px;
        max-height: 160px;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        touch-action: pan-y;
    }

    .detail-info {
        grid-template-columns: 1fr;
        gap: 4px;
    }
    .detail-info .info-item {
        font-size: 12px;
    }
    .detail-business-item .biz-name {
        font-size: 12px;
    }
    .detail-business-item .biz-note {
        font-size: 11px;
    }

    .toast-container {
        top: 12px;
        right: 12px;
        max-width: 280px;
    }
    .toast {
        font-size: 12px;
        padding: 10px 14px;
    }
}

@media (max-width: 420px) {
    table {
        min-width: 360px;
        font-size: 10px;
        table-layout: fixed;
    }
    thead th {
        padding: 3px 4px;
        font-size: 9px;
    }
    tbody td {
        padding: 6px 4px;
        font-size: 10px;
    }
    .business-item {
        font-size: 10px;
    }
    .business-note {
        font-size: 9.5px;
    }
    .btn-sm {
        padding: 1px 4px;
        height: 20px;
        font-size: 9px;
    }
    thead th:nth-child(1) { width: 10%; }
    thead th:nth-child(2) { width: 8%; }
    thead th:nth-child(3) { width: 10%; }
    thead th:nth-child(4) { width: 42%; }
    thead th:nth-child(5) { width: 10%; }
    thead th:nth-child(6) { width: 20%; }
    .tag-region {
        font-size: 8px;
        padding: 1px 4px;
    }
    .td-name .click-hint {
        font-size: 8px;
    }
}