/* ==========================================================================
   Reusable components
   ========================================================================== */

.hg-card {
  background: var(--hg-surface);
  border: 1px solid var(--hg-border);
  border-radius: var(--hg-radius-lg);
  padding: 20px;
}

.hg-stat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 20px;
}
.hg-stat {
  display: flex;
  gap: 14px;
  align-items: flex-start;
}
.hg-stat .icon {
  width: 40px; height: 40px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.hg-stat .label { font-size: 13px; color: var(--hg-gray-500); margin-bottom: 4px; }
.hg-stat .value { font-size: 22px; font-weight: 700; }
.hg-stat .delta { font-size: 12px; color: var(--hg-gray-500); margin-top: 2px; }
.hg-stat .delta.up { color: var(--hg-green-text); }
.hg-stat .delta.down { color: var(--hg-red-text); }

.icon-bg-blue    { background: var(--hg-blue-50);   color: var(--hg-blue-500); }
.icon-bg-amber   { background: var(--hg-amber-50);  color: var(--hg-amber-text); }
.icon-bg-green   { background: var(--hg-green-50);  color: var(--hg-green-text); }
.icon-bg-red     { background: var(--hg-red-50);    color: var(--hg-red-text); }
.icon-bg-purple  { background: var(--hg-purple-50); color: var(--hg-purple-500); }
.icon-bg-teal    { background: var(--hg-teal-50);   color: var(--hg-teal-500); }
.icon-bg-orange  { background: var(--hg-orange-50); color: var(--hg-orange-500); }
.icon-bg-gray    { background: var(--hg-gray-100);  color: var(--hg-gray-600); }

.hg-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: var(--hg-radius-pill);
}
.hg-badge-green  { background: var(--hg-green-50);  color: var(--hg-green-text); }
.hg-badge-amber  { background: var(--hg-amber-50);  color: var(--hg-amber-text); }
.hg-badge-red    { background: var(--hg-red-50);    color: var(--hg-red-text); }
.hg-badge-blue   { background: var(--hg-blue-50);   color: var(--hg-blue-500); }
.hg-badge-gray   { background: var(--hg-gray-100);  color: var(--hg-gray-600); }

.hg-btn {
  border-radius: var(--hg-radius-sm);
  border: 1px solid var(--hg-border);
  background: var(--hg-surface);
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 700;
  color: var(--hg-gray-700);
}
.hg-btn:hover { background: var(--hg-gray-50); }
.hg-btn-confirm { background: var(--hg-green-500); border-color: var(--hg-green-500); color: #fff; }
.hg-btn-confirm:hover { background: var(--hg-green-600); }
.hg-btn-decline { color: var(--hg-red-text); border-color: var(--hg-red-50); background: var(--hg-red-50); }
.hg-btn-decline:hover { background: #fbdcd9; }
.hg-btn-danger {
  border-radius: var(--hg-radius-sm);
  border: 1px solid var(--hg-red-500);
  background: var(--hg-red-500);
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 700;
  color: #fff;
}
.hg-btn-danger:hover { background: var(--hg-red-text); border-color: var(--hg-red-text); }
.hg-btn-dark { background: var(--hg-navy-950); border-color: var(--hg-navy-950); color: #fff; }
.hg-btn-dark:hover { background: var(--hg-navy-800); }

.hg-input {
  border: 1px solid var(--hg-border);
  border-radius: var(--hg-radius-sm);
  padding: 9px 12px;
  font-size: 14px;
  background: var(--hg-surface);
  width: 100%;
}
.hg-input:focus { outline: 2px solid var(--hg-teal-400); outline-offset: -1px; }

.hg-table { width: 100%; border-collapse: collapse; }
.hg-table th {
  text-align: left;
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--hg-gray-500);
  font-weight: 700;
  padding: 10px 12px;
  border-bottom: 1px solid var(--hg-border);
}
.hg-table td {
  padding: 14px 12px;
  border-bottom: 1px solid var(--hg-border);
  font-size: 14px;
}
.hg-table tr:last-child td { border-bottom: none; }
.hg-table tr:hover td { background: var(--hg-gray-50); }

.hg-avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}
.hg-person { display: flex; align-items: center; gap: 10px; }
.hg-person .name { font-weight: 700; }

.hg-tabs {
  display: inline-flex;
  background: var(--hg-gray-100);
  border-radius: var(--hg-radius-sm);
  padding: 3px;
  gap: 2px;
}
.hg-tab {
  border: none;
  background: transparent;
  padding: 7px 14px;
  font-size: 13px;
  font-weight: 700;
  color: var(--hg-gray-600);
  border-radius: 6px;
}
.hg-tab.active { background: var(--hg-surface); color: var(--hg-gray-900); box-shadow: var(--hg-shadow-sm); }

/* Modal */
.hg-modal-overlay {
  position: fixed; inset: 0;
  background: rgba(10, 20, 40, 0.5);
  display: flex; align-items: center; justify-content: center;
  z-index: 100;
  padding: 20px;
}
.hg-modal {
  background: var(--hg-surface);
  border-radius: var(--hg-radius-lg);
  width: min(900px, 100%);
  max-height: 90vh;
  overflow-y: auto;
  padding: 28px;
  box-shadow: var(--hg-shadow-lg);
}
.hg-modal-head { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 20px; }
.hg-modal-close {
  width: 32px; height: 32px;
  border-radius: 8px;
  border: 1px solid var(--hg-border);
  background: var(--hg-surface);
  display: flex; align-items: center; justify-content: center;
}

.hg-option-row {
  border: 1px solid var(--hg-border);
  border-radius: var(--hg-radius-md);
  padding: 12px 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
  cursor: pointer;
}
.hg-option-row .sub { font-size: 12px; color: var(--hg-gray-500); }
.hg-option-row.selected { border-color: var(--hg-teal-500); background: var(--hg-teal-50); }
.hg-option-row .check {
  width: 20px; height: 20px; border-radius: 50%;
  border: 2px solid var(--hg-gray-300);
  display: flex; align-items: center; justify-content: center;
}
.hg-option-row.selected .check { border-color: var(--hg-teal-500); background: var(--hg-teal-500); color: #fff; }

.hg-chip-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.hg-chip {
  border: 1px solid var(--hg-border);
  border-radius: var(--hg-radius-sm);
  padding: 10px 6px;
  text-align: center;
  background: var(--hg-surface);
}
.hg-chip .d { font-size: 11px; color: var(--hg-gray-500); }
.hg-chip .n { font-weight: 700; }
.hg-chip.active { background: var(--hg-navy-950); color: #fff; border-color: var(--hg-navy-950); }
.hg-chip.active .d { color: #b9c4da; }
.hg-chip.selected { border-color: var(--hg-teal-500); background: var(--hg-teal-50); }

.hg-empty {
  padding: 60px 20px;
  text-align: center;
  color: var(--hg-gray-500);
}

.hg-spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid var(--hg-gray-300, #d7dce3);
  border-top-color: var(--hg-navy-950);
  border-radius: 50%;
  animation: hg-spin 0.7s linear infinite;
}
@keyframes hg-spin {
  to { transform: rotate(360deg); }
}

.hg-field-error {
  color: var(--hg-red-text);
  font-size: 12px;
  margin-top: 4px;
}

.hg-login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--hg-navy-950);
  padding: 20px;
}
.hg-login-card {
  width: 100%;
  max-width: 380px;
  background: var(--hg-surface);
  border-radius: var(--hg-radius, 12px);
  padding: 36px 32px;
  box-shadow: 0 20px 60px rgba(0,0,0,.35);
}
.hg-login-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 24px;
}
.hg-login-logo .mark {
  width: 36px; height: 36px;
  border-radius: 8px;
  background: var(--hg-navy-950);
  color: var(--hg-gold-500);
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 15px;
}
.hg-login-logo .word .top { font-weight: 800; font-size: 15px; line-height: 1.1; }
.hg-login-logo .word .bottom { font-size: 10px; letter-spacing: .08em; color: var(--hg-gray-500); }
.hg-login-field { margin-bottom: 16px; }
.hg-login-field label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .05em;
  color: var(--hg-gray-500);
  margin-bottom: 6px;
}
.hg-login-submit {
  width: 100%;
  margin-top: 8px;
  justify-content: center;
}
.hg-login-error {
  background: var(--hg-red-50);
  color: var(--hg-red-text);
  border-radius: var(--hg-radius-sm, 8px);
  padding: 10px 12px;
  font-size: 13px;
  margin-bottom: 16px;
}
.hg-login-footer {
  margin-top: 20px;
  text-align: center;
  font-size: 13px;
  color: var(--hg-gray-500);
}
.hg-login-footer a {
  color: var(--hg-blue-500);
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
}
.hg-login-footer a:hover {
  text-decoration: underline;
}
.hg-login-hint {
  font-size: 12px;
  color: var(--hg-gray-500);
  margin: -10px 0 16px;
}

.hg-toolbar {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 16px;
}
.hg-toolbar .hg-input { max-width: 320px; }

.hg-switch { display: inline-flex; vertical-align: middle; }
.hg-switch input {
  appearance: none;
  width: 38px; height: 22px;
  background: var(--hg-gray-300);
  border-radius: 999px;
  position: relative;
  cursor: pointer;
  transition: background .15s ease;
}
.hg-switch input:checked { background: var(--hg-green-500); }
.hg-switch input::after {
  content: "";
  position: absolute;
  top: 2px; left: 2px;
  width: 18px; height: 18px;
  background: #fff;
  border-radius: 50%;
  transition: left .15s ease;
}
.hg-switch input:checked::after { left: 18px; }
.hg-switch input:disabled { cursor: default; opacity: .7; }
