/* ============================================
   TecniForge Motors: brand layer on top of the Invenza theme
   (TecniForge navy + blue, Urdu/RTL, app-specific components)
   ============================================ */
@import url('https://fonts.googleapis.com/css2?family=Noto+Nastaliq+Urdu:wght@400;600;700&display=swap');

:root {
  --primary: #1D6FE0;
  --primary-dark: #1557B5;
  --primary-light: #EAF2FD;
  --navy: #0B1F3A;
  --success: #16A34A;
}
.dark, html.dark { --primary-light: #10274A; }

/* Theme greens -> brand blue */
.btn-primary { background: var(--primary); border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }
.form-input:focus, .form-select:focus, .form-textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(29,111,224,.15); }
.auth-body { background: linear-gradient(135deg,#EEF4FF 0%,#EAF2FD 50%,#E0ECFF 100%); }
.dark .auth-body { background: linear-gradient(135deg,#0B1F3A 0%,#0F172A 60%,#111A33 100%); }
.auth-bg-shape-1 { background: linear-gradient(135deg, rgba(29,111,224,.30), rgba(29,111,224,.08)); }

/* Brand block */
.tf-logo-mark { width: 40px; height: 40px; border-radius: 12px; display: flex; align-items: center; justify-content: center; color: #fff;
  background: linear-gradient(135deg, var(--navy) 0%, var(--primary) 100%); box-shadow: 0 2px 8px rgba(29,111,224,.35); }
.tf-logo-mark-lg { width: 60px; height: 60px; border-radius: 18px; }
.tf-brand-text { border-left: 1px solid var(--border); padding-left: 12px; min-width: 0; }
.tf-brand-name { font-size: 15px; font-weight: 700; color: var(--text); line-height: 1.15; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 160px; }
.tf-brand-sub { font-size: 9.5px; color: var(--primary); font-weight: 600; letter-spacing: .6px; text-transform: uppercase; margin-top: 2px; }
.tf-sidebar-foot { padding: 12px 16px; border-top: 1px solid var(--border); text-align: center; }
.tf-sidebar-logo { height: 25px; width: auto; max-width: 180px; object-fit: contain; display: inline-block; opacity: .9; }
.dark .tf-sidebar-logo { filter: brightness(1.6); }

/* Division chip in the sidebar */
.tf-division-chip { display: flex; align-items: center; gap: 8px; margin: 10px 12px 0; padding: 9px 12px; border-radius: 10px;
  background: color-mix(in srgb, var(--div-color) 10%, transparent); color: var(--div-color); font-weight: 700; font-size: 13px; text-decoration: none;
  border: 1px solid color-mix(in srgb, var(--div-color) 30%, transparent); }
.tf-division-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--div-color); box-shadow: 0 0 0 3px color-mix(in srgb, var(--div-color) 25%, transparent); }
#sidebar.collapsed .tf-division-chip { display: none; }

/* Division select cards */
.tf-division-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 20px; width: 100%; max-width: 640px; margin: 0 auto; }
.tf-division-card { width: 100%; display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 30px 20px; border-radius: 22px; cursor: pointer;
  background: var(--surface); border: 2px solid var(--border); transition: all .2s ease; font-family: inherit; color: var(--text); }
.tf-division-card:hover { border-color: var(--div-color); transform: translateY(-3px); box-shadow: 0 12px 32px color-mix(in srgb, var(--div-color) 25%, transparent); }
.tf-division-icon { width: 72px; height: 72px; border-radius: 22px; display: flex; align-items: center; justify-content: center; color: #fff; background: var(--div-color); margin-bottom: 6px; }
.tf-division-title { font-size: 24px; font-weight: 800; }
.tf-division-desc { font-size: 13px; color: var(--muted); }
.tf-division-stats { font-size: 12px; color: var(--muted); }

/* Auth layout */
.tf-auth { flex-direction: column; position: relative; overflow-x: hidden; }
.tf-auth-wrap { position: relative; z-index: 2; width: 100%; max-width: 980px; display: flex; flex-direction: column; align-items: center; }
.tf-auth-top { display: flex; align-items: center; justify-content: space-between; width: 100%; max-width: 640px; margin-bottom: 18px; }
.tf-auth-logo { height: 34px; width: auto; }
.tf-card-narrow { width: 100%; max-width: 420px; }
.tf-auth-foot { margin-top: 22px; font-size: 12px; }
.tf-auth-foot a { color: var(--muted); text-decoration: none; }

/* Header */
.tf-icon-btn { color: var(--muted); border: none; background: none; cursor: pointer; }
.tf-icon-btn:hover { background: var(--background); }
.tf-lang-btn { font-size: 13px; font-weight: 700; padding: 6px 12px; border-radius: 999px; border: 1px solid var(--border); color: var(--primary); text-decoration: none; background: var(--surface); }
.tf-lang-btn:hover { background: var(--primary-light); }
.tf-avatar { width: 32px; height: 32px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-weight: 700; color: #fff; background: linear-gradient(135deg, var(--navy), var(--primary)); font-size: 13px; }
.tf-user-meta { display: flex; flex-direction: column; text-align: start; }
.tf-user-name { font-size: 13px; font-weight: 600; color: var(--text); line-height: 1.2; }
.tf-user-role { font-size: 11px; color: var(--muted); }
#mobile-overlay { position: fixed; inset: 0; background: rgba(15,23,42,.45); z-index: 65; display: none; }
#mobile-overlay.show { display: block; }

.tf-main { max-width: 1440px; width: 100%; }
.tf-footer { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 8px; padding: 14px 24px; font-size: 12px; color: var(--muted); border-top: 1px solid var(--border); }
.tf-footer a { color: var(--muted); text-decoration: none; }
.tf-footer a:hover { color: var(--primary); }

/* Alerts */
.tf-alert { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: 12px; margin-bottom: 14px; font-size: 14px; border: 1px solid; width: 100%; }
.tf-alert-success { background: #ECFDF5; border-color: #A7F3D0; color: #065F46; }
.tf-alert-error { background: #FEF2F2; border-color: #FECACA; color: #991B1B; }
.tf-alert-warning { background: #FFFBEB; border-color: #FDE68A; color: #92400E; }
.tf-alert-info { background: #EFF6FF; border-color: #BFDBFE; color: #1E40AF; }
.dark .tf-alert-success { background: #052e1c; color: #A7F3D0; border-color: #065F46; }
.dark .tf-alert-error { background: #3b0d0d; color: #FECACA; border-color: #7f1d1d; }
.dark .tf-alert-warning { background: #3a2a05; color: #FDE68A; border-color: #92400E; }
.dark .tf-alert-info { background: #0c1f45; color: #BFDBFE; border-color: #1E40AF; }

/* Page */
.tf-page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 20px; }
.tf-page-head h1 { font-size: 22px; font-weight: 800; color: var(--heading-color); }
.tf-page-head p { color: var(--muted); font-size: 13px; margin-top: 2px; }
.tf-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.tf-form-section { font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: .6px; color: var(--primary); margin: 18px 0 10px; }
.tf-grid-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; margin-bottom: 20px; }
.tf-stat { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 16px 18px; display: flex; gap: 14px; align-items: center; }
.tf-stat-icon { width: 44px; height: 44px; border-radius: 12px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.tf-stat-label { font-size: 12px; color: var(--muted); font-weight: 500; }
.tf-stat-value { font-size: 20px; font-weight: 800; color: var(--text); line-height: 1.2; }
.tf-stat-sub { font-size: 11px; color: var(--muted); }
.tf-kv { display: grid; grid-template-columns: 140px 1fr; gap: 6px 12px; font-size: 13px; }
.tf-kv dt { color: var(--muted); }
.tf-kv dd { font-weight: 600; color: var(--text); word-break: break-word; }
.tf-summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 0; border: 1px solid var(--border); border-radius: 14px; overflow: hidden; }
.tf-summary > div { padding: 12px 14px; border-inline-end: 1px solid var(--border); border-bottom: 1px solid var(--border); background: var(--surface); }
.tf-summary .lbl { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .4px; }
.tf-summary .val { font-size: 17px; font-weight: 800; }
.tf-pos { color: #16A34A; } .tf-neg { color: #DC2626; } .tf-warn { color: #D97706; }
.tf-empty { text-align: center; padding: 48px 20px; color: var(--muted); }
.tf-table-wrap { overflow-x: auto; }
.data-table td, .data-table th { white-space: nowrap; }
.data-table td.wrap { white-space: normal; }
.tf-row-overdue td { background: color-mix(in srgb, #EF4444 6%, transparent); }
.tf-row-paid td { color: var(--muted); }
.tf-chip { display: inline-flex; align-items: center; gap: 4px; padding: 3px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 600; background: var(--background); border: 1px solid var(--border); }
.tf-progress { height: 8px; border-radius: 99px; background: var(--background); overflow: hidden; }
.tf-progress > span { display: block; height: 100%; background: linear-gradient(90deg, var(--primary), #22C55E); border-radius: 99px; }
.tf-filter { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; margin-bottom: 16px; }
.tf-filter .form-input, .tf-filter .form-select { height: 38px; font-size: 13px; }
.tf-filter > div { min-width: 140px; }
.tf-pagination { display: flex; gap: 6px; justify-content: flex-end; padding: 12px 0; flex-wrap: wrap; }
.tf-pagination a, .tf-pagination span { padding: 6px 11px; border: 1px solid var(--border); border-radius: 8px; font-size: 13px; text-decoration: none; color: var(--text); background: var(--surface); }
.tf-pagination .on { background: var(--primary); color: #fff; border-color: var(--primary); }
.tf-tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 16px; overflow-x: auto; }
.tf-tabs a { padding: 10px 14px; font-size: 13.5px; font-weight: 600; color: var(--muted); text-decoration: none; border-bottom: 2px solid transparent; white-space: nowrap; }
.tf-tabs a.on { color: var(--primary); border-bottom-color: var(--primary); }
.tf-report-card { display: flex; gap: 14px; align-items: flex-start; padding: 18px; border-radius: 16px; border: 1px solid var(--border); background: var(--surface); text-decoration: none; color: var(--text); transition: all .15s; }
.tf-report-card:hover { border-color: var(--primary); box-shadow: var(--shadow-md); transform: translateY(-2px); }
.tf-report-card h3 { font-size: 15px; font-weight: 700; }
.tf-report-card p { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.tf-calc { background: var(--primary-light); border: 1px dashed var(--primary); border-radius: 14px; padding: 14px; }
.tf-big-input { font-size: 22px !important; font-weight: 800 !important; height: 52px !important; }
.tf-help { font-size: 11.5px; color: var(--muted); margin-top: 4px; }
.tf-doc-thumb { width: 100%; height: 110px; object-fit: cover; border-radius: 10px; border: 1px solid var(--border); background: var(--background); }
.tf-timeline { border-inline-start: 2px solid var(--border); padding-inline-start: 14px; }
.tf-timeline > div { position: relative; padding-bottom: 12px; }
.tf-timeline > div::before { content: ''; position: absolute; inset-inline-start: -20px; top: 4px; width: 10px; height: 10px; border-radius: 50%; background: var(--primary); }
.dropdown-item.danger { color: #DC2626; }
button.dropdown-item { background: none; border: none; cursor: pointer; text-align: start; font-family: inherit; }
.card { overflow: visible; }

/* Mobile */
@media (max-width: 640px) {
  .tf-kv { grid-template-columns: 110px 1fr; }
  .tf-page-head h1 { font-size: 19px; }
  #app-header { padding: 0 12px; gap: 8px; }
  .tf-main { padding: 12px !important; }
}

/* ============================================
   Urdu / RTL
   ============================================ */
html[dir="rtl"] body, html[dir="rtl"] .form-input, html[dir="rtl"] .form-select, html[dir="rtl"] button, html[dir="rtl"] .btn {
  font-family: 'Noto Nastaliq Urdu', 'Inter', sans-serif;
}
html[dir="rtl"] body { line-height: 2; }
html[dir="rtl"] .nav-item, html[dir="rtl"] .btn, html[dir="rtl"] .badge { line-height: 1.9; }
html[dir="rtl"] .tf-stat-value, html[dir="rtl"] .tf-summary .val, html[dir="rtl"] .data-table td.num, html[dir="rtl"] .ltr { font-family: 'Inter', sans-serif; direction: ltr; unicode-bidi: isolate; }
html[dir="rtl"] #sidebar { left: auto; right: 0; border-right: none; border-left: 1px solid var(--border); }
html[dir="rtl"] #main-wrapper { margin-left: 0; margin-right: var(--sidebar-width); transition: margin-right .3s; }
html[dir="rtl"] #main-wrapper.sidebar-collapsed { margin-right: var(--sidebar-collapsed-width); }
html[dir="rtl"] .tf-brand-text { border-left: none; border-right: 1px solid var(--border); padding-left: 0; padding-right: 12px; }
html[dir="rtl"] .search-box .search-icon { left: auto; right: 12px; }
html[dir="rtl"] .search-box .form-input { padding-left: 12px; padding-right: 36px; }
html[dir="rtl"] .data-table th, html[dir="rtl"] .data-table td { text-align: right; }
html[dir="rtl"] .text-right { text-align: left; }
html[dir="rtl"] .dropdown-menu { right: auto; left: 0; }
html[dir="rtl"] .tf-timeline > div::before { inset-inline-start: -20px; }
@media (max-width: 1023px) {
  html[dir="rtl"] #sidebar { transform: translateX(100%); }
  html[dir="rtl"] #sidebar.mobile-open { transform: translateX(0); }
  html[dir="rtl"] #main-wrapper { margin-right: 0 !important; }
}

@media print {
  #sidebar, #app-header, #mobile-overlay, .tf-footer, .no-print, .tf-filter, .tf-actions { display: none !important; }
  #main-wrapper { margin: 0 !important; }
  .card { box-shadow: none !important; border: 1px solid #ddd !important; }
}

/* Selects share the input look (Invenza pairs .form-input + .form-select) */
.form-select { width: 100%; padding: 10px 36px 10px 14px; border: 1px solid var(--border); border-radius: 10px; font-size: 14px; font-family: inherit;
  background-color: var(--surface); color: var(--text); outline: none; transition: border-color .15s, box-shadow .15s; min-height: 42px; }
.dark .form-select { background-color: rgba(255,255,255,0.05); }
html[dir="rtl"] .form-select { background-position: left 12px center; padding: 10px 14px 10px 36px; }
.tf-filter .form-select { padding-top: 6px; padding-bottom: 6px; min-height: 38px; }
.form-textarea { width: 100%; padding: 10px 14px; border: 1px solid var(--border); border-radius: 10px; font-family: inherit; font-size: 14px; background: var(--surface); color: var(--text); }
.dark .form-textarea { background: rgba(255,255,255,0.05); }

/* Brand welcome banner */
.welcome-banner { background: linear-gradient(135deg, #0B1F3A 0%, #12366B 45%, #1D6FE0 100%); }
.tf-grid-stats { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.tf-stat-value { white-space: nowrap; }
