/* proxy-ansible web — tối giản, ưu tiên mobile */
:root {
  --bg: #0f1419;
  --surface: #1a222d;
  --border: #2d3a4d;
  --text: #e6edf3;
  --muted: #8b9cb3;
  --accent: #3b82f6;
  --ok: #22c55e;
  --err: #ef4444;
  --warn: #eab308;
  --radius: 10px;
  --space: 1rem;
  font-size: 16px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: system-ui, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  padding: var(--space);
}

a {
  color: var(--accent);
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}

.app-wrap {
  max-width: 52rem;
  margin: 0 auto;
  width: 100%;
}

h1,
h2,
h3 {
  line-height: 1.25;
  font-weight: 600;
  margin: 0 0 var(--space);
}
h1 {
  font-size: clamp(1.35rem, 4vw, 1.6rem);
}
h2 {
  font-size: 1.1rem;
  margin-top: 1.5rem;
  color: var(--muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space);
  margin-bottom: 1.25rem;
  padding-bottom: var(--space);
  border-bottom: 1px solid var(--border);
}

.badge {
  display: inline-block;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}
.badge-ok {
  background: rgba(34, 197, 94, 0.2);
  color: var(--ok);
}
.badge-err {
  background: rgba(239, 68, 68, 0.2);
  color: var(--err);
}
.badge-warn {
  background: rgba(234, 179, 8, 0.2);
  color: var(--warn);
}

.msg {
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  margin: 0 0 var(--space);
  border: 1px solid var(--border);
}
.msg-err {
  color: #fecaca;
  background: rgba(239, 68, 68, 0.12);
  border-color: rgba(239, 68, 68, 0.35);
}
.msg-ok {
  color: #bbf7d0;
  background: rgba(34, 197, 94, 0.12);
  border-color: rgba(34, 197, 94, 0.35);
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  margin-bottom: var(--space);
}

/* Form */
label {
  display: block;
  margin-bottom: 0.35rem;
  color: var(--muted);
  font-size: 0.9rem;
}

input[type="text"],
input[type="password"],
textarea,
select {
  width: 100%;
  max-width: 100%;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
}

input:focus,
textarea:focus,
select:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

button,
.btn {
  display: inline-block;
  padding: 0.6rem 1rem;
  border: none;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  text-align: center;
  text-decoration: none;
}
button:hover,
.btn:hover {
  filter: brightness(1.08);
  text-decoration: none;
}
button.secondary,
.btn.secondary {
  background: var(--border);
  color: var(--text);
}
button.danger,
.btn.danger {
  background: #b91c1c;
}

/* Nút restart / thao tác hay dùng */
button.btn-cta,
.btn.btn-cta {
  background: linear-gradient(180deg, #f97316 0%, #ea580c 100%);
  color: #fff;
  font-size: 1.05rem;
  padding: 0.9rem 1.15rem;
  box-shadow: 0 2px 14px rgba(234, 88, 12, 0.38);
}
button.btn-cta:hover,
.btn.btn-cta:hover {
  filter: brightness(1.07);
}
.card-cta {
  border-color: rgba(234, 88, 12, 0.4);
  background: linear-gradient(160deg, rgba(234, 88, 12, 0.14) 0%, var(--surface) 65%);
}
.h-cta {
  color: #fdba74;
  font-size: 0.95rem;
  text-transform: none;
  letter-spacing: 0;
  margin-bottom: 0.5rem;
}
.label-limit {
  font-size: 0.9rem;
}
.label-limit input {
  margin-top: 0.4rem;
}

/* Grid nút trên mobile: xếp cột, desktop xếp hàng */
.btn-row {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin: 0.5rem 0 0;
}
@media (min-width: 40rem) {
  .btn-row {
    flex-direction: row;
    flex-wrap: wrap;
  }
  .btn-row > * {
    flex: 1 1 auto;
    min-width: 7rem;
  }
}

/* Bảng: cuộn ngang trên màn hình nhỏ */
.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin: 0.5rem 0 1rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 18rem;
  font-size: 0.95rem;
}
th,
td {
  border-bottom: 1px solid var(--border);
  padding: 0.65rem 0.75rem;
  text-align: left;
  vertical-align: top;
}
th {
  color: var(--muted);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: rgba(0, 0, 0, 0.2);
}
tr:last-child td {
  border-bottom: none;
}

textarea.code {
  font-family: ui-monospace, "Cascadia Code", "Consolas", monospace;
  font-size: 0.85rem;
  min-height: 20rem;
  line-height: 1.4;
}

.muted {
  color: var(--muted);
  font-size: 0.9rem;
}
.small {
  font-size: 0.8rem;
}

/* Layout stack tenant admin */
.tenant-block {
  margin-bottom: 1.5rem;
}
.tenant-block h3 {
  font-size: 1rem;
  color: var(--text);
  margin: 0 0 0.5rem;
}

/* Output log */
pre.out {
  background: #0a0d11;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  overflow: auto;
  max-height: min(70vh, 28rem);
  font-size: 0.8rem;
  line-height: 1.4;
  white-space: pre-wrap;
  word-break: break-word;
}

/* Login rộng hơn vừa màn hình */
.login-card {
  max-width: 22rem;
  margin: 2rem auto;
}

.stretch {
  width: 100%;
}

.stack > * + * {
  margin-top: 0.75rem;
}

/* Trạng thái đang xử lý: overlay đăng nhập + spinner */
.load-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(8, 12, 18, 0.72);
  backdrop-filter: blur(3px);
}
.load-overlay[hidden] {
  display: none;
}
.load-overlay-inner {
  text-align: center;
  color: var(--text);
  padding: 1.5rem;
}
.load-overlay-inner p {
  margin: 0.75rem 0 0;
  font-size: 0.95rem;
  color: var(--muted);
}

/* Spinner dùng chung (đăng nhập + dashboard tenant) */
.spinner {
  display: inline-block;
  width: 1.5rem;
  height: 1.5rem;
  vertical-align: middle;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
.health-summary .spinner {
  margin-left: 0.35rem;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}
