* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: #0b1020;
  color: #e7e9f0;
  font-family: "Segoe UI", system-ui, -apple-system, Arial, sans-serif;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  -webkit-text-size-adjust: 100%;
  touch-action: manipulation;
}

/* Fönstret fyller alltid hela skärmen (fullscreen) oavsett storlek. */
.win {
  width: 100%;
  height: 100vh;
  height: 100dvh;
  background: #11182e;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}
.titlebar {
  flex-shrink: 0;
  display: flex; align-items: center; gap: 8px;
  padding: 11px 16px;
  background: #0e1429;
  border-bottom: 1px solid #263255;
  font-size: 14px; color: #aeb6cc;
}
.dot { width: 12px; height: 12px; border-radius: 50%; display: inline-block; }
.dot.red { background: #e24b4a; } .dot.amber { background: #ef9f27; } .dot.green { background: #1d9e75; }
.title { margin-left: 8px; }

.tools {
  flex-shrink: 0;
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 9px 14px;
  border-bottom: 1px solid #1c2748;
}
.subtools { background: #0e1429; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 38px; min-width: 38px; padding: 0 12px;
  background: #1a2444; color: #e7e9f0;
  border: 1px solid #2c3a66; border-radius: 8px;
  font-size: 14px; cursor: pointer; touch-action: manipulation;
}
.btn:hover:not(:disabled) { background: #243056; }
.btn:active:not(:disabled) { background: #2c3a66; }
.btn:disabled { opacity: .4; cursor: default; }
.checkbtn { gap: 8px; cursor: pointer; }
.checkbtn input { margin: 0; width: 18px; height: 18px; }

.addr {
  flex: 1 1 200px; display: flex; align-items: center; flex-wrap: wrap; gap: 1px;
  min-height: 38px; padding: 3px 12px;
  background: #0b1020; border: 1px solid #2c3a66; border-radius: 8px;
  font-size: 14px; overflow: hidden;
}
.crumb { cursor: pointer; color: #9fb0d8; padding: 4px 6px; border-radius: 5px; }
.crumb:hover { background: #1a2444; color: #fff; }
.crumb.last { color: #fff; }
.sep { color: #5a678f; padding: 0 1px; }

.search {
  flex-shrink: 0;
  width: 200px; height: 38px; padding: 0 12px;
  background: #0b1020; color: #e7e9f0;
  border: 1px solid #2c3a66; border-radius: 8px; font-size: 14px;
}

.body { display: flex; flex: 1 1 auto; min-height: 0; }
.side {
  width: 210px; flex-shrink: 0;
  border-right: 1px solid #1c2748; padding: 12px 10px; font-size: 14px;
  overflow-y: auto; -webkit-overflow-scrolling: touch;
}
.sgroup { color: #61709a; font-size: 12px; margin: 10px 6px 4px; }
.sitem {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 10px; border-radius: 7px; color: #c4cce4; cursor: pointer;
}
.sitem:hover { background: #1a2444; color: #fff; }
.sitem:active { background: #1f2c52; color: #fff; }
.sitem.active { background: #1f2c52; color: #fff; }

.main {
  flex: 1 1 auto; min-width: 0; padding: 14px;
  overflow-y: auto; -webkit-overflow-scrolling: touch;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr));
  grid-auto-rows: min-content; gap: 6px; align-content: start;
}
.item {
  display: flex; flex-direction: column; align-items: center; gap: 7px;
  padding: 14px 8px; border-radius: 9px; cursor: pointer; text-align: center;
  border: 1px solid transparent; user-select: none; touch-action: manipulation;
}
.item:hover { background: #1a2444; }
.item.sel { background: #1f3a66; border-color: #3d6bb0; }
.ic { font-size: 38px; line-height: 1; }
.nm { font-size: 13px; line-height: 1.3; color: #dfe4f2; word-break: break-word; }
.item.hidden .ic, .item.hidden .nm { opacity: .45; }
.empty { grid-column: 1 / -1; color: #61709a; font-size: 14px; padding: 30px; text-align: center; }
.respath { font-size: 11px; color: #61709a; }

.status {
  flex-shrink: 0;
  display: flex; justify-content: space-between; gap: 12px;
  padding: 8px 16px; border-top: 1px solid #1c2748;
  font-size: 13px; color: #8b96b8;
}

.modal {
  display: none; position: absolute; inset: 0;
  background: rgba(4,8,20,.7); align-items: center; justify-content: center; padding: 24px;
}
.card {
  background: #131b34; border: 1px solid #2c3a66; border-radius: 11px;
  width: 100%; max-width: 480px; max-height: 80%; overflow: hidden;
  display: flex; flex-direction: column;
}
.cardhead {
  flex-shrink: 0;
  display: flex; justify-content: space-between; align-items: center;
  padding: 11px 14px; border-bottom: 1px solid #2c3a66; font-size: 14px;
}
.cardbody {
  padding: 16px; font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 14px; color: #c4cce4; white-space: pre-wrap; line-height: 1.6;
  overflow: auto; -webkit-overflow-scrolling: touch;
}
.proprow { display: flex; justify-content: space-between; gap: 16px; padding: 6px 0; }
.proprow .k { color: #8b96b8; }
.proprow .v { color: #e7e9f0; text-align: right; word-break: break-word; }
.restorebtn { margin-top: 6px; }

/* iPad-porträtt och smalare: krymp sidopanel och sökruta så toppraden får plats. */
@media (max-width: 860px) {
  .side { width: 180px; }
  .search { width: 150px; }
  .main { grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); }
}

/* Liggande mobil / liten surfplatta. */
@media (max-width: 620px) {
  .side { width: 150px; font-size: 13px; }
  .search { width: 100%; flex: 1 1 100%; }
  .main { grid-template-columns: repeat(auto-fill, minmax(88px, 1fr)); }
  .ic { font-size: 34px; }
}

/* Stående mobil: minimera sidopanelen så filytan får plats. */
@media (max-width: 460px) {
  .side { width: 118px; padding: 10px 6px; }
  .sgroup { margin: 8px 4px 4px; }
  .sitem { gap: 7px; padding: 9px 7px; }
  .main { grid-template-columns: repeat(auto-fill, minmax(78px, 1fr)); padding: 10px; gap: 4px; }
  .item { padding: 11px 5px; }
  .ic { font-size: 30px; }
  .nm { font-size: 12px; }
  .modal { padding: 12px; }
  .card { max-height: 88%; }
}

/* Touchenheter (iPad/surfplattor): större tryckytor och kryssrutor. */
@media (pointer: coarse) {
  .btn, .search, select#sort { height: 44px; }
  .addr { min-height: 44px; }
  .checkbtn input { width: 20px; height: 20px; }
  .sitem { padding: 12px 10px; }
}
