:root {
  --primary: #F07818;
  --primary-light: #F9A825;
  --primary-dark: #D46714;
  --bg: #F1F2F4;
  --surface: #FFFFFF;
  --text: #14161A;
  --text-sec: #8A8F98;
  --border: #EBECEF;
  --success: #2E7D32;
  --warning: #F57F17;
  --error: #C62828;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ===== AUTH ===== */
#screen-auth {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 1rem;
  background: var(--bg);
}

.auth-card {
  background: var(--surface);
  border-radius: 14px;
  padding: 32px 24px;
  width: 400px;
  max-width: calc(100% - 32px);
  box-shadow: rgba(20, 22, 26, 0.04) 0px 1px 2px 0px;
  text-align: center;
}

.auth-logo {
  display: block;
  margin: 0 auto 12px;
  color: var(--primary);
}

.auth-logo svg {
  height: 36px;
  width: auto;
}

.auth-card h1 {
  font-size: 15px;
  font-weight: 400;
  color: var(--text-sec);
  margin-bottom: 24px;
}

.auth-card label {
  text-align: left;
  display: block;
  font-weight: 600;
  font-size: 14px;
  color: var(--text);
  margin: 14px 0 6px;
}

.auth-card label:first-of-type { margin-top: 0; }

.auth-card input {
  text-align: left;
}

.auth-toggle {
  margin: 16px 0 0;
  font-size: 14px;
  color: var(--text-sec);
}

.auth-toggle a { color: var(--primary); text-decoration: none; font-weight: 600; }

.auth-footer {
  margin-top: 24px;
  font-size: 13px;
  color: var(--text-sec);
}

.pw-wrap {
  position: relative;
}

.pw-wrap input {
  padding-right: 44px;
}

.btn-eye {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-sec);
  padding: 4px;
  display: flex;
  align-items: center;
}

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

.btn-eye svg {
  width: 20px;
  height: 20px;
}

/* ===== HEADER ===== */
.app-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}

.header-inner {
  max-width: 800px;
  margin: 0 auto;
  padding: 0.75rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.header-left { display: flex; align-items: center; gap: 0.5rem; min-width: 0; overflow: hidden; }
.header-left .logo { color: var(--primary); display: flex; align-items: center; }
.header-left .logo svg { height: 32px; width: auto; }
.app-name { font-size: 0.8rem; color: var(--text-sec); display: none; }
@media (min-width: 480px) { .app-name { display: inline; } }

/* ===== TABS ===== */
.tabs {
  display: flex;
  background: var(--surface);
  border-bottom: 2px solid var(--border);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }

.tab {
  flex: 1;
  min-width: max-content;
  padding: 0.75rem 0.75rem;
  border: none;
  background: none;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-sec);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  white-space: nowrap;
  transition: color 0.2s, border-color 0.2s;
}

.tab:hover { color: var(--text); }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }

/* ===== CONTENT ===== */
.content { max-width: 800px; margin: 0 auto; padding: 1rem; }
.tab-content { display: none; }
.tab-content.active { display: block; }

/* ===== CARDS ===== */
.card {
  background: var(--surface);
  border-radius: 14px;
  padding: 1.25rem;
  margin-bottom: 1rem;
  box-shadow: rgba(20, 22, 26, 0.04) 0px 1px 2px 0px;
}

.card h2 { font-size: 1rem; font-weight: 600; margin-bottom: 1rem; }

/* ===== STATS GRID ===== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.stat-card {
  background: var(--surface);
  border-radius: 14px;
  padding: 1rem;
  box-shadow: rgba(20, 22, 26, 0.04) 0px 1px 2px 0px;
  text-align: center;
}

.stat-value { font-size: 1.35rem; font-weight: 700; color: var(--primary); }
.stat-label { font-size: 0.75rem; color: var(--text-sec); margin-top: 0.2rem; }

@media (min-width: 560px) {
  .stats-grid { grid-template-columns: repeat(4, 1fr); }
}

/* ===== FORMS ===== */
label {
  display: block;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  margin: 14px 0 6px;
}

label:first-child { margin-top: 0; }

input, textarea, select {
  width: 100%;
  padding: 13px 15px;
  border: 1px solid var(--border);
  border-radius: 14px;
  font-size: 16px;
  font-family: inherit;
  background: var(--surface);
  color: var(--text);
  transition: border-color 0.2s;
}

input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--primary);
}

input[readonly] { background: #F5F5F5; color: var(--text-sec); }

.input-group { display: flex; gap: 0.5rem; }
.input-group input { flex: 1; }

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 15px 22px;
  border: none;
  border-radius: 14px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, opacity 0.2s;
  font-family: inherit;
  line-height: 1.4;
}

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-secondary { background: #ECEFF1; color: var(--text); }
.btn-secondary:hover { background: #CFD8DC; }

.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { background: #1B5E20; }

.btn-text { background: none; color: var(--text-sec); padding: 0.5rem; }
.btn-text:hover { color: var(--primary); }
#btn-logout {
  background: var(--primary);
  color: #fff;
  padding: 0.4rem 0.75rem;
  border-radius: 8px;
  font-size: 0.8rem;
  font-weight: 600;
  white-space: nowrap;
  flex-shrink: 0;
}
#btn-logout:hover { opacity: 0.9; color: #fff; }

.btn-full { width: 100%; }
.btn-sm { padding: 0.375rem 0.75rem; font-size: 0.8rem; border-radius: 8px; }

/* ===== TOOLBAR ===== */
.toolbar { display: flex; gap: 0.75rem; margin-bottom: 1rem; }
.search-input { flex: 1; }

/* ===== TABLES ===== */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }

.data-table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }

.data-table th {
  text-align: left;
  padding: 0.5rem 0.5rem;
  font-weight: 600;
  color: var(--text-sec);
  border-bottom: 2px solid var(--border);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.data-table td {
  padding: 0.625rem 0.5rem;
  border-bottom: 1px solid #F0F0F0;
  vertical-align: top;
}

.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: #FAFAFA; }

/* ===== BADGES ===== */
.badge {
  display: inline-block;
  padding: 0.125rem 0.5rem;
  border-radius: 20px;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.2px;
}

.badge-thuong { background: #F5F5F5; color: #9E9E9E; }
.badge-bac { background: #ECEFF1; color: #546E7A; }
.badge-vang { background: #FFF8E1; color: #F57F17; }
.badge-kim-cuong { background: #EDE7F6; color: #5E35B1; }
.badge-success { background: #E8F5E9; color: var(--success); }
.badge-pending { background: #FFF3E0; color: #E65100; }

/* ===== INFO BOXES ===== */
.kh-info {
  background: #FFF8E1;
  border-left: 3px solid var(--warning);
  border-radius: 0 8px 8px 0;
  padding: 0.75rem 1rem;
  margin: 0.75rem 0;
  font-size: 0.9rem;
  line-height: 1.6;
}

.kh-info.new {
  background: #E3F2FD;
  border-left-color: #1976D2;
}

.uu-dai-box {
  background: #E8F5E9;
  border-left: 3px solid var(--success);
  border-radius: 0 8px 8px 0;
  padding: 0.75rem 1rem;
  margin: 0.75rem 0;
  font-size: 0.9rem;
  line-height: 1.6;
}

/* ===== MODAL ===== */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 1rem;
  animation: fadeInBg 0.2s;
}

.modal-content {
  background: var(--surface);
  border-radius: 14px;
  padding: 1.5rem;
  width: 100%;
  max-width: 440px;
  max-height: 90vh;
  overflow-y: auto;
  animation: slideUp 0.25s;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
}

.modal-header h2 { margin: 0; }

.modal-close {
  background: none;
  border: none;
  font-size: 1.75rem;
  cursor: pointer;
  color: var(--text-sec);
  padding: 0;
  line-height: 1;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
}

.modal-close:hover { background: #F5F5F5; }

/* ===== MESSAGES ===== */
.msg {
  padding: 0.625rem 0.875rem;
  border-radius: 8px;
  font-size: 0.85rem;
  margin-top: 0.75rem;
}

.msg-error { background: #FFEBEE; color: var(--error); }
.msg-success { background: #E8F5E9; color: var(--success); }
.msg-info { background: #E3F2FD; color: #1565C0; }

/* ===== TOAST ===== */
.toast {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%);
  background: #323232;
  color: #fff;
  padding: 0.75rem 1.5rem;
  border-radius: 14px;
  font-size: 0.9rem;
  font-weight: 500;
  z-index: 1000;
  box-shadow: 0 4px 16px rgba(0,0,0,0.2);
  animation: slideUp 0.3s;
  max-width: calc(100vw - 2rem);
  text-align: center;
}

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

/* ===== STATES ===== */
.empty {
  text-align: center;
  padding: 2rem 1rem;
  color: var(--text-sec);
  font-size: 0.9rem;
}

.loading {
  text-align: center;
  padding: 2rem;
  color: var(--text-sec);
}

/* ===== ANIMATIONS ===== */
@keyframes fadeInBg {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ===== SUB TABS (steps) ===== */
.sub-tabs {
  display: flex;
  gap: 0;
  margin-bottom: 1.25rem;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--border);
}

.sub-tab {
  flex: 1;
  padding: 0.625rem 0.5rem;
  border: none;
  background: var(--bg);
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-sec);
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
  white-space: nowrap;
}

.sub-tab + .sub-tab { border-left: 1px solid var(--border); }
.sub-tab:hover { background: #E8E9EB; }
.sub-tab.active { background: var(--primary); color: #fff; }
.sub-tab.done { background: #E8F5E9; color: var(--success); }

.step-panel { display: none; }
.step-panel.active { display: block; animation: fadeIn 0.2s; }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* ===== ROLE BADGE ===== */
.role-badge {
  display: inline-block;
  padding: 0.125rem 0.5rem;
  border-radius: 20px;
  font-size: 0.7rem;
  font-weight: 700;
  background: var(--primary);
  color: #fff;
  letter-spacing: 0.2px;
}

/* ===== APP LOADING ===== */
.app-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 200px;
}

/* ===== HỒ SƠ ===== */
.ho-so-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
  margin-top: 0.75rem;
}

.ho-so-grid > div small {
  color: var(--text-sec);
  font-size: 0.75rem;
}

@media (min-width: 560px) {
  .ho-so-grid { grid-template-columns: repeat(3, 1fr); }
}

/* Khối tiền: tiêu đề và số tiền cùng canh giữa ô cho thẳng cột */
.ho-so-grid-tien > div { text-align: center; }

/* Ô cuối nằm lẻ một mình trên hàng thì trải ngang cho cân */
.ho-so-grid-tien > div:last-child:nth-child(odd) { grid-column: 1 / -1; }

@media (min-width: 560px) {
  .ho-so-grid-tien > div:last-child:nth-child(odd) { grid-column: auto; }
  .ho-so-grid-tien > div:last-child:nth-child(3n + 1) { grid-column: 1 / -1; }
}

/* ===== GT CARDS ===== */
.gt-cards { display: flex; flex-direction: column; gap: 0.75rem; }
.gt-card {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.75rem 1rem;
  background: var(--bg);
}
.gt-card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
  font-size: 0.95rem;
}
.gt-card-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.2rem 0;
  font-size: 0.85rem;
  border-top: 1px solid var(--border);
}
.gt-card-row > span:first-child {
  color: var(--text-sec);
  flex-shrink: 0;
  margin-right: 0.5rem;
}
.gt-card-row > span:last-child { text-align: right; }

.gt-card-act {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  padding-top: 0.5rem;
  margin-top: 0.3rem;
  border-top: 1px solid var(--border);
}
.btn-sua-gt, .btn-xoa-gt {
  padding: 0.35rem 0.85rem;
  border-radius: 8px;
  background: transparent;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
}
.btn-sua-gt { border: 1px solid var(--primary); color: var(--primary); }
.btn-sua-gt:hover { background: var(--primary); color: #fff; }
.btn-xoa-gt { border: 1px solid var(--error); color: var(--error); }
.btn-xoa-gt:hover { background: var(--error); color: #fff; }

/* ===== GT PAGER ===== */
.gt-pager {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 1rem;
  margin-top: 0.75rem;
  padding: 0.5rem 0;
}
.gt-pager-info {
  font-size: 0.85rem;
  color: var(--text-sec);
}
.btn-pager {
  padding: 0.4rem 1rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--primary);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
}
.btn-pager:disabled {
  opacity: 0.4;
  cursor: default;
}

input[readonly] {
  background: var(--bg);
  color: var(--text-sec);
  cursor: default;
}

/* ===== CHỌN NGÂN HÀNG ===== */
.nh-wrap { position: relative; }
.nh-goi-y {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  z-index: 20;
  max-height: 260px;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 8px 24px rgba(20,24,31,.14);
}
.nh-muc {
  display: block;
  width: 100%;
  text-align: left;
  padding: 0.6rem 0.9rem;
  border: none;
  border-bottom: 1px solid var(--border);
  background: transparent;
  cursor: pointer;
  font-family: inherit;
}
.nh-muc:last-child { border-bottom: none; }
.nh-muc:hover { background: var(--bg); }
.nh-muc strong { display: block; font-size: 0.9rem; color: var(--text); }
.nh-muc small { display: block; font-size: 0.75rem; color: var(--text-sec); margin-top: 1px; }

/* ===== NÚT ZALO NỔI (lấy từ dektoncantho.vn) ===== */
.lien-he-noi {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 50;
  display: flex;
  flex-direction: column;
  gap: 9px;
  align-items: flex-end;
}
.lh-nut {
  position: relative;
  display: block;
  width: 50px;
  height: 50px;
  line-height: 0;
  border-radius: 999px;
  box-shadow: 0 12px 32px rgba(20,24,31,.12);
  transition: transform .15s ease, filter .15s ease;
}
.lh-nut svg { display: block; width: 100%; height: 100%; flex-shrink: 0; }
.lh-chu { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.lh-nut:hover { transform: translateY(-2px); filter: brightness(1.06); }

@media (max-width: 820px) {
  .lien-he-noi { right: 12px; bottom: 12px; gap: 7px; }
  .lh-nut { width: 46px; height: 46px; }
}

/* Làn sóng lan toả ra ngoài — hai vòng nối đuôi nhau, chậm và mờ dần.
   Cố ý KHÔNG rung, KHÔNG nảy: chuyển động giật gây khó chịu khi đọc trang. */
.lh-nut::before, .lh-nut::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 999px;
  pointer-events: none;
  z-index: -1;
  opacity: 0;
  animation: lan-song 5s cubic-bezier(.22,.61,.36,1) infinite;
}
.lh-nut::after { animation-delay: 2.5s; }
.lh-nut--zalo::before, .lh-nut--zalo::after { background: #0068FF; }
@keyframes lan-song {
  0%   { transform: scale(1);    opacity: .40; }
  60%  { opacity: .14; }
  100% { transform: scale(1.55); opacity: 0; }
}
/* Rê chuột vào thì sóng dừng, nút nhích lên cho biết bấm được */
.lh-nut:hover::before, .lh-nut:hover::after { animation-play-state: paused; }
/* Ai bật chế độ giảm chuyển động thì tắt hẳn */
@media (prefers-reduced-motion: reduce) {
  .lh-nut::before, .lh-nut::after { animation: none; }
}

/* ===== FOOTER ===== */
.app-footer {
  text-align: center;
  padding: 1.5rem 1rem;
  font-size: 13px;
  color: var(--text-sec);
  border-top: 1px solid var(--border);
  margin-top: 2rem;
}
