:root,
html[data-theme="light"] {
  --bg-page: #f4f6f8;
  --bg-surface: #ffffff;
  --bg-subtle: #f8fafc;
  --border-color: #dce1e7;
  --border-strong: #c4cdd5;
  --text-primary: #1e293b;
  --text-secondary: #475569;
  --text-muted: #64748b;
  --accent: #1d4ed8;
  --accent-hover: #1e40af;
  --link-color: #1d4ed8;
  --ok-bg: #dcfce7;
  --ok-text: #166534;
  --ok-border: #bbf7d0;
  --warn-bg: #fef9c3;
  --warn-text: #854d0e;
  --warn-border: #fde047;
  --err-bg: #fee2e2;
  --err-text: #991b1b;
  --err-border: #fecaca;
  --bar-track: #e2e8f0;
  --bar-fill: #2563eb;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05);
}

html[data-theme="dark"] {
  --bg-page: #0f141c;
  --bg-surface: #18202c;
  --bg-subtle: #1e2938;
  --border-color: #2b384b;
  --border-strong: #3b4c63;
  --text-primary: #f1f5f9;
  --text-secondary: #cbd5e1;
  --text-muted: #94a3b8;
  --accent: #3b82f6;
  --accent-hover: #2563eb;
  --link-color: #60a5fa;
  --ok-bg: rgba(22, 163, 74, 0.18);
  --ok-text: #86efac;
  --ok-border: rgba(22, 163, 74, 0.35);
  --warn-bg: rgba(202, 138, 4, 0.18);
  --warn-text: #fde047;
  --warn-border: rgba(202, 138, 4, 0.35);
  --err-bg: rgba(220, 38, 38, 0.2);
  --err-text: #fca5a5;
  --err-border: rgba(220, 38, 38, 0.4);
  --bar-track: #2b384b;
  --bar-fill: #3b82f6;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background-color: var(--bg-page);
  color: var(--text-primary);
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

.hidden {
  display: none !important;
}

.print-only {
  display: none;
}

code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 12px;
  background: var(--bg-subtle);
  padding: 2px 5px;
  border-radius: 4px;
  border: 1px solid var(--border-color);
}

/* Login */
.login-wrapper {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.login-box {
  width: 100%;
  max-width: 380px;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 28px 24px;
  box-shadow: var(--shadow-sm);
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 22px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border-color);
}

.brand-logo {
  width: 42px;
  height: 42px;
  object-fit: contain;
}

.login-titles h1 {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
}

.login-titles span {
  font-size: 12px;
  color: var(--text-muted);
}

.form-group {
  margin-bottom: 14px;
}

.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 5px;
}

.form-group input {
  width: 100%;
  padding: 9px 11px;
  font-size: 16px; /* evita zoom automático no iOS/Android */
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  background: var(--bg-surface);
  color: var(--text-primary);
}

.form-group input:focus {
  outline: 2px solid var(--accent);
  outline-offset: -1px;
}

.alert-error {
  background: var(--err-bg);
  color: var(--err-text);
  border: 1px solid var(--err-border);
  padding: 9px 11px;
  border-radius: 6px;
  font-size: 13px;
  margin-bottom: 14px;
}

/* Botões */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 36px;
  padding: 0 13px;
  font-size: 13px;
  font-weight: 500;
  border-radius: 6px;
  cursor: pointer;
  border: 1px solid transparent;
  white-space: nowrap;
  text-decoration: none;
  font-family: inherit;
}

.btn-block {
  width: 100%;
  height: 40px;
  font-weight: 600;
}

.btn-primary {
  background: var(--accent);
  color: #ffffff;
}

.btn-primary:hover {
  background: var(--accent-hover);
}

.btn-default {
  background: var(--bg-surface);
  color: var(--text-primary);
  border-color: var(--border-strong);
}

.btn-default:hover {
  background: var(--bg-subtle);
}

.btn-link {
  background: transparent;
  color: var(--text-secondary);
  padding: 0 10px;
}

.btn-link:hover {
  color: var(--text-primary);
  text-decoration: underline;
}

/* Header */
.app-header {
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-color);
}

.header-inner {
  max-width: 1320px;
  margin: 0 auto;
  padding: 12px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-logo-sm {
  width: 34px;
  height: 34px;
  object-fit: contain;
}

.header-title-block h1 {
  font-size: 16px;
  font-weight: 700;
}

.header-status-line {
  font-size: 12px;
  color: var(--text-secondary);
}

.header-controls {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.update-info {
  font-size: 12px;
  color: var(--text-muted);
}

.btn-group {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

/* Dropdown de exportação */
.dropdown {
  position: relative;
}

.dropdown-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 4px);
  min-width: 200px;
  background: var(--bg-surface);
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.12);
  z-index: 50;
  padding: 4px;
}

.dropdown-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 8px 10px;
  font-size: 13px;
  background: transparent;
  color: var(--text-primary);
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-family: inherit;
}

.dropdown-item:hover {
  background: var(--bg-subtle);
}

/* Conteúdo Principal */
.main-content {
  max-width: 1320px;
  margin: 0 auto;
  padding: 20px;
}

/* Faixa de Resumo */
.summary-strip {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  margin-bottom: 18px;
}

.summary-item {
  padding: 14px 16px;
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.summary-item:last-child {
  border-right: none;
}

.summary-label {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
}

.summary-value {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
}

.summary-note {
  font-size: 12px;
  color: var(--text-secondary);
}

/* Abas */
.filter-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 18px;
  border-bottom: 1px solid var(--border-color);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.tab-item {
  padding: 9px 14px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  white-space: nowrap;
  font-family: inherit;
}

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

/* Blocos de seção */
.section-block {
  margin-bottom: 28px;
}

.section-title-bar {
  margin-bottom: 12px;
}

.section-title-bar h2 {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 2px;
}

.section-title-bar p {
  font-size: 13px;
  color: var(--text-secondary);
}

/* Barras de recurso da VPS */
.resource-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 14px;
}

.resource-cell {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 12px 14px;
}

.resource-head {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 8px;
}

.bar-bg {
  width: 100%;
  height: 7px;
  background: var(--bar-track);
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 6px;
}

.bar-fill {
  height: 100%;
  background: var(--bar-fill);
  transition: width 0.3s ease;
}

.resource-cell small {
  font-size: 12px;
  color: var(--text-muted);
}

/* Tabelas */
.tables-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.table-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  overflow: hidden;
}

.table-card-header {
  padding: 11px 14px;
  background: var(--bg-subtle);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.table-card-header h3 {
  font-size: 14px;
  font-weight: 600;
}

.table-card-header span {
  font-size: 12px;
  color: var(--text-muted);
}

.table-responsive {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 13px;
}

.data-table th {
  padding: 9px 12px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-color);
  background: var(--bg-surface);
  white-space: nowrap;
}

.data-table td {
  padding: 9px 12px;
  border-bottom: 1px solid var(--border-color);
  vertical-align: middle;
}

.data-table tr:last-child td {
  border-bottom: none;
}

.cell-title {
  font-weight: 600;
  color: var(--text-primary);
}

.cell-sub {
  display: block;
  font-size: 11px;
  color: var(--text-muted);
}

.domain-link {
  color: var(--link-color);
  text-decoration: none;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 12px;
  white-space: nowrap;
}

.domain-link:hover {
  text-decoration: underline;
}

.mono-val {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 12px;
  color: var(--text-secondary);
  white-space: nowrap;
}

.status-tag {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 4px;
  border: 1px solid transparent;
  white-space: nowrap;
}

.status-tag.online {
  background: var(--ok-bg);
  color: var(--ok-text);
  border-color: var(--ok-border);
}

.status-tag.offline {
  background: var(--err-bg);
  color: var(--err-text);
  border-color: var(--err-border);
}

.status-tag.warning {
  background: var(--warn-bg);
  color: var(--warn-text);
  border-color: var(--warn-border);
}

.mini-bar-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 90px;
}

.mini-bar {
  flex: 1;
  height: 6px;
  background: var(--bar-track);
  border-radius: 3px;
  overflow: hidden;
}

.mini-bar-fill {
  height: 100%;
  background: var(--bar-fill);
}

/* Toast de aviso */
.toast {
  position: fixed;
  bottom: 20px;
  right: 20px;
  background: #1e293b;
  color: #ffffff;
  padding: 10px 16px;
  border-radius: 6px;
  font-size: 13px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
  z-index: 100;
}

/* Responsividade (Tablet e Mobile) */
@media (max-width: 992px) {
  .summary-strip {
    grid-template-columns: repeat(2, 1fr);
  }
  .summary-item:nth-child(2) {
    border-right: none;
  }
  .summary-item:nth-child(1),
  .summary-item:nth-child(2) {
    border-bottom: 1px solid var(--border-color);
  }
  .tables-grid {
    grid-template-columns: 1fr;
  }
  .resource-row {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .header-inner {
    padding: 12px 14px;
    flex-direction: column;
    align-items: stretch;
  }
  .header-controls {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }
  .update-info {
    display: block;
  }
  .btn-group {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
  }
  .btn-group .dropdown {
    width: 100%;
  }
  .btn-group .dropdown .btn {
    width: 100%;
  }
  .main-content {
    padding: 12px;
  }
  .summary-strip {
    grid-template-columns: 1fr 1fr;
  }
  .summary-value {
    font-size: 17px;
  }
  .data-table th,
  .data-table td {
    padding: 8px 10px;
    font-size: 12px;
  }
}

/* Estilo para Impressão / Exportar PDF */
@media print {
  body {
    background: #ffffff !important;
    color: #000000 !important;
  }
  .no-print {
    display: none !important;
  }
  .print-only {
    display: block !important;
    margin-bottom: 16px;
    padding-bottom: 10px;
    border-bottom: 2px solid #000;
  }
  #section-vps,
  #section-shared {
    display: block !important;
    page-break-inside: avoid;
  }
  .main-content {
    max-width: 100%;
    padding: 0;
  }
  .tables-grid {
    grid-template-columns: 1fr;
  }
  .table-card,
  .resource-cell,
  .summary-strip {
    box-shadow: none !important;
    border: 1px solid #ccc !important;
  }
}
