:root{--nav:#101d32;--nav2:#1c2c47;--blue:#2563eb;--blue-dark:#1d4ed8;--green:#16855b;--ink:#172033;--muted:#6b7280;--line:#e5e9f0;--bg:#f5f7fb;--danger:#c33131;--warning:#9a6810}
*{box-sizing:border-box}
html{scroll-behavior:smooth}
body{margin:0;font:14px Inter,Segoe UI,Arial,sans-serif;color:var(--ink);background:var(--bg)}
button,input,select,textarea{font:inherit}
button{touch-action:manipulation}
aside{position:fixed;inset:0 auto 0 0;width:248px;background:var(--nav);color:#fff;padding:24px 18px;display:flex;flex-direction:column;z-index:20}
.brand{display:flex;align-items:center;gap:13px;padding:0 8px 28px}
.brand img{width:64px;height:64px;object-fit:contain;background:#fff;border-radius:13px;padding:2px}
.brand b{font-size:23px;display:block}
.brand small,aside footer small{display:block;color:#9eabc0;margin-top:2px}
nav{display:grid;gap:7px}
nav button{border:0;color:#b7c1d1;background:none;text-align:left;border-radius:10px;padding:11px 13px;font-weight:650;cursor:pointer;font-size:15px;display:flex;align-items:center;gap:12px;white-space:nowrap}
nav button:hover,nav button.active{background:var(--nav2);color:#fff}
.nav-icon{width:36px;height:36px;display:inline-grid;place-items:center;border-radius:10px;background:#ffffff0b;line-height:1;flex:0 0 36px}
.nav-icon svg{width:21px;height:21px;fill:none;stroke:currentColor;stroke-width:1.8;stroke-linecap:round;stroke-linejoin:round}
nav button.active .nav-icon{background:linear-gradient(145deg,#3b78f2,#2457c5);color:#fff;box-shadow:0 5px 14px #0d173655}
aside footer{margin-top:auto;color:#dbeafe;padding:12px;display:grid;gap:10px}
aside footer i{display:inline-block;width:8px;height:8px;background:#35c786;border-radius:50%;margin-left:5px}
.logout{display:flex;align-items:center;justify-content:center;gap:8px;width:100%;border:1px solid #ffffff24;background:#ffffff0a;color:#dbeafe;border-radius:9px;padding:10px 12px;cursor:pointer;font-weight:700}
.logout span{font-size:20px;line-height:1}
.logout:hover{color:#fff;background:#c3313126;border-color:#ef777755}
.connection{font-size:12px}
.copyright{border-top:1px solid #ffffff16;padding-top:10px;line-height:1.45}

main{margin-left:248px;min-height:100vh;padding:32px 40px}
.main-header{display:flex;align-items:center;justify-content:space-between;margin-bottom:28px}
h1{font-size:26px;margin:0 0 5px}
h2{font-size:17px;margin:0 0 5px}
p{color:var(--muted);margin:0}
.primary,.success,.secondary{border:0;border-radius:9px;padding:11px 16px;font-weight:700;cursor:pointer}
.primary{background:var(--blue);color:#fff}
.primary:hover{background:var(--blue-dark)}
.success{background:var(--green);color:#fff}
.success:hover{background:#106e4a}
.secondary{background:#e9eef6;color:#34425a;border:1px solid #d9e0eb}
.page{display:none}
.page.active{display:block}
.cards{display:grid;grid-template-columns:repeat(5,1fr);gap:16px;margin-bottom:20px}
.cards article,.panel{background:#fff;border:1px solid var(--line);border-radius:13px;box-shadow:0 1px 2px #17203308}
.cards article{padding:19px}
.cards span{color:var(--muted);font-weight:650}
.cards strong{display:block;font-size:27px;margin:12px 0 7px}
.cards small{color:#8a94a5}
.panel{padding:22px}
.panelhead{display:flex;justify-content:space-between;align-items:center;gap:15px;margin-bottom:20px}
.link{border:0;background:none;color:var(--blue);font-weight:700;cursor:pointer;padding:8px}
.toolbar{display:flex;gap:10px;margin-bottom:16px;align-items:end}
.toolbar label{min-width:190px}
.toolbar label:first-child{flex:1}
.filterbar select{min-width:240px}
select,input,textarea{width:100%;border:1px solid #d8dee8;border-radius:8px;padding:10px 11px;background:#fff;color:var(--ink)}
select:focus,input:focus,textarea:focus{outline:3px solid #2563eb1f;border-color:#5c88eb}
table{width:100%;border-collapse:collapse}
th{text-align:left;padding:11px 10px;color:#7b8493;font-size:12px;text-transform:uppercase;letter-spacing:.04em;border-bottom:1px solid var(--line)}
td{padding:14px 10px;border-bottom:1px solid #edf0f4;vertical-align:middle}
tr:last-child td{border-bottom:0}
.money{font-weight:750;white-space:nowrap}
.badge{display:inline-block;padding:5px 9px;border-radius:20px;background:#fff5d9;color:#9a6810;font-size:12px}
.badge.closed{background:#e7f8f0;color:#14734d}
.table-actions{display:flex;align-items:center;gap:5px;flex-wrap:wrap}
.danger-button,.warning-button{border:0;border-radius:7px;padding:8px 10px;font-weight:650;cursor:pointer}
.danger-button{background:#feecec;color:var(--danger)}
.warning-button{background:#fff4d8;color:var(--warning)}
.view-button{background:#eaf1ff;border-radius:7px}
.empty{text-align:center;padding:42px;color:var(--muted)}
.empty.compact{padding:20px}
.split{display:grid;grid-template-columns:370px minmax(0,1fr);gap:20px}
.form{height:max-content;display:grid;gap:17px}
.form>div:first-child{margin-bottom:4px}
label{display:grid;gap:7px;font-size:13px;font-weight:650}
.row{display:grid;grid-template-columns:1fr 1fr;gap:12px}
.client-name-row{grid-template-columns:3fr 1fr}
.form small,label small,#priceRuleHint{color:var(--muted);font-weight:400;line-height:1.35}
input[readonly]{background:#f3f5f8;color:#4b5563}
.address-search{position:relative}
.address-suggestions{position:absolute;z-index:30;left:0;right:0;top:68px;display:none;max-height:230px;overflow-y:auto;background:#fff;border:1px solid #cfd7e4;border-radius:10px;box-shadow:0 14px 34px #17203324}
.address-suggestions.open{display:block}
.address-suggestion{display:block;width:100%;padding:11px 13px;border:0;border-bottom:1px solid #edf0f4;background:#fff;text-align:left;color:var(--ink);cursor:pointer}
.address-suggestion:last-child{border-bottom:0}
.address-suggestion:hover,.address-suggestion:focus{background:#eef4ff;outline:0}
.address-suggestion b{display:block;font-size:13px}
.address-suggestion small{display:block;margin-top:3px}
.address-confirmed{color:#14734d!important;font-weight:650!important}
.address-warning{color:#a56408!important}
.pending-panel{margin-bottom:20px}
.pending-grid{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:12px}
.pending-grid article{border:1px solid var(--line);border-radius:11px;padding:15px;display:grid;grid-template-columns:1fr auto;gap:8px 14px;align-items:center;background:#fbfcff}
.pending-grid article div{display:grid;gap:4px}
.pending-grid article small{color:var(--muted)}
.pending-grid article .link{grid-column:1/-1;text-align:left;padding-left:0}
.pager{display:flex;align-items:center;justify-content:center;gap:14px;padding-top:17px}
.pager button{border:1px solid var(--line);background:#fff;border-radius:8px;padding:8px 12px;color:var(--blue);font-weight:650;cursor:pointer}
.pager button:disabled{opacity:.4;cursor:default}
.pager span{color:var(--muted);font-size:13px}

dialog{border:0;border-radius:14px;padding:0;width:min(590px,calc(100% - 30px));box-shadow:0 22px 70px #17203345}
dialog::backdrop{background:#10182899}
dialog form{padding:24px;display:grid;gap:16px;max-height:92vh;overflow-y:auto}
.modalhead{display:flex;justify-content:space-between;align-items:start;gap:12px;margin-bottom:4px}
.close{border:0;background:none;font-size:29px;color:#687386;cursor:pointer;line-height:1}
.actions{display:flex;justify-content:flex-end;gap:10px;margin-top:5px}
.actions button{border:1px solid var(--line);background:#fff;border-radius:8px;padding:10px 16px;cursor:pointer}
.actions .primary{background:var(--blue);color:#fff;border-color:var(--blue)}
.actions .success{background:var(--green);color:#fff;border-color:var(--green)}
#toast{position:fixed;right:25px;bottom:25px;z-index:1000;background:#172033;color:#fff;border-radius:9px;padding:13px 18px;opacity:0;transform:translateY(10px);transition:.2s;pointer-events:none;max-width:min(430px,calc(100% - 30px))}
#toast.show{opacity:1;transform:none}

.authgate{position:fixed;inset:0;z-index:100;background:#f5f7fb;display:grid;place-items:center;padding:20px}
.authgate.hidden{display:none}
.authbox{width:min(410px,100%);background:#fff;padding:34px;border:1px solid var(--line);border-radius:15px;box-shadow:0 18px 55px #17203318;display:grid;gap:17px}
.authbox img{width:128px;height:128px;object-fit:contain;margin:auto}
.authbox h1,.authbox p{text-align:center}
.authbox small{color:#c33131;text-align:center;min-height:18px}

.report-dialog{width:min(1000px,calc(100% - 24px));max-width:none;background:#e9edf3;padding:18px}
.report-dialog[open]{display:flex;flex-direction:column}
.report-dialog[open]>#reportSheet,.report-dialog[open]>#clientReportSheet{margin:0 auto}
.report-actions{display:flex;justify-content:flex-end;gap:10px;margin-bottom:14px}
.report-actions button{padding:10px 16px;border:1px solid #d7dce4;border-radius:7px;background:#fff;cursor:pointer}
.report-actions .primary{background:var(--blue);color:#fff}
#reportSheet,#clientReportSheet{width:210mm;min-height:297mm;margin:auto;background:#fff;color:#111;padding:14mm 10mm;font:12px Arial,sans-serif}
.report-header{display:flex;justify-content:space-between;align-items:flex-start;margin:0 0 27px}
.report-header h1{color:#0794d2;font-size:22px;line-height:1.08;margin:0 0 15px}
.report-header p{color:#111;margin:4px 0}
.report-header img{width:150px;height:105px;object-fit:contain}
.report-dialog #reportSheet>h2{font-size:14px;margin:0 0 8px}
.report-table{border:2px solid #111}
.report-table th,.report-table td{border:1px solid #111;padding:7px 6px;text-align:center;color:#111}
.report-table th{font-size:11px;text-transform:none;letter-spacing:0}
.report-table .itinerary td{text-align:left;padding:7px 12px 9px;white-space:pre-line;line-height:1.45}
.report-table .right{text-align:right}
.report-table tfoot td{font-weight:700}
.report-footer{margin-top:30px;border:0;text-align:center;padding-top:13px;font-weight:700;font-size:11px;box-shadow:none}
.status-badge{display:inline-block;border-radius:20px;padding:5px 9px;font-size:12px;font-weight:700}
.status-badge.active{background:#e7f8f0;color:#14734d}
.status-badge.inactive{background:#f1f3f6;color:#687386}
.inactive-row{background:#fafbfc;color:#667085}
.activate-button{border:0;border-radius:7px;padding:8px 10px;font-weight:700;cursor:pointer;background:#e7f8f0;color:#14734d}
.report-summary{border:1px dashed #cfd7e4;border-radius:11px;padding:24px;background:#fbfcff}
.generated-report{display:flex;align-items:center;gap:18px;flex-wrap:wrap}
.generated-report span{color:var(--muted)}
.generated-report .link{margin-left:auto}
.client-report-table{width:100%;border:2px solid #111}
.client-report-table th,.client-report-table td{border:1px solid #111;padding:8px 7px;color:#111}
.client-report-table th{font-size:11px;text-transform:none;letter-spacing:0;background:#f4f6f8}
.client-report-table tr{break-inside:avoid}
.route-check-panel{margin-bottom:20px}
.route-status{border-radius:20px;padding:7px 11px;background:#f1f3f6;color:#687386;font-size:12px;font-weight:700}
.route-status.ready{background:#e7f8f0;color:#14734d}
.route-status.started{background:#eaf1ff;color:#1d4ed8}
.checklist-grid{display:grid;grid-template-columns:repeat(4,1fr);gap:12px;margin-bottom:16px}
.check-item{display:flex;align-items:center;gap:10px;border:1px solid var(--line);border-radius:11px;padding:14px;background:#fbfcff;cursor:pointer}
.check-item input{width:22px;height:22px;accent-color:var(--green);flex:0 0 auto}
.start-route{width:100%}
.start-route:disabled{opacity:.45;cursor:not-allowed}
.route-list{display:grid;gap:12px}
.route-stop{display:grid;grid-template-columns:auto minmax(0,1fr) auto;gap:15px;align-items:center;border:1px solid var(--line);border-radius:12px;padding:14px;background:#fff}
.route-stop.excluded{background:#f7f8fa;opacity:.72}
.route-order{display:grid;grid-template-columns:34px 30px 30px;gap:5px;align-items:center}
.route-order b{width:34px;height:34px;border-radius:50%;display:grid;place-items:center;background:#eaf1ff;color:var(--blue);font-size:15px}
.route-order button{width:30px;height:30px;border:1px solid var(--line);background:#fff;border-radius:7px;color:var(--ink);cursor:pointer}
.route-order button:disabled{opacity:.3;cursor:default}
.route-info{display:grid;gap:4px}
.route-info b{font-size:15px}
.route-info span{color:#4b5563}
.route-info small{color:var(--muted)}
.route-actions{display:flex;gap:7px;align-items:center;justify-content:flex-end;flex-wrap:wrap}
.gps-button{display:inline-flex;align-items:center;justify-content:center;min-height:38px;padding:8px 12px;border-radius:8px;color:#fff;text-decoration:none;font-weight:750}
.gps-button.waze{background:#0f9bd7}
.gps-button.maps{background:#2f8b57}

.routing-settings-panel{margin-bottom:20px}
.routing-key-form{display:grid;grid-template-columns:minmax(260px,1fr) auto auto auto;gap:10px;align-items:end}
.routing-key-form label{min-width:0}
.routing-key-form button{min-height:41px;white-space:nowrap}
.privacy-note{display:block;color:var(--muted);margin-top:11px}
.danger-link{color:var(--danger)}
.route-map-panel{margin-bottom:20px;overflow:hidden}
.route-map-toolbar{display:flex;gap:10px;flex-wrap:wrap;margin-bottom:14px}
.route-map-toolbar button{min-height:42px}
#routeMap{height:510px;width:100%;border:1px solid var(--line);border-radius:12px;background:#e8edf3;overflow:hidden;z-index:1}
.route-map-footer{display:flex;justify-content:space-between;align-items:center;gap:16px;padding-top:12px;color:var(--muted);font-size:13px}
.route-map-footer strong{color:var(--ink);white-space:nowrap}
.route-number-marker{width:34px!important;height:34px!important;margin:-17px 0 0 -17px!important;border-radius:50%;display:grid!important;place-items:center;background:var(--blue);color:#fff;border:3px solid #fff;box-shadow:0 3px 11px #17203355;font-weight:800;font-size:13px}
.driver-marker{width:24px!important;height:24px!important;margin:-12px 0 0 -12px!important;border-radius:50%;background:#14a46f;border:4px solid #fff;box-shadow:0 0 0 6px #14a46f3d,0 3px 12px #17203355}
.leaflet-popup-content b{display:block;margin-bottom:3px}
.leaflet-control-attribution{font-size:10px}
@media(max-width:1200px){
  .cards{grid-template-columns:repeat(3,1fr)}
  .pending-grid{grid-template-columns:repeat(2,minmax(0,1fr))}
}
@media(max-width:1000px){
  .split{grid-template-columns:1fr}
}
@media(max-width:700px){
  aside{position:static;width:auto;padding:12px 13px;display:grid;grid-template-columns:1fr auto;gap:10px 12px}
  .brand{padding:0;gap:9px}
  .brand img{width:54px;height:54px;border-radius:11px;padding:1px}
  .brand b{font-size:19px}
  .brand small{font-size:11px}
  aside nav{grid-column:1/-1;display:grid;grid-template-columns:repeat(3,minmax(0,1fr));overflow:visible;gap:7px;padding-bottom:2px}
  nav button{padding:8px 7px;font-size:12px;gap:5px;min-width:0}
  .nav-icon{width:32px;height:32px;font-size:24px}
  aside footer{margin:0;padding:2px 0;text-align:right;font-size:11px;align-self:center}
  aside footer small{font-size:10px}
  .logout{margin-left:auto;padding:7px 9px;font-size:11px}
  .copyright{font-size:9px!important}
  main{margin:0;padding:20px 13px}
  .main-header{align-items:stretch;gap:13px}
  .main-header>div{min-width:0}
  .main-header h1{font-size:23px}
  .main-header .new-delivery{white-space:nowrap;align-self:center}
  .cards{grid-template-columns:1fr}
  .cards article{padding:17px}
  .panel{padding:15px;overflow:visible}
  .panelhead,.responsive-head{align-items:flex-start}
  .responsive-head{flex-direction:column}
  .responsive-head>button{width:100%}
  .toolbar{flex-direction:column;align-items:stretch}
  .toolbar label,.filterbar select{min-width:0;width:100%}
  .toolbar button{width:100%}
  .row,.client-name-row{grid-template-columns:1fr}
  .pending-grid{grid-template-columns:1fr}
  .checklist-grid{grid-template-columns:1fr 1fr}
  .routing-key-form{grid-template-columns:1fr}
  .routing-key-form button{width:100%}
  .route-map-toolbar{display:grid;grid-template-columns:1fr}
  .route-map-toolbar button{width:100%}
  #routeMap{height:420px;border-radius:10px}
  .route-map-footer{align-items:flex-start;flex-direction:column;gap:7px}
  .route-map-footer strong{white-space:normal}
  .route-stop{grid-template-columns:1fr}
  .route-order{grid-template-columns:1fr 40px 40px}
  .route-order b{width:38px;height:38px}
  .route-order button{width:40px;height:38px}
  .route-actions{display:grid;grid-template-columns:1fr 1fr}
  .route-actions>*{width:100%}
  .pending-grid article{grid-template-columns:1fr auto}
  .responsive-table,.responsive-table tbody,.responsive-table tr,.responsive-table td{display:block;width:100%}
  .responsive-table thead{display:none}
  .responsive-table tr{border:1px solid var(--line);border-radius:11px;margin-bottom:12px;padding:7px 11px;background:#fff}
  .responsive-table td{display:flex;justify-content:space-between;align-items:center;gap:16px;padding:10px 2px;border-bottom:1px solid #edf0f4;text-align:right}
  .responsive-table td::before{content:attr(data-label);font-size:11px;text-transform:uppercase;letter-spacing:.04em;color:#7b8493;font-weight:750;text-align:left;flex:0 0 32%}
  .responsive-table td>span:first-child{text-align:right}
  .responsive-table .table-actions{justify-content:flex-end}
  .responsive-table .table-actions button{min-height:40px}
  .recent-table td:nth-child(3){display:none}
  .recent-table td:nth-child(3)::before{display:none}
  .delivery-table .table-actions{display:grid;grid-template-columns:1fr 1fr;width:100%}
  .delivery-table .table-actions::before{grid-column:1/-1}
  .delivery-table .table-actions button{width:100%}
  .closing-table .table-actions{display:grid;grid-template-columns:1fr 1fr;width:100%}
  .closing-table .table-actions::before{grid-column:1/-1}
  .closing-table .table-actions button{width:100%}
  .price-table td:first-child{align-items:flex-start}
  .price-table td:first-child span{max-width:66%}
  .pager{flex-wrap:wrap}
  dialog{width:calc(100% - 18px);max-height:96vh}
  dialog form{padding:18px;max-height:94vh}
  .actions{display:grid;grid-template-columns:1fr 1fr}
  .actions button{width:100%}
  #toast{right:15px;bottom:15px}
  .report-dialog{width:calc(100% - 8px);height:calc(100dvh - 8px);padding:6px;max-height:calc(100dvh - 8px);overflow-y:auto;overflow-x:hidden;overscroll-behavior:contain}
  .report-actions{position:sticky;top:-6px;z-index:5;flex:0 0 auto;background:#e9edf3;padding:9px 6px;margin:0 0 8px;box-shadow:0 4px 10px #17203318}
  #reportSheet,#clientReportSheet{width:100%;min-height:auto;padding:24px 14px}
  #clientReportSheet{overflow-x:auto;-webkit-overflow-scrolling:touch}
  .client-report-table{min-width:680px}
  .report-header{gap:10px}
  .report-header img{width:112px;height:82px}
  .report-header h1{font-size:17px}
  .report-table-wrap{overflow-x:auto;-webkit-overflow-scrolling:touch}
  .report-table{min-width:720px;font-size:10px}
  .report-table th,.report-table td{padding:5px 3px}
}
@media(max-width:430px){
  .main-header{flex-direction:column}
  .main-header .new-delivery{width:100%}
  .panelhead{flex-direction:column}
  .panelhead .link{padding-left:0}
  .report-header{align-items:center}
  .report-header img{width:96px;height:74px}
}

@page{size:A4 portrait;margin:14mm 10mm}
@media print{
  html,body{width:100%!important;min-width:0!important;height:auto!important;margin:0!important;padding:0!important;overflow:visible!important;background:#fff!important}

  body.printing-service>*:not(#reportDialog),body.printing-clients>*:not(#clientReportDialog){display:none!important}
  body.printing-service #reportDialog,body.printing-clients #clientReportDialog{display:block!important;position:static!important;inset:auto!important;width:100%!important;max-width:none!important;max-height:none!important;margin:0!important;padding:0!important;border:0!important;background:#fff!important;box-shadow:none!important;overflow:visible!important}
  .print-dialog::backdrop{display:none}
  .no-print{display:none!important}
  #reportSheet,#clientReportSheet{display:block!important;width:100%!important;max-width:none!important;min-height:0!important;margin:0!important;padding:0!important;box-shadow:none!important;overflow:visible!important;font:12px Arial,sans-serif!important}
  .report-header{width:100%!important;align-items:flex-start!important;margin:0 0 27px!important;break-inside:avoid;page-break-inside:avoid}
  .report-header>div{min-width:0;flex:1}
  .report-header h1{font-size:22px!important;line-height:1.08!important;margin:0 0 15px!important}
  .report-header img{width:150px!important;height:105px!important;flex:0 0 150px}
  .report-table-wrap{display:block!important;width:100%!important;overflow:visible!important}
  .report-table,.client-report-table{width:100%!important;min-width:0!important;max-width:100%!important;table-layout:auto!important}
  .report-table th,.report-table td{padding:7px 6px!important}
  .client-report-table th,.client-report-table td{padding:8px 7px!important}
  .report-table .itinerary td{white-space:pre-line!important;text-align:left!important;overflow-wrap:anywhere!important;word-break:normal!important}
  .report-table thead,.client-report-table thead{display:table-header-group}
  .report-table tfoot{display:table-row-group}
  .report-table tr,.client-report-table tr{break-inside:avoid;page-break-inside:avoid}
  .report-footer{break-inside:avoid;page-break-inside:avoid;border:0!important;box-shadow:none!important}
}
