/* ── Reset & Base ───────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:       #0e0e14;
  --surface:  #16161f;
  --surface2: #1e1e2a;
  --border:   #2b2b3c;
  --text:     #dde1f0;
  --muted:    #7a7f99;
  --green:    #22c55e;
  --yellow:   #f59e0b;
  --red:      #ef4444;
  --blue:     #4f8ef7;
  --radius:   10px;
  --shadow:   0 2px 12px rgba(0,0,0,.45);
}

html { font-size: 15px; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: ui-monospace, 'Cascadia Code', 'Fira Code', monospace;
  min-height: 100vh;
}
a { color: inherit; text-decoration: none; }
code { font-family: inherit; }

/* ── Header ─────────────────────────────────────────────────────── */
header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 1.5rem;
  position: sticky;
  top: 0;
  z-index: 10;
}
.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .9rem 0 .5rem;
  gap: 1rem;
}
h1 {
  font-size: 1.15rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: .55rem;
  color: var(--text);
}
.icon-logo {
  width: 1.25rem;
  height: 1.25rem;
  color: var(--blue);
  flex-shrink: 0;
}
.back-link {
  display: flex;
  align-items: center;
  color: var(--muted);
  transition: color .15s;
}
.back-link:hover { color: var(--blue); }
.back-link .icon-logo { width: 1.3rem; height: 1.3rem; }

.stats {
  font-size: .82rem;
  color: var(--muted);
  white-space: nowrap;
}
.refresh-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .3rem 0 .7rem;
  font-size: .78rem;
  color: var(--muted);
}
.btn-refresh {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: .25rem .7rem;
  border-radius: 5px;
  cursor: pointer;
  font-family: inherit;
  font-size: .78rem;
  transition: background .15s;
}
.btn-refresh:hover { background: var(--border); }

/* ── Main ────────────────────────────────────────────────────────── */
main {
  max-width: 1300px;
  margin: 0 auto;
  padding: 1.5rem 1.5rem 4rem;
}

/* ── Badge ───────────────────────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: .15em .55em;
  border-radius: 4px;
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
}
.badge.green  { background: rgba(34,197,94,.15);  color: var(--green); }
.badge.yellow { background: rgba(245,158,11,.15); color: var(--yellow); }
.badge.red    { background: rgba(239,68,68,.15);  color: var(--red); }

/* ── Group Sections ──────────────────────────────────────────────── */
.group-section {
  margin-bottom: 2rem;
}
.group-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .5rem 0 .6rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: .9rem;
}
.group-title {
  display: flex;
  align-items: center;
  gap: .5rem;
  font-size: .9rem;
  font-weight: 600;
}
.group-icon {
  width: 1rem;
  height: 1rem;
  color: var(--blue);
  flex-shrink: 0;
}
.group-path-dim  { color: var(--muted); font-weight: 400; }
.group-path-bold { color: var(--text); }
.group-domain-link {
  font-size: .72rem;
  font-weight: 500;
  color: var(--blue);
  text-decoration: none;
  background: color-mix(in srgb, var(--blue) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--blue) 35%, transparent);
  border-radius: 5px;
  padding: .2rem .6rem;
  white-space: nowrap;
  transition: background .15s;
}
.group-domain-link:hover {
  background: color-mix(in srgb, var(--blue) 22%, transparent);
}
.group-meta {
  font-size: .78rem;
  color: var(--muted);
}

/* ── Overview Grid ───────────────────────────────────────────────── */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
  display: flex;
  flex-direction: column;
  gap: .5rem;
  transition: border-color .15s, box-shadow .15s, transform .1s;
  cursor: pointer;
}
.card:hover {
  border-color: var(--blue);
  box-shadow: var(--shadow);
  transform: translateY(-2px);
}

.card-top {
  display: flex;
  align-items: center;
  gap: .55rem;
}
.card-name {
  font-weight: 600;
  font-size: .95rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.card-image {
  font-size: .8rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.card-meta {
  display: flex;
  justify-content: space-between;
  font-size: .75rem;
  color: var(--muted);
  margin-top: .25rem;
}
.card-ports {
  font-family: inherit;
  letter-spacing: .02em;
}

/* ── Detail Sections ─────────────────────────────────────────────── */
.detail-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 1.25rem;
  overflow: hidden;
}
.detail-section h2 {
  font-size: .8rem;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--muted);
  padding: .6rem 1.1rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface2);
}
.detail-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .85rem;
}
.detail-table th,
.detail-table td {
  padding: .55rem 1.1rem;
  text-align: left;
  vertical-align: top;
  border-bottom: 1px solid var(--border);
}
.detail-table tr:last-child th,
.detail-table tr:last-child td { border-bottom: none; }
.detail-table th {
  color: var(--muted);
  font-weight: 400;
  white-space: nowrap;
  width: 9rem;
}
.detail-table td code {
  word-break: break-all;
}

/* Mount table */
.mount-table th,
.mount-table td { width: auto; }
.mount-src {
  color: var(--muted);
  word-break: break-all;
  max-width: 14rem;
}

.tag {
  display: inline-block;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: .05em .4em;
  font-size: .75rem;
  color: var(--muted);
}
.red-tag { color: var(--red); border-color: rgba(239,68,68,.3); }

/* ── States ──────────────────────────────────────────────────────── */
.loading, .error {
  padding: 2rem;
  text-align: center;
  color: var(--muted);
}
.error { color: var(--red); }

/* ── Login page ──────────────────────────────────────────────────── */
.login-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
}
.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2.5rem 2rem;
  width: 100%;
  max-width: 360px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.25rem;
}
.login-logo svg {
  width: 2.5rem;
  height: 2.5rem;
  color: var(--blue);
}
.login-title {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text);
}
.login-card form {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: .9rem;
}
.field {
  display: flex;
  flex-direction: column;
  gap: .35rem;
}
.field label {
  font-size: .78rem;
  color: var(--muted);
  letter-spacing: .04em;
  text-transform: uppercase;
}
.field input {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-family: inherit;
  font-size: .9rem;
  padding: .55rem .75rem;
  outline: none;
  transition: border-color .15s;
}
.field input:focus { border-color: var(--blue); }
.login-card button[type="submit"] {
  margin-top: .25rem;
  background: var(--blue);
  border: none;
  border-radius: 6px;
  color: #fff;
  cursor: pointer;
  font-family: inherit;
  font-size: .9rem;
  font-weight: 600;
  padding: .6rem;
  transition: opacity .15s;
}
.login-card button[type="submit"]:hover  { opacity: .85; }
.login-card button[type="submit"]:disabled { opacity: .5; cursor: default; }
.login-error {
  font-size: .82rem;
  color: var(--red);
  text-align: center;
}

/* ── Toggle label ────────────────────────────────────────────────── */
.toggle-label {
  display: flex;
  align-items: center;
  gap: .45rem;
  font-size: .85rem;
  color: var(--text);
  cursor: pointer;
  user-select: none;
}
.toggle-label input[type="checkbox"] {
  accent-color: var(--blue);
  width: 1rem;
  height: 1rem;
}

/* ── Add button ──────────────────────────────────────────────────── */
.btn-add {
  background: var(--blue);
  border: none;
  border-radius: 6px;
  color: #fff;
  cursor: pointer;
  font-family: inherit;
  font-size: .82rem;
  font-weight: 600;
  padding: .35rem .85rem;
  transition: opacity .15s;
}
.btn-add:hover    { opacity: .85; }
.btn-add:disabled { opacity: .5; cursor: default; }

/* ── Modal ───────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}
.modal-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  width: 100%;
  max-width: 360px;
  box-shadow: var(--shadow);
}

/* ── Logout button ───────────────────────────────────────────────── */
.btn-logout {
  background: none;
  border: 1px solid var(--border);
  color: var(--muted);
  padding: .2rem .65rem;
  border-radius: 5px;
  cursor: pointer;
  font-family: inherit;
  font-size: .78rem;
  transition: color .15s, border-color .15s;
}
.btn-logout:hover { color: var(--red); border-color: var(--red); }
