/* ===== DASHBOARD LAYOUT ===== */
#dashboard-view {
  flex-direction: column;
  min-height: 100vh;
  padding: 2rem;
  max-width: 960px;
  margin: 0 auto;
  width: 100%;
}

/* --- Header --- */
.header {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.5rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--border);
}

.header img {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 2px solid var(--accent);
  flex-shrink: 0;
}

.header h1 {
  font-size: 1.3rem;
  font-weight: 700;
  color: #fff;
}

.header-title {
  min-width: 0;
}

.header .tag {
  font-size: 0.8rem;
  color: var(--text-dim);
}

.header-meta {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 0;
}

.header .status {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.85rem;
  color: var(--green);
  white-space: nowrap;
}

.header .status::before {
  content: '';
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--green);
  flex-shrink: 0;
}

/* --- Health Badge --- */
.health-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.85rem;
  font-weight: 600;
  white-space: nowrap;
  color: var(--text-dim);
  cursor: default;
}

.health-badge::before {
  content: '';
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
  transition: background 0.3s;
}

.health-badge.ok {
  color: var(--green);
}

.health-badge.ok::before {
  background: var(--green);
}

.health-badge.fail {
  color: var(--red);
}

.health-badge.fail::before {
  background: var(--red);
}

.health-badge.checking {
  color: var(--yellow);
}

.health-badge.checking::before {
  background: var(--yellow);
}

.version-link {
  color: var(--text-dim);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.35rem 0.6rem;
  font-size: 0.78rem;
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
  transition: all 0.2s;
}

.version-link:hover {
  color: var(--accent);
  border-color: var(--accent);
}

.version-link.update-available {
  color: var(--yellow);
  border-color: rgba(245, 158, 11, 0.4);
  background: rgba(245, 158, 11, 0.12);
}

.version-link.update-available:hover {
  color: var(--yellow);
  border-color: rgba(245, 158, 11, 0.65);
}

.version-refresh {
  width: 2rem;
  height: 2rem;
  display: inline-grid;
  place-items: center;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  transition: all 0.2s;
}

.version-refresh:hover:not(:disabled) {
  color: var(--accent);
  border-color: var(--accent);
}

.version-refresh:disabled {
  cursor: wait;
  opacity: 0.55;
}

/* --- Logout --- */
.btn-logout {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-dim);
  padding: 0.4rem 0.85rem;
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.2s;
  margin-left: 0.75rem;
  white-space: nowrap;
  flex-shrink: 0;
}

.btn-logout:hover {
  border-color: var(--red);
  color: var(--red);
}

/* --- Tabs --- */
.tabs {
  display: flex;
  gap: 0;
  margin-bottom: 1.5rem;
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.tabs::-webkit-scrollbar {
  display: none;
}

.tab-btn {
  padding: 0.65rem 1.25rem;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-dim);
  font-size: 0.9rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.tab-btn:hover {
  color: var(--text);
}

.tab-btn.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

/* --- Stats Grid --- */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  margin-bottom: 1rem;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  transition: border-color 0.2s;
}

.card:hover {
  border-color: var(--border-hover);
}

.card .label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-dim);
  margin-bottom: 0.4rem;
  font-weight: 600;
}

.card .value {
  font-size: 1.6rem;
  font-weight: 700;
  color: #fff;
}

.card .sub {
  font-size: 0.8rem;
  color: var(--accent);
  margin-top: 0.2rem;
}

/* --- Budget Bar --- */
.budget-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-bottom: 1.5rem;
}

.budget-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 0.6rem;
}

.budget-header .label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-dim);
  font-weight: 600;
}

.budget-header .amount {
  font-size: 0.85rem;
  color: var(--text);
}

.budget-bar {
  width: 100%;
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
}

.budget-bar .fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.5s ease, background 0.3s;
  background: var(--green);
  min-width: 0;
}

.budget-bar .fill.warning {
  background: var(--yellow);
}

.budget-bar .fill.danger {
  background: var(--red);
}

.budget-details {
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
  color: var(--text-dim);
  margin-top: 0.4rem;
}

/* --- Operations Panel --- */
.operations-panel {
  margin-bottom: 1.5rem;
}

.operations-header {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: flex-start;
  margin-bottom: 1rem;
}

.operations-header h2 {
  font-size: 1rem;
  color: var(--text);
}

.operations-mode {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}

.operations-mode-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-dim);
  font-weight: 600;
}

.operations-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.75rem;
}

.operations-card {
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.9rem;
  transition: border-color 0.2s;
}

.operations-card:hover {
  border-color: var(--border-hover);
}

.operations-card-header {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  align-items: center;
  margin-bottom: 0.75rem;
}

.operations-card h3 {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text);
  overflow-wrap: anywhere;
}

.operations-pill {
  display: inline-flex;
  align-items: center;
  min-height: 1.4rem;
  max-width: 100%;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.15rem 0.5rem;
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--text-dim);
  white-space: nowrap;
}

.operations-pill.ok {
  border-color: var(--green);
  color: var(--green);
}

.operations-pill.warn {
  border-color: var(--yellow);
  color: var(--yellow);
}

.operations-pill.danger {
  border-color: var(--red);
  color: var(--red);
}

.operations-pill.muted {
  color: var(--text-dim);
}

.operations-metrics {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.55rem 0.75rem;
}

.operations-metric {
  min-width: 0;
}

.operations-metric-label {
  display: block;
  margin-bottom: 0.15rem;
  font-size: 0.68rem;
  color: var(--text-dim);
}

.operations-metric strong {
  display: block;
  font-size: 1rem;
  color: #fff;
}

.operations-card-sub {
  margin-top: 0.75rem;
  padding-top: 0.7rem;
  border-top: 1px solid var(--border);
  font-size: 0.75rem;
  line-height: 1.4;
  color: var(--text-dim);
}

.operations-guidance {
  display: grid;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.operations-guidance:empty {
  display: none;
}

.operations-guidance-item {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.65rem 0.75rem;
  font-size: 0.78rem;
  color: var(--text-dim);
}

.operations-guidance-item strong {
  color: var(--text);
}

.operations-guidance-item.warning {
  border-color: var(--yellow);
}

.operations-guidance-item.critical {
  border-color: var(--red);
}

/* --- Per-Server Budget Overview Items --- */
.guild-budget-overview-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.45rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.8rem;
}

.guild-budget-overview-item:last-child {
  border-bottom: none;
}

.gbo-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text);
  font-weight: 500;
}

.gbo-tag {
  font-size: 0.6rem;
  color: var(--text-dim);
  background: var(--border);
  padding: 0.1rem 0.35rem;
  border-radius: 3px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  vertical-align: middle;
  margin-left: 0.25rem;
}

.gbo-cost {
  font-size: 0.75rem;
  color: var(--text-dim);
  white-space: nowrap;
}

.gbo-limit {
  font-size: 0.7rem;
  color: var(--text-dim);
  opacity: 0.6;
}

.gbo-bar {
  width: 60px;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
  flex-shrink: 0;
}

.gbo-bar .fill {
  height: 100%;
  background: var(--green);
  border-radius: 2px;
  transition: width 0.3s ease;
}

.gbo-bar .fill.warning {
  background: var(--yellow);
}

.gbo-bar .fill.danger {
  background: var(--red);
}

.gbo-exceeded {
  font-size: 0.6rem;
  font-weight: 700;
  color: var(--red);
  letter-spacing: 0.04em;
  white-space: nowrap;
}

/* --- Bar Chart --- */
.bar-chart {
  display: flex;
  align-items: flex-end;
  gap: 3px;
  height: 80px;
  padding: 0 1.25rem 0.5rem;
}

.bar-chart .bar {
  flex: 1;
  min-width: 8px;
  background: var(--accent);
  border-radius: 3px 3px 0 0;
  transition: height 0.3s;
  cursor: pointer;
  position: relative;
  opacity: 0.7;
}

.bar-chart .bar:hover {
  opacity: 1;
}

.bar-chart .bar:hover::after {
  content: attr(data-tip);
  position: absolute;
  bottom: calc(100% + 4px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  font-size: 0.65rem;
  white-space: nowrap;
  color: var(--text);
  z-index: 10;
}

/* --- Log Filters --- */
.log-filters {
  display: flex;
  gap: 0.5rem;
  padding: 0 1.25rem 0.5rem;
  overflow-x: auto;
}

.log-filter-btn {
  padding: 0.3rem 0.75rem;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-dim);
  font-size: 0.75rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.log-filter-btn:hover {
  border-color: var(--border-hover);
  color: var(--text);
}

.log-filter-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.log-row-error td {
  background: rgba(240, 71, 71, 0.04);
}

.log-detail-cell,
.log-error-text {
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.log-error-text {
  color: var(--text);
}

.log-suggestion {
  margin-top: 0.2rem;
  max-width: 260px;
  color: var(--text-dim);
  font-size: 0.72rem;
  line-height: 1.35;
}

.log-diagnostics {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  align-items: center;
  min-width: 150px;
}

.log-diagnostic-badge {
  display: inline-flex;
  align-items: center;
  min-height: 1.4rem;
  max-width: 100%;
  padding: 0.1rem 0.4rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-dim);
  font-size: 0.68rem;
  font-weight: 600;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.prefs-tools {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  margin: 0.75rem 0 1rem;
}

.prefs-tools input {
  flex: 1;
  min-width: 0;
  padding: 0.65rem 0.85rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-family: inherit;
  font-size: 0.9rem;
  outline: none;
  appearance: none;
  -webkit-appearance: none;
  transition: border-color 0.2s, background 0.2s;
}

.prefs-tools input:focus {
  border-color: var(--accent);
  background: var(--surface);
}

.prefs-tools input::placeholder {
  color: var(--text-dim);
}

.user-prefs-table th:first-child,
.user-prefs-table td:first-child {
  width: 2.5rem;
}

.user-prefs-table th:last-child,
.user-prefs-table td:last-child {
  width: 1%;
  white-space: nowrap;
}

.user-prefs-table .mono {
  overflow-wrap: anywhere;
}
