*{
    box-sizing:border-box;
}

:root{
    --primary:#18ad72;
    --primary-dark:#087b50;
    --primary-light:#e9f8f1;
    --bg:#f4f6f7;
    --card:#ffffff;
    --text:#17211c;
    --muted:#7b867f;
    --border:#e0e6e2;
    --danger:#d94343;
    --warning:#d79014;
    --success:#17975c;
}

html{
    scroll-behavior:smooth;
}

body{
    margin:0;
    background:var(--bg);
    color:var(--text);
    font-family:Arial,"Microsoft YaHei",sans-serif;
    padding-bottom:95px;
}

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

button{
    cursor:pointer;
}

.hidden{
    display:none !important;
}

/* 顶部 */

.topbar{
    position:sticky;
    top:0;
    z-index:30;

    display:flex;
    align-items:center;
    justify-content:space-between;

    padding:22px 20px 18px;

    background:var(--primary);
    color:white;

    box-shadow:0 3px 14px rgba(0,0,0,.10);
}

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

.topbar p{
    margin:0;
    font-size:14px;
    opacity:.88;
}

.settings-button{
    width:48px;
    height:48px;

    border:0;
    border-radius:50%;

    background:rgba(255,255,255,.18);
    color:white;
    font-size:23px;
}

/* 主区域 */

main{
    width:100%;
    max-width:760px;
    margin:0 auto;
    padding:18px 15px 30px;
}

.page{
    display:none;
}

.page.active{
    display:block;
}

.muted{
    margin:0;
    color:var(--muted);
    font-size:12px;
    letter-spacing:1px;
}

/* 首页 */

.welcome-card{
    display:flex;
    justify-content:space-between;
    align-items:center;

    background:linear-gradient(135deg,#fff,#eaf8f2);

    border:1px solid var(--border);
    border-radius:20px;

    padding:20px;
    margin-bottom:15px;
}

.welcome-card h2{
    margin:5px 0 0;
}

.logo-placeholder{
    display:flex;
    align-items:center;
    justify-content:center;

    width:60px;
    height:60px;

    border-radius:18px;

    background:var(--primary);
    color:white;

    font-size:21px;
    font-weight:bold;
}

.stats-grid{
    display:grid;
    grid-template-columns:repeat(2,1fr);
    gap:11px;
}

.stat-card{
    background:white;

    border:1px solid var(--border);
    border-radius:17px;

    padding:16px;

    box-shadow:0 3px 12px rgba(0,0,0,.035);
}

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

.stat-card strong{
    font-size:19px;
}

.success-text{
    color:var(--success);
}

.danger-text{
    color:var(--danger);
}

.section-heading{
    display:flex;
    justify-content:space-between;
    align-items:center;

    margin:24px 2px 12px;
}

.section-heading h2{
    margin:0;
    font-size:19px;
}

.link-button{
    border:0;
    background:none;
    color:var(--primary);
}

.quick-grid{
    display:grid;
    grid-template-columns:repeat(2,1fr);
    gap:11px;
}

.quick-card{
    display:flex;
    flex-direction:column;
    align-items:flex-start;
    gap:10px;

    min-height:100px;

    padding:17px;

    border:1px solid var(--border);
    border-radius:17px;

    background:white;

    color:var(--text);
    font-size:15px;
    font-weight:bold;
}

.quick-card span{
    font-size:27px;
}

/* 页面标题 */

.page-title{
    display:flex;
    justify-content:space-between;
    align-items:center;

    margin:2px 2px 17px;
}

.page-title h2{
    margin:4px 0 0;
    font-size:25px;
}

.page-title > span{
    font-size:34px;
}

/* 表单 */

.form-card{
    padding:18px;
    margin-bottom:14px;

    background:white;

    border:1px solid var(--border);
    border-radius:18px;

    box-shadow:0 3px 14px rgba(0,0,0,.04);
}

.form-card h3{
    margin:0 0 16px;
}

label{
    display:block;

    margin:15px 0 7px;

    color:#3f4c45;
    font-size:14px;
    font-weight:bold;
}

input,
select,
textarea{
    width:100%;
    min-height:48px;

    padding:12px 13px;

    border:1px solid #d5ddd8;
    border-radius:11px;

    background:white;
    color:var(--text);

    font-size:16px;
    outline:none;
}

textarea{
    min-height:88px;
    resize:vertical;
}

input:focus,
select:focus,
textarea:focus{
    border-color:var(--primary);
    box-shadow:0 0 0 3px rgba(24,173,114,.10);
}

.help-text{
    color:var(--muted);
    font-size:12px;
    line-height:1.65;
}

.two-columns{
    display:grid;
    grid-template-columns:1fr 1fr;
    gap:11px;
}

/* 按钮 */

.primary-button,
.secondary-button{
    width:100%;
    min-height:49px;

    margin-top:16px;

    border-radius:12px;

    font-size:16px;
    font-weight:bold;
}

.primary-button{
    border:0;
    background:var(--primary);
    color:white;
}

.secondary-button{
    border:1px solid #a9dfc7;
    background:var(--primary-light);
    color:var(--primary-dark);
}

.main-action{
    min-height:56px;
}

/* 客户商品列表 */

.badge{
    min-width:30px;

    padding:5px 9px;

    border-radius:30px;

    background:var(--primary-light);
    color:var(--primary-dark);

    text-align:center;
    font-size:13px;
    font-weight:bold;
}

.list-card{
    padding:16px;
    margin-bottom:11px;

    background:white;

    border:1px solid var(--border);
    border-radius:16px;
}

.list-card-header{
    display:flex;
    justify-content:space-between;
    gap:10px;
}

.list-card h3{
    margin:0 0 7px;
}

.list-card p{
    margin:4px 0;
    color:var(--muted);
    line-height:1.5;
    font-size:14px;
}

.mini-actions{
    display:flex;
    gap:8px;
    margin-top:13px;
}

.mini-button{
    flex:1;

    min-height:40px;

    border:1px solid var(--border);
    border-radius:10px;

    background:white;
}

.delete-button{
    color:var(--danger);
    background:#fff4f4;
    border-color:#ffd8d8;
}

/* 开单商品 */

.cart-row{
    display:grid;
    grid-template-columns:1fr auto;
    gap:12px;

    padding:15px;
    margin-bottom:10px;

    background:white;

    border:1px solid var(--border);
    border-radius:15px;
}

.cart-row h3{
    margin:0 0 7px;
    font-size:16px;
}

.cart-row p{
    margin:4px 0;
    color:var(--muted);
    font-size:14px;
}

.cart-right{
    text-align:right;
    font-weight:bold;
}

.remove-cart{
    margin-top:10px;

    border:0;
    background:#fff0f0;
    color:var(--danger);

    border-radius:9px;

    width:36px;
    height:36px;
}

.invoice-summary-card{
    padding:17px;
    margin:13px 0;

    border-radius:17px;

    color:white;

    background:linear-gradient(
        135deg,
        var(--primary),
        var(--primary-dark)
    );
}

.summary-row{
    display:flex;
    justify-content:space-between;
    gap:10px;

    padding:7px 0;
}

.summary-divider{
    height:1px;
    background:rgba(255,255,255,.3);
    margin:8px 0;
}

.grand-total{
    font-size:20px;
}

/* 历史 */

.search-box{
    margin-bottom:11px;
}

.filter-row{
    display:flex;
    overflow-x:auto;
    gap:8px;

    margin-bottom:15px;
    padding-bottom:3px;
}

.filter-button{
    flex-shrink:0;

    padding:9px 14px;

    border:1px solid var(--border);
    border-radius:30px;

    background:white;
    color:var(--muted);
}

.filter-button.active{
    border-color:var(--primary);

    background:var(--primary);
    color:white;
}

.invoice-card{
    padding:18px;
    margin-bottom:14px;

    background:white;

    border:1px solid var(--border);
    border-radius:19px;

    box-shadow:0 4px 15px rgba(0,0,0,.04);
}

.invoice-header{
    display:flex;
    justify-content:space-between;
    align-items:flex-start;
    gap:12px;

    padding-bottom:14px;

    border-bottom:1px solid var(--border);
}

.invoice-header h3{
    margin:0 0 6px;
    font-size:20px;
}

.invoice-meta{
    color:var(--muted);
    font-size:13px;
    line-height:1.65;
}

.status-pill{
    flex-shrink:0;

    padding:7px 10px;

    border-radius:30px;

    font-size:12px;
    font-weight:bold;
}

.unpaid{
    background:#fff0f0;
    color:var(--danger);
}

.partial{
    background:#fff6df;
    color:#b47300;
}

.paid{
    background:#eaf8f1;
    color:var(--success);
}

.cancelled{
    background:#eceeed;
    color:#707770;
}

.invoice-item{
    display:flex;
    justify-content:space-between;
    gap:12px;

    padding:8px 0;

    font-size:14px;
}

.money-box{
    margin-top:10px;
    padding:13px;

    border-radius:12px;

    background:#f6f8f7;
}

.money-row{
    display:flex;
    justify-content:space-between;
    padding:5px 0;
}

.payment-entry{
    padding:10px;
    margin-top:8px;

    border-radius:10px;
    background:#f4f6f5;

    font-size:13px;
    line-height:1.6;
}

.invoice-actions{
    display:grid;
    grid-template-columns:1fr 1fr;
    gap:8px;

    margin-top:14px;
}

.action-button{
    min-height:43px;

    border:1px solid var(--border);
    border-radius:10px;

    background:white;
}

.whatsapp{
    color:#087d49;
    border-color:#bce6cf;
    background:#ebf9f2;
}

.cancel-action{
    color:var(--danger);
}

/* 空状态 */

.empty-state{
    padding:28px 18px;

    border:1px dashed #ccd7d0;
    border-radius:17px;

    background:rgba(255,255,255,.7);

    color:var(--muted);
    text-align:center;
    line-height:1.65;
}

/* 底部导航 */

.bottom-nav{
    position:fixed;
    left:0;
    right:0;
    bottom:0;
    z-index:40;

    display:grid;
    grid-template-columns:repeat(5,1fr);

    min-height:72px;

    padding:7px 4px;

    background:rgba(255,255,255,.98);

    border-top:1px solid var(--border);

    box-shadow:0 -3px 14px rgba(0,0,0,.07);
}

.nav-button{
    display:flex;
    flex-direction:column;
    justify-content:center;
    align-items:center;
    gap:4px;

    border:0;
    background:none;

    color:#7a867f;

    font-size:11px;
}

.nav-button span{
    font-size:20px;
}

.nav-button.active{
    color:var(--primary);
    font-weight:bold;
}

.create-nav-button span{
    display:flex;
    align-items:center;
    justify-content:center;

    width:40px;
    height:40px;

    margin-top:-19px;

    border-radius:50%;

    background:var(--primary);
    color:white;

    box-shadow:0 4px 12px rgba(24,173,114,.32);
}

@media(min-width:600px){

    .stats-grid{
        grid-template-columns:repeat(4,1fr);
    }

    .quick-grid{
        grid-template-columns:repeat(4,1fr);
    }

}
