/* meowhome dark theme — matches existing NAS landing style. */

:root {
  --bg: #0f1117;
  --container: #1a1d26;
  --container-hover: #222631;
  --border: #2a2f3a;
  --text: #e6e6e6;
  --text-muted: #9aa0aa;
  --button: #272b36;
  --button-hover: #323744;
  --accent-red: #ff4d4d;
  --accent-red-hover: #ff6b6b;
  --accent-green: #22c55e;
  --accent-blue: #4f8cff;
  --radius: 10px;
  --radius-sm: 8px;
  --radius-lg: 14px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  font-size: 15px;
  line-height: 1.5;
  min-height: 100vh;
}

a { color: var(--accent-blue); text-decoration: none; }
a:hover { text-decoration: underline; }

nav.topbar {
  border-bottom: 1px solid var(--border);
  background: var(--container);
}
nav.topbar .topbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 1100px;
  margin: 0 auto;
  padding: 16px 24px;
}
nav.topbar h1 { margin: 0; font-size: 18px; font-weight: 600; }
nav.topbar a.logo {
  position: relative;
  display: inline-block;
  color: var(--text);
  text-decoration: none;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin-left: 0;
  padding: 0 22px 0 0;  /* tight room for paw right after the text */
}
nav.topbar a.logo:hover {
  color: var(--text); /* stay white — paw print is the hover affordance */
  text-decoration: none;
}
nav.topbar a.logo::after {
  content: "";
  position: absolute;
  right: 0;
  top: 50%;
  width: 18px;
  height: 18px;
  transform: translate(0, -50%) rotate(8deg);
  background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="%23e6e6e6"><ellipse cx="7" cy="7.5" rx="2.1" ry="2.7"/><ellipse cx="12" cy="4.8" rx="2.1" ry="2.7"/><ellipse cx="17" cy="7.5" rx="2.1" ry="2.7"/><ellipse cx="4.5" cy="13" rx="1.6" ry="2.1"/><ellipse cx="19.5" cy="13" rx="1.6" ry="2.1"/><path d="M12 10.2c-3.4 0-5.6 2.5-5.6 5.2 0 2.4 2.5 4.3 5.6 4.3s5.6-1.9 5.6-4.3c0-2.7-2.2-5.2-5.6-5.2z"/></svg>');
  background-size: contain;
  background-repeat: no-repeat;
  opacity: 0;
  transition: opacity 0.18s ease, transform 0.22s cubic-bezier(.34,1.56,.64,1);
  pointer-events: none;
}
nav.topbar a.logo:hover::after {
  opacity: 1;
  transform: translate(20%, -50%) rotate(14deg);
}
nav.topbar .who { color: var(--text-muted); font-size: 13px; }
nav.topbar .user-menu a { margin-left: 0; color: var(--text); }

/* --- User menu (dropdown) --- */
.user-menu { position: relative; display: inline-block; }
.user-menu summary {
  cursor: pointer;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  color: var(--text);
  list-style: none;
  font-size: 14px;
  user-select: none;
}
.user-menu summary::-webkit-details-marker { display: none; }
.user-menu summary:hover { background: var(--button); }
.user-menu[open] summary { background: var(--button); }
.user-menu summary .role-badge {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 6px;
  background: var(--accent-blue);
  color: white;
  border-radius: 4px;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 500;
  vertical-align: middle;
}
.user-menu ul {
  position: absolute;
  right: 0;
  top: 100%;
  margin: 8px 0 0;
  padding: 6px 0;
  min-width: 200px;
  background: var(--container);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  list-style: none;
  z-index: 100;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
}
.user-menu ul li { margin: 0; padding: 0; }
.user-menu ul li a {
  display: block;
  padding: 10px 16px;
  color: var(--text);
  margin-left: 0;
  text-decoration: none;
  font-size: 13px;
}
.user-menu ul li a:hover { background: var(--button-hover); text-decoration: none; }
.user-menu ul li a.logout-link { color: var(--accent-red); }

main {
  max-width: 1100px;
  margin: 32px auto;
  padding: 0 24px;
}

section { margin-bottom: 40px; }
section h2 { font-size: 16px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.08em; margin-bottom: 18px; }

/* --- Status cards (horizontal label/value layout, 2-up grid for breathing room) --- */
.status-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
  gap: 12px;
}
.status-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 16px;
  background: var(--container);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  min-height: 48px;
}
.status-card .status-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  flex-shrink: 0;
}
.status-card .status-value {
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  text-align: right;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.status-card .status-value small { font-weight: 400; color: var(--text-muted); }

/* --- Mini charts grid (CPU line / RAM line / Network line / Disk pie) --- */
.charts-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-top: 14px;
}
.chart-card {
  background: var(--container);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 6px 8px 8px;  /* tighter so canvas gets more room */
  aspect-ratio: 1 / 1;  /* 麦哥 07-11 13:54: 1:1 square */
  display: flex;
  flex-direction: column;
}
.chart-card--disk {
  justify-content: flex-start;  /* canvas centers via max-width:auto margins */
}
.chart-card .chart-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 2px;
  line-height: 1.2;
}
.chart-card .chart-meta {
  font-size: 11px;
  color: var(--text);
  margin-bottom: 2px;
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
}
.chart-card .legend-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 4px;
  vertical-align: middle;
}
.chart-card canvas {
  flex: 1;
  width: 100% !important;
  height: 100% !important;
  min-height: 0;
  display: block;
}
/* 麦哥 07-11 14:17 — disk pie: shrink radius + thinner ring, card size unchanged */
.chart-card--disk canvas {
  max-width: 68%;
  max-height: 68%;
  margin: auto;
}
.resource { display: flex; align-items: center; gap: 14px; }
.resource label {
  flex-shrink: 0;
  width: 240px;
  font-size: 12px;
  color: var(--text-muted);
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.resource .bar {
  flex: 1;
  height: 8px;
  background: var(--button);
  border: 1px solid var(--border);
  border-radius: 999px;
  overflow: hidden;
}
.resource .bar .fill {
  height: 100%;
  background: var(--accent-blue);
  border-radius: 999px;
  transition: width 0.4s ease;
}
.resource .bar .fill.warn { background: #f59e0b; }
.resource .bar .fill.danger { background: var(--accent-red); }

/* --- Service grid --- */
.service-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 14px;
}
.service-tile {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 18px;
  background: var(--button);
  border-radius: var(--radius);
  color: var(--text);
  text-decoration: none;
  transition: background 0.15s;
  border: 1px solid var(--border);
}
.service-tile:hover { background: var(--button-hover); text-decoration: none; }
.service-tile .icon { font-size: 24px; }
.service-tile .name { font-weight: 500; }

/* --- VPN section --- */
.vpn-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 18px;
}
.vpn-card {
  background: var(--container);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
}
.vpn-card h3 { margin: 0 0 12px; font-size: 16px; }
.vpn-card img { max-width: 160px; height: auto; display: block; margin: 0 auto; background: white; border-radius: var(--radius-sm); padding: 6px; }
.vpn-card .vless {
  margin-top: 12px;
  padding: 8px 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 11px;
  color: var(--text-muted);
  word-break: break-all;
}
.vpn-card button {
  margin-top: 8px;
  width: 100%;
  padding: 8px 12px;
  background: var(--button);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 13px;
}
.vpn-card button:hover { background: var(--button-hover); }

/* --- Downloads (5-column grid, matches services grid, whole block is the link) --- */
.download-list {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 14px;
}
.download-row {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: flex-start;
  padding: 16px 18px;
  background: var(--button);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-decoration: none;
  color: var(--text);
  min-height: 80px;
  transition: background 0.15s, border-color 0.15s, transform 0.12s;
}
.download-row:hover {
  background: var(--button-hover);
  border-color: var(--accent-blue);
  text-decoration: none;
  color: var(--text);
  transform: translateY(-1px);
}
.download-row .os { font-weight: 600; font-size: 14px; }
.download-row .filename { color: var(--text-muted); font-size: 11px; margin-top: 4px; word-break: break-all; line-height: 1.35; }

/* --- Login form --- */
.login-wrap {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 70vh;
}
.login-card {
  background: var(--container);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 32px;
  width: 360px;
}
.login-card h2 { margin-top: 0; }
.login-card label { display: block; margin: 14px 0 4px; color: var(--text-muted); font-size: 13px; }
.login-card input {
  width: 100%;
  padding: 10px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius-sm);
  font-size: 14px;
}
.login-card input:focus { outline: none; border-color: var(--accent-blue); }
.login-card button {
  width: 100%;
  margin-top: 20px;
  padding: 11px;
  background: var(--accent-blue);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
}
.login-card button:hover { background: #3d75e0; }
.error { color: var(--accent-red); font-size: 13px; margin-top: 12px; }

/* --- Admin tables --- */
table.admin-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--container);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
table.admin-table th, table.admin-table td {
  padding: 10px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}
table.admin-table th { background: var(--button); font-size: 12px; text-transform: uppercase; color: var(--text-muted); letter-spacing: 0.08em; }
table.admin-table tr:last-child td { border-bottom: none; }
table.admin-table .actions { display: flex; gap: 8px; }
table.admin-table a, table.admin-table button {
  padding: 5px 10px;
  background: var(--button);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 12px;
  cursor: pointer;
  text-decoration: none;
}
table.admin-table a:hover, table.admin-table button:hover { background: var(--button-hover); }
table.admin-table .danger { color: var(--accent-red); }
table.admin-table form { display: inline; }

a.btn, button.btn {
  display: inline-block;
  padding: 8px 14px;
  background: var(--button);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  cursor: pointer;
  text-decoration: none;
}
a.btn:hover, button.btn:hover { background: var(--button-hover); text-decoration: none; }
a.btn-primary, button.btn-primary { background: var(--accent-blue); border-color: var(--accent-blue); color: white; }
a.btn-primary:hover, button.btn-primary:hover { background: #3d75e0; border-color: #3d75e0; }
a.btn-danger, button.btn-danger { background: var(--accent-red); border-color: var(--accent-red); color: white; }
a.btn-danger:hover, button.btn-danger:hover { background: var(--accent-red-hover); border-color: var(--accent-red-hover); }

.admin-bar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.admin-bar h2 { margin: 0; }

form.admin-form {
  background: var(--container);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  max-width: 600px;
}
form.admin-form label { display: block; margin: 14px 0 4px; color: var(--text-muted); font-size: 13px; }
form.admin-form input[type="text"], form.admin-form input[type="number"], form.admin-form textarea, form.admin-form select {
  width: 100%;
  padding: 9px 11px;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: inherit;
}
form.admin-form textarea { min-height: 90px; resize: vertical; }
form.admin-form input[type="checkbox"] { margin-right: 8px; }
form.admin-form .checkbox-line { display: flex; align-items: center; margin-top: 14px; }
form.admin-form .actions { display: flex; gap: 10px; margin-top: 24px; }

.logout { color: var(--accent-red) !important; }
.logout:hover { color: var(--accent-red-hover) !important; }

.muted { color: var(--text-muted); }
.empty { padding: 24px; text-align: center; color: var(--text-muted); }

/* --- Status / badges (no emoji — text only) --- */
.status-ok { color: #22c55e; font-weight: 500; }
.status-error { color: #ff6b6b; font-weight: 500; }
.badge-ok { color: #22c55e; font-size: 13px; font-weight: 500; }
