* { box-sizing: border-box; }
body { margin: 0; font-family: system-ui, sans-serif; background: #f3f4f6; color: #111827; }
.bar { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; background: #111827; color: #fff; }
.bar a, .bar .link { color: #fff; margin-left: 16px; }
.inline { display: inline; }
.card { max-width: 420px; margin: 24px auto; padding: 24px; background: #fff; border-radius: 8px; }
h1 { font-size: 1.4rem; margin-top: 0; }
label { display: block; margin-bottom: 6px; }
input[name="code"] { width: 100%; font-size: 1.5rem; letter-spacing: 0.3em; padding: 12px; margin-bottom: 12px; }
button { width: 100%; min-height: 48px; font-size: 1rem; border: 0; border-radius: 6px; background: #2563eb; color: #fff; margin: 6px 0; }
button[disabled] { background: #9ca3af; }
button.link { width: auto; min-height: 0; background: none; text-decoration: underline; margin: 0 0 0 16px; padding: 0; }
.notice { background: #eff6ff; padding: 10px; border-radius: 6px; }
.error { background: #fef2f2; color: #991b1b; padding: 10px; border-radius: 6px; }
a { color: #2563eb; }

/* Fleet grid (phase 3) */
main.wide { max-width: none; margin: 16px; padding: 16px; background: #fff; border-radius: 8px; }
.bar nav a:first-child { margin-left: 0; }
.toolbar { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.toolbar label { display: inline; margin: 0; }
.banner { background: #fffbeb; color: #92400e; padding: 10px; border-radius: 6px; margin-bottom: 12px; }
.fleet { display: flex; flex-wrap: wrap; gap: 16px 24px; align-items: flex-start; }
.store { flex: 0 1 auto; }
.store h2 { font-size: 1rem; margin: 0 0 8px; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, 180px); gap: 8px; }
.tile { display: block; width: 180px; background: #1f2937; color: #e5e7eb; border-radius: 8px; overflow: hidden; text-decoration: none; }
.tile:hover { outline: 2px solid #9ca3af; }
.tile.problem:hover { outline-color: #dc2626; }
.tile canvas { display: block; width: 180px; height: auto; background: #222; }
.tile.offline canvas { filter: grayscale(1); opacity: .5; }
.cap { display: flex; align-items: center; gap: 6px; padding: 5px 8px; font-size: 12px; }
.cap .name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cap .ago { margin-left: auto; color: #9ca3af; white-space: nowrap; font-size: 11px; }
.dot { width: 8px; height: 8px; border-radius: 50%; flex: none; background: #6b7280; display: inline-block; }
.dot.on { background: #2fbf71; }
.dot.off { background: #dc2626; }
.ago.stale { color: #e0a526; }
.ago.label { color: #f87171; }
.summary { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.summary .sum-btn { width: auto; min-height: 32px; margin: 0; padding: 4px 12px; font-size: .9rem; background: #e5e7eb; color: #111827; border: 1px solid #d1d5db; }
.summary .sum-btn.active { background: #1f2937; color: #fff; border-color: #1f2937; }
.tile.problem { outline: 2px solid #dc2626; outline-offset: -2px; }
.tile .ctl { display: block; color: inherit; text-decoration: none; }
.namerow { padding: 0 8px; font-size: 12px; }
.namerow .info, .list li .info { color: #93c5fd; text-decoration: underline; }
.namerow .name { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.badges { display: flex; flex-wrap: wrap; gap: 4px; padding: 2px 8px 6px; }
.badges:empty { padding: 0; }
.list li { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; }
.list li.problem { border-left: 4px solid #dc2626; }
.list li a.ctl { flex: 1 1 60%; }
.list li .info { color: #2563eb; font-size: 13px; padding: 0 8px; }
.list li .badges { flex: 1 1 100%; padding: 0 8px 8px; }
.list { list-style: none; margin: 0; padding: 0; display: none; }
.list li { border-bottom: 1px solid #e5e7eb; }
.list li a { display: flex; align-items: center; gap: 10px; padding: 14px 8px; color: inherit; text-decoration: none; }
.list li .ago { margin-left: auto; color: #6b7280; font-size: 12px; }
.list li .ago.label { color: #dc2626; }
@media (max-width: 600px), (pointer: coarse) and (max-width: 950px) {
  .tiles { display: none; }
  .list { display: block; }
  .fleet { display: block; }
  main.wide { margin: 8px; padding: 8px; }
}

/* Remote-control viewer (03-08) */
.vbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 8px; }
.dim { color: #667; font-size: 12px; }
/* Fit the remote screen to the window: both max-* with auto size keeps the aspect ratio, so
   MeshCentral's canvas.width/clientWidth mouse scaling stays exact (no object-fit letterboxing). */
#Desk { max-width: 100%; max-height: calc(100vh - 96px); width: auto; height: auto; margin: 0 auto; background: #000; display: block; cursor: default; touch-action: pinch-zoom; }
main.wide:has(#viewer) { margin: 8px; padding: 8px; }
.vh { position: absolute; left: -9999px; width: 1px; height: 1px; opacity: 0; }
.vdialog { position: fixed; left: 50%; top: 20%; transform: translateX(-50%); background: #fff; border: 1px solid #999; border-radius: 8px; padding: 16px; z-index: 10; }
[hidden] { display: none !important; }
#status { font-weight: 600; }
.vdialog button, .vdialog a { margin: 4px 4px 0 0; }
.vdialog textarea { display: block; width: min(480px, 80vw); }
.vbar button, .vbar select { width: auto; min-height: 32px; margin: 0; padding: 4px 12px; font-size: .9rem; }
.vbar #disconnect { background: #b91c1c; }
.vbar .vhint { margin-left: auto; }
@media (max-width: 600px), (pointer: coarse) and (max-width: 950px) {
  .vbar .vhint { display: none; }
}

/* PC detail page (04-10) */
.badge { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 12px; background: #e5e7eb; color: #111827; }
.badge-ok { background: #dcfce7; color: #166534; }
.badge-bad { background: #fee2e2; color: #991b1b; }
.badge-warn { background: #fef3c7; color: #92400e; }
.badge-neutral { background: #e0e7ff; color: #3730a3; }
.kv { border-collapse: collapse; margin: 12px 0; }
.kv th { text-align: left; font-weight: 600; padding: 6px 16px 6px 0; vertical-align: top; white-space: nowrap; }
.kv td { padding: 6px 0; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0; }
.actions form { margin: 0; }
.actions button, .btn { width: auto; min-width: 140px; min-height: 44px; padding: 0 16px; display: inline-flex; align-items: center; justify-content: center; border-radius: 6px; background: #2563eb; color: #fff; text-decoration: none; border: 0; font-size: 1rem; margin: 0; }
.btn-danger, .actions button.btn-danger { background: #b91c1c; }
button.btn-danger { background: #b91c1c; }
@media (max-width: 600px) {
  .actions { flex-direction: column; }
  .actions button, .btn { width: 100%; }
  .kv th { white-space: normal; }
}

/* Terminal console (04-12) */
.notice { padding: 8px 12px; background: #fef3c7; color: #92400e; border-radius: 6px; }
.term-out { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 13px; background: #0b1020; color: #e5e7eb; padding: 12px; border-radius: 6px; min-height: 240px; max-height: 70vh; overflow: auto; white-space: pre-wrap; word-break: break-all; margin: 8px 0; }
.term-form { display: flex; gap: 8px; align-items: center; }
.term-form input[type=text] { flex: 1; font-family: ui-monospace, Menlo, Consolas, monospace; margin: 0; }
.term-form button { width: auto; min-height: 44px; margin: 0; padding: 0 16px; }
@media (max-width: 600px) {
  .term-form { flex-direction: column; align-items: stretch; }
  .term-form button, .term-form input[type=text] { width: 100%; }
}

/* File browser (04-13) */
.files-bar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.files-bar button { width: auto; min-height: 44px; margin: 0; padding: 0 16px; }
.files-path { font-family: ui-monospace, Menlo, Consolas, monospace; word-break: break-all; }
.files-table { width: 100%; border-collapse: collapse; }
.files-table th, .files-table td { text-align: left; padding: 6px 8px; border-bottom: 1px solid #e5e7eb; }
.files-table td button { width: auto; min-height: 36px; margin: 0; padding: 0 12px; }
button.files-link { background: none; border: 0; color: #1d4ed8; text-decoration: underline; padding: 0; min-height: 36px; width: auto; cursor: pointer; text-align: left; }
#files-progress { width: 100%; height: 14px; }
@media (max-width: 600px) {
  .files-hide { display: none; }
  .files-bar button { width: 100%; }
}
#inst-progress { width: 100%; height: 14px; }
.inst-table code { word-break: break-all; }
#inst input[type="text"] { width: 100%; }

/* Push (04-15) */
.store-set { margin: 8px 0; border: 1px solid #e5e7eb; border-radius: 6px; }
.pc-pick { display: block; margin: 4px 0; }
.push-table .badge { white-space: nowrap; }
.push-table pre { white-space: pre-wrap; word-break: break-all; max-height: 40vh; overflow: auto; }
