:root {
  --brand-primary: #4f8cff;
  --brand-accent: #22c55e;
}

[data-theme="dark"] {
  --bg: #0f1420;
  --surface: #1a2233;
  --surface-2: #232d42;
  --text: #e6ecf5;
  --muted: #8b98b0;
  --border: #2c3650;
}

[data-theme="light"] {
  --bg: #f4f6fb;
  --surface: #ffffff;
  --surface-2: #eef2f9;
  --text: #1a2233;
  --muted: #66738c;
  --border: #d8dfec;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Segoe UI", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 18px; }
.version-badge {
  font-size: 12px; font-weight: 600; color: var(--muted);
  border: 1px solid var(--border); border-radius: 999px;
  padding: 2px 8px; margin-left: 4px;
}
.logo { font-size: 22px; display: inline-flex; align-items: center; }
.logo-img {
  height: 28px;
  width: auto;
  max-width: 120px;
  object-fit: contain;
  display: block;
}
.logo-preview {
  height: 40px;
  width: auto;
  max-width: 160px;
  object-fit: contain;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 4px;
  background: var(--surface-2);
}
.logo-upload-block { display: flex; flex-direction: column; gap: 8px; }
.logo-upload-row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.branding-section-title {
  margin: 12px 0 0;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

.help-menu { position: relative; }
.help-menu-panel {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  min-width: 180px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 6px;
  box-shadow: 0 12px 30px rgba(0,0,0,0.35);
  z-index: 40;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.help-menu-panel a,
.help-menu-panel button {
  display: block;
  width: 100%;
  text-align: left;
  background: transparent;
  border: none;
  color: var(--text);
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 14px;
  cursor: pointer;
  text-decoration: none;
}
.help-menu-panel a:hover,
.help-menu-panel button:hover {
  background: var(--surface-2);
  color: var(--brand-primary);
}
.help-list { margin: 0 0 18px; padding-left: 18px; color: var(--muted); line-height: 1.55; }
.help-list li { margin-bottom: 8px; }
.help-list strong { color: var(--text); }
.vl-modal-card textarea {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  color: var(--text);
  font-size: 15px;
  font-family: inherit;
  resize: vertical;
  min-height: 100px;
}
.topbar-actions { display: flex; align-items: center; gap: 16px; }
#nav a { color: var(--muted); text-decoration: none; margin-left: 16px; font-weight: 500; }
#nav a:hover, #nav a.active { color: var(--brand-primary); }

.container { max-width: 960px; margin: 0 auto; padding: 32px 24px; }

.auth-card {
  max-width: 380px;
  margin: 8vh auto 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 32px;
  box-shadow: 0 20px 50px rgba(0,0,0,0.25);
}

h1 { margin: 0 0 6px; }

.auth-card h1,
.brand-name {
  animation: brand-heading-fade 10s ease-in-out infinite;
}

@keyframes brand-heading-fade {
  0%, 100% { color: var(--brand-primary); }
  33% { color: var(--brand-accent); }
  66% { color: #7dd3fc; }
}

@media (prefers-reduced-motion: reduce) {
  .auth-card h1,
  .brand-name {
    animation: none;
    color: var(--brand-primary);
  }
}
h2 { margin-top: 0; }
.muted { color: var(--muted); }
.error { color: #ef4444; min-height: 18px; margin: 4px 0 0; }

.stack { display: flex; flex-direction: column; gap: 14px; margin-top: 18px; }
label { display: flex; flex-direction: column; gap: 6px; font-size: 14px; color: var(--muted); }

input, select {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  color: var(--text);
  font-size: 15px;
}
input[type="color"] { height: 44px; padding: 4px; }

.primary-btn {
  background: var(--brand-primary);
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 11px 18px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
}
.primary-btn:hover { filter: brightness(1.08); }

.ghost-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 10px;
  padding: 6px 12px;
  cursor: pointer;
  font-size: 16px;
}

.link-btn {
  background: none; border: none; color: var(--brand-primary);
  cursor: pointer; font-size: 14px; padding: 0; margin-right: 10px;
}
.inline-input {
  width: 100%; background: var(--surface-2); border: 1px solid var(--brand-primary);
  border-radius: 8px; padding: 6px 8px; color: var(--text); font-size: 14px;
}
.danger { color: #ef4444; }
.warn { color: #f59e0b; }

.page-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; gap: 16px; }
.upload-btn { display: inline-block; }
.upload-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

.data-table { width: 100%; border-collapse: collapse; margin-top: 16px; }
.data-table th, .data-table td {
  text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); font-size: 14px;
}
.data-table th { color: var(--muted); font-weight: 600; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.panel {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 14px; padding: 22px;
}
.pill {
  display: inline-block; padding: 2px 10px; border-radius: 999px;
  background: var(--surface-2); font-size: 12px; color: var(--brand-accent); font-weight: 600;
}
label.row-inline { flex-direction: row; align-items: center; gap: 8px; }
label.row-inline input { width: auto; }

/* Connection status cards */
.card-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px;
}
.status-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 14px; padding: 18px;
}
.status-card-head {
  display: flex; justify-content: space-between; align-items: baseline;
  margin-bottom: 12px; gap: 8px;
}
.status-user { font-weight: 700; font-size: 16px; }
.status-email { color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; }
.status-row { display: flex; align-items: center; gap: 8px; margin: 8px 0; }
.status-label { font-weight: 600; width: 78px; }
.status-meta { color: var(--muted); font-size: 13px; }
.status-bucket {
  margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--border);
  color: var(--muted); font-size: 13px;
}
.led {
  width: 12px; height: 12px; border-radius: 50%; display: inline-block; flex: 0 0 auto;
  background: var(--muted); box-shadow: 0 0 0 rgba(0,0,0,0);
}
.led-on { background: #22c55e; box-shadow: 0 0 8px #22c55e; }
.led-off { background: #ef4444; box-shadow: 0 0 8px #ef4444; }
.led-idle { background: #6b7280; }

/* Status summary chips */
.status-summary { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 16px; }
.status-chip {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-radius: 999px;
  padding: 8px 14px; cursor: pointer; font-size: 14px; font-weight: 600;
}
.status-chip:hover { border-color: var(--brand-primary); }
.status-chip.active { border-color: var(--brand-primary); background: var(--surface-2); }
.chip-count {
  background: var(--surface-2); border-radius: 999px; padding: 1px 9px;
  font-size: 13px; min-width: 22px; text-align: center;
}
.status-chip.active .chip-count { background: var(--brand-primary); color: #fff; }

.status-toolbar { margin-bottom: 16px; }
.status-toolbar input {
  width: 100%; max-width: 360px;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 10px; padding: 10px 12px; color: var(--text); font-size: 15px;
}

/* Object storage page */
.os-toolbar { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; margin-bottom: 14px; }
.os-toolbar input[type="password"],
.os-toolbar input[type="text"] {
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 10px; padding: 8px 10px; color: var(--text); font-size: 14px;
  min-width: 180px;
}
.led-inline { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); font-size: 14px; }
.os-context { margin: 4px 0 14px; }
.os-context code, .data-table code {
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 6px; padding: 1px 7px; font-size: 13px;
}

.pager { display: flex; align-items: center; gap: 14px; margin-top: 20px; justify-content: center; }
.pager-info { color: var(--muted); font-size: 14px; }
.ghost-btn:disabled { opacity: 0.4; cursor: default; }

/* Passphrase / dialog modal */
.vl-modal {
  position: fixed; inset: 0; z-index: 1000;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.vl-modal[hidden] { display: none !important; }
.vl-modal-backdrop {
  position: absolute; inset: 0;
  background: rgba(8, 12, 20, 0.72);
  backdrop-filter: blur(4px);
}
.vl-modal-card {
  position: relative; z-index: 1;
  width: min(420px, 100%);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 28px 24px 22px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
  animation: vl-modal-in 0.18s ease-out;
}
@keyframes vl-modal-in {
  from { opacity: 0; transform: translateY(10px) scale(0.98); }
  to { opacity: 1; transform: none; }
}
.vl-modal-card h2 { margin: 0 0 8px; font-size: 20px; }
.vl-modal-card .muted { margin: 0 0 16px; font-size: 14px; line-height: 1.45; }
.vl-modal-label { display: flex; flex-direction: column; gap: 6px; font-size: 14px; color: var(--muted); }
.vl-modal-label input {
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 10px; padding: 12px 14px; color: var(--text); font-size: 16px;
}
.vl-modal-label input:focus {
  outline: none; border-color: var(--brand-primary);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand-primary) 28%, transparent);
}
.vl-modal-actions {
  display: flex; flex-wrap: wrap; gap: 10px; justify-content: flex-end;
  margin-top: 20px;
}
.vl-modal-actions .primary-btn { min-width: 110px; }
.vl-modal-actions .ghost-btn { padding: 10px 14px; font-size: 14px; }

.portal-eyebrow {
  text-transform: uppercase; letter-spacing: 0.08em; font-size: 12px;
  font-weight: 700; color: var(--brand-primary); margin: 0 0 8px;
}
.client-portal-card h1 { font-size: 26px; }
.portal-badge {
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em;
  border: 1px solid var(--border); border-radius: 999px;
  padding: 2px 8px; margin-left: 4px; color: var(--muted);
}
.portal-badge-admin {
  color: #fff; background: var(--brand-primary); border-color: var(--brand-primary);
}
.signed-in { font-size: 13px; margin-right: 4px; max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

@media (max-width: 720px) {
  .grid-2 { grid-template-columns: 1fr; }
  .signed-in { display: none; }
}
