:root{
    --red:#ff4d4d;
    --red-dark:#e94141;
    --blue:#6ec6ff;
    --blue-dark:#279fe6;
    --gray:#e5e5e5;
    --dark:#1f1f1f;
    --white:#ffffff;
    --bg:#f5f5f5;
    --muted:#666666;
    --green:#17a34a;
    --yellow:#ffeb3b;
    --shadow:0 10px 22px rgba(31,31,31,.11),0 3px 8px rgba(31,31,31,.07);
    --shadow-strong:0 18px 34px rgba(31,31,31,.17),0 7px 14px rgba(31,31,31,.10);
}

#spis{
    background-color: lightcoral;
}

*{box-sizing:border-box}
html{scroll-behavior:smooth}
body{
    margin:0;
    padding:20px;
    min-height:100vh;
    font-family:"Segoe UI",Arial,sans-serif;
    background:
        radial-gradient(circle at top left,rgba(110,198,255,.24),transparent 260px),
        linear-gradient(180deg,#f7fbff 0,var(--bg) 320px,var(--bg) 100%);
    color:var(--dark);
}

a{color:inherit}
img{max-width:100%}
button,input,select,textarea{font:inherit}

.page{
    max-width:1100px;
    margin:auto;
}


.topbar,.header,.hero,.panel,.filters,.summary-box,.card,.offer-card,.form-panel,.selected-book,.admin-card,.empty-state{
    background:var(--white);
    border-radius:14px;
    box-shadow:var(--shadow);
    border:1px solid rgba(0,0,0,.04);
}

.topbar{
    display:flex;
    justify-content:space-between;
    align-items:center;
    gap:12px;
    flex-wrap:wrap;
    margin-bottom:24px;
    padding:14px 16px;
    transform:translateZ(0);
}

.brand{
    color:var(--dark);
    font-size:22px;
    font-weight:900;
    text-decoration:none;
}

.nav,.actions,.tabs,.admin-actions,.top-links{
    display:flex;
    gap:8px;
    flex-wrap:wrap;
    align-items:center;
}

.nav a,.top-links a,.btn,.ghost-btn,.danger-btn,.tab{
    display:inline-flex;
    align-items:center;
    justify-content:center;
    min-height:40px;
    padding:9px 13px;
    border:2px solid var(--gray);
    border-radius:10px;
    background:var(--white);
    color:var(--dark);
    font-weight:900;
    text-decoration:none;
    cursor:pointer;
    transition:.2s;
}

.nav a:hover,.top-links a:hover,.ghost-btn:hover,.tab:hover{
    border-color:var(--red);
    color:var(--red);
}

.nav a:active,.btn:active,.ghost-btn:active,.danger-btn:active,.tab:active{
    transform:translateY(1px);
}

.btn.primary,.tab.active{
    border-color:var(--red);
    background:var(--red);
    color:var(--white);
}

.btn.primary:hover,.tab.active:hover{
    background:var(--red-dark);
}

.btn.success{
    border-color:var(--green);
    background:var(--green);
    color:var(--white);
}

.danger-btn{
    border-color:var(--red);
    color:var(--red);
}

.danger-btn:hover{
    background:var(--red);
    color:var(--white);
}

.hero,.panel{
    margin-bottom:20px;
    padding:24px;
    position:relative;
    overflow:hidden;
}

.auth-page{
    min-height:calc(100vh - 40px);
    display:grid;
    place-items:center;
}

.auth-panel{
    width:min(100%,430px);
}

.auth-panel .brand{
    display:inline-block;
    margin-bottom:16px;
}

.auth-form{
    margin-top:16px;
}

.hero::after,.panel::after{
    content:"";
    position:absolute;
    inset:auto 18px 0 18px;
    height:7px;
    border-radius:999px 999px 0 0;
    background:linear-gradient(90deg,var(--red),var(--blue));
    opacity:.9;
}

.hero h1,.panel h1{
    margin:0 0 12px;
    font-size:38px;
    line-height:1.08;
}

.hero h2,.panel h2{
    margin:0 0 10px;
    font-size:26px;
}

.hero p,.muted,.meta{
    color:var(--muted);
}

.filters{
    display:grid;
    grid-template-columns:1fr;
    gap:12px;
    margin-bottom:15px;
    padding:15px;
}

.filter label,.field label,.field > span,.filter-title{
    display:block;
    margin-bottom:6px;
    color:var(--dark);
    font-size:13px;
    font-weight:900;
}

select,input,textarea{
    width:100%;
    min-height:44px;
    padding:11px;
    border:2px solid var(--blue);
    border-radius:10px;
    background:var(--white);
    color:var(--dark);
}

select:focus,input:focus,textarea:focus{
    outline:none;
    border-color:var(--red);
    box-shadow:0 0 0 4px rgba(255,77,77,.16);
}

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

.direction-picker{
    display:grid;
    gap:12px;
    margin:20px 0;
}

.big-select{
    font-size:18px;
    font-weight:800;
    min-height:56px;
}

.class-btns,.condition-row,.week-row{
    display:flex;
    gap:8px;
    flex-wrap:wrap;
    justify-content:center;
}

.c-btn,.choice{
    min-width:52px;
    min-height:52px;
    display:inline-flex;
    align-items:center;
    justify-content:center;
    border:2px solid var(--gray);
    border-radius:10px;
    background:var(--white);
    color:var(--dark);
    font-weight:900;
    cursor:pointer;
    transition:.2s;
}

.c-btn:hover,.choice:hover{
    border-color:var(--red);
    color:var(--red);
}

.c-btn.active,.choice:has(input:checked){
    border-color:var(--red);
    background:var(--red);
    color:var(--white);
    box-shadow:0 0 10px rgba(255,77,77,.4);
}

.hint-btn{
    width:auto;
    min-width:220px;
    padding:0 16px;
    color:var(--muted);
    cursor:not-allowed;
}

.choice input{display:none}

.start-cta{
    width:100%;
    min-height:56px;
    margin-top:8px;
    font-size:18px;
}

.start-cta:disabled{
    opacity:.45;
    cursor:not-allowed;
}

.summary-row{
    display:grid;
    grid-template-columns:repeat(2,1fr);
    gap:10px;
    margin-bottom:15px;
}

.summary-box{
    padding:14px;
    transform:translateY(0);
    transition:.2s;
}

.summary-box:hover{
    transform:translateY(-3px);
    box-shadow:var(--shadow-strong);
}

.summary-value{
    display:block;
    color:var(--red);
    font-size:26px;
    line-height:1;
    font-weight:900;
}

.grid{
    display:grid;
    grid-template-columns:repeat(auto-fill,minmax(170px,1fr));
    gap:20px;
}

.card{
    position:relative;
    display:block;
    padding:15px;
    color:inherit;
    text-align:center;
    text-decoration:none;
    cursor:pointer;
    transition:.2s;
    transform-style:preserve-3d;
}

.card:hover{
    transform:translateY(-6px) rotateX(1deg);
    box-shadow:var(--shadow-strong);
}

.card img,.selected-book img{
    width:100%;
    height:190px;
    object-fit:contain;
    border-radius:10px;
    background:#fafafa;
}

.card-title{
    margin:10px 0 6px;
    color:var(--dark);
    font-size:15px;
    line-height:1.25;
    font-weight:900;
}

.price-pill,.big-price{
    color:var(--red);
    font-weight:900;
}

.price-pill{
    display:inline-flex;
    margin-top:8px;
    padding:7px 12px;
    border-radius:8px;
    background:var(--yellow);
    color:#000;
    box-shadow:0 3px 10px rgba(0,0,0,.18);
    transform:rotate(-3deg);
}

.big-price{
    font-size:28px;
}

.count-pill,.status-pill{
    display:inline-flex;
    width:max-content;
    max-width:100%;
    padding:5px 10px;
    border-radius:6px;
    background:var(--dark);
    color:var(--white);
    font-size:12px;
    font-weight:900;
}

.status-pill.wait{background:#f59e0b}
.status-pill.ok{background:var(--green)}
.status-pill.bad,.status-pill.expired{background:var(--red)}

.offer-footer{
    display:flex;
    gap:8px;
    align-items:center;
    justify-content:space-between;
    flex-wrap:wrap;
    margin-top:8px;
}

.empty-state{
    padding:22px;
    color:var(--muted);
    text-align:center;
    font-weight:900;
}

.modal{
    position:fixed;
    inset:0;
    z-index:50;
    display:none;
    justify-content:center;
    align-items:center;
    padding:20px;
    background:rgba(0,0,0,.7);
}

.modal.open{display:flex}

.modal-content{
    width:100%;
    max-width:1000px;
    max-height:90vh;
    overflow-y:auto;
    padding:25px;
    border-radius:18px;
    background:var(--white);
}

.modal-head{
    display:flex;
    justify-content:space-between;
    gap:12px;
    align-items:flex-start;
    margin-bottom:15px;
}

.close-btn{
    width:42px;
    height:42px;
    border:0;
    border-radius:10px;
    background:var(--gray);
    font-size:28px;
    cursor:pointer;
}

.offer-list,.admin-list{
    display:grid;
    gap:15px;
}

.offer-card,.admin-card{
    display:grid;
    grid-template-columns:100px 1fr;
    gap:14px;
    align-items:center;
    padding:14px;
    border:2px solid var(--gray);
    box-shadow:0 8px 18px rgba(0,0,0,.08);
    background:linear-gradient(180deg,#fff,#fbfbfb);
}

.offer-card:hover,.admin-card:hover{
    border-color:var(--red);
    transform:translateY(-2px);
    box-shadow:var(--shadow-strong);
}

.offer-card.is-expired{
    display:none;
}

.offer-card img,.admin-photo{
    width:100px;
    height:130px;
    object-fit:cover;
    border-radius:10px;
    background:#fafafa;
    box-shadow:0 5px 12px rgba(0,0,0,.08);
}

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

.photo-compare span{
    display:block;
    margin-bottom:5px;
    color:var(--muted);
    font-size:12px;
    font-weight:900;
    text-align:center;
}

.photo-compare .admin-photo{
    width:100%;
    height:145px;
    object-fit:contain;
    box-shadow:0 6px 13px rgba(0,0,0,.14);
}

.offer-main h3,.admin-main h3{
    margin:0 0 6px;
    font-size:18px;
    line-height:1.18;
}

.offer-topline{
    margin:3px 0;
    color:var(--dark);
    font-weight:900;
}

.inline-form{
    margin-top:8px;
}

.extend-form{
    display:flex;
    align-items:center;
    gap:8px;
    flex-wrap:nowrap;
    width:max-content;
    max-width:100%;
}

.owner-actions{
    display:grid;
    gap:8px;
    align-content:start;
    justify-items:stretch;
    justify-self:end;
    width:220px;
    max-width:100%;
}

.owner-actions .big-price{
    margin-bottom:2px;
    text-align:right;
}

.owner-actions .btn,
.owner-actions .danger-btn{
    width:100%;
}

.owner-actions .inline-form{
    width:100%;
    margin-top:0;
}

.owner-actions .extend-form{
    display:grid;
    grid-template-columns:74px minmax(0,1fr);
    gap:0;
    width:100%;
    overflow:hidden;
    border:2px solid var(--green);
    border-radius:12px;
    background:var(--white);
    box-shadow:0 6px 14px rgba(23,163,74,.16);
}

.mini-input{
    flex:0 0 74px;
    width:74px;
    min-height:40px;
    border:2px solid var(--line);
    border-radius:10px;
    padding:8px;
    font-weight:900;
    text-align:center;
}

.owner-actions .extend-form .mini-input{
    width:100%;
    min-height:44px;
    border:0;
    border-radius:0;
    box-shadow:none;
}

.owner-actions .extend-form .btn{
    min-height:44px;
    border:0;
    border-radius:0;
}

.limit-note{
    margin-top:8px;
    font-weight:900;
}

.days-badge{
    display:inline-flex;
    align-items:center;
    justify-content:center;
    width:max-content;
    margin-top:8px;
    padding:7px 10px;
    border-radius:999px;
    background:#f2f2f2;
    color:var(--dark);
    font-weight:900;
}

.days-badge.warning{
    background:#ffb020;
    color:#241300;
    box-shadow:0 6px 12px rgba(255,176,32,.28);
}

.pager{
    display:flex;
    align-items:center;
    justify-content:center;
    gap:12px;
    margin:20px 0;
}

.pager-info{
    min-width:70px;
    text-align:center;
    font-weight:900;
}

.pager-btn{
    min-width:52px;
    font-size:22px;
    line-height:1;
}

.pager-btn:disabled{
    opacity:.45;
    cursor:not-allowed;
}

.flow-layout{
    display:grid;
    grid-template-columns:1fr;
    gap:20px;
}

.selected-book,.form-panel{
    padding:18px;
}

.extend-panel{
    margin-top:20px;
}

.how-grid{
    display:grid;
    grid-template-columns:1fr;
    gap:12px;
    margin-top:12px;
}

.how-card{
    padding:16px;
    border:2px solid var(--gray);
    border-radius:14px;
    background:#fff;
    box-shadow:0 8px 18px rgba(0,0,0,.08);
}

.how-card strong,.how-card span{
    display:block;
}

.how-card strong{
    margin-bottom:5px;
    font-size:17px;
}

.how-card span{
    color:var(--muted);
}

.how-link{
    display:block;
    color:inherit;
    text-decoration:none;
}

.print-toolbar{
    display:flex;
    justify-content:space-between;
    align-items:center;
    gap:12px;
    margin-bottom:14px;
    padding:14px 16px;
    border-radius:16px;
    background:var(--white);
    box-shadow:var(--shadow);
}

.print-toolbar strong,
.print-toolbar span{
    display:block;
}

.print-sheet{
    padding:22px;
    border-radius:16px;
    background:var(--white);
    box-shadow:var(--shadow-strong);
}

.print-head{
    display:flex;
    justify-content:space-between;
    gap:20px;
    align-items:flex-start;
    margin-bottom:16px;
    padding-bottom:12px;
    border-bottom:3px solid var(--dark);
}

.print-head h1{
    margin:0 0 4px;
    font-size:28px;
}

.print-head p{
    margin:0;
    color:var(--muted);
    font-weight:900;
}

.print-meta{
    display:grid;
    gap:3px;
    text-align:right;
}

.print-meta span{
    color:var(--muted);
    font-weight:800;
}

.table-wrap{
    width:100%;
    overflow-x:auto;
}

.print-table{
    width:100%;
    border-collapse:collapse;
    background:var(--white);
    font-size:13px;
}

.print-table th,
.print-table td{
    padding:8px 9px;
    border:1px solid #c9c9c9;
    text-align:left;
    vertical-align:top;
}

.print-table th{
    background:#f0f4f8;
    color:#111;
    font-weight:900;
}

.print-table tbody tr:nth-child(even){
    background:#fafafa;
}

.print-table td:first-child,
.print-table th:first-child{
    width:44px;
    text-align:center;
}

.print-cover{
    width:42px;
    height:58px;
    display:block;
    object-fit:contain;
    border-radius:6px;
    background:#f6f6f6;
}

.table-empty{
    padding:18px;
    color:var(--muted);
    text-align:center !important;
    font-weight:900;
}

.field{
    margin-bottom:14px;
}

.notice,.reject{
    margin:0 0 15px;
    padding:12px 14px;
    border-radius:12px;
    font-weight:900;
}

.notice{
    border:1px solid #b7e3c5;
    background:#e9f8ef;
    color:#137333;
}

.reject{
    border:1px solid #fecaca;
    background:#fee2e2;
    color:#991b1b;
}

.to-top{
    position:fixed;
    right:16px;
    bottom:16px;
    z-index:60;
    width:52px;
    height:52px;
    display:grid;
    place-items:center;
    border-radius:50%;
    background:var(--red);
    color:var(--white);
    box-shadow:0 0 16px rgba(255,77,77,.45);
    font-size:28px;
    font-weight:900;
    text-decoration:none;
}

@media(min-width:720px){
    .page{padding:0}
    .filters{grid-template-columns:1fr 170px auto;align-items:end}
    .direction-picker{grid-template-columns:1.4fr 1fr}
    .summary-row{grid-template-columns:repeat(4,1fr)}
    .flow-layout{grid-template-columns:320px 1fr}
    .offer-card{grid-template-columns:120px 1fr auto}
    .admin-card{grid-template-columns:250px 1fr auto}
    .offer-card img,.admin-photo{width:120px;height:155px}
    .photo-compare .admin-photo{height:165px}
    .how-grid{grid-template-columns:repeat(3,1fr)}
}

@media(max-width:700px){
    body{padding:10px}
    .page{max-width:520px}
    .hero h1,.panel h1{font-size:30px}
    .topbar{
        display:grid;
        grid-template-columns:1fr;
        align-items:start;
        padding:12px;
        margin-bottom:16px;
    }
    .brand{
        width:100%;
        text-align:center;
        font-size:21px;
    }
    .nav{
        width:100%;
        display:grid;
        grid-template-columns:repeat(2,minmax(0,1fr));
        gap:8px;
    }
    .nav a,.btn,.ghost-btn,.danger-btn,.tab{
        min-height:42px;
        padding:8px 10px;
        text-align:center;
    }
    .actions,.tabs,.admin-actions{gap:8px}
    .actions .btn,.actions .ghost-btn,.tabs .tab,.admin-actions .btn,.admin-actions .danger-btn{flex:1 1 auto}
    .extend-form .btn{flex:0 0 auto}
    .extend-form .mini-input{flex:0 0 72px}
    .owner-actions{
        width:100%;
        justify-self:stretch;
    }
    .owner-actions .big-price{text-align:left}
    .owner-actions .extend-form{grid-template-columns:76px minmax(0,1fr)}
    .grid{grid-template-columns:repeat(2,minmax(0,1fr));gap:12px}
    .card{padding:10px}
    .card img{height:145px}
    .offer-card{
        grid-template-columns:88px 1fr;
        gap:12px;
        padding:12px;
    }
    .offer-card img,.admin-photo{width:88px;height:116px}
    .admin-card{
        grid-template-columns:88px 1fr;
        gap:12px;
        padding:12px;
    }
    .admin-card > div:last-child{
        grid-column:1 / -1;
        display:grid;
        grid-template-columns:1fr;
        gap:8px;
    }
    .photo-compare .admin-photo{height:155px}
    .big-price{font-size:22px}
    .summary-row{grid-template-columns:1fr 1fr}
    .hero,.panel,.filters,.form-panel,.selected-book{padding:16px}
    .print-toolbar,.print-head{display:grid;text-align:left}
    .print-meta{text-align:left}
    .print-table{font-size:12px}
    .print-cover{width:38px;height:52px}
}

@media print{
    @page{
        size:A4 landscape;
        margin:10mm;
    }

    *{
        box-shadow:none !important;
        text-shadow:none !important;
    }

    html,
    body{
        width:auto;
        min-height:auto;
        margin:0;
        padding:0;
        background:#fff !important;
        color:#000;
    }

    .no-print,
    .topbar,
    .hero,
    .filters,
    .print-toolbar,
    .to-top{
        display:none !important;
    }

    .page{
        max-width:none;
        margin:0;
    }

    .print-sheet{
        padding:0;
        border:0;
        border-radius:0;
        background:#fff;
    }

    .print-head{
        margin-bottom:8mm;
        border-bottom:2px solid #000;
    }

    .print-head h1{
        font-size:18pt;
    }

    .print-head p,
    .print-meta span{
        color:#000;
    }

    .table-wrap{
        overflow:visible;
    }

    .print-table{
        font-size:9pt;
    }

    .print-table th,
    .print-table td{
        padding:4px 5px;
        border:1px solid #333;
    }

    .print-cover{
        width:34px;
        height:48px;
    }

    .print-table th{
        background:#eee !important;
        -webkit-print-color-adjust:exact;
        print-color-adjust:exact;
    }

    .print-table tr{
        break-inside:avoid;
        page-break-inside:avoid;
    }
}
