:root {
  /* Windows 95-ish palette */
  --win-bg: #008080;
  --win-surface: #c0c0c0;
  --win-surface-2: #d6d6d6;
  --win-text: #000;
  --win-muted: #404040;
  --win-white: #fff;
  --win-light: #dfdfdf;
  --win-mid: #a0a0a0;
  --win-dark: #808080;
  --win-black: #000;
  --win-title: #000080;
  --win-title-text: #fff;
  --win-danger: #b00000;
  --win-ok: #006400;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
}

body {
  min-height: 100vh;
  background: var(--win-bg);
  color: var(--win-text);
  font-family: "MS Sans Serif", "Microsoft Sans Serif", Tahoma, Verdana, Arial, sans-serif;
  font-size: 14px;
  display: grid;
  place-items: center;
  padding: 18px;
}

/* Window shell */
.window,
.card {
  width: min(980px, 100%);
  background: var(--win-surface);
  color: var(--win-text);
  border: 2px solid var(--win-black);
  box-shadow:
    -1px -1px 0 var(--win-white),
    1px 1px 0 var(--win-dark),
    2px 2px 0 var(--win-black);
}

.titlebar {
  height: 24px;
  display: flex;
  align-items: center;
  padding: 2px 6px;
  background: var(--win-title);
  color: var(--win-title-text);
  user-select: none;
}

.titlebar-text {
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 0.02em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.window-body {
  padding: 14px;
}

.page-title {
  margin: 0 0 8px;
  font-size: 18px;
  font-weight: 700;
}

p {
  margin: 0;
  color: var(--win-muted);
}

/* Forms */
.form-row {
  margin-top: 12px;
  display: grid;
  gap: 10px;
}

label {
  display: block;
  margin: 0 0 6px;
  font-size: 13px;
}

input {
  width: 100%;
  padding: 7px 8px;
  background: var(--win-white);
  color: var(--win-text);
  border: 2px solid var(--win-black);
  box-shadow:
    inset 1px 1px 0 var(--win-dark),
    inset -1px -1px 0 var(--win-white);
  outline: none;
}

input:focus {
  outline: 1px dotted var(--win-black);
  outline-offset: -4px;
}

/* Buttons */
.btn,
button {
  font-family: inherit;
}

.btn {
  margin-top: 6px;
  padding: 6px 12px;
  background: var(--win-surface);
  color: var(--win-text);
  border: 2px solid var(--win-black);
  box-shadow:
    -1px -1px 0 var(--win-white),
    1px 1px 0 var(--win-dark);
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.btn:hover {
  background: var(--win-surface-2);
}

.btn:active {
  box-shadow:
    inset 1px 1px 0 var(--win-dark),
    inset -1px -1px 0 var(--win-white);
}

.btn:focus {
  outline: 1px dotted var(--win-black);
  outline-offset: -4px;
}

.btn.secondary {
  background: var(--win-surface);
}

.btn.tiny {
  margin-top: 0;
  padding: 2px 8px;
  font-size: 12px;
  line-height: 1.2;
  min-height: 0;
}

.btn.port-action {
  background: var(--win-surface);
}

.btn-link {
  text-decoration: none;
}

.row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: end;
}

.actions {
  display: inline-flex;
  gap: 8px;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
}

#adminCreatePortBtn[hidden],
#adminAllTagsBtn[hidden] {
  display: none !important;
}

/* Messages */
.message {
  margin-top: 6px;
  min-height: 18px;
  font-size: 13px;
}

.message.error { color: var(--win-danger); }
.message.ok { color: var(--win-ok); }

/* Panels / groupboxes */
.result,
.history-panel {
  margin-top: 12px;
  padding: 10px;
  background: var(--win-surface);
  border: 2px solid var(--win-black);
  box-shadow:
    inset 1px 1px 0 var(--win-white),
    inset -1px -1px 0 var(--win-dark);
}

.result {
  display: none;
}

.history-title {
  font-weight: 700;
  margin-bottom: 8px;
}

.history-empty {
  color: var(--win-muted);
  font-size: 13px;
}

.history-list {
  display: grid;
  gap: 6px;
}

.history-item {
  width: 100%;
  text-align: left;
  background: var(--win-surface);
  color: var(--win-text);
  border: 2px solid var(--win-black);
  box-shadow:
    -1px -1px 0 var(--win-white),
    1px 1px 0 var(--win-dark);
  padding: 6px 8px;
  cursor: pointer;
  display: grid;
  grid-template-columns: auto auto 1fr;
  gap: 8px;
  align-items: center;
}

.history-item:active {
  box-shadow:
    inset 1px 1px 0 var(--win-dark),
    inset -1px -1px 0 var(--win-white);
}

.history-user {
  font-weight: 700;
}

.history-time {
  text-align: right;
  color: var(--win-muted);
  font-size: 12px;
}

.grid {
  display: grid;
  grid-template-columns: 130px 1fr;
  gap: 8px 12px;
  align-items: start;
}

.port-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.mono {
  font-family: "Lucida Console", "Courier New", monospace;
  word-break: break-all;
}

/* QR */
.qr-grid {
  margin-top: 10px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  align-items: start;
}

.qr-box {
  display: grid;
  justify-items: start;
  gap: 6px;
}

.qr-title {
  font-weight: 700;
  color: var(--win-text);
}

.qr {
  width: 280px;
  max-width: 100%;
  background: var(--win-white);
  padding: 8px;
  border: 2px solid var(--win-black);
  box-shadow:
    inset 1px 1px 0 var(--win-dark),
    inset -1px -1px 0 var(--win-white);
}

.clash-open {
  display: inline-block;
  margin-top: 2px;
  color: var(--win-text);
  text-decoration: underline;
  font-weight: 700;
}

/* Modals */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 14px;
  z-index: 30;
}

.modal.show {
  display: flex;
}

.modal-card {
  width: min(760px, 100%);
  max-height: 92vh;
  overflow: auto;
  background: var(--win-surface);
  border: 2px solid var(--win-black);
  box-shadow:
    -1px -1px 0 var(--win-white),
    1px 1px 0 var(--win-dark),
    2px 2px 0 var(--win-black);
  padding: 12px;
}

.modal-card h2 {
  margin: 0 0 10px;
  font-size: 16px;
}

.modal-close {
  margin: 0 0 10px auto;
  display: block;
  width: auto;
}

.loading-wrap {
  display: grid;
  justify-items: center;
  gap: 10px;
  padding: 8px 0;
}

.spinner {
  width: 34px;
  height: 34px;
  border: 2px solid var(--win-dark);
  border-top-color: var(--win-black);
  border-radius: 50%;
  animation: spin .9s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.hint {
  color: var(--win-muted);
  font-size: 13px;
}

/* Admin lists */
.admin-list,
.admin-users {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

.admin-item {
  width: 100%;
  background: var(--win-surface);
  border: 2px solid var(--win-black);
  box-shadow:
    -1px -1px 0 var(--win-white),
    1px 1px 0 var(--win-dark);
  padding: 8px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
}

.admin-meta {
  display: grid;
  gap: 4px;
}

.admin-line {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: baseline;
}

.admin-label {
  font-weight: 700;
}

.admin-owner {
  color: var(--win-muted);
  font-size: 13px;
}

.admin-port {
  font-family: "Lucida Console", "Courier New", monospace;
}

.icon-btn {
  width: 28px;
  height: 28px;
  display: inline-grid;
  place-items: center;
  border: 2px solid var(--win-black);
  box-shadow:
    -1px -1px 0 var(--win-white),
    1px 1px 0 var(--win-dark);
  background: var(--win-surface);
  color: var(--win-text);
  cursor: pointer;
}

.icon-btn:active {
  box-shadow:
    inset 1px 1px 0 var(--win-dark),
    inset -1px -1px 0 var(--win-white);
}

.user-pick {
  width: 100%;
  text-align: left;
  padding: 8px;
  border: 2px solid var(--win-black);
  box-shadow:
    -1px -1px 0 var(--win-white),
    1px 1px 0 var(--win-dark);
  background: var(--win-surface);
  color: var(--win-text);
  cursor: pointer;
}

.user-pick:active {
  box-shadow:
    inset 1px 1px 0 var(--win-dark),
    inset -1px -1px 0 var(--win-white);
}

/* Toast (simple Win9x-style notice) */
.toast {
  position: fixed;
  left: 50%;
  bottom: 18px;
  transform: translate(-50%, 10px);
  background: var(--win-surface);
  color: var(--win-text);
  padding: 8px 10px;
  border: 2px solid var(--win-black);
  box-shadow:
    -1px -1px 0 var(--win-white),
    1px 1px 0 var(--win-dark),
    2px 2px 0 var(--win-black);
  opacity: 0;
  transition: opacity .15s ease, transform .15s ease;
  pointer-events: none;
  z-index: 50;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

@media (max-width: 860px) {
  body { padding: 14px; }
  .window-body { padding: 12px; }
  .row { grid-template-columns: 1fr; }
  .btn { width: 100%; }
  .grid { grid-template-columns: 1fr; }
  .history-item { grid-template-columns: 1fr; }
  .history-time { text-align: left; }
}

@media (max-width: 430px) {
  body { padding: 10px; }
  .window-body { padding: 10px; }
  input { padding: 7px 8px; }
  .qr { width: 100%; }
  .qr-grid { grid-template-columns: 1fr; }
}

