:root{
    --bg:#0b1020;
    --panel:#131b31;
    --panel-2:#19233d;
    --text:#eef2ff;
    --muted:#9aa8c7;
    --line:rgba(255,255,255,.08);
    --accent:#7c9cff;
    --accent-2:#44d2b8;
    --danger:#ff6b6b;
    --radius:20px;
    --shadow:0 18px 50px rgba(0,0,0,.28);
}

*{box-sizing:border-box}
html,body{margin:0;padding:0;font-family:Inter,system-ui,sans-serif;background:linear-gradient(180deg,#09101d,#0d1427);color:var(--text)}
a{text-decoration:none;color:inherit}
button,input,textarea{font:inherit}

.app-shell{display:grid;grid-template-columns:280px 1fr;min-height:100vh}
.sidebar{background:rgba(12,18,34,.82);backdrop-filter:blur(18px);border-right:1px solid var(--line);padding:22px;display:flex;flex-direction:column;gap:22px}
.brand{display:flex;gap:14px;align-items:center}
.brand-mark{width:48px;height:48px;border-radius:16px;display:grid;place-items:center;background:linear-gradient(135deg,var(--accent),var(--accent-2));font-size:24px;color:#08111f}
.brand-title{font-weight:800;font-size:20px}
.brand-sub{font-size:13px;color:var(--muted)}
.nav{display:flex;flex-direction:column;gap:8px}
.nav-link{padding:12px 14px;border-radius:14px;color:var(--muted);display:flex;gap:10px;align-items:center}
.nav-link:hover,.nav-link.is-active{background:rgba(124,156,255,.14);color:var(--text)}
.sidebar-actions{margin-top:auto;display:grid;gap:10px}

.main{padding:26px}
.topbar{display:flex;justify-content:space-between;align-items:flex-start;margin-bottom:20px}
.topbar h1{margin:0;font-size:30px}
.topbar-sub{margin-top:6px;color:var(--muted)}

.btn{border:none;border-radius:14px;padding:12px 14px;cursor:pointer}
.btn-ghost{background:var(--panel);color:var(--text);border:1px solid var(--line)}
.btn-primary{background:linear-gradient(135deg,var(--accent),var(--accent-2));color:#07111e;font-weight:800}
.btn-danger{background:var(--danger);color:white}

.page-grid{
    display:grid;
    grid-template-columns:repeat(12,minmax(0,1fr));
    gap:16px;
}

.tile{
    grid-column:span 6;
    background:linear-gradient(180deg,rgba(24,33,60,.95),rgba(17,24,44,.95));
    border:1px solid var(--line);
    border-radius:var(--radius);
    box-shadow:var(--shadow);
    padding:18px;
    position:relative;
}

.tile.full{grid-column:1 / -1}
.tile.small{grid-column:span 4}
.tile-header{display:flex;justify-content:space-between;align-items:center;margin-bottom:14px}
.tile-title{font-size:18px;font-weight:800}
.tile-sub{font-size:13px;color:var(--muted)}
.tile.dragging{opacity:.7}
.tile.sort-mode{outline:2px dashed rgba(124,156,255,.5);cursor:grab}

.counter-value{font-size:40px;font-weight:900;line-height:1}
.counter-sub{margin-top:8px;color:var(--muted)}

.form-stack{display:grid;gap:12px}
.field{display:grid;gap:8px}
.field label{font-size:13px;color:var(--muted)}
.field input,.field textarea,.field select{
    width:100%;
    border:1px solid var(--line);
    background:var(--panel-2);
    color:var(--text);
    border-radius:14px;
    padding:12px 14px;
}
.field textarea{min-height:140px;resize:vertical}

.doc-list{display:grid;gap:10px}
.doc-item{
    border:1px solid var(--line);
    background:rgba(255,255,255,.03);
    border-radius:16px;
    padding:14px;
    cursor:pointer;
}
.doc-item:hover{background:rgba(255,255,255,.05)}
.doc-top{display:flex;justify-content:space-between;gap:10px}
.doc-vendor{font-weight:700}
.doc-meta{font-size:13px;color:var(--muted)}

.empty-state{
    padding:18px;
    border:1px dashed var(--line);
    border-radius:16px;
    color:var(--muted);
    text-align:center;
}

.badge{
    display:inline-flex;
    padding:6px 10px;
    border-radius:999px;
    font-size:12px;
    font-weight:700;
    background:rgba(68,210,184,.14);
    color:#98f1df;
}

.bottom-sheet{position:fixed;inset:0;display:none;z-index:60}
.bottom-sheet.is-open{display:block}
.bottom-sheet-backdrop{position:absolute;inset:0;background:rgba(0,0,0,.45)}
.bottom-sheet-panel{
    position:absolute;
    left:0;right:0;bottom:0;
    background:#121a31;
    border-top-left-radius:22px;
    border-top-right-radius:22px;
    min-height:45vh;
    max-height:85vh;
    overflow:auto;
    padding:14px 16px 28px;
}
.sheet-handle{
    width:56px;height:6px;border-radius:999px;background:rgba(255,255,255,.18);
    margin:4px auto 16px;
}
.sheet-content{max-width:960px;margin:0 auto}
.items-table{width:100%;border-collapse:collapse}
.items-table th,.items-table td{padding:10px;border-bottom:1px solid var(--line);text-align:left;font-size:14px}
.sheet-head{display:grid;gap:6px;margin-bottom:18px}
.sheet-title{font-size:22px;font-weight:900}
.order-mode-on .tile{user-select:none}

@media (max-width: 980px){
    .app-shell{grid-template-columns:1fr}
    .sidebar{border-right:none;border-bottom:1px solid var(--line)}
    .page-grid{grid-template-columns:1fr}
    .tile,.tile.small,.tile.full{grid-column:1/-1}
    .main{padding:14px}
    .topbar h1{font-size:24px}
}