/* ============================================================
   NEXUS PAGE-LEVEL PREMIUM STYLES
   Covers all module pages: Dashboard, Upload, Fiscal, Users, API Keys
   Also provides Bootstrap grid compatibility layer
   ============================================================ */

/* ===== FLEX UTILITIES ===== */
.d-flex           { display: flex !important; }
.d-block          { display: block !important; }
.d-inline-block   { display: inline-block !important; }
.d-none           { display: none !important; }
.align-items-center   { align-items: center !important; }
.align-items-start    { align-items: flex-start !important; }
.align-items-end      { align-items: flex-end !important; }
.justify-content-between { justify-content: space-between !important; }
.justify-content-center  { justify-content: center !important; }
.justify-content-end     { justify-content: flex-end !important; }
.flex-wrap  { flex-wrap: wrap !important; }
.flex-column { flex-direction: column !important; }
.flex-1     { flex: 1 !important; }
.flex-shrink-0 { flex-shrink: 0 !important; }
.gap-1 { gap: 4px !important; }
.gap-2 { gap: 8px !important; }
.gap-3 { gap: 12px !important; }
.gap-4 { gap: 16px !important; }
.w-100 { width: 100% !important; }
.ms-auto { margin-left: auto !important; }
.me-auto { margin-right: auto !important; }
.py-3   { padding-top: 12px !important; padding-bottom: 12px !important; }
.px-3   { padding-left: 12px !important; padding-right: 12px !important; }
.pt-3   { padding-top: 12px !important; }
.pb-3   { padding-bottom: 12px !important; }
.small  { font-size: 12px !important; }
.font-monospace { font-family: 'SF Mono', monospace !important; }
.fw-bold { font-weight: 700 !important; }
.fw-600  { font-weight: 600 !important; }
.text-end { text-align: right !important; }
.text-start { text-align: left !important; }

/* Bootstrap heading resets (<h2> used inline as size) */
.h2 { font-size: 20px; font-weight: 700; color: var(--text-primary); letter-spacing: -0.4px; }
.h3 { font-size: 17px; font-weight: 700; color: var(--text-primary); letter-spacing: -0.3px; }
.h4 { font-size: 15px; font-weight: 700; color: var(--text-primary); }
.h5 { font-size: 13.5px; font-weight: 700; color: var(--text-primary); }
.h6 { font-size: 12px;  font-weight: 700; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.4px; }
.mb-0 { margin-bottom: 0 !important; }

/* Flex gap shorthand on rows */
.row.gap-2 > * { padding: 4px; }

/* Extended col sizes */
.col-lg-5, .col-lg-7 { flex: 0 0 50%; max-width: 50%; }
.col-lg-5 { flex: 0 0 41.66%; max-width: 41.66%; }
.col-lg-7 { flex: 0 0 58.33%; max-width: 58.33%; }
.col-sm-6 { flex: 0 0 50%; max-width: 50%; }
.col-6    { flex: 0 0 50%; max-width: 50%; }
.col-4    { flex: 0 0 33.33%; max-width: 33.33%; }
.col-8    { flex: 0 0 66.66%; max-width: 66.66%; }
.col-3    { flex: 0 0 25%; max-width: 25%; }
.col-2    { flex: 0 0 16.66%; max-width: 16.66%; }
.col-1    { flex: 0 0 8.33%; max-width: 8.33%; }

@media (max-width: 768px) {
  .col-lg-5, .col-lg-7, .col-sm-6,
  .col-6, .col-4, .col-8, .col-3, .col-2, .col-1 {
    flex: 0 0 100%; max-width: 100%;
  }
}

/* ===== SEMANTIC BADGE COLOURS ===== */
.badge-green,  .badge.badge-green  { background: rgba(52,199,89,0.13);  color: #1A7A36; }
.badge-red,    .badge.badge-red    { background: rgba(255,59,48,0.13);  color: var(--brand-red); }
.badge-orange, .badge.badge-orange { background: rgba(255,149,0,0.13);  color: #B36B00; }
.badge-blue,   .badge.badge-blue   { background: rgba(0,122,255,0.13);  color: var(--brand-blue); }
.badge-gray,   .badge.badge-gray   { background: var(--bg-surface-3);   color: var(--text-secondary); }
.badge-indigo, .badge.badge-indigo { background: rgba(88,86,214,0.13);  color: #5856D6; }

[data-theme="dark"] .badge-green  { background: rgba(52,199,89,0.2);  color: #5AD67D; }
[data-theme="dark"] .badge-red    { background: rgba(255,59,48,0.2);  color: #FF6961; }
[data-theme="dark"] .badge-orange { background: rgba(255,149,0,0.2);  color: #FFB340; }
[data-theme="dark"] .badge-blue   { background: rgba(0,122,255,0.2);  color: #4DA3FF; }
[data-theme="dark"] .badge-indigo { background: rgba(88,86,214,0.2);  color: #968EF5; }

/* Legacy badge classes used in fiscal_years_unified */
.badge-success  { display:inline-flex; padding:2px 8px; border-radius:var(--r-full); font-size:11px; font-weight:600; background: rgba(52,199,89,0.13); color: #1A7A36; }
.badge-enhanced { display:inline-flex; padding:2px 8px; border-radius:var(--r-full); font-size:11px; font-weight:600; background: var(--bg-surface-3); color: var(--text-secondary); }
.badge-error    { display:inline-flex; padding:2px 8px; border-radius:var(--r-full); font-size:11px; font-weight:600; background: rgba(255,59,48,0.13); color: var(--brand-red); }

[data-theme="dark"] .badge-success { background: rgba(52,199,89,0.2); color: #5AD67D; }
[data-theme="dark"] .badge-error   { background: rgba(255,59,48,0.2); color: #FF6961; }

/* ===== LIST GROUP (fiscal recent locks) ===== */
.list-group-flush { list-style: none; margin: 0; padding: 0; }
.list-group-item {
  padding: 10px 0;
  border-bottom: 1px solid var(--divider);
  font-size: 13px;
  color: var(--text-primary);
}
.list-group-item:last-child { border-bottom: none; }
.px-0 { padding-left: 0 !important; padding-right: 0 !important; }

/* ===== RAW API KEY GENERATED ALERT ===== */
.alert-warning {
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: rgba(255,149,0,0.10);
  border: 1px solid rgba(255,149,0,0.3);
  border-radius: var(--r-md);
  padding: 12px 16px;
  font-size: 13px;
  color: var(--text-primary);
  margin-bottom: 14px;
  animation: nx-slide-up 0.2s both;
}

.alert-warning code,
.alert-warning .bg-light {
  display: block;
  font-family: 'SF Mono', monospace;
  font-size: 12px;
  background: var(--bg-surface-3) !important;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 8px 10px;
  word-break: break-all;
  color: var(--brand-orange);
  letter-spacing: 0.5px;
}

.alert-dismissible .btn-close {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-tertiary);
  font-size: 18px;
  align-self: flex-start;
  line-height: 1;
  padding: 0;
}

.alert-danger {
  background: rgba(255,59,48,0.08);
  border: 1px solid rgba(255,59,48,0.2);
  border-radius: var(--r-md);
  padding: 12px 16px;
  font-size: 13px;
  color: var(--brand-red);
  margin-bottom: 12px;
}

/* ===== ENHANCED BUTTON VARIANTS (legacy premium) ===== */
.btn-primary-enhanced {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  background: var(--brand-blue);
  color: white;
  border: none;
  border-radius: var(--r-md);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity var(--t-fast), transform var(--t-fast);
}
.btn-primary-enhanced:hover { opacity: 0.88; transform: translateY(-1px); }

.btn-secondary-enhanced {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  background: var(--bg-surface-2);
  color: var(--text-secondary);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--t-fast);
}
.btn-secondary-enhanced:hover { background: var(--bg-surface-3); }

/* Scale up animation for form reveal */
.scale-up {
  animation: nx-slide-up 0.22s cubic-bezier(0.4,0,0.2,1) both;
}

/* ===== FORM CHECK (checkbox) ===== */
.form-check {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}
.form-check-input {
  width: 16px; height: 16px;
  accent-color: var(--brand-blue);
  cursor: pointer;
  flex-shrink: 0;
}
.form-check-label {
  font-size: 13px;
  color: var(--text-primary);
  cursor: pointer;
}

/* ===== PAGE HEADER ===== */
.page-header {
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--divider);
}

.page-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.5px;
  margin-bottom: 3px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.page-title-icon {
  width: 32px; height: 32px;
  background: var(--brand-blue-glow);
  border-radius: var(--r-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.page-subtitle {
  font-size: 13px;
  color: var(--text-tertiary);
  margin: 0;
}

/* Legacy compat — plain h2 at top of page */
#view-content > h2,
.view-root > h2 {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 4px;
  letter-spacing: -0.4px;
  display: flex;
  align-items: center;
  gap: 8px;
}

#view-content > p:first-of-type,
.view-root > p:first-of-type {
  font-size: 13px;
  color: var(--text-tertiary);
  margin-bottom: 16px;
}

/* ===== PREMIUM STATS GRID ===== */
.stats-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}

/* Legacy stat-card override */
.stat-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 14px 16px;
  box-shadow: var(--shadow-xs);
  transition: box-shadow var(--t-fast), transform var(--t-fast);
  cursor: default;
}

.stat-card:hover {
  box-shadow: var(--shadow-sm);
  transform: translateY(-1px);
}

.stat-card strong,
.stat-card .stat-value {
  display: block;
  font-size: 26px;
  font-weight: 800;
  color: var(--text-primary);
  letter-spacing: -1px;
  line-height: 1;
  margin-top: 6px;
}

.stat-card .stat-label,
.stat-card > *:first-child:not(strong):not(.stat-value) {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-tertiary);
}

/* ===== BOOTSTRAP GRID COMPAT ===== */
.row {
  display: flex;
  flex-wrap: wrap;
  margin: -6px;
}

.row.g-2 { margin: -4px; }
.row.g-2 > * { padding: 4px; }

.row.g-3 { margin: -6px; }
.row.g-3 > * { padding: 6px; }

.row > * { padding: 6px; box-sizing: border-box; }

/* Bootstrap col sizes */
.col-12 { flex: 0 0 100%; max-width: 100%; }
.col-md-1  { flex: 0 0 8.33%;  max-width: 8.33%; }
.col-md-2  { flex: 0 0 16.66%; max-width: 16.66%; }
.col-md-3  { flex: 0 0 25%;    max-width: 25%; }
.col-md-4  { flex: 0 0 33.33%; max-width: 33.33%; }
.col-md-5  { flex: 0 0 41.66%; max-width: 41.66%; }
.col-md-6  { flex: 0 0 50%;    max-width: 50%; }
.col-md-7  { flex: 0 0 58.33%; max-width: 58.33%; }
.col-md-8  { flex: 0 0 66.66%; max-width: 66.66%; }
.col-md-9  { flex: 0 0 75%;    max-width: 75%; }
.col-md-10 { flex: 0 0 83.33%; max-width: 83.33%; }
.col-md-12 { flex: 0 0 100%;   max-width: 100%; }

@media (max-width: 768px) {
  .col-md-1, .col-md-2, .col-md-3, .col-md-4,
  .col-md-5, .col-md-6, .col-md-7, .col-md-8,
  .col-md-9, .col-md-10, .col-md-12 {
    flex: 0 0 100%; max-width: 100%;
  }
}

/* Margin-bottom helpers */
.mb-1 { margin-bottom: 4px !important; }
.mb-2 { margin-bottom: 8px !important; }
.mb-3 { margin-bottom: 12px !important; }
.mb-4 { margin-bottom: 16px !important; }
.mb-5 { margin-bottom: 24px !important; }
.mt-1 { margin-top: 4px !important; }
.mt-2 { margin-top: 8px !important; }
.mt-3 { margin-top: 12px !important; }
.mt-4 { margin-top: 16px !important; }
.p-3  { padding: 12px !important; }
.p-4  { padding: 16px !important; }

/* ===== ENHANCED CARD (legacy compat) ===== */
.card-enhanced {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  overflow: hidden;
  box-shadow: var(--shadow-xs);
}

/* card with padding convenience */
.card.p-3 { padding: 16px; }
.card.p-4 { padding: 20px; }

/* ===== PREMIUM TABS (replaces Bootstrap nav-tabs) ===== */
.nav-tabs {
  display: flex;
  gap: 2px;
  padding: 4px;
  background: var(--bg-surface-3);
  border-radius: var(--r-md);
  border: none;
  margin-bottom: 0;
  width: fit-content;
}

.nav-tabs .nav-item { margin: 0; }

.nav-tabs .nav-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  background: none;
  border: none;
  border-radius: var(--r-sm);
  cursor: pointer;
  transition: background var(--t-fast), color var(--t-fast);
  white-space: nowrap;
  text-decoration: none;
}

.nav-tabs .nav-link:hover {
  color: var(--text-primary);
  background: rgba(0,0,0,0.04);
  text-decoration: none;
}

[data-theme="dark"] .nav-tabs .nav-link:hover {
  background: rgba(255,255,255,0.06);
}

.nav-tabs .nav-link.active {
  background: var(--bg-surface);
  color: var(--text-primary);
  box-shadow: var(--shadow-xs);
}

/* Tab content padding */
.tab-content-area,
.tab-content {
  padding-top: 16px;
}

/* Content header (used in fiscal_main etc.) */
.content-header {
  margin-bottom: 16px;
}

.content-header .page-title,
.content-header h1 {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 2px;
  letter-spacing: -0.4px;
}

.content-header .page-subtitle,
.content-header p {
  font-size: 13px;
  color: var(--text-tertiary);
}

/* Tab wrapper card */
.tab-container {
  padding: 0;
}

/* ===== PREMIUM TABLE COMPAT ===== */
/* table-responsive wrapper */
.table-responsive {
  overflow-x: auto;
  border-radius: var(--r-lg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-xs);
}

/* table-striped — subtle */
.table-striped tbody tr:nth-child(even) {
  background: var(--bg-surface-2);
}

/* Bootstrap badge compat (bg-success, bg-danger etc.) */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: var(--r-full);
  font-size: 11px;
  font-weight: 600;
}

.badge.bg-success, .badge-success { background: rgba(52,199,89,0.13); color: #1A7A36; }
.badge.bg-danger,  .badge-danger  { background: rgba(255,59,48,0.13);  color: var(--brand-red); }
.badge.bg-warning, .badge-warning { background: rgba(255,149,0,0.13);  color: #B36B00; }
.badge.bg-info,    .badge-info    { background: rgba(0,122,255,0.13);  color: var(--brand-blue); }
.badge.bg-secondary,.badge-secondary { background: var(--bg-surface-3); color: var(--text-secondary); }
.badge.bg-primary, .badge-primary { background: rgba(0,122,255,0.13);  color: var(--brand-blue); }

[data-theme="dark"] .badge.bg-success { background: rgba(52,199,89,0.2);  color: #5AD67D; }
[data-theme="dark"] .badge.bg-danger  { background: rgba(255,59,48,0.2);  color: #FF6961; }
[data-theme="dark"] .badge.bg-warning { background: rgba(255,149,0,0.2);  color: #FFB340; }
[data-theme="dark"] .badge.bg-info    { background: rgba(0,122,255,0.2);  color: #4DA3FF; }

/* Bootstrap btn compat */
.btn-success        { background: var(--brand-green); color: white; border: none; }
.btn-success:hover  { background: #28A745; }
.btn-danger         { background: var(--brand-red); color: white; border: none; }
.btn-danger:hover   { background: #CC2E25; }
.btn-warning        { background: var(--brand-orange); color: white; border: none; }
.btn-sm             { padding: 4px 10px; font-size: 12px; }
.btn-xs             { padding: 2px 8px; font-size: 11px; border-radius: var(--r-xs); }

.btn-outline-primary {
  background: none;
  border: 1px solid var(--brand-blue);
  color: var(--brand-blue);
  border-radius: var(--r-sm);
  font-size: 13px;
  font-weight: 600;
  padding: 5px 12px;
  cursor: pointer;
  transition: background var(--t-fast);
}
.btn-outline-primary:hover {
  background: var(--brand-blue-glow);
}

/* ===== PERMISSIONS TREE (MANAGEMENT) ===== */
.perms-tree {
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--bg-surface);
  overflow: hidden;
}

.perm-module-block {
  padding: 16px;
  background: var(--bg-surface);
  transition: background var(--t-fast);
}

.perm-module-block:hover {
  background: var(--bg-surface-2);
}

.perm-module-block label {
  cursor: pointer;
  user-select: none;
}

.perm-module-block input[type="checkbox"] {
  width: 16px;
  height: 16px;
  cursor: pointer;
  accent-color: var(--brand-blue);
}

.perms-tree hr {
  margin: 0;
  border-color: var(--divider);
}

.ms-4 {
  margin-left: 24px !important;
}

.gap-3 {
  gap: 12px !important;
}

.btn-outline-danger {
  background: none;
  border: 1px solid var(--brand-red);
  color: var(--brand-red);
  border-radius: var(--r-sm);
  font-size: 13px;
  font-weight: 600;
  padding: 5px 12px;
  cursor: pointer;
  transition: background var(--t-fast);
}
.btn-outline-danger:hover { background: rgba(255,59,48,0.08); }

/* ===== SECTION PANEL (used in fiscal, users, api-keys) ===== */
.panel {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  overflow: hidden;
  margin-bottom: 14px;
  box-shadow: var(--shadow-xs);
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: var(--bg-surface-2);
  border-bottom: 1px solid var(--border);
}

.panel-title {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 7px;
}

.panel-title-icon {
  font-size: 15px;
  line-height: 1;
}

.panel-body { padding: 14px 16px; }

/* ===== FORM GRID inside panel ===== */
.panel { overflow: visible !important; } /* Fix for dropdowns being cut off */
.panel-body { overflow: visible !important; }

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

.form-grid-flex {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 12px;
  margin-bottom: 14px;
}

.form-grid-flex .form-group { margin: 0; min-width: 150px; }
.form-grid-flex .flex-1 { flex: 1.5; }
.form-grid-flex .flex-2 { flex: 2.5; min-width: 220px; }
.form-grid-flex .form-group-btn { flex-shrink: 0; padding-bottom: 0; }

.z-index-top { position: relative; z-index: 100; }

.multiselect-wrapper { position: relative; }
.multiselect-menu { 
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  z-index: 2000 !important; 
  margin-top: 4px;
  background: var(--bg-surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-sm);
  box-shadow: var(--shadow-lg);
}

.form-grid-4 { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.form-grid-2 { grid-template-columns: repeat(2, 1fr); }
.form-grid-3 { grid-template-columns: repeat(3, 1fr); }

@media (max-width: 768px) {
  .form-grid,
  .form-grid-2,
  .form-grid-3,
  .form-grid-4 {
    grid-template-columns: 1fr;
  }
}

/* ===== PROGRESS BAR (Bootstrap compat) ===== */
.progress {
  height: 6px;
  background: var(--bg-surface-3);
  border-radius: var(--r-full);
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  background: var(--brand-blue);
  border-radius: var(--r-full);
  transition: width 0.4s ease;
}

.progress-bar-striped {
  background-image: repeating-linear-gradient(
    45deg,
    transparent,
    transparent 10px,
    rgba(255,255,255,0.1) 10px,
    rgba(255,255,255,0.1) 20px
  );
}

.progress-bar-animated {
  animation: nx-progress-stripe 0.8s linear infinite;
  width: 100%;
}

@keyframes nx-progress-stripe {
  from { background-position: 0 0; }
  to   { background-position: 40px 0; }
}

/* ===== TWO-COLUMN LAYOUT (fiscal stats layout) ===== */
.two-col {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 14px;
  align-items: start;
}

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

/* ===== HR DIVIDER ===== */
hr {
  border: none;
  border-top: 1px solid var(--divider);
  margin: 14px 0;
}

h5 {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 10px;
  letter-spacing: -0.2px;
}

/* ===== API KEY DISPLAY ===== */
.api-key-value {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-surface-3);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 7px 10px;
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 12px;
  color: var(--text-secondary);
  max-width: 320px;
  overflow: hidden;
}

.api-key-text {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ===== LOCK STATUS INDICATORS ===== */
.lock-status {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: var(--r-full);
}

.lock-status.locked   { background: rgba(88,86,214,0.12); color: #5856D6; }
.lock-status.unlocked { background: rgba(52,199,89,0.12);  color: var(--brand-green); }
.lock-status.active   { background: rgba(0,122,255,0.12);  color: var(--brand-blue); }
.lock-status.closed   { background: var(--bg-surface-3);  color: var(--text-secondary); }

[data-theme="dark"] .lock-status.locked   { background: rgba(88,86,214,0.2); color: #968EF5; }
[data-theme="dark"] .lock-status.unlocked { background: rgba(52,199,89,0.2); color: #5AD67D; }

/* ===== STATUS TEXT ===== */
.text-success { color: var(--brand-green) !important; }
.text-danger  { color: var(--brand-red) !important; }
.text-warning { color: var(--brand-orange) !important; }
.text-info    { color: var(--brand-blue) !important; }
.text-muted   { color: var(--text-tertiary) !important; }
.text-center  { text-align: center !important; }

/* ===== UPLOAD STATUS PANEL ===== */
#upload-status {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  overflow: hidden;
  margin-top: 14px;
  box-shadow: var(--shadow-xs);
}

#status-content {
  padding: 14px 16px;
}

/* ===== SECTION DIVIDER ===== */
.section-sep {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 16px 0 12px;
}

.section-sep-line {
  flex: 1;
  height: 1px;
  background: var(--divider);
}

.section-sep-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-tertiary);
  white-space: nowrap;
}

/* ===== INLINE ACTIONS ROW ===== */
.actions-row {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

/* ===== PREMIUM ACCORDION (fiscal lock rows) ===== */
.lock-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-bottom: 1px solid var(--divider);
  transition: background var(--t-fast);
}

.lock-row:last-child { border-bottom: none; }
.lock-row:hover { background: var(--bg-surface-2); }

.lock-row-info { flex: 1; }
.lock-row-period {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
}
.lock-row-meta {
  font-size: 11px;
  color: var(--text-tertiary);
  margin-top: 1px;
}

/* ===== INPUT GROUP ===== */
.input-group {
  display: flex;
  align-items: stretch;
}

.input-group .form-control {
  border-radius: var(--r-sm) 0 0 var(--r-sm);
  flex: 1;
}

.input-group .btn {
  border-radius: 0 var(--r-sm) var(--r-sm) 0;
  flex-shrink: 0;
}

/* ===== EMPTY TABLE STATE ===== */
.td-empty {
  text-align: center;
  padding: 32px !important;
  color: var(--text-tertiary);
  font-size: 13px;
}

/* ===== TOGGLE SWITCH ===== */
.toggle-switch {
  position: relative;
  width: 36px; height: 20px;
  flex-shrink: 0;
}

.toggle-switch input {
  opacity: 0;
  width: 0; height: 0;
  position: absolute;
}

.toggle-track {
  position: absolute;
  inset: 0;
  background: var(--bg-inset);
  border-radius: var(--r-full);
  cursor: pointer;
  transition: background var(--t-fast);
}

.toggle-track::after {
  content: '';
  position: absolute;
  left: 2px; top: 2px;
  width: 16px; height: 16px;
  background: white;
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
  transition: transform var(--t-fast);
}

.toggle-switch input:checked + .toggle-track {
  background: var(--brand-blue);
}

.toggle-switch input:checked + .toggle-track::after {
  transform: translateX(16px);
}

/* ===== INFO BOX ===== */
.info-box {
  display: flex;
  gap: 10px;
  padding: 11px 14px;
  background: rgba(0,122,255,0.06);
  border: 1px solid rgba(0,122,255,0.15);
  border-radius: var(--r-md);
  font-size: 12.5px;
  color: var(--text-secondary);
  line-height: 1.5;
  margin-bottom: 12px;
}

.info-box-icon {
  color: var(--brand-blue);
  font-size: 15px;
  flex-shrink: 0;
  margin-top: 1px;
}

/* ===== SEARCH + FILTER BAR ===== */
.filter-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.filter-bar .form-control { max-width: 240px; }
.filter-bar .form-select  { max-width: 180px; }

/* ===== FISCAL YEAR CARD ===== */
.fy-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 11px 14px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  margin-bottom: 8px;
  transition: box-shadow var(--t-fast);
}

.fy-card:hover { box-shadow: var(--shadow-sm); }

.fy-card-label {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.3px;
}

.fy-card-dates {
  font-size: 11.5px;
  color: var(--text-tertiary);
  margin-top: 1px;
}

/* ===== UPGRADE: fancy header for page intro ===== */
.page-intro {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 18px;
  gap: 12px;
}

.page-intro-left { flex: 1; }

.page-intro-left h2 {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 3px;
  letter-spacing: -0.4px;
}

.page-intro-left p {
  font-size: 13px;
  color: var(--text-tertiary);
  margin: 0;
}

.page-intro-right {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-shrink: 0;
}

/* ===== TABLE INSIDE CARD ===== */
.card > .table,
.card > .table-responsive {
  margin: -16px;
  width: calc(100% + 32px);
  border-radius: 0 0 var(--r-lg) var(--r-lg);
  border: none;
}

.card > .table-responsive {
  border: none;
  border-radius: 0 0 var(--r-lg) var(--r-lg);
  box-shadow: none;
}

/* ===== RESULT DISPLAY ===== */
.result-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  overflow: hidden;
  margin-top: 14px;
}

.result-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 11px 16px;
  background: var(--bg-surface-2);
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  font-weight: 700;
  color: var(--text-primary);
}

.result-card-body { padding: 14px 16px; }

.result-stats-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1px;
  background: var(--divider);
  border-bottom: 1px solid var(--border);
}

@media (max-width: 600px) {
  .result-stats-row { grid-template-columns: repeat(2, 1fr); }
}

.result-stat-cell {
  background: var(--bg-surface);
  padding: 10px 14px;
  text-align: center;
}

.result-stat-num {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.5px;
  line-height: 1;
  color: var(--text-primary);
}

.result-stat-num.green  { color: var(--brand-green); }
.result-stat-num.red    { color: var(--brand-red); }
.result-stat-num.orange { color: var(--brand-orange); }

.result-stat-lbl {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--text-tertiary);
  margin-top: 2px;
}

/* ===== SMOOTH PAGE TRANSITIONS ===== */
#view-content > * {
  animation: nx-slide-up 0.22s cubic-bezier(0.4,0,0.2,1) both;
}
/* ===== DATA ENTRY DASHBOARD (PREMIUM) ===== */
.de-dashboard {
  animation: nx-fade-in 0.4s ease-out;
}

.de-stats-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

.de-stat-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition: transform var(--t-fast), box-shadow var(--t-fast);
}

.de-stat-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.de-stat-card::after {
  content: '';
  position: absolute;
  top: 0; right: 0;
  width: 80px; height: 80px;
  background: radial-gradient(circle at top right, var(--brand-blue-glow), transparent 70%);
  opacity: 0.5;
}

.de-stat-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.de-stat-value {
  font-size: 32px;
  font-weight: 800;
  color: var(--text-primary);
  letter-spacing: -1px;
}

.de-stat-icon {
  font-size: 24px;
  margin-bottom: 4px;
}

/* Company Grid */
.company-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

.company-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 16px;
  cursor: pointer;
  transition: all var(--t-fast);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.company-card:hover {
  border-color: var(--brand-blue);
  background: var(--bg-surface-2);
  transform: scale(1.02);
}

.company-info {
  display: flex;
  flex-direction: column;
}

.company-name {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
}

.company-amount {
  font-size: 13px;
  color: var(--brand-blue);
  font-weight: 600;
  margin-top: 2px;
}

.company-arrow {
  color: var(--text-tertiary);
  font-size: 18px;
  transition: transform var(--t-fast);
}

.company-card:hover .company-arrow {
  color: var(--brand-blue);
  transform: translateX(4px);
}

/* Drill-down Modal/Overlay */
.de-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: nx-fade-in 0.2s ease-out;
}

.de-modal {
  background: var(--bg-surface);
  width: 100%;
  max-width: 500px;
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  animation: nx-slide-up 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.de-modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--divider);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-surface-2);
}

.de-modal-body {
  padding: 0;
  max-height: 70vh;
  overflow-y: auto;
}

.location-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px;
  border-bottom: 1px solid var(--divider);
  transition: background var(--t-fast);
}

.location-item:last-child { border-bottom: none; }
.location-item:hover { background: var(--bg-surface-2); }

.location-name {
  font-size: 14px;
  color: var(--text-primary);
  font-weight: 500;
}

.location-amount {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
}

/* Action Toolbar */
.de-toolbar {
  background: var(--bg-surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 12px 20px;
  margin-bottom: 24px;
  display: flex;
  align-items: center;
  gap: 16px;
}

@media (max-width: 768px) {
  .de-stats-row { grid-template-columns: 1fr; }
  .de-toolbar { flex-direction: column; align-items: stretch; }
}

/* ========================================================================
   TABLE ARCHITECT (SYSTEM MODULE)
   ======================================================================== */

.architect-layout {
    display: grid;
    grid-template-columns: 300px 1fr;
    gap: 24px;
    height: calc(100vh - 180px);
    margin-top: 20px;
}

.arch-sidebar {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--bg-surface);
    min-width: 280px;
    border: 1px solid var(--border);
}

.arch-sidebar .table-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
}

.table-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    color: var(--text-secondary);
}

.table-item:hover {
    background: var(--bg-surface-3);
    color: var(--text-primary);
}

.table-item.active {
    background: var(--brand-blue-glow);
    color: var(--brand-blue);
    font-weight: 600;
}

.table-icon {
    font-size: 16px;
    opacity: 0.7;
}

.architect-main {
    overflow-y: auto;
}

.schema-card {
    border: 1px solid var(--border);
}

.architect-table {
    width: 100%;
    border-collapse: collapse;
}

.architect-table th {
    text-align: left;
    padding: 12px 16px;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-tertiary);
    border-bottom: 1px solid var(--border);
    background: rgba(0,0,0,0.02);
}

[data-theme="dark"] .architect-table th {
    background: rgba(255,255,255,0.02);
}

.architect-table td {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

.col-info {
    display: flex;
    align-items: center;
    gap: 8px;
}

.col-name {
    font-weight: 600;
    font-family: 'SF Mono', 'Fira Code', monospace;
    font-size: 13px;
}

.type-code {
    background: var(--bg-surface-3);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 12px;
    color: var(--brand-blue);
}

.delete-btn {
    color: var(--brand-red);
    opacity: 0.4;
    transition: all 0.2s;
    background: none;
    border: none;
    cursor: pointer;
}

.delete-btn:hover {
    opacity: 1;
    background: rgba(255, 59, 48, 0.1);
    transform: scale(1.1);
}

.lock-icon {
    opacity: 0.3;
    font-size: 12px;
}

/* Modal Enhancements */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.4);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-card {
    width: 100%;
    max-width: 500px;
    border-radius: 16px;
    box-shadow: var(--shadow-lg);
    background: var(--bg-surface);
}

.modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-body {
    padding: 24px;
}

.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    cursor: pointer;
}

@media (max-width: 1200px) {
    .architect-layout {
        grid-template-columns: 240px 1fr;
        gap: 16px;
    }
}

@media (max-width: 900px) {
    .architect-layout {
        grid-template-columns: 1fr;
        height: auto;
    }
    .arch-sidebar {
        height: 200px;
        margin-bottom: 20px;
        min-width: 100%;
    }
}

.btn-group-compact {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

.btn-group-compact .btn-icon {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    font-size: 14px;
    background: var(--bg-surface-3);
    border: 1px solid var(--border);
}

.btn-group-compact .edit-btn:hover {
    background: var(--brand-blue-glow);
    color: var(--brand-blue);
}

.scale-up {
    animation: nx-scale-up 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes nx-scale-up {
    from { transform: scale(0.95); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}
