@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&family=JetBrains+Mono:wght@400;500;600;700&family=Space+Grotesk:wght@500;600;700&display=swap');

:root {
  /* 🔤 Typography Tokens (Theo chuẩn cc.dangdi.dev) */
  --font-sans: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --font-display: 'Space Grotesk', 'Inter', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;

  /* 🟡 VNPost Gold Accent */
  --gold-primary: #FDB813;
  --gold-hover: #E5A305;
  --gold-active: #C98E02;
  --gold-light: rgba(253, 184, 19, 0.12);
  --gold-border: rgba(253, 184, 19, 0.45);
  --gold-shadow: 0 6px 20px -2px rgba(253, 184, 19, 0.35);

  /* 🔵 VNPost Brand Navy */
  --navy-primary: #014C8D;
  --navy-hover: #013A6E;
  --navy-light: rgba(1, 76, 141, 0.08);
  --navy-border: rgba(1, 76, 141, 0.2);

  /* ⚪ Neutral / Light Theme */
  --bg-body: #F4F6FA;
  --bg-surface: #FFFFFF;
  --bg-surface-subtle: #F8FAFC;
  --bg-surface-elevated: #FFFFFF;
  --text-main: #0F172A;
  --text-secondary: #475569;
  --text-muted: #94A3B8;
  --border-color: #E2E8F0;
  --border-subtle: #EDF2F7;

  /* Status Colors */
  --success: #10B981;
  --success-bg: rgba(16, 185, 129, 0.1);
  --danger: #EF4444;
  --danger-bg: rgba(239, 68, 68, 0.1);

  /* Shadows */
  --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.05), 0 1px 2px rgba(15, 23, 42, 0.03);
  --shadow-md: 0 6px 20px -4px rgba(1, 76, 141, 0.08), 0 2px 6px -2px rgba(15, 23, 42, 0.03);
  --shadow-lg: 0 16px 36px -6px rgba(1, 76, 141, 0.12), 0 6px 16px -4px rgba(15, 23, 42, 0.04);

  /* Radii */
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-full: 9999px;

  /* Transitions */
  --transition-fast: 0.18s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-normal: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* 🌙 Dark Mode (Theo hệ điều hành) */
@media (prefers-color-scheme: dark) {
  :root {
    --bg-body: #0A0F1D;
    --bg-surface: #131B2E;
    --bg-surface-subtle: #19233C;
    --bg-surface-elevated: #1E2943;
    --text-main: #F8FAFC;
    --text-secondary: #CBD5E1;
    --text-muted: #64748B;
    --border-color: #23314F;
    --border-subtle: #1C273E;
    --shadow-md: 0 8px 24px -4px rgba(0, 0, 0, 0.5);
    --shadow-lg: 0 18px 40px -6px rgba(0, 0, 0, 0.7);
    --navy-light: rgba(144, 202, 249, 0.12);
  }
}

/* ==========================================================================
   RESET & BASE TYPOGRAPHY
   ========================================================================== */
* {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 0;
  font-family: var(--font-sans);
  font-feature-settings: "cv11", "ss01";
  background-color: var(--bg-body);
  color: var(--text-main);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, h4, h5, h6,
.header-title,
.hero-content h1,
.page-title,
.card-title,
.tariff-title,
.menubar-header,
.login-title,
.metric-value {
  font-family: var(--font-display);
  letter-spacing: -0.025em;
}

code, kbd, samp, pre, .contract-display {
  font-family: var(--font-mono);
}

/* ==========================================================================
   TOP HEADER BAR
   ========================================================================== */
.header {
  display: flex;
  align-items: center;
  background: var(--bg-surface);
  box-shadow: var(--shadow-sm);
  border-bottom: 1px solid var(--border-color);
  padding: 0 20px;
  height: 58px;
  position: sticky;
  top: 0;
  z-index: 50;
}

.logo {
  height: 38px;
  width: auto;
  margin-right: 14px;
  cursor: pointer;
  transition: transform var(--transition-fast);
}

.logo:hover {
  transform: scale(1.03);
}

.header-title {
  font-size: 1.12em;
  font-weight: 700;
  color: var(--navy-primary);
  flex: 1;
  letter-spacing: 0.4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: flex;
  align-items: center;
  gap: 8px;
}

@media (prefers-color-scheme: dark) {
  .header-title {
    color: var(--gold-primary);
  }
}

.menu-btn {
  background: var(--gold-light);
  border: 1px solid var(--gold-border);
  font-size: 1.35em;
  color: var(--navy-primary);
  cursor: pointer;
  margin-right: 12px;
  height: 40px;
  width: 40px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
}

.menu-btn:hover {
  background: var(--gold-primary);
  color: #000;
  transform: translateY(-1px);
}

@media (prefers-color-scheme: dark) {
  .menu-btn {
    color: var(--gold-primary);
  }
  .menu-btn:hover {
    color: #000;
  }
}

.back-btn {
  background: var(--bg-surface-subtle);
  color: var(--navy-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 8px 18px;
  font-size: 0.95em;
  font-weight: 600;
  cursor: pointer;
  margin-left: 12px;
  transition: all var(--transition-fast);
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  text-decoration: none;
}

.back-btn:hover {
  background: var(--gold-primary);
  color: #000;
  border-color: var(--gold-primary);
  box-shadow: var(--gold-shadow);
  transform: translateY(-1px);
}

@media (prefers-color-scheme: dark) {
  .back-btn {
    background: var(--bg-surface-elevated);
    color: var(--text-main);
  }
  .back-btn:hover {
    color: #000;
  }
}

/* ==========================================================================
   DRAWER / SIDEBAR (MENUBAR)
   ========================================================================== */
.menubar {
  position: fixed;
  top: 0;
  left: 0;
  width: 270px;
  max-width: 85vw;
  height: 100vh;
  background: var(--bg-surface);
  box-shadow: 6px 0 24px rgba(0, 0, 0, 0.15);
  border-right: 1px solid var(--border-color);
  z-index: 100;
  transform: translate3d(-100%, 0, 0);
  will-change: transform;
  transition: transform 0.22s cubic-bezier(0, 0, 0.2, 1);
  display: flex;
  flex-direction: column;
  padding: 20px 16px;
}

.menubar.open {
  transform: translate3d(0, 0, 0);
}

.menubar-header {
  font-size: 1.25em;
  font-weight: 800;
  color: var(--navy-primary);
  padding-bottom: 14px;
  border-bottom: 2px solid var(--gold-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

@media (prefers-color-scheme: dark) {
  .menubar-header {
    color: var(--gold-primary);
  }
}

.menubar-user {
  font-size: 0.95em;
  color: var(--text-secondary);
  margin: 14px 0 18px 0;
  padding: 10px 14px;
  background: var(--bg-surface-subtle);
  border-radius: var(--radius-sm);
  border-left: 4px solid var(--gold-primary);
  font-weight: 500;
}

.menubar-list {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.menubar-list a {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text-main);
  text-decoration: none;
  font-size: 0.98em;
  font-weight: 600;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  transition: all var(--transition-fast);
}

.menubar-list a:hover {
  background: var(--gold-light);
  color: var(--navy-primary);
  transform: translateX(4px);
}

@media (prefers-color-scheme: dark) {
  .menubar-list a:hover {
    color: var(--gold-primary);
  }
}

.menubar-list .btn, .btn-logout {
  background: var(--danger-bg);
  color: var(--danger);
  border: 1px solid rgba(239, 68, 68, 0.2);
  border-radius: var(--radius-sm);
  padding: 11px 16px;
  font-size: 0.98em;
  font-weight: 600;
  cursor: pointer;
  width: 100%;
  margin-top: auto;
  transition: all var(--transition-fast);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.menubar-list .btn:hover, .btn-logout:hover {
  background: var(--danger);
  color: #fff;
}

.menubar-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 90;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.2s ease, visibility 0.2s ease;
}

.menubar-overlay.open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

/* ==========================================================================
   LAYOUT CONTAINERS & CARDS
   ========================================================================== */
.main {
  max-width: 1240px;
  margin: 28px auto;
  padding: 0 20px;
  position: relative;
  z-index: 1;
}

.container {
  max-width: 900px;
  margin: 28px auto;
  background: var(--bg-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  border: 1px solid var(--border-color);
  padding: 32px 28px;
  position: relative;
  z-index: 1;
  transition: box-shadow var(--transition-normal);
}

.container:hover {
  box-shadow: var(--shadow-lg);
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
}

.card {
  background: var(--bg-surface);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-color);
  padding: 14px 14px 10px 14px;
  display: flex;
  flex-direction: column;
  cursor: pointer;
  transition: all var(--transition-fast);
  position: relative;
  overflow: hidden;
  min-height: 105px;
}

.card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 3px;
  background: linear-gradient(90deg, var(--gold-primary), var(--gold-hover));
  opacity: 0;
  transition: opacity var(--transition-fast);
}

.card:hover {
  box-shadow: var(--shadow-md);
  border-color: var(--gold-primary);
  transform: translateY(-2px);
}

.card:hover::before {
  opacity: 1;
}

.card-title {
  font-size: 0.94em;
  font-weight: 700;
  color: var(--navy-primary);
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: 6px;
  line-height: 1.3;
}

@media (prefers-color-scheme: dark) {
  .card-title {
    color: var(--gold-primary);
  }
}

.card-desc {
  color: var(--text-secondary);
  font-size: 0.81em;
  line-height: 1.35;
  flex: 1;
  margin-bottom: 8px;
}

.card-progress {
  height: 3px;
  border-radius: var(--radius-full);
  background: linear-gradient(90deg, var(--gold-primary) 0%, rgba(253, 184, 19, 0.25) 100%);
  width: 40%;
  margin-top: auto;
  transition: width var(--transition-fast);
}

.card:hover .card-progress {
  width: 75%;
}

/* ==========================================================================
   BUTTONS & FORM INPUTS
   ========================================================================== */
h2, .page-title {
  text-align: center;
  color: var(--navy-primary);
  font-size: 1.6em;
  font-weight: 800;
  margin: 0 0 24px 0;
  letter-spacing: -0.3px;
}

@media (prefers-color-scheme: dark) {
  h2, .page-title {
    color: var(--gold-primary);
  }
}

label {
  font-size: 0.92em;
  font-weight: 600;
  color: var(--text-main);
  margin-bottom: 6px;
  display: block;
}

input, select, textarea {
  width: 100%;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border-color);
  background: var(--bg-surface-subtle);
  color: var(--text-main);
  font-family: inherit;
  font-size: 0.98em;
  transition: all var(--transition-fast);
  box-sizing: border-box;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--gold-primary);
  outline: none;
  background: var(--bg-surface);
  box-shadow: 0 0 0 3px rgba(253, 184, 19, 0.2);
}

/* Primary Gold Action Button */
.btn-primary, .btn-calc, .btn-export, .login-btn, .btn-upload {
  background: linear-gradient(135deg, var(--gold-primary) 0%, var(--gold-hover) 100%);
  color: #111827;
  border: none;
  border-radius: var(--radius-sm);
  padding: 13px 24px;
  font-size: 1.02em;
  font-weight: 700;
  cursor: pointer;
  transition: all var(--transition-fast);
  box-shadow: var(--gold-shadow);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  letter-spacing: 0.2px;
}

.btn-primary:hover, .btn-calc:hover, .btn-export:hover, .login-btn:hover, .btn-upload:hover {
  background: linear-gradient(135deg, #FFC024 0%, #D49300 100%);
  transform: translateY(-2px);
  box-shadow: 0 8px 24px -2px rgba(253, 184, 19, 0.45);
}

.btn-primary:active, .btn-calc:active, .btn-export:active, .login-btn:active, .btn-upload:active {
  transform: translateY(0);
}

/* Navy Button */
.btn-navy {
  background: var(--navy-primary);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  padding: 12px 22px;
  font-size: 1em;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.btn-navy:hover {
  background: var(--navy-hover);
  transform: translateY(-1px);
}

/* Copy Photo Button */
.btn-copy-img {
  background: linear-gradient(135deg, var(--navy-primary) 0%, #013A6E 100%);
  color: #fff;
  border: 1px solid var(--gold-primary);
  border-radius: var(--radius-sm);
  padding: 10px 20px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
  box-shadow: var(--shadow-sm);
}

.btn-copy-img:hover {
  background: var(--gold-primary);
  color: #000;
  border-color: var(--gold-primary);
  box-shadow: var(--gold-shadow);
  transform: translateY(-2px);
}

/* ==========================================================================
   DATA TABLES (MODERN STYLED WITH RESPONSIVE OPTIMIZATION)
   ========================================================================== */
.tariff-section {
  margin-top: 28px;
  margin-bottom: 32px;
}

.tariff-title {
  font-size: 1.18em;
  font-weight: 700;
  color: var(--navy-primary);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  border-left: 4px solid var(--gold-primary);
  padding-left: 12px;
}

@media (prefers-color-scheme: dark) {
  .tariff-title {
    color: var(--gold-primary);
  }
}

.table-responsive {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-color);
  background: var(--bg-surface);
}

table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  text-align: center;
}

th, td {
  padding: 13px 12px;
  border-bottom: 1px solid var(--border-subtle);
  font-size: 0.95em;
  white-space: nowrap;
}

th {
  background: var(--bg-surface-subtle);
  color: var(--navy-primary);
  font-weight: 700;
  border-bottom: 2px solid var(--gold-primary);
  position: sticky;
  top: 0;
  z-index: 2;
}

@media (prefers-color-scheme: dark) {
  th {
    color: var(--gold-primary);
    background: var(--bg-surface-elevated);
  }
}

tr:hover td {
  background: var(--gold-light);
  transition: background var(--transition-fast);
}

tr:last-child td {
  border-bottom: none;
}

/* Mobile Sticky first column for Tables */
@media (max-width: 768px) {
  th:first-child, td:first-child {
    position: sticky;
    left: 0;
    z-index: 3;
    background: var(--bg-surface);
    box-shadow: 2px 0 6px rgba(0, 0, 0, 0.05);
    font-weight: 700;
  }
  th:first-child {
    z-index: 4;
    background: var(--bg-surface-subtle);
  }
}

/* ==========================================================================
   WATERMARK & TOASTS
   ========================================================================== */
.watermark-logo {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.035;
}

.watermark-logo img {
  max-width: 55vw;
  max-height: 55vh;
  filter: grayscale(1);
  user-select: none;
}

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: #0F172A;
  color: #fff;
  border: 1px solid var(--gold-primary);
  padding: 14px 28px;
  border-radius: var(--radius-full);
  box-shadow: var(--shadow-lg);
  font-size: 0.98em;
  font-weight: 600;
  opacity: 0;
  pointer-events: none;
  transition: all var(--transition-normal);
  z-index: 9999;
  display: flex;
  align-items: center;
  gap: 8px;
}

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

/* Responsive tweaks */
@media (max-width: 640px) {
  .header {
    padding: 0 12px;
    height: 52px;
  }
  .header-title {
    font-size: 0.95em;
  }
  .container {
    padding: 18px 14px;
    margin: 14px auto;
    border-radius: var(--radius-md);
  }
  .card-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
  }
  .watermark-logo img {
    max-width: 85vw;
  }
}

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

