*{box-sizing:border-box}
:root{--bg:#07111f;--panel:#101a2b;--panel-2:#0d1626;--line:#26384f;--line-2:#334862;--text:#eef6ff;--muted:#9eb0c7;--blue:#2f7df6;--green:#16a34a;--red:#dc2626;--amber:#f59e0b;--sidebar-open:276px;--sidebar-closed:86px;--radius:8px;--shadow:0 18px 45px rgba(0,0,0,.28)}
html{min-width:320px}
body{margin:0;font-family:Inter,Segoe UI,Arial,sans-serif;background:linear-gradient(135deg,#07111f 0%,#0b1423 45%,#091522 100%);color:var(--text);font-size:15px;line-height:1.45}
a{color:inherit}
h1{font-size:clamp(28px,3vw,40px);line-height:1.05;margin:0 0 22px}
h2,h3,h4{line-height:1.2}
p{margin:0 0 14px}
.layout{min-height:100vh}
.sidebar{position:fixed;inset:0 auto 0 0;width:var(--sidebar-open);background:rgba(5,10,19,.98);border-right:1px solid var(--line);padding:18px;z-index:30;transition:width .22s ease,padding .22s ease;box-shadow:12px 0 35px rgba(0,0,0,.18)}
.sidebar nav{display:grid;gap:7px;max-height:calc(100vh - 122px);overflow:auto;padding-right:2px}
.brand-row{display:flex;align-items:center;justify-content:space-between;gap:10px;margin-bottom:14px}
.brand{min-width:0;display:flex;align-items:center;gap:10px;font-size:21px;font-weight:900;letter-spacing:.2px}
.brand-icon{width:38px;height:38px;display:grid;place-items:center;border-radius:8px;background:linear-gradient(135deg,#12345e,#125b37);color:#fff;flex:0 0 auto;box-shadow:inset 0 0 0 1px rgba(255,255,255,.08)}
.brand-name{white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.sidebar-toggle{width:38px;height:38px;min-height:38px;padding:0;border-radius:8px;border:1px solid var(--line-2);background:#132238;color:#dbeafe;font-size:18px;box-shadow:none}
.sidebar-toggle:hover{background:#1a2d49}
.license{font-size:12px;background:#101e34;border:1px solid #294264;color:#cfe6ff;border-radius:8px;padding:10px 12px;margin-bottom:16px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.nav a{display:flex;align-items:center;gap:11px;min-height:46px;padding:10px 12px;border-radius:8px;text-decoration:none;color:#c8d2e0;border:1px solid transparent;white-space:nowrap;overflow:hidden;transition:background .16s ease,border-color .16s ease,color .16s ease,transform .16s ease}
.nav a:hover,.nav a.active{background:#102643;border-color:#315a89;color:#fff}
.nav a:hover{transform:translateX(2px)}
.nav .ico{width:28px;height:28px;display:grid;place-items:center;border-radius:8px;background:#182943;font-size:15px;line-height:1;box-shadow:inset 0 0 0 1px rgba(255,255,255,.05);flex:0 0 28px}
.nav-label{overflow:hidden;text-overflow:ellipsis;transition:opacity .14s ease,width .14s ease}
.sidebar-drag-handle{position:absolute;top:0;right:-10px;width:20px;height:100%;cursor:ew-resize}
.sidebar-drag-handle::after{content:"";position:absolute;top:50%;right:3px;width:4px;height:54px;border-radius:999px;background:#365273;transform:translateY(-50%);opacity:.75}
.main{margin-left:var(--sidebar-open);width:calc(100% - var(--sidebar-open));min-height:100vh;padding:28px;transition:margin-left .22s ease,width .22s ease}
.sidebar-collapsed .sidebar{width:var(--sidebar-closed);padding:18px 14px}
.sidebar-collapsed .main{margin-left:var(--sidebar-closed);width:calc(100% - var(--sidebar-closed))}
.sidebar-collapsed .brand-row{justify-content:center}
.sidebar-collapsed .brand{justify-content:center}
.sidebar-collapsed .brand-name,.sidebar-collapsed .license,.sidebar-collapsed .nav-label{opacity:0;width:0;pointer-events:none}
.sidebar-collapsed .sidebar-toggle{position:absolute;right:-19px;top:18px;box-shadow:0 12px 30px rgba(0,0,0,.34)}
.sidebar-collapsed .nav a{justify-content:center;padding:10px}
.top{position:sticky;top:0;z-index:10;display:flex;justify-content:flex-end;gap:16px;align-items:center;margin:-28px -28px 26px;padding:18px 28px;background:rgba(7,17,31,.82);border-bottom:1px solid rgba(38,56,79,.72);backdrop-filter:blur(14px)}
.user{background:#101a2b;border:1px solid var(--line);padding:9px 13px;border-radius:8px;color:#dbeafe}
.user a{font-weight:800}
.grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(min(100%,280px),1fr));gap:18px;margin-bottom:22px}
.card{background:linear-gradient(180deg,rgba(16,26,43,.98),rgba(13,22,38,.98));border:1px solid var(--line);border-radius:8px;padding:22px;box-shadow:var(--shadow)}
.card h3{margin:0 0 16px;font-size:20px}
.card h4{margin:22px 0 10px;color:#dbeafe}
.section-title{display:flex;align-items:flex-end;justify-content:space-between;gap:16px;margin-bottom:22px}
.section-title h1{margin:0}
.section-title .muted{margin:8px 0 0}
.kpi{font-size:clamp(30px,4vw,42px);font-weight:900;margin:6px 0;color:#fff}
.btn,button{display:inline-flex;align-items:center;justify-content:center;gap:8px;border:0;background:var(--green);color:white;text-decoration:none;border-radius:8px;padding:10px 14px;cursor:pointer;min-height:40px;font-weight:800;max-width:100%;transition:filter .16s ease,transform .16s ease,opacity .16s ease}
.btn:hover,button:hover{filter:brightness(1.08);transform:translateY(-1px)}
.btn.blue,button.blue{background:var(--blue)}
.btn.red,button.red{background:var(--red)}
.btn.gray,button.gray{background:#334155}
.btn.small{padding:7px 10px;min-height:34px;font-size:13px}
.actions{display:flex;gap:10px;flex-wrap:wrap;align-items:center}
.table-wrap{overflow:auto;border:1px solid var(--line);border-radius:8px;background:var(--panel);margin-top:18px}
.table-searchbar{display:grid;grid-template-columns:150px minmax(180px,1fr);gap:12px;align-items:center;padding:14px;border-bottom:1px solid var(--line);background:#0d1728}
.table-searchbar label{font-size:13px;font-weight:900;color:#dbeafe}
.table-searchbar input{margin:0;max-width:560px}
.table{width:100%;border-collapse:collapse;background:var(--panel);min-width:680px}
.table th,.table td{padding:13px 14px;border-bottom:1px solid var(--line);text-align:left;vertical-align:middle}
.table th{color:#b8d9ff;background:#0d1728;white-space:nowrap;position:relative}
.table tr:hover td{background:#141f31}
.column-filter{display:none}
.sortable{cursor:pointer}
.sortable::after{content:" ↕";font-size:11px;color:#64748b}
.field{display:grid;gap:7px;margin-bottom:14px}
.field label{font-size:13px;font-weight:900;color:#dbeafe}
.hint{font-size:12px;color:#93a4b8;line-height:1.4}
.field input,.field select,.field textarea,input,select,textarea{width:100%;padding:11px 12px;border:1px solid #354a64;background:#111d30;color:white;border-radius:8px;margin:0;min-height:42px}
input:focus,select:focus,textarea:focus{outline:2px solid rgba(47,125,246,.34);border-color:#4b8df8}
textarea{min-height:132px;resize:vertical}
.form-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(min(100%,240px),1fr));gap:16px}
.form-grid.wide{grid-template-columns:repeat(12,1fr)}
.span-3{grid-column:span 3}.span-4{grid-column:span 4}.span-6{grid-column:span 6}.span-8{grid-column:span 8}.span-12{grid-column:1/-1}
.notice,.error{padding:13px 14px;border-radius:8px;margin-bottom:16px}
.notice{background:#123f2a;border:1px solid #22c55e}
.error{background:#7f1d1d;border:1px solid #ef4444}
.muted{color:var(--muted)}
.progress{height:10px;background:#1f2937;border-radius:999px;overflow:hidden}
.bar{height:10px;background:linear-gradient(90deg,#22c55e,#38bdf8)}
.card-head{display:flex;justify-content:space-between;align-items:flex-start;gap:14px;margin-bottom:14px}
.card-head h3{margin:0}
.status-pill{display:inline-flex;align-items:center;white-space:nowrap;border:1px solid #365273;background:#142238;color:#dbeafe;border-radius:999px;padding:6px 10px;font-size:12px;font-weight:900}
.status-pill.ok{border-color:#256d43;background:#123f2a;color:#bbf7d0}
.storage-meter{height:16px;background:#0b1220;border:1px solid var(--line);border-radius:999px;overflow:hidden;margin:8px 0 16px}
.storage-meter div{height:100%;background:linear-gradient(90deg,#22c55e,#38bdf8,#f59e0b)}
.storage-numbers{display:grid;grid-template-columns:repeat(3,1fr);gap:10px;margin-bottom:14px}
.storage-numbers div,.mini-stats span{background:#0d1728;border:1px solid var(--line);border-radius:8px;padding:11px}
.storage-numbers span,.mini-stats span{display:block;color:var(--muted);font-size:12px;margin-bottom:5px}
.storage-numbers b,.mini-stats b{color:#fff}
.mini-stats{display:grid;grid-template-columns:repeat(auto-fit,minmax(140px,1fr));gap:10px;margin:14px 0}
.backup-progress{margin:14px 0}
.backup-progress-top{display:flex;justify-content:space-between;gap:10px;margin-bottom:8px;color:#cbd5e1}
.small-text{font-size:12px;line-height:1.45;word-break:break-word}
.security-card{grid-column:1/-1}
.compact-table{margin:10px 0 12px}
.compact-table .table th,.compact-table .table td{padding:10px 12px;font-size:13px}
.backup-live{margin-top:18px;background:#0d1728;border:1px solid var(--line);border-radius:8px;padding:14px}
.backup-log{margin:12px 0 0;max-height:220px;overflow:auto;background:#070b14;border:1px solid var(--line);border-radius:8px;color:#cbd5e1;padding:12px;white-space:pre-wrap;font-size:12px;line-height:1.45}
.backup-runner button:disabled{opacity:.72;cursor:wait}
.inline-option{display:flex;gap:9px;align-items:center;margin:12px 0;color:#dbeafe}
.inline-option input{width:auto;min-height:0}
.backup-parts{display:flex;gap:8px;flex-wrap:wrap;margin-top:14px}
.backup-parts h4{width:100%;margin:0 0 4px;color:#dbeafe}
.print{background:white;color:#111;max-width:760px;margin:20px auto;padding:24px}
.print .muted{color:#444}
.thumb,.camera-tile{width:58px;height:58px;border-radius:8px;object-fit:cover;background:#182132;display:inline-grid;place-items:center;text-decoration:none;font-size:22px}
.page-tools{display:flex;justify-content:space-between;gap:16px;align-items:flex-end;flex-wrap:wrap;margin:0 0 18px}
.search-panel{display:grid;grid-template-columns:minmax(260px,2fr) minmax(150px,1fr) minmax(150px,1fr) minmax(140px,auto);gap:14px;align-items:end}
.search-panel .field{margin:0}
.search-panel button{width:100%;white-space:nowrap}
.modal{position:fixed;inset:0;background:rgba(0,0,0,.86);display:flex;justify-content:center;align-items:center;z-index:9999;padding:24px}
.modal-tools{position:fixed;inset:auto 24px 24px 24px;display:flex;justify-content:center;gap:10px;pointer-events:none}
.modal-tools button{pointer-events:auto}
.login-page{min-height:100vh;display:grid;place-items:center;padding:28px;background:linear-gradient(135deg,#07111f,#0d1728 52%,#07111f)}
.login-shell{width:min(980px,96vw);display:grid;grid-template-columns:minmax(320px,1fr) minmax(360px,430px);border:1px solid #2b3c55;border-radius:8px;overflow:hidden;box-shadow:0 30px 90px rgba(0,0,0,.48);background:rgba(9,14,25,.72)}
.login-hero-panel{padding:42px;display:flex;flex-direction:column;justify-content:flex-end;min-height:560px;background:linear-gradient(160deg,rgba(15,23,42,.42),rgba(6,12,23,.95)),url('logo.png');background-repeat:no-repeat;background-position:center 96px;background-size:230px auto}
.login-brand-mark{width:58px;height:58px;border-radius:8px;background:var(--green);color:#fff;display:grid;place-items:center;font-weight:900;font-size:22px;margin-bottom:auto;box-shadow:0 16px 36px rgba(22,163,74,.25)}
.login-hero-panel h2{font-size:42px;margin:0 0 12px}
.login-hero-panel p{max-width:430px;margin:0;color:#cbd5e1;font-size:18px;line-height:1.45}
.login-trust{display:flex;gap:10px;flex-wrap:wrap;margin-top:26px}
.login-trust span{border:1px solid #365273;background:rgba(15,23,42,.82);color:#dbeafe;border-radius:999px;padding:8px 11px;font-size:12px;font-weight:900}
.login-box{background:rgba(17,24,39,.96);padding:44px 38px;text-align:center;backdrop-filter:blur(14px);display:flex;flex-direction:column;justify-content:center}
.login-logo{width:110px;height:110px;margin:0 auto 16px;border-radius:26px;background:#0f172a;border:1px solid #30415b;display:grid;place-items:center;box-shadow:inset 0 0 0 8px rgba(255,255,255,.02),0 18px 40px rgba(0,0,0,.28)}
.login-logo img{width:86px;margin:0}
.login-kicker{margin:0 0 6px;color:#86efac;text-transform:uppercase;letter-spacing:0;font-size:12px;font-weight:900}
.login-box h1{margin:0;font-size:34px}
.login-subtitle{margin:10px auto 24px;color:#a7b5c8;max-width:320px;line-height:1.45}
.login-form{display:grid;gap:13px;text-align:left}
.login-form input{min-height:50px;background:#0f172a;border-color:#32435e;padding-left:15px}
.login-form button{min-height:50px;background:linear-gradient(135deg,#16a34a,#2563eb);width:100%;box-shadow:0 14px 30px rgba(37,99,235,.24)}
.login-footnote{margin:18px 0 0;color:#7f91a8;font-size:12px;line-height:1.45}
@media(max-width:1180px){.main{padding:22px}.top{margin:-22px -22px 22px;padding:16px 22px}.grid{gap:16px}.search-panel{grid-template-columns:1fr 1fr}.search-panel .field:first-child{grid-column:1/-1}}
@media(max-width:900px){body.sidebar-collapsed .sidebar{width:100%;padding:14px}.layout{display:block}.sidebar{position:sticky;top:0;width:100%;height:auto;padding:14px;overflow:visible}.sidebar nav{max-height:none;display:flex;gap:8px;overflow:auto;padding:2px 0 4px}.brand-row{margin-bottom:10px}.sidebar-drag-handle,.sidebar-toggle{display:none}.brand-name,.license,.nav-label,.sidebar-collapsed .brand-name,.sidebar-collapsed .license,.sidebar-collapsed .nav-label{opacity:1;width:auto;pointer-events:auto}.license{margin-bottom:10px}.nav a,.sidebar-collapsed .nav a{justify-content:flex-start;flex:0 0 auto;padding:9px 11px}.main,.sidebar-collapsed .main{margin-left:0;width:100%;padding:18px}.top{position:static;margin:-18px -18px 20px;padding:14px 18px;justify-content:flex-start}.user{width:100%;display:flex;gap:8px;flex-wrap:wrap}.form-grid.wide{grid-template-columns:1fr}.span-3,.span-4,.span-6,.span-8{grid-column:1/-1}.table-searchbar{grid-template-columns:1fr}.search-panel{grid-template-columns:1fr}.storage-numbers{grid-template-columns:1fr}}
@media(max-width:640px){body{font-size:14px}.main{padding:14px}.top{margin:-14px -14px 18px;padding:12px 14px}.card{padding:16px}.grid{grid-template-columns:1fr;gap:14px}.actions,.page-tools,.card-head{align-items:stretch;flex-direction:column}.btn,button{width:100%}.table{min-width:620px}.login-page{padding:14px}.login-shell{grid-template-columns:1fr;width:100%}.login-hero-panel{display:none}.login-box{padding:30px 22px}.login-logo{width:96px;height:96px}.login-logo img{width:76px}.login-box h1{font-size:30px}.nav .ico{width:30px;height:30px;flex-basis:30px}.nav a{min-height:44px}}

/* Responsive polish for square/compact desktop screens */
body{overflow-x:hidden}
.sidebar{overflow:hidden}
.sidebar nav{scrollbar-width:none}
.sidebar nav::-webkit-scrollbar{width:0;height:0}
.sidebar-collapsed .sidebar{overflow:hidden}
.sidebar-collapsed .sidebar nav{padding-right:0}
.sidebar-collapsed .sidebar-drag-handle::after{opacity:0}
.main{max-width:1600px}
.card{min-width:0}
.card canvas{max-width:100%;height:auto!important}
.grid{align-items:stretch}
.storage-card .mini-stats{grid-template-columns:1fr}
.storage-card .storage-numbers{grid-template-columns:repeat(3,minmax(0,1fr))}
.storage-card .storage-numbers div{min-width:0}
.storage-card .storage-numbers b{display:block;font-size:16px;line-height:1.25;word-break:break-word}
.storage-card .small-text{font-size:11px;color:#8ea3bd}
.backup-progress-top b{white-space:nowrap}
.main>h1:first-child{margin-bottom:18px}

@media (min-width:901px) and (max-width:1180px){
  :root{--sidebar-closed:72px;--sidebar-open:248px}
  .sidebar{padding:14px 10px}
  .sidebar-collapsed .sidebar{padding:14px 10px}
  .brand-icon{width:38px;height:38px}
  .sidebar-toggle{width:38px;height:38px;right:-18px}
  .nav a{min-height:42px;padding:8px}
  .nav .ico{width:28px;height:28px;flex-basis:28px}
  .main{padding:22px 28px 32px}
  .top{margin:-22px -28px 22px;padding:14px 28px}
  .grid{grid-template-columns:repeat(auto-fit,minmax(min(100%,260px),1fr));gap:16px}
  .card{padding:20px}
  .card h3{font-size:19px}
  .kpi{font-size:32px}
}

@media (min-width:901px) and (max-width:1080px){
  .grid{grid-template-columns:repeat(2,minmax(0,1fr))}
  .grid:first-of-type{grid-template-columns:repeat(5,minmax(140px,1fr));gap:12px}
  .grid:first-of-type .card{padding:16px;min-height:116px}
  .grid:first-of-type .card h3{font-size:15px;margin-bottom:8px}
  .grid:first-of-type .kpi{font-size:24px}
  .grid:first-of-type .muted{font-size:12px}
  .storage-card{grid-column:auto}
  .security-card{grid-column:1/-1}
}

@media (min-width:901px) and (max-width:1080px) and (max-height:820px){
  .main{padding:18px 22px 28px}
  .top{margin:-18px -22px 18px;padding:12px 22px}
  h1{font-size:30px;margin-bottom:16px}
  .grid{gap:14px;margin-bottom:16px}
  .card{padding:18px}
  .card h3{font-size:18px;margin-bottom:12px}
  .storage-numbers{gap:8px}
  .storage-numbers div,.mini-stats span{padding:10px}
  .backup-live,.table-wrap{margin-top:12px}
  .nav{gap:6px}
}

@media (min-width:1181px){
  .main{padding:32px 40px 44px}
  .top{margin:-32px -40px 28px;padding:18px 40px}
  .grid{gap:22px}
  .card{padding:24px}
}

@media (min-width:1400px){
  .grid{grid-template-columns:repeat(auto-fit,minmax(320px,1fr))}
  .grid:first-of-type{grid-template-columns:repeat(5,minmax(180px,1fr))}
}

@media (max-width:900px){
  .sidebar{box-shadow:0 12px 30px rgba(0,0,0,.24);border-right:0;border-bottom:1px solid var(--line)}
  .sidebar nav{scrollbar-width:none}
  .sidebar nav::-webkit-scrollbar{height:0}
  .main{max-width:none}
  .grid:first-of-type{grid-template-columns:repeat(auto-fit,minmax(150px,1fr))}
}

@media (max-width:520px){
  .grid:first-of-type{grid-template-columns:1fr 1fr}
  .grid:first-of-type .card{padding:14px}
  .grid:first-of-type .card h3{font-size:14px}
  .grid:first-of-type .kpi{font-size:24px}
  .storage-card .storage-numbers{grid-template-columns:1fr}
}

/* Full fluid adaptation layer */
:root{
  --fluid-gap:clamp(10px,1.6vw,24px);
  --fluid-pad:clamp(14px,2vw,28px);
  --fluid-card-pad:clamp(14px,1.8vw,24px);
  --content-max:1680px;
}
img,video,canvas,svg{max-width:100%}
canvas{display:block}
.main{max-width:var(--content-max);margin-right:auto}
.sidebar-collapsed .main{margin-right:auto}
.main>h1:first-child,.section-title h1{overflow-wrap:anywhere}
.grid{grid-template-columns:repeat(auto-fit,minmax(min(100%,clamp(220px,28vw,340px)),1fr));gap:var(--fluid-gap)}
.card{padding:var(--fluid-card-pad);overflow:hidden}
.card>*:last-child{margin-bottom:0}
.card h1,.card h2,.card h3,.card h4{overflow-wrap:anywhere}
.card p,.muted,.hint{overflow-wrap:anywhere}
.kpi{font-size:clamp(24px,3.4vw,42px)}
.actions,.page-tools{gap:clamp(8px,1vw,14px)}
.actions>*{flex:0 1 auto}
.btn,button{white-space:normal;text-align:center}
.btn.small,button.small{width:auto}
form.card,form{min-width:0}
label{min-width:0}
.field{min-width:0}
input,select,textarea{max-width:100%;font-size:16px}
input[type=checkbox],input[type=radio]{width:auto;min-height:0}
.form-grid{grid-template-columns:repeat(auto-fit,minmax(min(100%,clamp(190px,24vw,320px)),1fr));gap:var(--fluid-gap)}
.form-grid.wide{grid-template-columns:repeat(12,minmax(0,1fr))}
.span-3{grid-column:span 3}.span-4{grid-column:span 4}.span-6{grid-column:span 6}.span-8{grid-column:span 8}.span-12{grid-column:1/-1}
.table-wrap{width:100%;max-width:100%;overflow:auto;-webkit-overflow-scrolling:touch}
.table{min-width:min(760px,calc(100vw - 32px))}
.table th,.table td{overflow-wrap:anywhere}
.table td .actions{min-width:max-content}
.table-searchbar{grid-template-columns:minmax(100px,150px) minmax(160px,1fr)}
.search-panel{grid-template-columns:minmax(220px,2fr) repeat(2,minmax(140px,1fr)) minmax(120px,.7fr)}
.modal{overflow:auto;align-items:flex-start}
.modal img,.modal video{max-height:calc(100vh - 120px);object-fit:contain}
.thumb,.camera-tile{width:clamp(48px,7vw,64px);height:clamp(48px,7vw,64px)}
.storage-numbers{grid-template-columns:repeat(auto-fit,minmax(92px,1fr))}
.mini-stats{grid-template-columns:repeat(auto-fit,minmax(min(100%,130px),1fr))}
.chart-card,.card:has(canvas){min-height:clamp(250px,38vh,420px)}
.card canvas{width:100%!important;height:clamp(210px,34vh,360px)!important}
.compact-table .table{min-width:680px}
.login-shell{width:min(980px,calc(100vw - 28px))}

@media (min-width:901px){
  .main{padding:clamp(18px,2.2vw,42px)}
  .top{margin:calc(-1 * clamp(18px,2.2vw,42px)) calc(-1 * clamp(18px,2.2vw,42px)) clamp(18px,2vw,30px);padding:clamp(12px,1.4vw,20px) clamp(18px,2.2vw,42px)}
}

@media (min-width:901px) and (max-width:1250px){
  .grid{grid-template-columns:repeat(auto-fit,minmax(min(100%,240px),1fr))}
  .grid:first-of-type{grid-template-columns:repeat(auto-fit,minmax(145px,1fr))}
  .grid:first-of-type .card{padding:clamp(12px,1.2vw,18px)}
  .grid:first-of-type .card h3{font-size:clamp(14px,1.5vw,17px)}
  .grid:first-of-type .kpi{font-size:clamp(22px,2.3vw,30px)}
}

@media (min-width:901px) and (max-width:1050px){
  .grid{grid-template-columns:repeat(2,minmax(0,1fr))}
  .security-card,.card:has(.table-wrap){grid-column:1/-1}
  .table{min-width:720px}
  .user{font-size:14px}
  .card canvas{height:260px!important}
}

@media (max-height:760px) and (min-width:901px){
  .top{position:static}
  .card{padding:14px}
  .card h3{font-size:18px;margin-bottom:10px}
  .grid{gap:12px;margin-bottom:14px}
  .card canvas{height:220px!important}
  .storage-meter{margin-bottom:10px}
  .mini-stats{margin:10px 0}
}

@media (max-width:900px){
  .main{max-width:none}
  .grid,.grid:first-of-type{grid-template-columns:repeat(auto-fit,minmax(min(100%,220px),1fr))}
  .section-title{display:block}
  .page-tools{align-items:stretch}
  .page-tools>*{width:100%}
  .actions>*{flex:1 1 160px}
  .search-panel{grid-template-columns:1fr 1fr}
  .search-panel .field:first-child{grid-column:1/-1}
  .form-grid.wide{grid-template-columns:repeat(2,minmax(0,1fr))}
  .span-3,.span-4,.span-6,.span-8{grid-column:span 1}
  .span-12{grid-column:1/-1}
  .table-searchbar{grid-template-columns:1fr}
  .table{min-width:680px}
  .card:has(canvas){min-height:300px}
  .card canvas{height:260px!important}
  .modal{padding:14px}
}

@media (max-width:680px){
  .main{padding:12px}
  .top{margin:-12px -12px 16px;padding:12px}
  h1{font-size:clamp(24px,8vw,32px)}
  .grid,.grid:first-of-type{grid-template-columns:1fr}
  .grid:first-of-type{grid-template-columns:repeat(2,minmax(0,1fr))}
  .grid:first-of-type .card{padding:12px}
  .grid:first-of-type .card h3{font-size:13px;margin-bottom:6px}
  .grid:first-of-type .kpi{font-size:22px}
  .grid:first-of-type .muted{font-size:11px}
  .storage-card,.security-card,.card:has(.table-wrap),.card:has(canvas){grid-column:1/-1}
  .card{padding:14px}
  .card-head{display:block}
  .card-head .status-pill{margin-top:8px}
  .storage-numbers{grid-template-columns:1fr}
  .search-panel,.form-grid,.form-grid.wide{grid-template-columns:1fr}
  .span-3,.span-4,.span-6,.span-8,.span-12{grid-column:1/-1}
  .actions{flex-direction:column;align-items:stretch}
  .actions>*{width:100%;flex:auto}
  .btn,button{width:100%}
  .btn.small,button.small{width:auto}
  .table{min-width:620px}
  .table th,.table td{padding:10px}
  .card canvas{height:240px!important}
  .login-shell{width:100%;min-height:auto}
}

@media (max-width:420px){
  .grid:first-of-type{grid-template-columns:1fr}
  .nav a{font-size:13px}
  .nav-label{max-width:95px}
  .user{font-size:13px}
  .table{min-width:560px}
  .card canvas{height:220px!important}
}

@media (min-width:1600px){
  .main{max-width:1780px}
  .grid{grid-template-columns:repeat(auto-fit,minmax(340px,1fr))}
  .grid:first-of-type{grid-template-columns:repeat(5,minmax(210px,1fr))}
}

/* Professional UI polish pass */
:root{
  --surface-glow:rgba(47,125,246,.10);
  --success-glow:rgba(22,163,74,.10);
}
body{background:
  radial-gradient(circle at 18% 8%,rgba(47,125,246,.10),transparent 28%),
  radial-gradient(circle at 82% 12%,rgba(22,163,74,.08),transparent 26%),
  linear-gradient(135deg,#07111f 0%,#0a1423 48%,#07111f 100%);
}
.sidebar{border-right-color:#1d314b}
.sidebar-collapsed .sidebar-toggle{right:-23px;top:18px;width:42px;height:42px;min-height:42px;border-radius:10px;background:#14243b;border-color:#3a5574;z-index:40}
.sidebar-toggle{box-shadow:0 12px 28px rgba(0,0,0,.28)}
.sidebar-toggle:hover{transform:none;filter:brightness(1.12)}
.sidebar-collapsed .sidebar{box-shadow:10px 0 34px rgba(0,0,0,.28)}
.sidebar-collapsed .brand-icon{width:42px;height:42px;font-size:18px}
.nav a{position:relative}
.nav a.active::before{content:"";position:absolute;left:0;top:11px;bottom:11px;width:3px;border-radius:999px;background:#38bdf8}
.sidebar-collapsed .nav a.active::before{left:-7px}
.nav .ico{background:linear-gradient(145deg,#1b2d49,#132238)}
.top{min-height:68px}
.user{box-shadow:0 12px 28px rgba(0,0,0,.18)}
.main>h1:first-child{font-size:clamp(30px,3.5vw,44px);letter-spacing:.2px;margin-bottom:20px}
.main>h1:first-child::after{content:"";display:block;width:54px;height:4px;border-radius:999px;background:linear-gradient(90deg,#38bdf8,#22c55e);margin-top:12px}
.card{position:relative;background:
  linear-gradient(180deg,rgba(17,29,48,.96),rgba(12,22,38,.98));
  border-color:#29415f;
}
.card::before{content:"";position:absolute;inset:0;border-radius:inherit;pointer-events:none;background:linear-gradient(135deg,rgba(255,255,255,.045),transparent 42%)}
.card:hover{border-color:#3b5f86;box-shadow:0 22px 55px rgba(0,0,0,.30)}
.grid:first-of-type .card{min-height:132px;display:flex;flex-direction:column;justify-content:space-between}
.grid:first-of-type .card h3{display:flex;align-items:center;gap:10px;color:#dcecff;font-size:18px;margin-bottom:14px}
.grid:first-of-type .card h3::before{width:34px;height:34px;border-radius:9px;display:grid;place-items:center;background:#14243b;border:1px solid #31506f;color:#dbeafe;font-size:16px;box-shadow:inset 0 0 0 1px rgba(255,255,255,.04)}
.grid:first-of-type .card:nth-child(1) h3::before{content:"✓"}
.grid:first-of-type .card:nth-child(2) h3::before{content:"€"}
.grid:first-of-type .card:nth-child(3) h3::before{content:"⚒"}
.grid:first-of-type .card:nth-child(4) h3::before{content:"👥"}
.grid:first-of-type .card:nth-child(5) h3::before{content:"📦"}
.grid:first-of-type .kpi{margin-top:auto;text-shadow:0 2px 18px rgba(56,189,248,.12)}
.grid:first-of-type .muted{margin-top:6px;color:#aec3dc}
.card-head h3{display:flex;align-items:center;gap:10px}
.status-pill{box-shadow:inset 0 0 0 1px rgba(255,255,255,.04)}
.storage-meter,.progress{box-shadow:inset 0 0 0 1px rgba(255,255,255,.04)}
.storage-numbers div,.mini-stats span{background:rgba(13,23,40,.78)}
.table-wrap{box-shadow:0 16px 36px rgba(0,0,0,.20)}
.table th{font-size:12px;text-transform:uppercase;letter-spacing:.03em}
.table td{color:#e6effa}
input,select,textarea{transition:border-color .16s ease,box-shadow .16s ease,background .16s ease}
input:hover,select:hover,textarea:hover{border-color:#466485}
.btn,button{letter-spacing:.01em}
.btn.blue,button.blue{background:linear-gradient(135deg,#2f7df6,#2563eb)}
.btn.gray,button.gray{background:linear-gradient(135deg,#334155,#263445)}
.btn.red,button.red{background:linear-gradient(135deg,#dc2626,#b91c1c)}
.notice{box-shadow:0 14px 30px rgba(34,197,94,.10)}
.error{box-shadow:0 14px 30px rgba(239,68,68,.12)}
.login-box,.login-shell{border-color:#34506f}

@media (min-width:901px){
  .sidebar-collapsed .main{padding-left:clamp(28px,3vw,48px)}
  .main{padding-top:clamp(22px,2.4vw,42px)}
}

@media (min-width:901px) and (max-width:1080px){
  .grid:first-of-type{grid-template-columns:repeat(2,minmax(0,1fr))}
  .grid:first-of-type .card:nth-child(5){grid-column:1/-1}
  .grid:first-of-type .card{min-height:124px}
}

@media (min-width:1180px){
  .grid:first-of-type{grid-template-columns:repeat(5,minmax(0,1fr))}
}

@media (max-height:780px) and (min-width:901px){
  .top{min-height:58px}
  .grid:first-of-type .card{min-height:112px}
  .grid:first-of-type .card h3::before{width:30px;height:30px}
}

@media (max-width:900px){
  .main>h1:first-child::after{margin-top:10px}
  .nav a.active::before{display:none}
  .top{min-height:auto}
}

@media (max-width:680px){
  .grid:first-of-type .card:nth-child(5){grid-column:1/-1}
  .grid:first-of-type .card h3::before{width:28px;height:28px}
  .grid:first-of-type .card{min-height:104px}
}

/* Final multi-screen square desktop and chart correction */
.chart-card{min-height:auto!important}
.chart-wrap{position:relative;width:100%;height:clamp(220px,30vh,320px);min-height:220px}
.chart-wrap canvas{width:100%!important;height:100%!important;max-height:none!important}
.card:has(.chart-wrap){min-height:auto!important}

@media (min-width:901px){
  .main{min-width:0}
  .grid:first-of-type{
    display:grid;
    grid-template-columns:repeat(auto-fit,minmax(150px,1fr))!important;
    gap:clamp(10px,1.2vw,16px)!important;
  }
  .grid:first-of-type .card{
    min-height:118px!important;
    padding:clamp(12px,1.2vw,17px)!important;
  }
  .grid:first-of-type .card h3{
    font-size:clamp(13px,1.35vw,17px)!important;
    margin-bottom:8px!important;
  }
  .grid:first-of-type .card h3::before{
    width:30px!important;
    height:30px!important;
    flex:0 0 30px!important;
  }
  .grid:first-of-type .kpi{
    font-size:clamp(22px,2.4vw,32px)!important;
    line-height:1.05!important;
  }
  .grid:first-of-type .muted{
    font-size:clamp(11px,1vw,13px)!important;
    line-height:1.35!important;
  }
}

@media (min-width:901px) and (max-width:1120px){
  :root{--sidebar-closed:70px}
  .main{padding-left:24px!important;padding-right:18px!important}
  .top{padding-left:24px!important;padding-right:18px!important}
  .grid:not(:first-of-type){
    grid-template-columns:repeat(2,minmax(0,1fr))!important;
    gap:14px!important;
  }
  .storage-card,.chart-card{
    grid-column:auto!important;
  }
  .security-card,.card:has(.table-wrap){
    grid-column:1/-1!important;
  }
  .chart-wrap{height:240px;min-height:220px}
  .storage-numbers{grid-template-columns:repeat(3,minmax(0,1fr))!important}
  .storage-numbers div,.mini-stats span{padding:9px!important}
  .mini-stats{grid-template-columns:1fr!important}
  .card{padding:16px!important}
}

@media (min-width:901px) and (max-width:1120px) and (max-height:820px){
  .main{padding-top:16px!important}
  .top{position:static!important;margin-top:-16px!important;margin-bottom:16px!important;min-height:54px!important}
  .main>h1:first-child{font-size:30px!important;margin-bottom:14px!important}
  .main>h1:first-child::after{height:3px;margin-top:8px}
  .grid{margin-bottom:14px!important}
  .grid:first-of-type .card{min-height:98px!important}
  .grid:first-of-type .card h3::before{display:none!important}
  .chart-wrap{height:220px!important;min-height:200px!important}
  .card h3{font-size:17px!important;margin-bottom:10px!important}
  .kpi{font-size:26px!important}
}

@media (min-width:1121px) and (max-width:1360px){
  .grid:not(:first-of-type){
    grid-template-columns:repeat(auto-fit,minmax(280px,1fr))!important;
  }
  .chart-wrap{height:280px}
}

@media (max-width:900px){
  .chart-wrap{height:260px}
  .grid:first-of-type{grid-template-columns:repeat(auto-fit,minmax(145px,1fr))!important}
}

@media (max-width:560px){
  .chart-wrap{height:230px}
  .grid:first-of-type{grid-template-columns:1fr 1fr!important}
}

@media (max-width:400px){
  .grid:first-of-type{grid-template-columns:1fr!important}
  .chart-wrap{height:220px}
}


/* Customer portal */
.portal-public-page{display:block;padding:clamp(14px,3vw,34px)}
.portal-shell{width:min(1120px,100%);margin:0 auto;display:grid;gap:18px}
.portal-hero{background:linear-gradient(135deg,rgba(16,34,59,.98),rgba(13,22,38,.98))}
.portal-brand{display:flex;align-items:center;gap:14px;margin-bottom:18px}
.portal-brand img{width:64px;height:64px;object-fit:contain;background:white;border-radius:8px;padding:6px}
.portal-chat{display:grid;gap:10px;margin-bottom:14px}
.portal-msg{max-width:78%;border:1px solid var(--line);border-radius:8px;padding:10px 12px;background:#0d1728}
.portal-msg.support{margin-left:auto;background:#123f2a;border-color:#256d43}
.portal-msg span{display:block;color:var(--muted);font-size:12px}
.portal-form{display:grid;gap:10px}
.portal-qr{width:92px;height:92px;background:white;border-radius:8px;padding:5px}
@media(max-width:680px){.portal-msg{max-width:100%}.portal-brand{align-items:flex-start}.portal-qr{width:74px;height:74px}}

/* Portal dashboard summary */
.portal-dashboard-card .card-title-row{display:flex;align-items:center;justify-content:space-between;gap:12px;margin-bottom:14px}
.badge-soft{display:inline-flex;align-items:center;border:1px solid var(--border,#203a5c);border-radius:999px;padding:5px 10px;color:var(--muted,#9fb5cf);font-weight:800;font-size:12px;background:rgba(255,255,255,.04)}
.badge-soft.ok{color:#adffd3;border-color:rgba(46,204,113,.45);background:rgba(46,204,113,.13)}
.dashboard-kpi-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:10px;margin:10px 0 14px}
.dashboard-kpi-grid>div{border:1px solid var(--border,#203a5c);border-radius:8px;padding:12px;background:rgba(255,255,255,.03)}
.dashboard-kpi-grid span{display:block;color:var(--muted,#9fb5cf);font-size:12px;margin-bottom:6px}
.dashboard-kpi-grid strong{font-size:24px}
@media (max-width:560px){.dashboard-kpi-grid{grid-template-columns:1fr}.portal-dashboard-card .btn{width:100%;justify-content:center}}

/* Paid module and protected gallery states */
.module-locked{display:grid;grid-template-columns:auto 1fr;gap:18px;align-items:flex-start;background:linear-gradient(135deg,rgba(17,35,59,.98),rgba(13,22,38,.98));border:1px solid #365273;border-radius:8px;padding:24px;box-shadow:var(--shadow);max-width:760px}
.module-locked h2{margin:0 0 8px}
.module-locked-icon{width:44px;height:44px;border-radius:8px;display:grid;place-items:center;background:#123f2a;border:1px solid #22c55e;color:#bbf7d0;font-weight:900;font-size:22px}
.module-inline-lock{border:1px solid #365273;background:#101e34;color:#dbeafe;border-radius:8px;padding:12px 14px;margin:12px 0}
.gallery-grid{display:flex;flex-wrap:wrap;gap:16px;margin-top:18px}
.protected-media{-webkit-touch-callout:none}
@media(max-width:560px){.module-locked{grid-template-columns:1fr}.module-locked-icon{width:40px;height:40px}}
