/* ==========================================================================
   STYLE CHO HỆ THỐNG SOẠN HỒ SƠ & TRA CỨU MST
   Tối ưu cho Cloudflare Pages (Desktop 2 cột, Mobile 1 cột dọc)
   ========================================================================== */

:root {
  --bg: #f8fafc;
  --card: #ffffff;
  --line: #e2e8f0;
  --line-hover: #cbd5e1;
  --text: #0f172a;
  --muted: #64748b;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-light: #eff6ff;
  --accent: #0ea5e9;
  --ok: #10b981;
  --ok-light: #ecfdf5;
  --warn: #f59e0b;
  --warn-light: #fffbeb;
  --err: #ef4444;
  --err-light: #fef2f2;
  --radius-sm: 8px;
  --radius: 14px;
  --radius-lg: 18px;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.05);
  --shadow: 0 4px 12px -2px rgba(15, 23, 42, 0.06), 0 2px 6px -1px rgba(15, 23, 42, 0.04);
  --shadow-lg: 0 10px 25px -5px rgba(15, 23, 42, 0.08), 0 8px 10px -6px rgba(15, 23, 42, 0.04);
  --shadow-dock: 0 12px 32px -4px rgba(15, 23, 42, 0.16), 0 4px 12px rgba(15, 23, 42, 0.08);
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  line-height: 1.55;
  padding-bottom: 40px;
}

/* --- HEADER --- */
header {
  background: linear-gradient(135deg, #0f172a 0%, #1e3a8a 50%, #2563eb 100%);
  color: #ffffff;
  padding: 22px 20px 20px;
  box-shadow: 0 4px 20px rgba(15, 23, 42, 0.15);
}

.header-inner {
  max-width: 1240px;
  margin: 0 auto;
}

.header-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 10px;
}

header h1 {
  margin: 0;
  font-size: 21px;
  font-weight: 700;
  letter-spacing: -0.02em;
  display: flex;
  align-items: center;
  gap: 10px;
}

header p {
  margin: 0;
  font-size: 13.5px;
  color: #cbd5e1;
  max-width: 820px;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  background: rgba(255, 255, 255, 0.14);
  border: 1px solid rgba(255, 255, 255, 0.25);
  backdrop-filter: blur(8px);
}

.badge-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #10b981;
  box-shadow: 0 0 8px #10b981;
}

/* --- THANH ICON DẪN LINK NHANH (QUICK-LINKS DOCK) --- */
.quick-links {
  position: fixed;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: #ffffff;
  padding: 12px 9px;
  border-radius: 20px;
  box-shadow: var(--shadow-dock);
  border: 1.5px solid #cbd5e1;
  z-index: 1000;
}

.quick-link-item {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  color: #ffffff;
  text-decoration: none;
  transition: all 0.22s cubic-bezier(0.34, 1.56, 0.64, 1);
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.12);
}

.quick-link-item:hover {
  transform: scale(1.12) translateX(-3px);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
}

.quick-link-item svg {
  width: 22px;
  height: 22px;
  flex-shrink: 0;
}

.quick-link-label {
  display: none;
}

.link-intro {
  background: linear-gradient(135deg, #0284c7, #0ea5e9);
}

.link-home {
  background: linear-gradient(135deg, #1d4ed8, #3b82f6);
}

.link-invoice {
  background: linear-gradient(135deg, #059669, #10b981);
}

.link-fb {
  background: linear-gradient(135deg, #1877f2, #2563eb);
}

.link-yt {
  background: linear-gradient(135deg, #dc2626, #ef4444);
}

.quick-link-item::after {
  content: attr(data-title);
  position: absolute;
  right: calc(100% + 12px);
  top: 50%;
  transform: translateY(-50%) translateX(6px);
  background: #0f172a;
  color: #ffffff;
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: all 0.2s ease;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.quick-link-item::before {
  content: '';
  position: absolute;
  right: calc(100% + 6px);
  top: 50%;
  transform: translateY(-50%) translateX(6px);
  border: 5px solid transparent;
  border-left-color: #0f172a;
  opacity: 0;
  pointer-events: none;
  transition: all 0.2s ease;
}

.quick-link-item:hover::after,
.quick-link-item:hover::before {
  opacity: 1;
  transform: translateY(-50%) translateX(0);
}

/* --- BỐ CỤC CHÍNH (MAIN LAYOUT) --- */
main {
  max-width: 1240px;
  margin: 18px auto 0;
  padding: 0 16px;
}

.main-layout {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 20px;
  align-items: start;
}

.content-column {
  min-width: 0;
}

.sidebar-column {
  position: sticky;
  top: 16px;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 16px;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.card:hover {
  border-color: var(--line-hover);
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
}

.card h2 {
  margin: 0;
  font-size: 15.5px;
  font-weight: 700;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
  letter-spacing: -0.01em;
}

.card h2 em {
  font-weight: 400;
  font-style: normal;
  color: var(--muted);
  font-size: 12px;
}

/* --- FORM ELEMENTS --- */
.row {
  display: flex;
  gap: 12px;
  align-items: flex-end;
  flex-wrap: wrap;
}

.grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.grow {
  flex: 1 1 240px;
}

.span2 {
  grid-column: span 2;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field > span {
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text);
}

.field > span em {
  font-weight: normal;
  color: var(--muted);
  font-size: 11.5px;
}

input,
textarea,
select {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 9px;
  font-family: inherit;
  font-size: 13.5px;
  background: #fbfcfe;
  color: var(--text);
  transition: all 0.2s ease;
}

input:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
  background: #ffffff;
}

input[readonly] {
  background: #f1f5f9;
  color: #475569;
  cursor: not-allowed;
}

/* --- BUTTONS --- */
.btn {
  border: 1px solid var(--line);
  background: #ffffff;
  color: var(--text);
  padding: 10px 16px;
  border-radius: 9px;
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  white-space: nowrap;
  transition: all 0.18s ease;
}

.btn:hover {
  background: #f8fafc;
  border-color: #cbd5e1;
}

.btn-primary {
  background: var(--primary);
  border-color: var(--primary);
  color: #ffffff;
  box-shadow: 0 2px 6px rgba(37, 99, 235, 0.25);
}

.btn-primary:hover {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
  box-shadow: 0 4px 10px rgba(37, 99, 235, 0.35);
}

.btn-secondary {
  background: #f1f5f9;
  border-color: #e2e8f0;
  color: #334155;
}

.btn-secondary:hover {
  background: #e2e8f0;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 16px;
}

/* --- CHECKBOX / RADIO PILL BUTTONS --- */
.option-group {
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 11px;
  padding: 12px 14px;
  margin-bottom: 10px;
}

.option-title {
  font-size: 13px;
  font-weight: 600;
  color: #334155;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.option-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.option-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #ffffff;
  border: 1px solid #cbd5e1;
  padding: 7px 13px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  color: #334155;
  cursor: pointer;
  user-select: none;
  transition: all 0.18s ease;
}

.option-pill input[type="radio"] {
  display: none;
}

.option-pill .pill-box {
  width: 16px;
  height: 16px;
  border-radius: 4px;
  border: 1.5px solid #94a3b8;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  color: #ffffff;
  transition: all 0.18s ease;
}

.option-pill:hover {
  border-color: var(--primary);
  background: #f0f7ff;
}

.option-pill.active {
  border-color: var(--primary);
  background: var(--primary-light);
  color: var(--primary);
  font-weight: 600;
}

.option-pill.active .pill-box {
  border-color: var(--primary);
  background: var(--primary);
}

.option-pill.active .pill-box::after {
  content: '✓';
}

/* --- TIỆN ÍCH THỊ TRƯỜNG TÀI CHÍNH (SIDEBAR) --- */
.card-sidebar {
  padding: 16px;
  border-color: #cbd5e1;
}

.market-tabs {
  display: flex;
  gap: 4px;
  background: #f1f5f9;
  padding: 4px;
  border-radius: 10px;
  margin-bottom: 12px;
}

.market-tab-btn {
  flex: 1;
  background: transparent;
  border: none;
  padding: 7px 8px;
  border-radius: 7px;
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  transition: all 0.2s;
  white-space: nowrap;
}

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

.market-tab-btn.active {
  color: var(--primary);
  background: #ffffff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
}

.iframe-wrapper {
  position: relative;
  width: 100%;
  height: 520px;
  overflow: hidden;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #ffffff;
}

.iframe-wrapper iframe {
  width: 100%;
  height: 100%;
  border: none;
}

/* --- THÔNG BÁO VÀ HƯỚNG DẪN --- */
.msg {
  margin: 12px 0 0;
  font-size: 13px;
  font-weight: 500;
  white-space: pre-line;
  border-radius: 8px;
  padding: 0;
}

.msg.ok {
  color: var(--ok);
  background: var(--ok-light);
  padding: 8px 12px;
  border: 1px solid rgba(16, 185, 129, 0.2);
}

.msg.err {
  color: var(--err);
  background: var(--err-light);
  padding: 8px 12px;
  border: 1px solid rgba(239, 68, 68, 0.2);
}

.msg.warn {
  color: var(--warn);
  background: var(--warn-light);
  padding: 8px 12px;
  border: 1px solid rgba(245, 158, 11, 0.2);
}

.helper {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px dashed var(--line);
}

.helper summary {
  cursor: pointer;
  font-weight: 600;
  font-size: 13px;
  color: var(--primary);
}

.helper p {
  margin: 8px 0 10px;
  font-size: 12.5px;
  color: var(--muted);
}

.tablewrap {
  overflow: auto;
  max-height: 420px;
  border: 1px solid var(--line);
  border-radius: 10px;
}

table {
  border-collapse: collapse;
  width: 100%;
  font-size: 12.5px;
}

th,
td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

th {
  position: sticky;
  top: 0;
  background: #f8fafc;
  z-index: 1;
  font-size: 11.5px;
  text-transform: uppercase;
  color: var(--muted);
  letter-spacing: 0.03em;
  font-weight: 600;
}

td.num {
  text-align: right;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

td.empty {
  text-align: center;
  color: var(--muted);
  padding: 24px;
}

.hint {
  margin: 0 0 10px;
  font-size: 12.5px;
  color: var(--muted);
}

footer {
  max-width: 1240px;
  margin: 10px auto 0;
  padding: 16px 20px;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

/* ==========================================================================
   RESPONSIVE CHO ĐIỆN THOẠI & TABLET (TẤT CẢ XẾP THEO CHIỀU DỌC)
   ========================================================================== */
@media (max-width: 1080px) {
  .main-layout {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  .sidebar-column {
    position: static;
    width: 100%;
  }

  .quick-links {
    position: static;
    transform: none;
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: center;
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.25);
    box-shadow: none;
    padding: 8px 12px;
    margin-top: 14px;
    border-radius: 12px;
    gap: 8px;
  }

  .quick-link-item {
    width: auto;
    height: 36px;
    padding: 0 12px;
    border-radius: 8px;
    gap: 6px;
  }

  .quick-link-item::after,
  .quick-link-item::before {
    display: none !important;
  }

  .quick-link-label {
    display: inline;
    font-size: 12px;
    font-weight: 600;
  }

  .iframe-wrapper {
    height: 480px;
  }
}

@media (max-width: 680px) {
  .grid {
    grid-template-columns: 1fr;
  }

  .span2 {
    grid-column: span 1;
  }

  .actions .btn {
    flex: 1 1 100%;
  }

  .iframe-wrapper {
    height: 440px;
  }
}
