/* ===== Base tokens ===== */
:root {
  --bg: #f5f6f8;
  --card: #fff;
  --text: #212529;
  --muted: #6c757d;
  --brand: #0d6efd;
  --brand-600: #0b5ed7;
  --danger: #dc3545;
  --success: #198754;
  --shadow: 0 8px 30px rgba(0, 0, 0, .08);
  --radius: 12px;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}

/* ===== Reusable buttons ===== */
.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 44px;
  padding: 0 16px;
  border: 0;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
}

a.btn {
  text-decoration: none;
}

.btn-primary {
  background: var(--brand);
  color: #fff;
}

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

.btn-outline {
  background: #fff;
  color: #212529;
  border: 1px solid #ced4da;
}

.btn-outline:hover {
  background: #f1f3f5;
}

.btn-secondary {
  background: #6c757d;
  border: 1px solid #6c757d;
  color: #fff;
}

.btn-secondary:hover {
  background: #5a6268;
}

.is-disabled {
  pointer-events: none;
  opacity: .6;
}

/* ===== Login page ===== */
.auth-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.auth-card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  width: min(450px, 100%);
  display: flex;
  flex-direction: column;
}

.auth-header {
  padding: 12px;
  border-bottom: 1px solid #e9ecef;
}

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

.brand-logo {
  width: 44px;
  height: 44px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: var(--brand);
  color: #fff;
  font-size: 22px;
}

.brand-text h1 {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
}

.brand-text p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: .9rem;
}

.auth-form {
  padding: 20px;
  display: grid;
  gap: 16px;
}

.form-row {
  display: grid;
  gap: 8px;
}

.form-row label {
  font-weight: 600;
  font-size: .9rem;
  color: var(--text);
}

.form-row input {
  width: 100%;
  height: 42px;
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid #ced4da;
  font-size: .95rem;
}

.form-row input:focus {
  border-color: var(--brand);
  outline: none;
  box-shadow: 0 0 0 3px rgba(13, 110, 253, .15);
}

.hint {
  color: var(--muted);
  font-size: .8rem;
}

.password-field {
  position: relative;
}

.btn-eye {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  border: none;
  background: transparent;
  cursor: pointer;
  color: var(--muted);
}

.btn-eye.on {
  color: var(--brand);
}

.options {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: .85rem;
  color: var(--muted);
}

.checkbox {
  display: flex;
  align-items: center;
  gap: 6px;
  white-space:nowrap;
}

.link {
  color: var(--brand);
  text-decoration: none;
}

.link.muted {
  color: var(--muted);
}

.auth-footer {
  padding: 12px 20px;
  text-align: center;
  border-top: 1px solid #e9ecef;
  font-size: .85rem;
  color: var(--muted);
}

.auth-footer p {
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%) translateY(8px);
  opacity: 0;
  transition: all .25s ease;
  z-index: 50;
  background: #212529;
  color: #fff;
  padding: 10px 14px;
  border-radius: 6px;
  font-size: .9rem;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.toast.success {
  background: var(--success);
}

.toast.error {
  background: var(--danger);
}

/* ===== App shell & main sheet ===== */
.app-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.app-main {
  width: min(900px, calc(100% - 24px));
  margin: 24px auto;
  padding: 16px 18px;
  background: #fff;
  border: 1px solid #e9ecef;
  border-radius: 12px;
  box-shadow: var(--shadow);
}

/* Header (nằm trong app-main) */
.sheet-header {
  text-align: center;
  color: #fff;
  background: linear-gradient(135deg, #2c3e50 0%, #3498db 100%);
  border-radius: 12px;
  padding: 16px;
  box-shadow: 0 4px 10px rgba(0, 0, 0, .08);
}

.sheet-title {
  margin: 0 0 6px;
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: .3px;
  text-transform: uppercase;
}

.sheet-subtitle {
  margin: 0;
  font-size: .9rem;
  opacity: .92;
}

/* Panel (các khối nội dung) */
.panel {
  padding: 16px 0;
}

.panel+.panel {
  border-top: 1px solid #e9ecef;
  margin-top: 12px;
}

.panel__row {
  display: flex;
  gap: 24px;
  justify-content: space-between;
}

.panel__col {
  flex: 1 1 0;
  min-width: 280px;
}

.line {
  display: flex;
  gap: 8px;
  margin: 8px 0;
  align-items: baseline
}

.label {
  color: #495057;
  min-width: 120px;
}

.value {
  font-weight: 700;
  color: #212529;
}

.badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
}

.badge-open {
  background: #e7f1ff;
  border: 1px solid #cfe2ff;
  color: #0b5ed7;
}

.badge-closed {
  background: #fff3cd;
  border: 1px solid #ffeeba;
  color: #856404;
}

.panel__actions {
  margin-top: 16px;
  display: flex;
  gap: 12px;
}

/* Footer */
.app-footer {
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  padding: 10px 16px;
}

.app-footer p {
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
  .app-main {
    width: calc(100% - 24px);
    margin: 16px auto;
    padding: 12px 14px;
    border-radius: 10px;
  }

  .sheet-header {
    border-radius: 10px;
    padding: 12px;
  }

  .sheet-title {
    font-size: 1.1rem;
  }

  .sheet-subtitle {
    font-size: .82rem;
  }

  .panel {
    padding: 12px 0;
  }

  .panel__row {
    flex-direction: column;
    gap: 12px;
  }

  .panel__col {
    min-width: 0;
  }

  .label {
    min-width: 96px;
  }

  .panel__actions {
    flex-direction: column;
    align-items: stretch;
  }

  .panel__actions .btn {
    width: 100%;
  }
}

/* ===== check status ===== */
.panel__actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: space-between;
  /* nút trái – thông điệp phải */
}

.actions-status {
  margin-left: auto;
  /* đẩy sang phải nếu không dùng space-between */
  font-size: 14px;
  line-height: 1.4;
  min-height: 20px;
  /* tránh nhảy layout khi text đến chậm */
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* màu theo loại message */
.actions-status.info {
  color: #0b5ed7;
}

.actions-status.success {
  color: #0f5132;
}

.actions-status.warning {
  color: #856404;
}

.actions-status.error {
  color: #842029;
}

/* nút spin xoay khi đăng nhập và disable nút */
/* Message area + spinner */
.message{margin-top:8px;font-size:14px}
.message.info{color:#0b5ed7}
.message.success{color:#0f5132}
.message.error{color:#842029}

/* Vòng tròn quay cho showLoading() -> <span class="loading"></span> */
.loading{
  display:inline-block;
  width:16px;height:16px;
  border:2px solid currentColor;
  border-right-color: transparent;
  border-radius:50%;
  animation: spin .8s linear infinite;
  vertical-align:-2px;
  margin-right:8px;
}
@keyframes spin{ to{ transform: rotate(360deg); } }

/* Nút bị vô hiệu hoá trong lúc gửi */
.btn.is-disabled{pointer-events:none;opacity:.6}
/* giờ hệ thống */
#server-clock { font-variant-numeric: tabular-nums; letter-spacing: .3px; }