
:root{
    --bg:#f3f7fb;
    --surface:#ffffff;
    --surface-soft:#f8fbfe;
    --text:#35526c;
    --muted:#7c95ab;
    --border:#dbe7f0;
    --line:#eaf1f6;
    --primary:#19b6e8;
    --primary-dark:#0f9fcd;
    --primary-soft:#ebfafe;
    --shadow:0 14px 32px rgba(31,79,122,.08);
    --radius-xl:20px;
    --radius-lg:16px;
    --radius-md:12px;
}

*{box-sizing:border-box}
html,body{height:100%}
body{
    margin:0;
    font-family:Inter,Segoe UI,Arial,sans-serif;
    background:var(--bg);
    color:var(--text);
}

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

.topbar{
    position:sticky;
    top:0;
    z-index:20;
    height:78px;
    background:#fff;
    border-bottom:1px solid var(--border);
    display:flex;
    align-items:center;
    justify-content:space-between;
    gap:20px;
    padding:0 26px;
    box-shadow:0 6px 20px rgba(32,71,108,.04);
}

.topbar__brand{
    display:flex;
    align-items:center;
    gap:14px;
}

.topbar__logo{
    width:44px;
    height:44px;
    border-radius:14px;
    display:flex;
    align-items:center;
    justify-content:center;
    font-size:20px;
    font-weight:800;
    color:#fff;
    background:linear-gradient(135deg,var(--primary),#4cd0f6);
    box-shadow:0 12px 24px rgba(25,182,232,.28);
}

.topbar__title{
    font-weight:800;
    font-size:18px;
    line-height:1.1;
}

.topbar__subtitle{
    color:var(--muted);
    font-size:12px;
    margin-top:4px;
}

.topbar__actions{
    display:flex;
    gap:10px;
    flex-wrap:wrap;
}

.page{
    max-width:1540px;
    margin:0 auto;
    padding:28px 24px 120px;
}

.hero{
    display:flex;
    justify-content:space-between;
    align-items:flex-start;
    gap:20px;
    margin-bottom:22px;
}

.hero h1{
    margin:0 0 6px;
    font-size:38px;
    line-height:1.05;
    letter-spacing:-.03em;
    color:#20384d;
}

.hero p{
    margin:0;
    color:var(--muted);
    font-size:15px;
}

.hero__chips{
    display:flex;
    gap:10px;
    flex-wrap:wrap;
}

.chip{
    background:#fff;
    border:1px solid var(--border);
    color:var(--text);
    border-radius:999px;
    padding:8px 12px;
    font-size:13px;
    font-weight:700;
}

.chip--success{
    background:#ebfaf1;
    color:#259d57;
    border-color:#c7edd7;
}

.layout-grid{
    display:grid;
    grid-template-columns:minmax(0,1fr) 330px;
    gap:20px;
    align-items:start;
}

.main-content,.side-content{
    display:flex;
    flex-direction:column;
    gap:20px;
}

.card{
    background:var(--surface);
    border:1px solid var(--border);
    border-radius:var(--radius-xl);
    box-shadow:var(--shadow);
    padding:22px;
}

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

.card__head--compact{
    margin-bottom:14px;
}

.card__head h2{
    margin:0 0 5px;
    font-size:22px;
    color:#244258;
}

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

.card__head-actions{
    display:flex;
    gap:10px;
    flex-wrap:wrap;
}

.text-link{
    text-decoration:none;
    color:var(--primary-dark);
    font-weight:700;
    white-space:nowrap;
}

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

.field{
    display:flex;
    flex-direction:column;
    gap:8px;
    min-width:0;
}

.field--span-2{grid-column:span 2}

.field label{
    font-size:13px;
    font-weight:700;
    color:#68839b;
}

input,select,textarea{
    width:100%;
    border:1px solid var(--border);
    background:#fff;
    color:var(--text);
    border-radius:14px;
    padding:13px 14px;
    outline:none;
    transition:.2s ease;
}

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

input[readonly]{
    background:var(--surface-soft);
}

input:focus,select:focus,textarea:focus{
    border-color:#8fdcf5;
    box-shadow:0 0 0 4px rgba(25,182,232,.12);
}

.inline-input{
    display:flex;
    align-items:center;
    gap:10px;
}

.inline-input > *:first-child{
    flex:1;
}

.square-btn{
    width:46px;
    height:46px;
    border:none;
    border-radius:14px;
    background:var(--primary-soft);
    color:var(--primary-dark);
    font-size:26px;
    cursor:pointer;
    border:1px solid #caeff8;
}

.search-bar{
    display:flex;
    align-items:center;
    gap:10px;
    background:#fff;
    border:1px solid var(--border);
    border-radius:16px;
    padding:0 16px;
    margin-bottom:16px;
}

.search-bar__icon{
    font-size:18px;
}

.search-bar input{
    border:none;
    box-shadow:none;
    padding-left:0;
}
.search-bar input:focus{box-shadow:none}

.table-wrap{
    border:1px solid var(--border);
    border-radius:18px;
    overflow:hidden;
    background:#fff;
}

.invoice-table{
    width:100%;
    border-collapse:collapse;
}

.invoice-table thead th{
    background:#f8fbfe;
    color:#6e879d;
    font-size:13px;
    text-align:left;
    padding:15px 16px;
    border-bottom:1px solid var(--line);
}

.empty-cell{
    padding:0;
}

.empty-state{
    text-align:center;
    padding:44px 18px;
}

.empty-state__icon{
    width:70px;
    height:70px;
    margin:0 auto 14px;
    border-radius:22px;
    background:var(--primary-soft);
    display:flex;
    align-items:center;
    justify-content:center;
    font-size:28px;
}

.empty-state h3{
    margin:0 0 8px;
    font-size:22px;
    color:#27475f;
}

.empty-state p{
    margin:0 0 18px;
    color:var(--muted);
}

.summary-list{
    display:flex;
    flex-direction:column;
    gap:12px;
}

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

.summary-row span{
    color:var(--muted);
}

.separator{
    height:1px;
    background:var(--line);
    margin:18px 0;
}

.totals-box{
    display:flex;
    flex-direction:column;
    gap:12px;
}

.totals-row{
    display:flex;
    justify-content:space-between;
    gap:10px;
    font-size:15px;
}

.totals-row--main{
    padding-top:12px;
    border-top:1px dashed var(--border);
    font-size:18px;
    font-weight:800;
    color:#20384d;
}

.action-stack{
    display:flex;
    flex-direction:column;
    gap:10px;
}

.btn{
    border:none;
    border-radius:14px;
    padding:12px 16px;
    cursor:pointer;
    font-weight:700;
    transition:.2s ease;
}

.btn:hover{
    transform:translateY(-1px);
}

.btn--full{width:100%}

.btn--primary{
    color:#fff;
    background:linear-gradient(135deg,var(--primary),#48cff6);
    box-shadow:0 10px 22px rgba(25,182,232,.20);
}

.btn--primary:hover{
    background:linear-gradient(135deg,var(--primary-dark),#34c6ef);
}

.btn--secondary{
    background:#daf4fc;
    color:#0c8bb7;
}

.btn--ghost{
    background:#fff;
    color:var(--text);
    border:1px solid var(--border);
}

.bottom-bar{
    position:fixed;
    left:22px;
    right:22px;
    bottom:18px;
    background:rgba(255,255,255,.96);
    backdrop-filter:blur(8px);
    border:1px solid var(--border);
    box-shadow:0 22px 40px rgba(28,74,115,.12);
    border-radius:20px;
    padding:16px 18px;
    display:flex;
    justify-content:space-between;
    align-items:center;
    gap:18px;
    z-index:25;
}

.bottom-bar__totals{
    display:flex;
    gap:12px;
    flex-wrap:wrap;
}

.bottom-total{
    min-width:135px;
    background:#f8fbfe;
    border:1px solid var(--border);
    border-radius:14px;
    padding:10px 14px;
}

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

.bottom-total strong{
    font-size:20px;
}

.bottom-total--main{
    background:var(--primary-soft);
    border-color:#c7edf8;
}

.bottom-bar__actions{
    display:flex;
    gap:10px;
    flex-wrap:wrap;
}

.modal{
    position:fixed;
    inset:0;
    display:none;
    z-index:40;
}

.modal.is-open{
    display:block;
}

.modal__overlay{
    position:absolute;
    inset:0;
    background:rgba(31,49,68,.48);
}

.modal__window{
    position:relative;
    width:min(1180px, calc(100% - 30px));
    max-height:calc(100vh - 36px);
    overflow:auto;
    margin:18px auto;
    background:#fff;
    border-radius:24px;
    box-shadow:0 30px 80px rgba(26,58,93,.28);
}

.modal__header,
.modal__footer{
    padding:22px 24px;
    display:flex;
    justify-content:space-between;
    align-items:flex-start;
    gap:16px;
}

.modal__header{
    border-bottom:1px solid var(--line);
}

.modal__footer{
    border-top:1px solid var(--line);
    justify-content:flex-end;
    align-items:center;
}

.modal__header h2{
    margin:0 0 6px;
    font-size:30px;
}

.modal__header p{
    margin:0;
    color:var(--muted);
}

.modal__body{
    padding:24px;
}

.modal__close{
    width:44px;
    height:44px;
    border:none;
    border-radius:14px;
    background:#f5f9fc;
    color:#72889d;
    font-size:30px;
    cursor:pointer;
}

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

.subcard{
    background:var(--surface-soft);
    border:1px solid var(--border);
    border-radius:18px;
    padding:18px;
}

.subcard--full{
    grid-column:1 / -1;
}

.subcard__head{
    margin-bottom:16px;
}

.subcard__head h3{
    margin:0;
    font-size:18px;
    color:#26445a;
}

@media (max-width: 1180px){
    .layout-grid{
        grid-template-columns:1fr;
    }
    .side-content{
        order:-1;
    }
}

@media (max-width: 900px){
    .topbar,
    .hero,
    .card__head,
    .bottom-bar{
        flex-direction:column;
        align-items:stretch;
    }

    .form-grid--2,
    .form-grid--3,
    .modal-grid{
        grid-template-columns:1fr;
    }

    .field--span-2,
    .subcard--full{
        grid-column:auto;
    }

    .page{
        padding:18px 14px 150px;
    }

    .topbar{
        height:auto;
        padding:14px;
    }

    .bottom-bar{
        left:12px;
        right:12px;
        bottom:12px;
    }

    .topbar__actions,
    .card__head-actions,
    .bottom-bar__actions,
    .inline-input{
        flex-direction:column;
    }

    .btn,.square-btn{
        width:100%;
    }
}
