* {
    box-sizing: border-box;
}

body {
    margin: 0;
    color: #1f2937;
    background: #f5f7fb;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
}

a {
    color: inherit;
    text-decoration: none;
}

.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 32px 20px;
    background: #f5f7fb;
}

.sidebar-logo span {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
}

.login-card {
    width: min(100%, 390px);
    padding: 34px;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 18px 48px rgba(20, 39, 76, 0.1);
}

.login-card-head h2 {
    margin: 0;
    font-size: 24px;
}

.alert-error {
    margin-top: 22px;
    padding: 12px 14px;
    color: #b42318;
    background: #fff1f0;
    border: 1px solid #ffd2cf;
    border-radius: 6px;
    font-size: 14px;
}

.flash-message {
    margin-bottom: 18px;
    padding: 13px 15px;
    border-radius: 6px;
    font-size: 14px;
}

.flash-success {
    color: #067647;
    background: #ecfdf3;
    border: 1px solid #abefc6;
}

.flash-error {
    color: #b42318;
    background: #fff1f0;
    border: 1px solid #ffd2cf;
}

.login-form {
    margin-top: 24px;
}

.login-form label {
    display: block;
    margin-bottom: 18px;
}

.login-form span {
    display: block;
    margin-bottom: 8px;
    color: #4b5563;
    font-size: 14px;
}

.login-form input {
    width: 100%;
    height: 44px;
    padding: 0 13px;
    color: #1f2937;
    background: #f9fafc;
    border: 1px solid #d8dee9;
    border-radius: 6px;
    font-size: 15px;
    outline: none;
    transition: border-color 0.16s, box-shadow 0.16s, background 0.16s;
}

.login-form input:focus {
    background: #fff;
    border-color: #1976ff;
    box-shadow: 0 0 0 3px rgba(25, 118, 255, 0.12);
}

.login-form button {
    width: 100%;
    height: 46px;
    margin-top: 4px;
    color: #fff;
    background: #1976ff;
    border: 0;
    border-radius: 6px;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 10px 22px rgba(25, 118, 255, 0.28);
}

.app-shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 232px 1fr;
}

.sidebar {
    background: #101828;
    color: #d0d5dd;
    padding: 20px 16px;
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 6px 6px 24px;
}

.sidebar-logo span {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    color: #fff;
    background: #1976ff;
}

.sidebar-logo strong {
    color: #fff;
    font-size: 18px;
}

.sidebar-nav {
    display: grid;
    gap: 6px;
}

.sidebar-nav a {
    padding: 12px 14px;
    border-radius: 6px;
    color: #cbd5e1;
    font-size: 14px;
}

.sidebar-nav a:hover,
.sidebar-nav a.active {
    color: #fff;
    background: #1976ff;
}

.main-panel {
    min-width: 0;
}

.topbar {
    height: 76px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 32px;
    background: #fff;
    border-bottom: 1px solid #e5eaf3;
}

.topbar-kicker {
    margin: 0 0 3px;
    color: #758195;
    font-size: 13px;
}

.topbar h1 {
    margin: 0;
    font-size: 22px;
}

.user-box {
    display: flex;
    align-items: center;
    gap: 14px;
    color: #4b5563;
    font-size: 14px;
}

.user-box a {
    padding: 8px 12px;
    color: #1976ff;
    background: #eef5ff;
    border-radius: 6px;
}

.root-badge {
    padding: 5px 9px;
    color: #8a4b00;
    background: #fff4d6;
    border-radius: 999px;
    font-size: 12px;
}

.dashboard-content {
    padding: 28px 32px 36px;
}

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

.stat-card,
.panel {
    background: #fff;
    border: 1px solid #e5eaf3;
    border-radius: 8px;
    box-shadow: 0 10px 28px rgba(20, 39, 76, 0.04);
}

.stat-card {
    padding: 22px;
}

.stat-card p,
.stat-card span {
    margin: 0;
    color: #758195;
    font-size: 14px;
}

.stat-card strong {
    display: block;
    margin: 10px 0;
    color: #101828;
    font-size: 32px;
    line-height: 1;
}

.content-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.6fr) minmax(280px, 0.8fr);
    gap: 18px;
    margin-top: 18px;
}

.panel {
    padding: 22px;
}

.panel-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 18px;
}

.collapse-head {
    width: 100%;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin: 0 0 18px;
    padding: 0;
    color: inherit;
    background: transparent;
    border: 0;
    text-align: left;
    cursor: pointer;
}

.collapse-head h2 {
    margin: 0;
    font-size: 18px;
}

.collapse-icon {
    flex: 0 0 auto;
    min-width: 48px;
    height: 30px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #1976ff;
    background: #eef5ff;
    border-radius: 6px;
    font-size: 13px;
}

.collapse-body[hidden] {
    display: none;
}

.panel h2 {
    margin: 0;
    font-size: 18px;
}

.panel p {
    margin: 7px 0 0;
    color: #758195;
    font-size: 14px;
}

.ghost-button {
    height: 34px;
    padding: 0 14px;
    color: #1976ff;
    background: #fff;
    border: 1px solid #b8d5ff;
    border-radius: 6px;
    cursor: pointer;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.data-table th,
.data-table td {
    padding: 14px 12px;
    text-align: left;
    border-bottom: 1px solid #edf1f7;
}

.data-table th {
    color: #758195;
    background: #f8fafd;
    font-weight: 600;
}

.status-pill {
    display: inline-flex;
    align-items: center;
    min-height: 26px;
    padding: 0 10px;
    color: #b54708;
    background: #fff7e6;
    border-radius: 999px;
    font-size: 13px;
}

.timeline {
    display: grid;
    gap: 18px;
}

.timeline div {
    display: grid;
    grid-template-columns: 12px 1fr;
    gap: 12px;
    align-items: start;
}

.timeline span {
    width: 10px;
    height: 10px;
    margin-top: 5px;
    background: #1976ff;
    border-radius: 999px;
}

.timeline p {
    margin: 0;
    line-height: 1.7;
}

.settings-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 18px;
}

.settings-form {
    display: grid;
    gap: 18px;
}

.settings-form label {
    display: grid;
    gap: 8px;
}

.settings-form label > span {
    color: #4b5563;
    font-size: 14px;
}

.settings-form input,
.settings-form select,
.settings-form textarea {
    width: 100%;
    padding: 0 12px;
    color: #1f2937;
    background: #f9fafc;
    border: 1px solid #d8dee9;
    border-radius: 6px;
    font-size: 14px;
    outline: none;
}

.settings-form input,
.settings-form select {
    height: 42px;
}

.settings-form textarea {
    min-height: 86px;
    padding-top: 10px;
    padding-bottom: 10px;
    resize: vertical;
}

.settings-form input:focus,
.settings-form select:focus,
.settings-form textarea:focus {
    background: #fff;
    border-color: #1976ff;
    box-shadow: 0 0 0 3px rgba(25, 118, 255, 0.12);
}

.switch-row {
    grid-template-columns: auto 1fr;
    align-items: center;
}

.switch-row input {
    width: 18px;
    height: 18px;
}

.form-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.primary-button {
    height: 36px;
    padding: 0 16px;
    color: #fff;
    background: #1976ff;
    border: 0;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 700;
}

.primary-link-button,
.ghost-link-button {
    min-height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 16px;
    border-radius: 6px;
    font-size: 14px;
}

.primary-link-button {
    color: #fff;
    background: #1976ff;
    font-weight: 700;
}

.ghost-link-button {
    color: #1976ff;
    background: #fff;
    border: 1px solid #b8d5ff;
}

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

.search-box {
    flex: 1 1 auto;
}

.search-box input {
    width: 100%;
    height: 40px;
    padding: 0 13px;
    color: #1f2937;
    background: #f9fafc;
    border: 1px solid #d8dee9;
    border-radius: 6px;
    font-size: 14px;
    outline: none;
}

.search-box input:focus {
    background: #fff;
    border-color: #1976ff;
    box-shadow: 0 0 0 3px rgba(25, 118, 255, 0.12);
}

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

.product-category-card {
    padding: 18px;
    background: #f8fafd;
    border: 1px solid #e5eaf3;
    border-radius: 8px;
}

.product-category-card h3 {
    margin: 0;
    font-size: 16px;
}

.compact-form {
    padding: 0;
}

.category-list {
    display: grid;
    gap: 10px;
    margin-top: 16px;
}

.category-root {
    background: #fff;
}

.category-child {
    margin-left: 16px;
    background: #fbfcfe;
}

.category-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 14px;
    border: 1px solid #e5eaf3;
    border-radius: 6px;
}

.category-item strong {
    display: block;
    color: #101828;
    font-size: 14px;
}

.category-item span {
    color: #758195;
    font-size: 12px;
}

.category-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.category-actions button {
    padding: 0;
    color: #1976ff;
    background: transparent;
    border: 0;
    cursor: pointer;
}

.category-actions form button {
    color: #b42318;
}

.product-category-card select {
    width: 100%;
    height: 42px;
    padding: 0 12px;
    color: #1f2937;
    background: #f9fafc;
    border: 1px solid #d8dee9;
    border-radius: 6px;
    font-size: 14px;
    outline: none;
}

.table-wrap {
    overflow-x: auto;
}

.customer-table {
    min-width: 860px;
}

.remark-cell {
    max-width: 260px;
    color: #4b5563;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.table-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.table-actions a,
.table-actions button {
    color: #1976ff;
    background: transparent;
    border: 0;
    padding: 0;
    font: inherit;
    cursor: pointer;
}

.table-actions button {
    color: #b42318;
}

.empty-table {
    padding: 30px 12px;
    color: #758195;
    text-align: center;
}

.form-panel {
    max-width: 720px;
}

.modal-mask {
    position: fixed;
    inset: 0;
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: rgba(15, 23, 42, 0.42);
}

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

.modal-panel {
    width: min(100%, 620px);
    max-height: calc(100vh - 48px);
    overflow-y: auto;
    padding: 22px;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 24px 80px rgba(15, 23, 42, 0.28);
}

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

.modal-head h2 {
    margin: 0;
    font-size: 18px;
}

.modal-close {
    width: 32px;
    height: 32px;
    color: #667085;
    background: #f2f4f7;
    border: 0;
    border-radius: 6px;
    cursor: pointer;
    font-size: 22px;
    line-height: 1;
}

.template-preview {
    padding: 12px 14px;
    color: #1976ff;
    background: #eef5ff;
    border-radius: 6px;
    font-size: 14px;
}

.template-hint {
    display: grid;
    gap: 6px;
    padding: 12px 14px;
    background: #f8fafd;
    border: 1px solid #edf1f7;
    border-radius: 6px;
    font-size: 13px;
    color: #4b5563;
}

.template-hint strong {
    color: #101828;
}

.admin-lock {
    display: grid;
    gap: 14px;
}

.admin-lock div {
    padding: 14px;
    background: #f8fafd;
    border: 1px solid #edf1f7;
    border-radius: 6px;
}

.admin-lock span {
    display: block;
    margin-bottom: 6px;
    color: #758195;
    font-size: 13px;
}

.admin-lock strong {
    color: #101828;
    font-size: 16px;
}

.empty-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    text-align: center;
}

.empty-page h1 {
    margin: 0;
    font-size: 60px;
}

.empty-page a {
    display: inline-block;
    margin-top: 14px;
    color: #1976ff;
}

@media (max-width: 960px) {
    .login-page {
        padding: 24px 16px;
    }

    .app-shell {
        grid-template-columns: 1fr;
    }

    .sidebar {
        display: none;
    }

    .stats-grid,
    .content-grid,
    .settings-grid {
        grid-template-columns: 1fr;
    }

    .topbar,
    .dashboard-content {
        padding-left: 18px;
        padding-right: 18px;
    }
}

@media (max-width: 560px) {
    .login-card {
        padding: 24px;
    }

    .topbar {
        height: auto;
        gap: 14px;
        align-items: flex-start;
        flex-direction: column;
        padding-top: 16px;
        padding-bottom: 16px;
    }

    .data-table {
        min-width: 620px;
    }

    .panel-wide {
        overflow-x: auto;
    }

    .customer-toolbar {
        align-items: stretch;
        flex-direction: column;
    }
}
