body {
  background:
    radial-gradient(circle at 82% 4%, rgba(64, 194, 255, .13), transparent 31%),
    radial-gradient(circle at 18% 82%, rgba(117, 77, 255, .12), transparent 34%),
    linear-gradient(145deg, #080b10, #090c13 48%, #0a0d15);
}
body::before { content: ""; position: fixed; inset: 0; z-index: -1; pointer-events: none; opacity: .18; background-image: linear-gradient(rgba(132,153,255,.08) 1px, transparent 1px), linear-gradient(90deg, rgba(132,153,255,.08) 1px, transparent 1px); background-size: 42px 42px; mask-image: linear-gradient(to bottom, black, transparent 72%); }
.sidebar { background: linear-gradient(180deg, rgba(15,20,30,.96), rgba(9,14,21,.98) 58%, rgba(13,17,26,.98)); box-shadow: 14px 0 42px #0003; }
.main > header { position: sticky; top: 0; z-index: 5; background: rgba(8,12,18,.72); backdrop-filter: blur(16px); }
.tile, .panel, .empty { position: relative; overflow: hidden; background: linear-gradient(145deg, rgba(19,29,41,.96), rgba(12,18,25,.96)); box-shadow: 0 10px 28px #0003, inset 0 1px rgba(255,255,255,.025); }
.tile::before { content: ""; position: absolute; inset: 0 14% auto; height: 1px; background: linear-gradient(90deg, transparent, rgba(128,104,255,.8), transparent); opacity: .65; }
.tile:nth-child(1) { background: linear-gradient(145deg, rgba(47,188,215,.12), #10161e 42%, #0d1219); }
.tile:nth-child(2) { background: linear-gradient(145deg, rgba(113,78,240,.14), #10161e 45%, #0d1219); }
.tile:nth-child(3) { background: linear-gradient(145deg, rgba(46,210,151,.11), #10161e 43%, #0d1219); }
.tile.wide { grid-column: span 2; }
.tile.layout-hidden:not(.editing-preview) { display: none; }
.tile-editor { display: none; flex-wrap: wrap; gap: 5px; margin-top: 12px; padding-top: 10px; border-top: 1px dashed #4d4190; }
.editing .tile-editor { display: flex; }
.editing .tile { border-style: dashed; border-color: #51449a; }
.layout-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; padding: 10px 12px; border: 1px dashed #5f4dc4; border-radius: 10px; color: #bbb1f4; background: #17132a; font-size: 11px; }
.security-warning { padding: 9px 10px; border: 1px solid #583143; border-radius: 8px; color: #ffadc1 !important; background: #24131b; }
.badge.starting { color: #9dd9ff; background: #102433; }
.badge.recovering { color: #d6c1ff; background: #211936; }
.badge.waiting { color: #f0d28b; background: #2b2414; }
.audit-actions { margin-top: 0; }
.audit-actions label { display: flex; align-items: center; gap: 7px; color: #83949e; font-size: 10px; }
.audit-actions select { padding: 7px 9px; border: 1px solid #2a3744; border-radius: 8px; color: #dce6e9; background: #10171f; }
.button.primary { background: linear-gradient(135deg, #6f52f3, #4c37cf); box-shadow: 0 6px 20px rgba(92,65,226,.18); }
.console-button { border-color: #315d68; color: #a3efff; background: #0f2228; }
.console-dialog-body { width: min(760px, calc(100vw - 30px)); }
.console-title { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.console-title h2 { margin: 0; }
.console-output { min-height: 270px; max-height: 48vh; overflow: auto; margin: 18px 0 10px; padding: 15px; border: 1px solid #263645; border-radius: 10px; color: #9cf0c7; background: #070b0f; font: 12px/1.6 ui-monospace, SFMono-Regular, Consolas, monospace; white-space: pre-wrap; }
.console-form { display: grid; grid-template-columns: 1fr auto; gap: 8px; }
.secondary-heading { margin-top: 26px; }
.service-link { display: flex; align-items: center; gap: 8px; }
.file-picker { cursor: pointer; }
.upload-progress { margin-bottom: 12px; padding: 12px 14px; border: 1px solid #315466; border-radius: 11px; background: #0d1c24; }
.upload-progress-head { display: flex; justify-content: space-between; gap: 12px; margin-bottom: 8px; color: #a9dce8; font-size: 11px; }
.upload-progress-track { height: 6px; overflow: hidden; border-radius: 999px; background: #142934; }
.upload-progress-track span { display: block; width: 0; height: 100%; border-radius: inherit; background: linear-gradient(90deg, #5f48e7, #38cfd2); transition: width .18s ease; }
.file-actions { display: flex; justify-content: flex-end; gap: 7px; }
.files-empty { padding: 26px 10px; color: #7e909b; text-align: center; }
.metric-tile { cursor: pointer; transition: transform .18s ease, border-color .18s ease, box-shadow .18s ease; }
.metric-tile:hover { transform: translateY(-2px); border-color: #3a4960; box-shadow: 0 16px 34px #0005, inset 0 1px rgba(255,255,255,.035); }
.metric-tile .actions { position: relative; z-index: 2; }
.metric-summary { display: grid; grid-template-columns: minmax(100px, .9fr) minmax(150px, 1.25fr); gap: 14px; min-height: 112px; margin-top: 15px; padding-top: 13px; border-top: 1px solid #202c37; }
.metric-placeholder { grid-column: 1 / -1; display: grid; place-items: center; min-height: 90px; color: #718390; font-size: 11px; }
.core-section { min-width: 0; }
.metric-label { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; color: #738794; font-size: 9px; }
.metric-label strong { color: #bfeef2; font-size: 12px; }
.core-bars { display: flex; align-items: stretch; justify-content: center; gap: 5px; height: 76px; }
.core-bar { position: relative; flex: 1 1 12px; max-width: 22px; overflow: hidden; border: 1px solid #253746; border-radius: 5px 5px 3px 3px; background: linear-gradient(180deg, #111a23, #0b1117); }
.core-bar::after { content: ""; position: absolute; inset: 25% 0 auto; height: 1px; background: #31404c88; box-shadow: 0 19px #31404c88, 0 38px #31404c88; }
.core-bar i { position: absolute; inset: auto 2px 2px; z-index: 1; border-radius: 3px 3px 1px 1px; background: #4dd9dd; box-shadow: 0 0 12px #4acfd855; transition: height .35s ease, background .35s ease, box-shadow .35s ease; }
.metric-resource-list { display: grid; align-content: center; gap: 9px; min-width: 0; }
.metric-resource { padding: 8px 9px; border: 1px solid #23303c; border-radius: 8px; background: rgba(9,15,21,.55); }
.metric-resource > div:first-child, .storage-metric-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; color: #718591; font-size: 9px; }
.metric-resource strong, .storage-metric-head strong { color: #dbe9ec; font-size: 10px; text-align: right; }
.metric-resource small { display: block; margin-top: 4px; color: #667984; font-size: 8px; text-align: right; }
.metric-load-track { height: 6px; overflow: hidden; margin-top: 7px; border-radius: 999px; background: #162530; }
.metric-load-track.large { height: 9px; margin: 9px 0 11px; }
.metric-load-track i { display: block; width: 0; height: 100%; border-radius: inherit; background: #4dd9dd; transition: width .35s ease, background .35s ease, box-shadow .35s ease; }
.metric-values { display: grid; align-content: center; gap: 9px; }
.metric-values > div { display: grid; grid-template-columns: 1fr auto; gap: 2px 8px; padding: 8px 9px; border: 1px solid #23303c; border-radius: 8px; background: rgba(9,15,21,.55); }
.metric-values span { color: #718591; font-size: 9px; }
.metric-values strong { color: #dbe9ec; font-size: 10px; text-align: right; }
.metric-values small { grid-column: 1 / -1; color: #667984; font-size: 8px; text-align: right; }
.process-metrics { display: grid; align-content: center; gap: 10px; }
.process-row { display: grid; grid-template-columns: 28px minmax(50px,1fr) 34px; align-items: center; gap: 7px; color: #748894; font-size: 9px; }
.process-row strong { color: #cce7ea; text-align: right; }
.mini-track { height: 7px; overflow: hidden; border-radius: 999px; background: #162530; }
.mini-track i { display: block; height: 100%; border-radius: inherit; background: #4dd9dd; transition: width .35s ease, background .35s ease, box-shadow .35s ease; }
.storage-metric-summary { display: block; }
.storage-metric { min-width: 0; }
.storage-metric-head { margin-bottom: 2px; }
.live-indicator { color: #68dca9; white-space: nowrap; }
.live-indicator i { display: inline-block; width: 6px; height: 6px; margin: 0 4px 1px 6px; border-radius: 50%; background: #4de0a2; box-shadow: 0 0 9px #4de0a2; animation: live-pulse 1.8s ease-in-out infinite; }
@keyframes live-pulse { 50% { opacity: .35; transform: scale(.75); } }
.transfer-meta { display: flex; justify-content: space-between; gap: 12px; margin-top: 8px; color: #78909c; font-size: 10px; }
.transfer-panel { margin-bottom: 12px; }
.transfer-panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.transfer-panel-head p { margin: 3px 0 0; color: #718390; font-size: 10px; }
.transfers-list { display: grid; gap: 8px; }
.transfer-row { padding: 10px 11px; border: 1px solid #243443; border-radius: 9px; background: #0c141b; }
.transfer-row-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 7px; font-size: 11px; }
.transfer-row-head div { min-width: 0; }
.transfer-row-head strong { display: block; overflow: hidden; color: #dbe8eb; text-overflow: ellipsis; white-space: nowrap; }
.transfer-row-head span { color: #79909c; font-size: 9px; }
.transfer-row-status { display: flex; flex: 0 0 auto; align-items: center; gap: 8px; }
.transfer-action { min-height: 25px; padding: 4px 8px; font-size: 9px; }
.transfer-empty { padding: 10px 0 2px; color: #70818d; font-size: 10px; text-align: center; }
.metrics-dialog-body { width: min(900px, calc(100vw - 30px)); }
.metrics-controls { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.metrics-range { display: flex; gap: 5px; }
.metrics-range .button, #metrics-reset-view { min-height: 30px; padding: 6px 10px; font-size: 9px; }
.metrics-range .button.selected { border-color: #7965ee; color: #eeeaff; background: linear-gradient(135deg, #5b47d0, #4234a4); box-shadow: 0 0 16px rgba(104,82,232,.18); }
.chart-hint { flex: 1 1 240px; color: #718590; font-size: 9px; text-align: right; }
.metrics-current { display: grid; grid-template-columns: repeat(3,1fr); gap: 9px; margin: 18px 0 10px; }
.metrics-current > div { padding: 10px 12px; border: 1px solid #253542; border-radius: 9px; background: #0b1218; }
.metrics-current span { display: block; color: #718590; font-size: 9px; }
.metrics-current strong { display: block; margin-top: 4px; color: #dce9ec; font-size: 18px; }
.chart-wrap { position: relative; height: min(42vh,360px); min-height: 250px; padding: 10px; border: 1px solid #263645; border-radius: 11px; background: linear-gradient(180deg,#091016,#080c11); }
.chart-wrap canvas { display: block; width: 100%; height: 100%; cursor: crosshair; touch-action: none; }
.chart-wrap canvas.dragging { cursor: grabbing; }
.metrics-tooltip { position: absolute; z-index: 3; display: grid; gap: 4px; min-width: 150px; padding: 9px 10px; pointer-events: none; border: 1px solid #344758; border-radius: 8px; color: #a9bac3; background: rgba(7,12,17,.94); box-shadow: 0 12px 30px #0008; backdrop-filter: blur(10px); font-size: 9px; }
.metrics-tooltip.hidden { display: none; }
.metrics-tooltip time { margin-bottom: 2px; color: #e2ebee; font-weight: 700; }
.metrics-tooltip span { display: flex; align-items: center; gap: 5px; }
.metrics-tooltip i { width: 7px; height: 7px; border-radius: 50%; }
.metrics-tooltip strong { margin-left: auto; color: #edf4f5; }
.chart-legend { display: flex; gap: 18px; margin-top: 10px; color: #80929d; font-size: 10px; }
.chart-legend span { display: flex; align-items: center; gap: 6px; }
.chart-legend i { width: 18px; height: 2px; background: #4fd6df; }
.chart-legend i.memory { background: #8c6dff; }
.sessions-panel { max-width: 760px; margin-top: 14px; }
.sessions-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.sessions-heading h3 { margin: 0; font-size: 15px; }
.sessions-heading p { margin: 3px 0 0; color: #718390; font-size: 10px; }
.sessions-list { display: grid; gap: 8px; }
.session-row { display: grid; grid-template-columns: minmax(0,1fr) auto; align-items: center; gap: 12px; padding: 11px 12px; border: 1px solid #243443; border-radius: 9px; background: #0c141b; }
.session-row strong { display: flex; align-items: center; gap: 7px; color: #dce9ec; font-size: 11px; }
.session-row p { margin: 4px 0 0; color: #78909c; font-size: 9px; }
.session-current { color: #76eab5; background: #10261f; }
@media (max-width: 620px) {
  .tile.wide { grid-column: span 1; }
  .layout-toolbar { align-items: flex-start; flex-direction: column; }
  .sidebar nav { display: flex; gap: 5px; overflow-x: auto; padding: 2px 0 5px; scrollbar-width: none; }
  .sidebar nav::-webkit-scrollbar { display: none; }
  .nav-button { flex: 0 0 auto; width: auto; padding: 8px 10px; font-size: 10px; white-space: nowrap; }
  .console-form { grid-template-columns: 1fr; }
  .file-actions { justify-content: flex-start; }
  .metric-summary { grid-template-columns: 1fr; }
  .core-bars { justify-content: flex-start; }
  .core-bar { min-width: 14px; }
  .metrics-current { grid-template-columns: 1fr 1fr; }
  .metrics-controls { align-items: stretch; flex-direction: column; }
  .metrics-range { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); width: 100%; }
  .metrics-range .button, #metrics-reset-view { min-height: 38px; }
  #metrics-reset-view { width: 100%; }
  .chart-hint { flex-basis: auto; text-align: left; line-height: 1.5; }
  .chart-wrap { height: 330px; min-height: 260px; padding: 5px; }
  .transfer-meta { align-items: flex-start; flex-direction: column; gap: 3px; }
  .sessions-heading { align-items: flex-start; flex-direction: column; }
  .session-row { grid-template-columns: 1fr; }
}

/* Dashboard layout editor */
.tile.full { grid-column: 1 / -1; }
.layout-toolbar-actions { display: flex; flex: 0 0 auto; gap: 7px; }
.tile-editor { grid-template-columns: auto minmax(280px, 1fr) auto; align-items: end; gap: 12px; }
.editing .tile-editor { display: grid; }
.editing .tile.layout-hidden.editing-preview { opacity: .58; }
.tile-editor-group { display: grid; gap: 6px; }
.tile-editor-group > span { color: #7f8f9a; font-size: 9px; }
.tile-editor-row, .tile-size-options { display: grid; grid-auto-flow: column; gap: 5px; }
.tile-size-options { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.tile-editor .button { min-height: 34px; padding: 7px 9px; font-size: 10px; }
.tile-size-options .button.selected { border-color: #7660ec; color: #efeaff; background: linear-gradient(135deg, #5c46d4, #4434a9); box-shadow: inset 0 0 0 1px #9d8cff33; }
.tile-hide-button { align-self: end; }

html, body { max-width: 100%; }
body { min-width: 0; overflow-x: hidden; }
.shell, .sidebar, .main, .page { min-width: 0; }

@media (max-width: 800px) {
  .tile.wide, .tile.full { grid-column: 1 / -1; }
}

@media (max-width: 620px) {
  .shell { display: block; width: 100%; max-width: 100%; overflow-x: hidden; }
  .sidebar { width: 100%; max-width: 100%; min-width: 0; overflow: hidden; padding: 13px 10px 9px; }
  .brand { justify-content: flex-start; min-width: 0; padding: 2px 4px; }
  .sidebar nav { width: 100%; max-width: 100%; min-width: 0; scroll-behavior: smooth; scroll-snap-type: x proximity; overscroll-behavior-x: contain; }
  .nav-button { min-height: 39px; padding: 9px 12px; scroll-snap-align: center; }
  .main { width: 100%; max-width: 100%; overflow-x: hidden; }
  .main > header { width: 100%; min-width: 0; gap: 8px; padding: 10px 12px; }
  #page-title { min-width: 0; overflow: hidden; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
  .user-menu { min-width: 0; gap: 6px; }
  #current-user { max-width: 42vw; overflow: hidden; font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
  #logout { flex: 0 0 auto; }
  .notice { margin: 10px 12px 0; }
  .page { width: 100%; max-width: 100%; padding: 14px 12px 24px; overflow-x: hidden; }
  .page-heading { width: 100%; min-width: 0; gap: 10px; margin-bottom: 14px; }
  .page-heading > div { width: 100%; min-width: 0; }
  .page-heading h2 { overflow-wrap: anywhere; font-size: 20px; }
  .page-heading > .button { width: 100%; min-height: 42px; }
  .tile-grid, .account-layout, .user-list { width: 100%; min-width: 0; grid-template-columns: minmax(0, 1fr); }
  .tile, .panel, .empty { width: 100%; min-width: 0; padding: 14px; }
  .tile.wide, .tile.full { grid-column: 1; }
  .tile-head { min-width: 0; }
  .tile-head > :first-child { min-width: 0; overflow-wrap: anywhere; }
  .tile h3 { margin-top: 15px; overflow-wrap: anywhere; font-size: 18px; }
  .tile > .actions, .service-row > .actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); width: 100%; }
  .tile > .actions .button, .service-row > .actions .button { min-width: 0; min-height: 40px; padding-inline: 7px; white-space: normal; }
  .service-row { width: 100%; min-width: 0; }
  .service-row > div { width: 100%; min-width: 0; }
  .service-row > .button { width: 100%; min-height: 40px; }
  .layout-toolbar { position: sticky; top: 54px; z-index: 4; width: 100%; min-width: 0; padding: 10px; box-shadow: 0 12px 28px #0008; }
  .layout-toolbar-actions { display: grid; grid-template-columns: 1fr 1fr; width: 100%; }
  .layout-toolbar-actions .button { min-height: 40px; }
  .tile-editor { grid-template-columns: minmax(0, 1fr); width: 100%; }
  .tile-editor .button { min-height: 42px; }
  .tile-editor-row { grid-auto-flow: initial; grid-template-columns: 1fr 1fr; }
  .tile-size-options { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .tile-size-options .button { min-width: 0; padding-inline: 5px; font-size: 9px; white-space: normal; }
  .tile-hide-button { width: 100%; }
  .permission-title { align-items: stretch; flex-direction: column; }
  .permission-title > div, .permission-title > .actions { width: 100%; min-width: 0; }
  .permission-title > .actions { display: grid; grid-template-columns: 1fr 1fr; }
  .permission-title > .actions .button { min-width: 0; white-space: normal; }
  .permission-group, .permission-body, .permission-actions { min-width: 0; }
  .audit-actions { align-items: stretch; flex-direction: column; width: 100%; }
  .audit-actions label, .audit-actions select, .audit-actions .button { width: 100%; max-width: 100%; }
  .table-wrap { width: 100%; max-width: 100%; overflow-x: auto; padding: 4px 0; -webkit-overflow-scrolling: touch; }
  .table-wrap table { width: max-content; min-width: 620px; }
  dialog { max-width: calc(100% - 16px); max-height: calc(100dvh - 16px); overflow: auto; }
  .dialog-body, .console-dialog-body, .metrics-dialog-body { width: 100%; max-width: 100%; padding: 16px; }
  .console-title { align-items: stretch; flex-direction: column; }
  .console-title > .button { width: 100%; }
}

@media (max-width: 400px) {
  #current-user { display: none; }
  .permission-actions { grid-template-columns: minmax(0, 1fr); }
  .tile > .actions, .service-row > .actions { grid-template-columns: minmax(0, 1fr); }
  .metrics-current { grid-template-columns: minmax(0, 1fr); }
}

#reservations-panel { margin-top: 18px; }
#reservations-panel .transfer-meta { flex-wrap: wrap; gap: 8px; }
.upload-progress-head { flex-wrap: wrap; gap: 10px; }
@media (max-width: 620px) {
  #reservations-panel .transfer-panel-head { flex-direction: column; align-items: stretch; gap: 12px; }
  #reservations-panel .transfer-row-head { flex-wrap: wrap; gap: 10px; }
  .transfer-row-status { flex-wrap: wrap; justify-content: flex-end; }
}
