/* ==========================================================================
   HabbaTech SHOOF Subscription Portal — Unified Stylesheet
   Supports: Dark & Light Themes | English LTR & Arabic RTL
   ========================================================================== */

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

/* ===== DARK THEME (DEFAULT) ===== */
:root,
html[data-theme="dark"] {
    --ht-bg:             #0b1120;
    --ht-surface:        #111b30;
    --ht-card:           #162038;
    --ht-card-hover:     #1c2a4a;
    --ht-accent:         #fb923c;
    --ht-accent-hover:   #f97316;
    --ht-accent-rgb:     251, 146, 60;
    --ht-glow:           rgba(251, 146, 60, 0.15);
    --ht-glow-strong:    rgba(251, 146, 60, 0.30);
    --ht-text:           #f1f5f9;
    --ht-text-heading:   #ffffff;
    --ht-muted:          #94a3b8;
    --ht-border:         rgba(251, 146, 60, 0.18);
    --ht-border-light:   rgba(255, 255, 255, 0.08);
    --ht-nav-bg:         rgba(11, 17, 32, 0.92);
    --ht-footer-bg:      #060e1c;
    --ht-input-bg:       rgba(15, 23, 42, 0.7);
    --ht-shadow:         0 12px 36px rgba(0, 0, 0, 0.45);
    --ht-badge-green:    rgba(16, 185, 129, 0.2);
    --ht-badge-green-txt:#34d399;
    --ht-badge-amber:    rgba(245, 158, 11, 0.2);
    --ht-badge-amber-txt:#fbbf24;
    --ht-badge-red:      rgba(239, 68, 68, 0.2);
    --ht-badge-red-txt:  #f87171;
    --ht-badge-blue:     rgba(59, 130, 246, 0.2);
    --ht-badge-blue-txt: #60a5fa;
    --ht-modal-bg:       rgba(17, 27, 48, 0.98);
}

/* ===== LIGHT THEME ===== */
html[data-theme="light"] {
    --ht-bg:             #f8fafc;
    --ht-surface:        #ffffff;
    --ht-card:           #f1f5f9;
    --ht-card-hover:     #e2e8f0;
    --ht-accent:         #ea580c;
    --ht-accent-hover:   #c2410c;
    --ht-accent-rgb:     234, 88, 12;
    --ht-glow:           rgba(234, 88, 12, 0.12);
    --ht-glow-strong:    rgba(234, 88, 12, 0.25);
    --ht-text:           #1e293b;
    --ht-text-heading:   #0f172a;
    --ht-muted:          #64748b;
    --ht-border:         rgba(234, 88, 12, 0.22);
    --ht-border-light:   rgba(0, 0, 0, 0.08);
    --ht-nav-bg:         rgba(255, 255, 255, 0.95);
    --ht-footer-bg:      #0f172a;
    --ht-input-bg:       #ffffff;
    --ht-shadow:         0 12px 32px rgba(0, 0, 0, 0.08);
    --ht-badge-green:    #dcfce7;
    --ht-badge-green-txt:#15803d;
    --ht-badge-amber:    #fef3c7;
    --ht-badge-amber-txt:#b45309;
    --ht-badge-red:      #fee2e2;
    --ht-badge-red-txt:  #b91c1c;
    --ht-badge-blue:     #dbeafe;
    --ht-badge-blue-txt: #1d4ed8;
    --ht-modal-bg:       #ffffff;
}

/* ===== BASE & RESET ===== */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--ht-bg);
    color: var(--ht-text);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
    transition: opacity 0.08s ease-in;
}

/* Anti-Flicker (FOUC) Guard for Arabic Mode */
html[lang="ar"]:not(.ht-i18n-ready) body {
    opacity: 0 !important;
}

/* Instant Top Navigation Progress Bar */
#ht-top-progress {
    position: fixed;
    top: 0;
    left: 0;
    height: 3px;
    width: 0%;
    background: linear-gradient(90deg, var(--ht-accent), #f59e0b);
    z-index: 99999;
    box-shadow: 0 0 10px var(--ht-accent);
    transition: width 0.35s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.2s ease;
    pointer-events: none;
    opacity: 0;
}
#ht-top-progress.ht-loading {
    opacity: 1;
    width: 75%;
}

html[dir="rtl"] body {
    font-family: 'Tajawal', 'Inter', sans-serif;
}

/* Container */
.ht-container {
    width: 100%;
    max-width: 1280px;
    margin: 0 auto;
    padding: 0 24px;
}

/* Quick Role Bar (Tester Bar) */
.ht-tester-bar {
    background: linear-gradient(90deg, #1e1b4b, #312e81);
    color: #e0e7ff;
    padding: 8px 24px;
    font-size: 0.82rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    z-index: 1050;
}
.ht-tester-left { display: flex; align-items: center; gap: 12px; }
.ht-tester-btn {
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.25);
    padding: 3px 12px;
    border-radius: 6px;
    font-size: 0.78rem;
    cursor: pointer;
    transition: all 0.2s ease;
}
.ht-tester-btn:hover, .ht-tester-btn.active {
    background: var(--ht-accent);
    color: #0b1120;
    font-weight: 700;
    border-color: var(--ht-accent);
}

/* Top Navbar */
#ht-nav-header {
    min-height: 72px;
    width: 100%;
    display: block;
}
.ht-navbar {
    position: sticky;
    top: 0;
    min-height: 72px;
    background: var(--ht-nav-bg);
    backdrop-filter: blur(14px);
    border-bottom: 1px solid var(--ht-border-light);
    z-index: 1000;
}
.ht-navbar-container,
.ht-nav-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 72px;
    max-width: 1280px;
    margin: 0 auto;
    padding: 0 24px;
    width: 100%;
}
.ht-brand-group,
.ht-brand {
    display: flex;
    align-items: center;
    gap: 12px;
}
.ht-brand-link {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    color: inherit;
}
.ht-brand-logo {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    object-fit: contain;
    box-shadow: 0 0 16px var(--ht-glow);
    flex-shrink: 0;
    display: block;
}
span.ht-brand-logo {
    border-radius: 10px;
    background: linear-gradient(135deg, var(--ht-accent), #f59e0b);
    color: #0b1120;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 900;
    font-size: 1.25rem;
}
img.ht-brand-logo {
    background: transparent;
    border: none;
}
.ht-footer-logo-img {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    object-fit: contain;
    flex-shrink: 0;
    display: inline-block;
    vertical-align: middle;
}
.ht-brand-title {
    font-size: 1.25rem;
    font-weight: 800;
    color: var(--ht-text-heading);
    letter-spacing: -0.5px;
    line-height: 1.2;
}
.ht-brand-sub {
    font-size: 0.72rem;
    color: var(--ht-muted);
    font-weight: 500;
}
.ht-brand-accent { color: var(--ht-accent); }
.ht-nav-menu,
.ht-nav-links {
    display: flex;
    align-items: center;
    gap: 8px;
    list-style: none;
}
.ht-nav-link {
    padding: 8px 14px;
    color: var(--ht-text);
    text-decoration: none;
    font-size: 0.92rem;
    font-weight: 600;
    border-radius: 8px;
    transition: all 0.2s ease;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}
.ht-nav-link:hover, .ht-nav-link.active {
    color: var(--ht-accent);
    background: var(--ht-glow);
}
.ht-nav-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}
.ht-icon-btn {
    width: auto;
    min-width: 38px;
    height: 38px;
    padding: 0 10px;
    white-space: nowrap;
    border-radius: 9px;
    background: var(--ht-card);
    border: 1px solid var(--ht-border-light);
    color: var(--ht-text);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
}
.ht-icon-btn:hover {
    color: var(--ht-accent);
    border-color: var(--ht-accent);
    transform: translateY(-1px);
}
.ht-lang-btn {
    padding: 6px 14px;
    font-weight: 700;
    font-size: 0.85rem;
    border-radius: 8px;
    border: 1px solid var(--ht-border);
    background: transparent;
    color: var(--ht-accent);
    cursor: pointer;
    transition: all 0.2s ease;
}
.ht-lang-btn:hover {
    background: var(--ht-accent);
    color: #0b1120;
}

/* User Account Pill */
.ht-user-pill {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 5px 14px;
    border-radius: 20px;
    background: var(--ht-surface);
    border: 1px solid var(--ht-border);
    cursor: pointer;
    white-space: nowrap;
}
.ht-avatar,
.ht-user-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--ht-accent);
    color: #0b1120;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 0.75rem;
    flex-shrink: 0;
}
.ht-user-name {
    font-size: 0.88rem;
    font-weight: 700;
    color: var(--ht-text-heading);
    white-space: nowrap;
}
.ht-role-badge {
    font-size: 0.65rem;
    font-weight: 800;
    padding: 2px 6px;
    border-radius: 4px;
    letter-spacing: 0.5px;
}
.ht-role-badge.admin {
    background: rgba(239, 68, 68, 0.2);
    color: #f87171;
    border: 1px solid rgba(239, 68, 68, 0.4);
}
.ht-role-badge.client {
    background: rgba(16, 185, 129, 0.2);
    color: #34d399;
    border: 1px solid rgba(16, 185, 129, 0.4);
}
.ht-logout-btn,
.ht-btn-logout {
    background: var(--ht-card);
    color: var(--ht-text);
    border: 1px solid var(--ht-border-light);
    width: 32px;
    height: 32px;
    border-radius: 8px;
    font-size: 0.85rem;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}
html[dir="rtl"] .ht-logout-btn,
html[dir="rtl"] .ht-btn-logout {
    margin-left: 0;
    margin-right: 4px;
}
.ht-logout-btn:hover,
.ht-btn-logout:hover {
    background: #ef4444 !important;
    color: #ffffff !important;
    border-color: #ef4444 !important;
}

/* Document Download & Action Buttons */
.ht-doc-download-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 6px;
    background: var(--ht-card);
    color: var(--ht-accent);
    border: 1px solid var(--ht-border);
    font-size: 0.78rem;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.2s;
}
.ht-doc-download-btn:hover {
    background: var(--ht-accent);
    color: #0b1120;
    border-color: var(--ht-accent);
}

/* Recurring Extra Services */
.ht-service-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 14px;
    background: var(--ht-card);
    border: 1px solid var(--ht-border-light);
    border-radius: 8px;
    margin-bottom: 8px;
}

/* Hero Section */
.ht-hero {
    padding: 48px 0 32px;
    text-align: center;
    position: relative;
}
.ht-hero::before {
    content: '';
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 600px;
    height: 280px;
    background: radial-gradient(circle, var(--ht-glow-strong) 0%, transparent 70%);
    filter: blur(40px);
    z-index: 0;
    pointer-events: none;
}
.ht-hero-content {
    position: relative;
    z-index: 1;
    max-width: 820px;
    margin: 0 auto;
}
.ht-section-pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: var(--ht-glow);
    color: var(--ht-accent);
    border: 1px solid var(--ht-border);
    padding: 6px 16px;
    border-radius: 30px;
    font-size: 0.82rem;
    font-weight: 700;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    margin-bottom: 20px;
}
.ht-hero-title {
    font-size: 2.8rem;
    font-weight: 800;
    color: var(--ht-text-heading);
    letter-spacing: -1px;
    line-height: 1.2;
    margin-bottom: 16px;
}
.ht-hero-lead {
    font-size: 1.15rem;
    color: var(--ht-muted);
    line-height: 1.7;
    margin-bottom: 32px;
}

.ht-dashboard-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 16px;
    margin-bottom: 28px;
}

/* Interactive Store Calculator Banner */
.ht-calc-box {
    background: var(--ht-surface);
    border: 1px solid var(--ht-border);
    border-radius: 20px;
    padding: 32px;
    margin-bottom: 48px;
    box-shadow: var(--ht-shadow);
    position: relative;
    overflow: hidden;
}
.ht-calc-grid {
    display: grid;
    grid-template-columns: 1.5fr 1fr;
    gap: 36px;
    align-items: center;
}
@media (max-width: 991px) {
    .ht-calc-grid { grid-template-columns: 1fr; }
}

.ht-slider-label-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}
.ht-slider-val {
    font-size: 1.8rem;
    font-weight: 800;
    color: var(--ht-accent);
}
.ht-range-slider {
    width: 100%;
    -webkit-appearance: none;
    appearance: none;
    height: 8px;
    border-radius: 4px;
    background: var(--ht-border-light);
    outline: none;
    margin: 16px 0 8px;
}
.ht-range-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--ht-accent);
    cursor: pointer;
    box-shadow: 0 0 12px rgba(251, 146, 60, 0.6);
    transition: transform 0.15s ease;
}
.ht-range-slider::-webkit-slider-thumb:hover {
    transform: scale(1.15);
}

/* Period Switcher (Monthly, Annual, Biennial) */
.ht-period-toggle {
    display: inline-flex;
    background: var(--ht-card);
    border: 1px solid var(--ht-border-light);
    padding: 4px;
    border-radius: 12px;
    gap: 4px;
    margin-top: 16px;
}
.ht-period-btn {
    padding: 8px 16px;
    border-radius: 8px;
    border: none;
    background: transparent;
    color: var(--ht-muted);
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 6px;
}
.ht-period-btn.active {
    background: var(--ht-surface);
    color: var(--ht-text-heading);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}
.ht-discount-tag {
    background: #10b981;
    color: #ffffff;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 800;
}

/* Calculation Output Summary */
.ht-calc-summary,
.ht-calc-summary-card {
    background: var(--ht-card);
    border: 1px solid var(--ht-border);
    border-radius: 16px;
    padding: 24px;
    text-align: center;
    box-shadow: var(--ht-shadow);
}
.ht-summary-price,
.ht-calc-summary-price {
    font-size: 2.6rem;
    font-weight: 900;
    color: var(--ht-accent);
    line-height: 1;
    margin: 12px 0 6px;
}
.ht-summary-cycle,
.ht-calc-summary-sub {
    color: var(--ht-muted);
    font-size: 0.85rem;
}
.ht-summary-breakdown {
    border-top: 1px solid var(--ht-border-light);
    margin-top: 16px;
    padding-top: 14px;
    font-size: 0.85rem;
    color: var(--ht-muted);
    display: flex;
    justify-content: space-between;
}

/* Pricing Grid - MUST BE SIDE-BY-SIDE 3 COLUMNS ON DESKTOP */
.ht-plans-grid,
.ht-pricing-grid {
    display: grid !important;
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
    gap: 28px !important;
    margin-top: 24px !important;
    margin-bottom: 64px !important;
    align-items: stretch !important;
    width: 100% !important;
}
@media (max-width: 991px) {
    .ht-plans-grid,
    .ht-pricing-grid {
        grid-template-columns: 1fr !important;
    }
}

.ht-plan-card {
    background: var(--ht-surface);
    border: 1px solid var(--ht-border-light);
    border-radius: 18px;
    padding: 36px 28px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    transition: all 0.3s ease;
    position: relative;
}
.ht-plan-card:hover {
    border-color: var(--ht-accent);
    transform: translateY(-4px);
    box-shadow: var(--ht-shadow);
}
.ht-plan-popular {
    border-color: var(--ht-accent);
    background: linear-gradient(180deg, var(--ht-surface) 0%, var(--ht-card) 100%);
    box-shadow: 0 0 28px var(--ht-glow);
}
.ht-plan-badge {
    position: absolute;
    top: -13px;
    right: 28px;
    background: var(--ht-accent);
    color: #0b1120;
    font-size: 0.75rem;
    font-weight: 800;
    padding: 4px 14px;
    border-radius: 20px;
    text-transform: uppercase;
    letter-spacing: 1px;
}
html[dir="rtl"] .ht-plan-badge { right: auto; left: 28px; }

.ht-plan-title {
    font-size: 1.4rem;
    font-weight: 800;
    color: var(--ht-text-heading);
    margin-bottom: 8px;
}
.ht-plan-desc {
    font-size: 0.9rem;
    color: var(--ht-muted);
    margin-bottom: 24px;
}
.ht-plan-price-box {
    margin-bottom: 24px;
}
.ht-plan-price {
    font-size: 2.8rem;
    font-weight: 900;
    color: var(--ht-text-heading);
}
.ht-plan-curr {
    font-size: 1.2rem;
    font-weight: 600;
    vertical-align: super;
    margin-right: 4px;
}
.ht-plan-features {
    list-style: none;
    margin-bottom: 32px;
}
.ht-plan-feature-item {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 14px;
    font-size: 0.92rem;
    color: var(--ht-text);
}
.ht-plan-feature-item i {
    color: var(--ht-accent);
    font-size: 0.95rem;
}

/* View Section Wrapper */
.ht-view-section {
    padding: 32px 0 64px;
    flex: 1;
    width: 100%;
}

/* Primary Button */
.ht-btn-primary {
    background: linear-gradient(135deg, var(--ht-accent), var(--ht-accent-hover));
    color: #ffffff !important;
    font-weight: 800;
    border: none;
    border-radius: 10px;
    padding: 14px 28px;
    font-size: 0.95rem;
    cursor: pointer;
    text-decoration: none !important;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.2s ease;
    width: 100%;
    box-shadow: 0 4px 14px var(--ht-glow);
    white-space: nowrap;
}
.ht-btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px var(--ht-glow-strong);
}

/* Secondary / Ghost Button (Sign In nav button) */
.ht-btn-secondary {
    background: transparent;
    color: var(--ht-text) !important;
    font-weight: 600;
    padding: 0.45rem 0.9rem;
    border-radius: 8px;
    border: 1px solid var(--ht-border-light);
    cursor: pointer;
    font-size: 0.875rem;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    text-decoration: none;
    transition: all 0.2s ease;
    white-space: nowrap;
}
.ht-btn-secondary:hover {
    border-color: var(--ht-accent);
    color: var(--ht-accent) !important;
}

.ht-btn-outline {
    background: transparent;
    color: var(--ht-text) !important;
    font-weight: 600;
    border: 1px solid var(--ht-border-light);
    border-radius: 10px;
    padding: 12px 24px;
    font-size: 0.95rem;
    cursor: pointer;
    text-decoration: none !important;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.2s ease;
    width: 100%;
}
.ht-btn-outline:hover {
    border-color: var(--ht-accent);
    color: var(--ht-accent) !important;
}

/* Dashboard Cockpit Cards */
.ht-kpi-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
    margin-bottom: 32px;
}
@media (max-width: 991px) {
    .ht-kpi-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 576px) {
    .ht-kpi-grid { grid-template-columns: 1fr; }
}
/* Six-card variant (admin overview): one row on wide screens, then 3 / 2 / 1 per row. */
.ht-kpi-grid.ht-kpi-grid-6 { grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 16px; }
.ht-kpi-grid.ht-kpi-grid-6 .ht-kpi-card { padding: 18px 18px; }
.ht-kpi-grid.ht-kpi-grid-6 .ht-kpi-val { font-size: 1.75rem; overflow-wrap: anywhere; }
@media (max-width: 1399px) {
    .ht-kpi-grid.ht-kpi-grid-6 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 767px) {
    .ht-kpi-grid.ht-kpi-grid-6 { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
}
@media (max-width: 420px) {
    .ht-kpi-grid.ht-kpi-grid-6 { grid-template-columns: 1fr; }
}

.ht-metric-card {
    background: var(--ht-surface);
    border: 1px solid var(--ht-border);
    border-radius: 14px;
    padding: 22px;
    transition: all 0.2s ease;
}
.ht-metric-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--ht-shadow);
}
.ht-metric-label {
    font-size: 0.85rem;
    color: var(--ht-muted);
    font-weight: 600;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.ht-metric-value {
    font-size: 2.1rem;
    font-weight: 800;
    color: var(--ht-text-heading);
    letter-spacing: -0.5px;
}
.ht-metric-sub {
    font-size: 0.8rem;
    margin-top: 6px;
    color: var(--ht-muted);
}

/* Tables & Data Lists */
.ht-table-card {
    background: var(--ht-surface);
    border: 1px solid var(--ht-border);
    border-radius: 16px;
    overflow: hidden;
    margin-bottom: 36px;
    box-shadow: var(--ht-shadow);
}
.ht-table-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--ht-border-light);
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.ht-table-title {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--ht-text-heading);
}
.ht-table-wrap {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    scrollbar-color: var(--ht-border) transparent;
}
.ht-table-wrap::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}
.ht-table-wrap::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.03);
    border-radius: 4px;
}
.ht-table-wrap::-webkit-scrollbar-thumb {
    background: var(--ht-border);
    border-radius: 4px;
}
.ht-table-wrap::-webkit-scrollbar-thumb:hover {
    background: var(--ht-accent);
}
.ht-table-wrap-vscroll {
    max-height: 600px;
    overflow-y: auto;
}
.ht-table-wrap-vscroll thead th,
.ht-table-wrap[style*="overflow-y"] thead th {
    position: sticky;
    top: 0;
    z-index: 3;
    background: var(--ht-card);
    box-shadow: 0 1px 0 var(--ht-border-light);
}
.ht-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}
.ht-table th {
    background: var(--ht-card);
    padding: 14px 20px;
    text-align: left;
    font-weight: 600;
    color: var(--ht-muted);
    border-bottom: 1px solid var(--ht-border-light);
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.8px;
}
html[dir="rtl"] .ht-table th { text-align: right; }
.ht-table td {
    padding: 16px 20px;
    border-bottom: 1px solid var(--ht-border-light);
    color: var(--ht-text);
    vertical-align: middle;
}
.ht-table tbody tr:hover {
    background: var(--ht-card-hover);
}

/* Status Badges */
.ht-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.ht-badge-active {
    background: var(--ht-badge-green);
    color: var(--ht-badge-green-txt);
}
.ht-badge-pending,
.ht-badge-amber {
    background: var(--ht-badge-amber);
    color: var(--ht-badge-amber-txt);
}
.ht-badge-expired,
.ht-badge-red {
    background: var(--ht-badge-red);
    color: var(--ht-badge-red-txt);
}
.ht-badge-blue {
    background: var(--ht-badge-blue);
    color: var(--ht-badge-blue-txt);
}

/* Modals */
.ht-modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(8px);
    z-index: 2000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.ht-modal-backdrop.open { display: flex; }
.ht-modal {
    background: var(--ht-modal-bg);
    border: 1px solid var(--ht-border);
    border-radius: 20px;
    width: 100%;
    max-width: 620px;
    max-height: 90vh;
    overflow-y: auto;
    padding: 32px;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.6);
    position: relative;
}
.ht-modal-close {
    position: absolute;
    top: 20px;
    right: 24px;
    font-size: 1.5rem;
    background: transparent;
    border: none;
    color: var(--ht-muted);
    cursor: pointer;
}
html[dir="rtl"] .ht-modal-close { right: auto; left: 24px; }

/* Popup dialogs (PortalUtil.alert / confirm / prompt) */
.ht-dialog-backdrop { z-index: 3000; }
.ht-dialog-backdrop.ht-dialog-backdrop-stacked { background: rgba(0, 0, 0, 0.3); backdrop-filter: none; }
.ht-dialog {
    --ht-dialog-accent: #3b82f6;
    max-width: 460px;
    padding: 26px 26px 22px;
    border-top: 4px solid var(--ht-dialog-accent);
    animation: ht-dialog-in 0.14s ease-out;
}
.ht-dialog-success { --ht-dialog-accent: #10b981; }
.ht-dialog-error   { --ht-dialog-accent: #ef4444; }
.ht-dialog-warning { --ht-dialog-accent: #f59e0b; }
.ht-dialog-question { --ht-dialog-accent: var(--ht-accent); }
.ht-dialog .ht-modal-close { top: 14px; right: 16px; }
html[dir="rtl"] .ht-dialog .ht-modal-close { right: auto; left: 16px; }
.ht-dialog-head {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0 0 12px;
    padding-inline-end: 28px;
}
.ht-dialog-icon { font-size: 1.35rem; color: var(--ht-dialog-accent); flex-shrink: 0; }
.ht-dialog-title {
    margin: 0;
    font-size: 1.05rem;
    font-weight: 800;
    color: var(--ht-text-heading);
}
.ht-dialog-message {
    color: var(--ht-text);
    font-size: 0.93rem;
    line-height: 1.55;
    white-space: pre-line;
    overflow-wrap: anywhere;
}
.ht-dialog-input { margin-top: 14px; }
textarea.ht-dialog-input { resize: vertical; min-height: 72px; font-family: inherit; }
.ht-dialog-error { color: #ef4444; font-size: 0.82rem; font-weight: 600; margin-top: 6px; }
.ht-dialog-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 20px;
    flex-wrap: wrap;
}
.ht-dialog-btn { width: auto; min-width: 96px; padding: 9px 20px; }
.ht-dialog-btn-danger,
.ht-dialog-btn-danger:hover { background: #ef4444; border-color: #ef4444; color: #fff; }
/* Light "refreshing" state for tab data reloads (no full-page spinner) */
.ht-refreshing {
    opacity: 0.6;
    transition: opacity 0.15s ease;
    cursor: progress;
}
@keyframes ht-dialog-in {
    from { opacity: 0; transform: translateY(6px) scale(0.98); }
    to   { opacity: 1; transform: none; }
}
@media (max-width: 480px) {
    .ht-dialog { padding: 22px 18px 18px; }
    .ht-dialog-btn { flex: 1 1 auto; }
}

/* Form Elements */
.ht-form-group {
    margin-bottom: 20px;
}
.ht-form-label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--ht-text-heading);
    margin-bottom: 8px;
}
.ht-input {
    width: 100%;
    padding: 12px 16px;
    background: var(--ht-input-bg);
    border: 1px solid var(--ht-border-light);
    border-radius: 10px;
    color: var(--ht-text);
    font-size: 0.95rem;
    outline: none;
    transition: all 0.2s ease;
}
.ht-input:focus {
    border-color: var(--ht-accent);
    box-shadow: 0 0 0 3px var(--ht-glow);
}

/* ==========================================================================
   PRINTABLE TAX INVOICE STYLES & PRINT MEDIA OVERHAUL
   ========================================================================== */
.ht-invoice-paper {
    background: #ffffff;
    color: #1e293b;
    border-radius: 14px;
    padding: 36px;
    font-family: 'Inter', 'Tajawal', sans-serif;
}
.ht-invoice-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    border-bottom: 2px solid #e2e8f0;
    padding-bottom: 24px;
    margin-bottom: 24px;
}
.ht-invoice-meta {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 28px;
}
.ht-invoice-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 24px;
}
.ht-invoice-table th {
    background: #f8fafc;
    color: #475569;
    padding: 10px 14px;
    text-align: left;
    font-size: 0.8rem;
    text-transform: uppercase;
}
html[dir="rtl"] .ht-invoice-table th { text-align: right; }
.ht-invoice-table td {
    padding: 12px 14px;
    border-bottom: 1px solid #f1f5f9;
    color: #1e293b;
}

@media print {
    @page {
        size: A4 portrait;
        margin: 12mm;
    }
    html, body {
        background: #ffffff !important;
        color: #0f172a !important;
        margin: 0 !important;
        padding: 0 !important;
        height: auto !important;
        min-height: 0 !important;
        font-size: 11pt !important;
    }
    body > * {
        display: none !important;
    }
    #invoice-modal {
        display: block !important;
        position: static !important;
        background: transparent !important;
        padding: 0 !important;
        margin: 0 !important;
        width: 100% !important;
        max-width: none !important;
    }
    #invoice-modal .ht-modal {
        box-shadow: none !important;
        border: none !important;
        padding: 0 !important;
        margin: 0 !important;
        max-width: 100% !important;
        background: transparent !important;
    }
    #invoice-modal .ht-modal-close,
    #invoice-modal button,
    .ht-tester-bar,
    .ht-navbar,
    .ht-footer,
    .ht-view-section {
        display: none !important;
    }
    .ht-invoice-paper {
        display: block !important;
        background: #ffffff !important;
        color: #0f172a !important;
        border: 1px solid #cbd5e1 !important;
        border-radius: 8px !important;
        padding: 24px !important;
        box-sizing: border-box !important;
    }
    .ht-invoice-table th {
        background: #f1f5f9 !important;
        color: #0f172a !important;
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }
    .ht-invoice-table td {
        border-bottom: 1px solid #e2e8f0 !important;
        color: #0f172a !important;
    }
}

/* ==========================================================================
   SUB-TABS & MULTI-VIEW NAVIGATION
   ========================================================================== */
.ht-subtabs {
    display: flex;
    gap: 8px;
    border-bottom: 1px solid var(--ht-border-light);
    margin-bottom: 24px;
    padding-bottom: 8px;
    overflow-x: auto;
}
.ht-subtab-btn {
    background: transparent;
    border: 1px solid transparent;
    padding: 8px 18px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--ht-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s ease;
    white-space: nowrap;
}
.ht-subtab-btn:hover {
    color: var(--ht-accent);
    background: var(--ht-glow);
}
.ht-subtab-btn.active {
    background: var(--ht-card);
    color: var(--ht-accent);
    border-color: var(--ht-border);
    box-shadow: 0 2px 8px var(--ht-glow);
}

/* Auth & Modal Tab Styles */
.ht-auth-tabs {
    display: flex;
    border-bottom: 1px solid var(--ht-border-light);
    margin-bottom: 20px;
    gap: 12px;
}
.ht-auth-tab {
    background: none;
    border: none;
    padding: 8px 16px;
    font-weight: 700;
    color: var(--ht-muted);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    font-size: 0.95rem;
}
.ht-auth-tab.active {
    color: var(--ht-accent);
    border-bottom-color: var(--ht-accent);
}
.ht-credentials-box {
    background: rgba(251, 146, 60, 0.08);
    border: 1px dashed var(--ht-accent);
    border-radius: 10px;
    padding: 12px 16px;
    margin-bottom: 18px;
    font-size: 0.82rem;
}
.ht-credentials-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 6px;
    padding-top: 6px;
    border-top: 1px solid rgba(251, 146, 60, 0.15);
}

/* Status Pills & Gateway Cards */
.ht-gateway-card {
    background: var(--ht-surface);
    border: 1px solid var(--ht-border);
    border-radius: 14px;
    padding: 24px;
    margin-bottom: 20px;
}
.ht-gateway-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}
.ht-status-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.78rem;
    font-weight: 700;
}
.ht-status-active {
    background: var(--ht-badge-green);
    color: var(--ht-badge-green-txt);
}
.ht-status-unverified {
    background: var(--ht-badge-amber);
    color: var(--ht-badge-amber-txt);
}
.ht-status-pending {
    background: var(--ht-badge-blue);
    color: var(--ht-badge-blue-txt);
}
.ht-pending-banner {
    background: linear-gradient(90deg, rgba(245, 158, 11, 0.15), rgba(245, 158, 11, 0.05));
    border: 1px solid #f59e0b;
    border-radius: 12px;
    padding: 16px 20px;
    margin-bottom: 24px;
    display: flex;
    align-items: center;
    gap: 14px;
    color: var(--ht-text-heading);
}
.ht-doc-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: var(--ht-card);
    border: 1px solid var(--ht-border-light);
    border-radius: 8px;
    margin-bottom: 8px;
}
.ht-upload-dropzone {
    border: 2px dashed var(--ht-border);
    border-radius: 12px;
    padding: 24px;
    text-align: center;
    background: var(--ht-surface);
    cursor: pointer;
    transition: all 0.2s;
    margin-bottom: 16px;
}
.ht-upload-dropzone:hover {
    border-color: var(--ht-accent);
    background: var(--ht-glow);
}

/* ==========================================================================
   FOOTER (ENFORCED CONTRAST IN ALL THEMES)
   ========================================================================== */
.ht-footer {
    background: var(--ht-footer-bg);
    border-top: 1px solid var(--ht-border-light);
    padding: 36px 0 24px;
    margin-top: auto;
    font-size: 0.88rem;
    color: #94a3b8 !important;
}
.ht-footer-inner {
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.ht-footer h4, .ht-footer h4 * {
    color: #ffffff !important;
}
.ht-footer .ht-brand-accent {
    color: var(--ht-accent) !important;
}
.ht-footer p, .ht-footer div {
    color: #94a3b8 !important;
}
@media (max-width: 768px) {
    .ht-footer-inner { flex-direction: column; gap: 16px; text-align: center; }
}

/* ==========================================================================
   USER PILL, LOGOUT & DOCUMENT ACTION BUTTONS
   ========================================================================== */
.ht-user-pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: var(--ht-card);
    border: 1px solid var(--ht-border-light);
    border-radius: 999px;
    padding: 3px 8px 3px 4px;
    cursor: default;
}
.ht-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--ht-accent);
    color: #0b1120;
    font-weight: 800;
    font-size: 0.78rem;
    display: flex;
    align-items: center;
    justify-content: center;
    letter-spacing: 0.5px;
    flex-shrink: 0;
}
.ht-logout-btn {
    background: transparent;
    border: 1px solid var(--ht-border-light);
    color: var(--ht-text);
    border-radius: 6px;
    padding: 3px 7px;
    cursor: pointer;
    font-size: 0.75rem;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.ht-logout-btn:hover {
    background: rgba(239, 68, 68, 0.15);
    border-color: #ef4444;
    color: #ef4444;
}

/* Document & Object Storage UI */
.ht-storage-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: rgba(59, 130, 246, 0.1);
    border: 1px solid rgba(59, 130, 246, 0.3);
    color: #60a5fa;
    border-radius: 8px;
    padding: 6px 14px;
    font-size: 0.82rem;
    font-weight: 600;
    font-family: monospace;
}
.ht-doc-view-btn {
    background: rgba(245, 158, 11, 0.15);
    border: 1px solid var(--ht-accent);
    color: var(--ht-accent);
    border-radius: 6px;
    padding: 5px 12px;
    font-size: 0.8rem;
    font-weight: 600;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    transition: all 0.2s;
}
.ht-doc-view-btn:hover {
    background: var(--ht-accent);
    color: #0b1120;
    text-decoration: none;
}
.ht-doc-download-btn {
    background: var(--ht-surface);
    border: 1px solid var(--ht-border-light);
    color: var(--ht-text-heading);
    border-radius: 6px;
    padding: 5px 12px;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s;
}
.ht-doc-download-btn:hover {
    border-color: var(--ht-accent);
    color: var(--ht-accent);
}

/* ==========================================================================
   ENHANCED SUBTABS & SEGMENTED CONTROLS
   ========================================================================== */
.ht-subtabs {
    display: flex;
    gap: 8px;
    margin-bottom: 24px;
    background: var(--ht-surface);
    border: 1px solid var(--ht-border-light);
    border-radius: 14px;
    padding: 6px;
    flex-wrap: wrap;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}
.ht-subtab-btn {
    background: transparent;
    border: 1px solid transparent;
    color: var(--ht-muted);
    border-radius: 10px;
    padding: 10px 18px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s ease;
}
.ht-subtab-btn:hover {
    color: var(--ht-text-heading);
    background: var(--ht-card);
}
.ht-subtab-btn.active {
    background: var(--ht-card);
    border-color: var(--ht-accent);
    color: var(--ht-accent);
    box-shadow: 0 4px 12px rgba(245, 158, 11, 0.15);
    font-weight: 700;
}

/* View Tax Invoice Button (High Contrast & Theme-Adaptive) */
.ht-invoice-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    border-radius: 8px;
    font-size: 0.82rem;
    font-weight: 700;
    cursor: pointer;
    text-decoration: none !important;
    transition: all 0.2s;
}
[data-theme="dark"] .ht-invoice-btn {
    background: rgba(245, 158, 11, 0.15);
    border: 1px solid var(--ht-accent);
    color: var(--ht-accent);
}
[data-theme="dark"] .ht-invoice-btn:hover {
    background: var(--ht-accent);
    color: #0b1120;
}
[data-theme="light"] .ht-invoice-btn {
    background: #fef3c7;
    border: 1px solid #d97706;
    color: #92400e;
}
[data-theme="light"] .ht-invoice-btn:hover {
    background: #f59e0b;
    border-color: #d97706;
    color: #ffffff;
}

/* Persistent Countdown Banner in Client Cockpit */
.ht-countdown-banner {
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.08) 0%, rgba(59, 130, 246, 0.08) 100%);
    border: 1px solid var(--ht-border-light);
    border-left: 4px solid var(--ht-accent);
    border-radius: 14px;
    padding: 16px 24px;
    margin-bottom: 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 16px;
}
html[dir="rtl"] .ht-countdown-banner {
    border-left: 1px solid var(--ht-border-light);
    border-right: 4px solid var(--ht-accent);
}
.ht-countdown-title {
    font-size: 0.82rem;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--ht-muted);
    font-weight: 700;
}
.ht-countdown-days {
    font-size: 1.4rem;
    font-weight: 800;
    color: var(--ht-text-heading);
    display: flex;
    align-items: center;
    gap: 10px;
}
.ht-days-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;   /* flex drops the space text between the icon and the label */
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 700;
}
.ht-days-green { background: rgba(16, 185, 129, 0.15); color: #10b981; border: 1px solid #10b981; }
.ht-days-amber { background: rgba(245, 158, 11, 0.15); color: #f59e0b; border: 1px solid #f59e0b; }
.ht-days-red { background: rgba(239, 68, 68, 0.15); color: #ef4444; border: 1px solid #ef4444; }

/* Countdown banner states (expired / suspended / cancelled = danger; postponed / pending = warn) */
.ht-countdown-banner.ht-countdown-banner-danger {
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.14) 0%, rgba(239, 68, 68, 0.05) 100%);
    border-color: rgba(239, 68, 68, 0.45);
    border-left: 4px solid #ef4444;
}
.ht-countdown-banner.ht-countdown-banner-warn {
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.14) 0%, rgba(245, 158, 11, 0.05) 100%);
    border-color: rgba(245, 158, 11, 0.45);
    border-left: 4px solid #f59e0b;
}
html[dir="rtl"] .ht-countdown-banner.ht-countdown-banner-danger {
    border-left: 1px solid rgba(239, 68, 68, 0.45);
    border-right: 4px solid #ef4444;
}
html[dir="rtl"] .ht-countdown-banner.ht-countdown-banner-warn {
    border-left: 1px solid rgba(245, 158, 11, 0.45);
    border-right: 4px solid #f59e0b;
}
.ht-countdown-note {
    margin-top: 6px;
    font-size: 0.88rem;
    font-weight: 700;
}
.ht-countdown-note-danger { color: #ef4444; }
.ht-countdown-note-warn { color: #f59e0b; }

/* Executive KPI Cards (TASK-21) */
.ht-kpi-card {
    background: var(--ht-card);
    border: 1px solid var(--ht-border-light);
    border-radius: 14px;
    padding: 20px 22px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    position: relative;
    overflow: hidden;
    transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}
/* Accent bar on the leading edge */
.ht-kpi-card::before {
    content: '';
    position: absolute;
    inset-inline-start: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    background: var(--ht-accent);
    opacity: 0.85;
}
.ht-kpi-card.ht-clickable {
    cursor: pointer;
}
.ht-kpi-card.ht-clickable:hover {
    transform: translateY(-3px);
    border-color: var(--ht-accent);
    box-shadow: 0 10px 28px rgba(0,0,0,0.28);
}
.ht-kpi-card .ht-kpi-label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--ht-muted);
    text-transform: uppercase;
    letter-spacing: 0.4px;
}
.ht-kpi-card .ht-kpi-value,
.ht-kpi-card .ht-kpi-val {
    font-size: 2rem;
    font-weight: 800;
    color: var(--ht-text-heading);
    line-height: 1.1;
}
/* Severity variants */
.ht-kpi-card.is-warning::before { background: #f59e0b; }
.ht-kpi-card.is-danger::before  { background: #ef4444; }
.ht-kpi-card.is-success::before { background: #10b981; }
/* One priority count badge per card (red = act now, amber = watch), pinned to the trailing bottom corner */
.ht-kpi-card .ht-kpi-count {
    position: absolute;
    bottom: 14px;
    inset-inline-end: 16px;
    font-size: 0.75rem;
    padding: 3px 9px;
    font-weight: 800;
}

.ht-kpi-card.ht-clickable::after {
    content: "➔";
    position: absolute;
    top: 16px;
    right: 18px;
    font-size: 0.85rem;
    color: var(--ht-muted);
    opacity: 0;
    transition: all 0.2s ease;
}
html[dir="rtl"] .ht-kpi-card.ht-clickable::after {
    right: auto;
    left: 18px;
    content: "←";
}
.ht-kpi-card.ht-clickable:hover::after {
    opacity: 1;
    color: var(--ht-accent);
}

/* Side-by-Side Action Buttons (Approve / Reject) */
.ht-action-btn-group {
    display: inline-flex;
    gap: 8px;
    align-items: center;
}

/* ---------------------------------------------------------------------------
   Inline buttons must size to their content.

   .ht-btn-primary and .ht-btn-outline both declare `width: 100%` because they
   were designed for forms and modals, where a full-width button is correct.
   Inside a flex row that is NOT content-sized — the attention queue row, a
   table cell — that 100% resolves against the full row width, so a single
   button claims the entire line and squeezes the text beside it into a
   one-word-per-line column.

   Twenty call sites in admin.html work around this with an inline
   `style="width:auto"`, and every new button forgets it. Scoping the override
   here fixes the whole class of bug instead of one button at a time, while
   leaving form and modal buttons full-width as intended.
   --------------------------------------------------------------------------- */
.ht-attention-item .ht-btn-primary,
.ht-attention-item .ht-btn-outline,
.ht-action-btn-group .ht-btn-primary,
.ht-action-btn-group .ht-btn-outline,
td .ht-btn-primary,
td .ht-btn-outline {
    width: auto;
    flex: 0 0 auto;
}

/* Give the text side of an attention row the remaining space, and let long
   titles wrap normally instead of being squeezed to a narrow column. */
.ht-attention-item > div:first-child {
    min-width: 0;
}
.ht-btn-approve {
    background: #10b981;
    color: #ffffff !important;
    border: 1px solid #059669;
    border-radius: 6px;
    padding: 6px 14px;
    font-size: 0.82rem;
    font-weight: 700;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    transition: all 0.2s;
    text-decoration: none !important;
}
.ht-btn-approve:hover {
    background: #059669;
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}
.ht-btn-reject {
    background: #ef4444;
    color: #ffffff !important;
    border: 1px solid #dc2626;
    border-radius: 6px;
    padding: 6px 14px;
    font-size: 0.82rem;
    font-weight: 700;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    transition: all 0.2s;
    text-decoration: none !important;
}
.ht-btn-reject:hover {
    background: #dc2626;
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
}

/* YouTube-Style Instant Search Dropdown */
.ht-search-container {
    position: relative;
    width: 100%;
}
.ht-search-input-wrap {
    position: relative;
}
.ht-search-input-wrap i {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--ht-muted);
}
html[dir="rtl"] .ht-search-input-wrap i {
    left: auto;
    right: 14px;
}
.ht-search-input {
    padding-left: 40px !important;
}
html[dir="rtl"] .ht-search-input {
    padding-left: 14px !important;
    padding-right: 40px !important;
}
.ht-search-dropdown {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    right: 0;
    background: var(--ht-card);
    border: 1px solid var(--ht-border-light);
    border-radius: 12px;
    max-height: 340px;
    overflow-y: auto;
    z-index: 1200;
    box-shadow: var(--ht-shadow);
    display: none;
}

/* A card holding a type-ahead must not clip its dropdown.
   .ht-table-card sets overflow:hidden for rounded table corners, which cut the
   client-search results down to roughly one visible row — the list was there,
   it was just outside the card's box. Scoped so ordinary table cards keep
   their clipping. */
.ht-table-card:has(.ht-search-dropdown),
.ht-table-card:has(.ht-search-container) {
    overflow: visible;
}
.ht-search-item {
    padding: 12px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--ht-border-light);
    cursor: pointer;
    transition: background 0.15s ease;
}
.ht-search-item:last-child {
    border-bottom: none;
}
.ht-search-item:hover {
    background: var(--ht-card-hover);
}

/* Client Detail Drawer Modal */
.ht-drawer-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.65);
    backdrop-filter: blur(4px);
    z-index: 1200;
    display: none;
    align-items: center;
    justify-content: flex-end;
}
.ht-drawer {
    background: var(--ht-card);
    width: 100%;
    max-width: 620px;
    height: 100vh;
    overflow-y: auto;
    box-shadow: -8px 0 32px rgba(0,0,0,0.4);
    padding: 32px 28px;
    display: flex;
    flex-direction: column;
    position: relative;
    animation: slideInRight 0.3s ease;
}
/* Client drawer buttons: one size everywhere, sized to their content (the base button classes are
   full-width for forms, which made the drawer header and action rows uneven). */
.ht-drawer .ht-btn-primary,
.ht-drawer .ht-btn-secondary,
.ht-drawer .ht-btn-outline { width: auto; }
/* drawer sub-tabs (Overview / Billing / Timeline / Audit) wrap instead of overflowing on phones */
.ht-drawer .ht-auth-tabs { flex-wrap: wrap; row-gap: 4px; }
.ht-drawer-btn {
    height: 36px;
    padding: 0 14px !important;
    font-size: 0.8rem !important;
    font-weight: 600;
    gap: 6px;
    justify-content: center;
    white-space: nowrap;
    border-radius: 8px;
}
.ht-drawer-btn-sm { height: 28px; padding: 0 10px !important; font-size: 0.74rem !important; }
.ht-drawer-header {
    border-bottom: 1px solid var(--ht-border-light);
    padding-bottom: 14px;
    margin-bottom: 16px;
}
.ht-drawer-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.ht-drawer-head .ht-modal-close { flex: 0 0 auto; margin: 0; }
.ht-drawer-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.ht-drawer-mgmt { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 8px; }
.ht-drawer-mgmt .ht-drawer-btn { width: 100%; }

.ht-drawer .ht-modal-close {
    position: static;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    font-size: 1.5rem;
    line-height: 1;
    padding: 0;
    margin-left: 8px;
    border-radius: 6px;
    transition: background 0.2s ease, color 0.2s ease;
}
.ht-drawer .ht-modal-close:hover {
    background: var(--ht-card-hover);
    color: var(--ht-text-heading);
}
html[dir="rtl"] .ht-drawer .ht-modal-close {
    margin-left: 0;
    margin-right: 8px;
    right: auto;
    left: auto;
}
html[dir="rtl"] .ht-drawer {
    animation: slideInLeft 0.3s ease;
}
@keyframes slideInRight {
    from { transform: translateX(100%); }
    to { transform: translateX(0); }
}
@keyframes slideInLeft {
    from { transform: translateX(-100%); }
    to { transform: translateX(0); }
}

/* Sub-User Permission Pills */
.ht-perm-badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: 6px;
    font-size: 0.72rem;
    font-weight: 600;
    background: rgba(59, 130, 246, 0.12);
    color: #3b82f6;
    border: 1px solid rgba(59, 130, 246, 0.25);
    margin: 2px;
}

/* ==========================================================================
    MOBILE RESPONSIVENESS & TOUCH ENHANCEMENTS
   ========================================================================== */

html, body {
    overflow-x: hidden !important;
    width: 100% !important;
    max-width: 100vw !important;
    -webkit-text-size-adjust: 100%;
}

.ht-nav-toggle {
    display: none;
}

.ht-nav-menu-footer {
    display: none;
}

/* Tablet Breakpoint (<= 991px) */
@media (max-width: 991px) {
    .ht-kpi-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 16px !important;
    }
    .ht-calc-grid {
        grid-template-columns: 1fr !important;
        gap: 28px !important;
    }
    .ht-plans-grid,
    .ht-pricing-grid {
        grid-template-columns: 1fr !important;
        gap: 20px !important;
    }
}

/* Top bar collapses to the menu button below 1100px: brand + links + language/theme + user pill
   + sign-out do not fit in one row on tablets/small laptops (they wrapped and pushed sign-out off-screen). */
@media (max-width: 1100px) {
    .ht-navbar-container { position: relative; }
    .ht-brand-sub { display: none !important; }
    .ht-user-controls-desktop { display: none !important; }
    .ht-nav-toggle {
        display: inline-flex !important;
        align-items: center;
        justify-content: center;
        width: 38px !important;
        height: 38px !important;
        font-size: 1rem;
    }
    .ht-nav-menu {
        display: none;
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        background: var(--ht-card);
        border-bottom: 2px solid var(--ht-border);
        flex-direction: column;
        align-items: stretch;
        padding: 16px 14px 20px;
        gap: 6px;
        box-shadow: 0 16px 40px rgba(0,0,0,0.5);
        z-index: 1000;
        max-height: calc(100dvh - 72px);
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }
    .ht-nav-menu.is-open { display: flex !important; }
    .ht-nav-link {
        width: 100%;
        padding: 12px 14px;
        font-size: 0.95rem;
        border-radius: 10px;
        gap: 10px;
    }
    .ht-nav-link.active {
        background: rgba(249, 115, 22, 0.12);
        color: var(--ht-accent);
        font-weight: 700;
    }
    .ht-nav-menu-footer {
        display: block !important;
        border-top: 1px solid var(--ht-border-light);
        padding-top: 14px;
        margin-top: 10px;
    }
}

/* Mobile Breakpoint (<= 768px) */
@media (max-width: 768px) {
    /* 1. Containers & Section Spacing */
    .ht-container {
        padding: 0 16px !important;
        width: 100% !important;
        max-width: 100% !important;
    }
    .ht-view-section {
        padding: 20px 0 40px !important;
    }

    /* 2. Top Navigation Bar */
    .ht-navbar {
        padding: 0 !important;
    }
    .ht-navbar-container {
        padding: 0 14px !important;
        height: 60px !important;
    }
    .ht-brand-sub {
        display: none !important;
    }
    .ht-brand-title {
        font-size: 1.05rem !important;
        letter-spacing: -0.3px;
    }
    .ht-brand-logo {
        width: 28px !important;
        height: 28px !important;
    }
    .ht-nav-actions {
        gap: 6px !important;
    }
    .ht-icon-btn {
        width: 38px !important;
        height: 38px !important;
        min-height: 38px !important;
        padding: 0 6px !important;
        font-size: 0.85rem !important;
    }
    .ht-user-controls-desktop {
        display: none !important;
    }
    .ht-nav-toggle {
        display: inline-flex !important;
        align-items: center;
        justify-content: center;
        width: 38px !important;
        height: 38px !important;
        font-size: 1rem;
    }
    .ht-nav-menu {
        display: none;
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        background: var(--ht-card);
        border-bottom: 2px solid var(--ht-border);
        flex-direction: column;
        padding: 16px 14px 20px;
        gap: 6px;
        box-shadow: 0 16px 40px rgba(0,0,0,0.5);
        z-index: 1000;
        max-height: calc(100dvh - 60px);
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }
    .ht-nav-menu.is-open {
        display: flex !important;
    }
    .ht-nav-link {
        width: 100%;
        padding: 12px 14px;
        font-size: 0.95rem;
        border-radius: 10px;
        display: flex;
        align-items: center;
        gap: 10px;
    }
    .ht-nav-link.active {
        background: rgba(249, 115, 22, 0.12);
        color: var(--ht-accent);
        font-weight: 700;
    }
    .ht-nav-menu-footer {
        display: block !important;
        border-top: 1px solid var(--ht-border-light);
        padding-top: 14px;
        margin-top: 10px;
    }

    /* 3. Dashboard Header & Hero Actions */
    .ht-dashboard-header {
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 14px !important;
        margin-bottom: 20px !important;
    }
    .ht-dashboard-header > div:last-child {
        display: flex !important;
        flex-wrap: wrap !important;
        gap: 8px !important;
        width: 100% !important;
    }
    .ht-dashboard-header > div:last-child a,
    .ht-dashboard-header > div:last-child button {
        flex: 1 1 auto !important;
        justify-content: center !important;
        text-align: center !important;
        padding: 10px 14px !important;
        font-size: 0.85rem !important;
    }
    .ht-hero-title {
        font-size: 1.55rem !important;
        line-height: 1.25 !important;
    }

    /* 4. Sub-Navigation Tabs (Horizontal Touch Scroll) */
    .ht-subtabs {
        flex-wrap: nowrap !important;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        padding: 4px !important;
        gap: 6px !important;
        margin-bottom: 20px !important;
        border-radius: 12px !important;
    }
    .ht-subtabs::-webkit-scrollbar {
        display: none;
    }
    .ht-subtab-btn {
        flex-shrink: 0 !important;
        white-space: nowrap !important;
        padding: 8px 14px !important;
        font-size: 0.85rem !important;
    }

    /* 5. Automatic Single-Column Collapse for All Multi-Column Grids */
    [style*="grid-template-columns:1fr 1fr"],
    [style*="grid-template-columns: 1fr 1fr"],
    [style*="grid-template-columns: 1fr 1.2fr"],
    [style*="grid-template-columns:1fr 1.2fr"],
    [style*="grid-template-columns:repeat(2"],
    [style*="grid-template-columns: repeat(2"],
    [style*="grid-template-columns:repeat(3"],
    [style*="grid-template-columns: repeat(3"] {
        grid-template-columns: 1fr !important;
        gap: 16px !important;
    }

    /* 6. KPI Grid Cards */
    .ht-kpi-grid {
        grid-template-columns: 1fr !important;
        gap: 12px !important;
        margin-bottom: 20px !important;
    }
    .ht-kpi-card {
        padding: 18px 16px !important;
    }
    .ht-kpi-val {
        font-size: 1.45rem !important;
    }

    /* 7. Persistent Countdown Banner */
    .ht-countdown-banner {
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 16px !important;
        padding: 16px !important;
        border-radius: 12px !important;
        margin-bottom: 20px !important;
    }
    .ht-countdown-banner > div:last-child {
        width: 100% !important;
    }
    .ht-countdown-banner .ht-btn-primary {
        width: 100% !important;
        justify-content: center !important;
        text-align: center !important;
        display: flex !important;
        padding: 12px !important;
    }
    .ht-countdown-days {
        flex-wrap: wrap !important;
        font-size: 1.2rem !important;
        gap: 8px !important;
    }

    /* 8. Card-Based Tables on Mobile */
    .ht-table-wrap {
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch;
        border-radius: 12px;
    }
    .ht-table {
        min-width: 0 !important;
        width: 100% !important;
        border-collapse: separate;
        border-spacing: 0;
    }
    .ht-table thead {
        display: none !important;
    }
    .ht-table tbody,
    .ht-table tr,
    .ht-table td {
        display: block !important;
        width: 100% !important;
        box-sizing: border-box !important;
    }
    .ht-table tr {
        margin-bottom: 12px;
        padding: 14px 16px;
        border: 1px solid var(--ht-border-light);
        border-radius: 12px;
        background: var(--ht-card);
        box-shadow: 0 2px 8px rgba(0,0,0,0.12);
    }
    .ht-table td {
        display: flex !important;
        justify-content: space-between;
        align-items: center;
        gap: 12px;
        padding: 9px 0 !important;
        border: none !important;
        border-bottom: 1px solid rgba(255, 255, 255, 0.05) !important;
        text-align: right;
        font-size: 0.88rem;
    }
    html[dir="rtl"] .ht-table td {
        text-align: left;
    }
    .ht-table td:last-child {
        border-bottom: none !important;
        padding-bottom: 0 !important;
    }
    .ht-table td::before {
        content: attr(data-label);
        font-weight: 700;
        font-size: 0.75rem;
        color: var(--ht-muted);
        text-transform: uppercase;
        letter-spacing: 0.5px;
        flex-shrink: 0;
        text-align: left;
    }
    html[dir="rtl"] .ht-table td::before {
        text-align: right;
    }
    .ht-table td[colspan] {
        display: block !important;
        width: 100% !important;
        text-align: center !important;
        padding: 24px 12px !important;
        border: none !important;
    }
    .ht-table td[colspan]::before {
        display: none !important;
    }
    .ht-table td:not([data-label])::before {
        display: none !important;
    }
    .ht-table td .ht-invoice-btn {
        width: 100% !important;
        justify-content: center !important;
        margin-top: 4px;
        padding: 9px 12px !important;
    }

    /* 9. Cards, Forms & Inputs */
    .ht-table-card,
    .ht-card,
    .ht-calc-box {
        padding: 20px 16px !important;
        border-radius: 14px !important;
        margin-bottom: 20px !important;
    }
    .ht-form-group {
        margin-bottom: 16px !important;
    }
    .ht-btn-primary,
    .ht-btn-secondary,
    .ht-btn-outline {
        min-height: 44px;
    }

    /* 10. Modals & Drawers Mobile Polish */
    .ht-modal-backdrop {
        padding: 12px !important;
        align-items: center !important;
        justify-content: center !important;
    }
    .ht-modal {
        max-width: calc(100vw - 24px) !important;
        width: calc(100vw - 24px) !important;
        max-height: 90dvh !important;
        height: auto !important;
        border-radius: 16px !important;
        padding: 24px 18px !important;
        margin: auto !important;
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch;
    }
    .ht-drawer {
        max-width: 100% !important;
        width: 100% !important;
        height: 100dvh !important;
        padding: 20px 16px !important;
        border-radius: 0 !important;
    }

    /* 11. Footer Content */
    .ht-footer {
        padding: 24px 0 20px !important;
    }
    .ht-footer-content {
        flex-direction: column !important;
        gap: 16px !important;
        text-align: center !important;
        align-items: center !important;
    }
    .ht-footer-content > div {
        justify-content: center !important;
        flex-wrap: wrap !important;
        text-align: center !important;
        gap: 8px 12px !important;
        font-size: 0.82rem !important;
    }

    /* 12. Store Capacity Manager Controls */
    .ht-table-card .ht-table-header {
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 12px !important;
    }
    .ht-table-card .ht-table-header button {
        width: 100% !important;
        justify-content: center !important;
    }
}

/* Extra Small Mobile (320px - 414px) */
@media (max-width: 480px) {
    .ht-navbar-container {
        padding: 0 10px !important;
    }
    .ht-hero-title {
        font-size: 1.45rem !important;
    }
    .ht-pricing-card,
    .ht-calc-box {
        padding: 18px 14px !important;
    }
    .ht-plan-card {
        padding: 26px 18px !important;
    }
    .ht-slider {
        height: 12px;
    }
    .ht-slider::-webkit-slider-thumb {
        width: 28px;
        height: 28px;
    }
}

/* ==========================================
   DAY 2 COMPONENT STYLES
   ========================================== */

/* 1. Impersonation Top Banner (TASK-S8) */
.ht-impersonation-bar {
    position: sticky;
    top: 0;
    left: 0;
    right: 0;
    z-index: 99999;
    background: linear-gradient(90deg, #ea580c, #f59e0b);
    color: #ffffff;
    padding: 10px 24px;
    font-size: 0.92rem;
    font-weight: 700;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 4px 16px rgba(234, 88, 12, 0.35);
}
.ht-impersonation-bar i {
    margin-right: 8px;
}
.ht-impersonation-exit-btn {
    background: #ffffff;
    color: #ea580c;
    border: none;
    border-radius: 6px;
    padding: 6px 14px;
    font-size: 0.82rem;
    font-weight: 800;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s ease;
}
.ht-impersonation-exit-btn:hover {
    background: #fff7ed;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

/* 2. Needs Attention Queue (TASK-27b) */
.ht-attention-item {
    background: var(--ht-surface);
    border: 1px solid var(--ht-border-light);
    border-left: 4px solid var(--ht-accent);
    border-radius: 12px;
    padding: 16px 20px;
    margin-bottom: 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    transition: transform 0.2s ease, border-color 0.2s ease;
}
.ht-attention-item:hover {
    transform: translateX(3px);
    border-color: var(--ht-accent);
}
.ht-attention-item.is-high {
    border-left-color: #ef4444;
    background: rgba(239, 68, 68, 0.04);
}
.ht-attention-item.is-med {
    border-left-color: #f59e0b;
    background: rgba(245, 158, 11, 0.04);
}

/* 3. Search & Filter Bar (TASK-27) */
.ht-filter-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
    background: var(--ht-surface);
    border: 1px solid var(--ht-border-light);
    border-radius: 12px;
    padding: 16px 20px;
}
.ht-filter-group {
    display: flex;
    align-items: center;
    gap: 8px;
}
/* .ht-input carries padding:12px 16px. Forcing height:38px on top of that left
   only ~14px of usable line box, so text was visually cut in half. Reduce the
   vertical padding to match the constrained height and include it in the box. */
.ht-filter-group select,
.ht-filter-group input,
.ht-filter-bar select,
.ht-filter-bar input {
    margin-bottom: 0 !important;
    height: 38px;
    padding-top: 6px;
    padding-bottom: 6px;
    line-height: 1.4;
    box-sizing: border-box;
    font-size: 0.85rem;
}

/* 4. Customer Vertical Timeline (TASK-S7) */
.ht-vertical-timeline {
    position: relative;
    padding-left: 28px;
    margin: 20px 0;
}
.ht-vertical-timeline::before {
    content: '';
    position: absolute;
    top: 4px;
    bottom: 4px;
    left: 11px;
    width: 2px;
    background: var(--ht-border);
}
.ht-timeline-event {
    position: relative;
    margin-bottom: 22px;
}
.ht-timeline-icon-wrap {
    position: absolute;
    left: -28px;
    top: 0;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--ht-card);
    border: 2px solid var(--ht-accent);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.65rem;
    color: var(--ht-accent);
}
.ht-timeline-event.is-alert .ht-timeline-icon-wrap {
    border-color: #ef4444;
    color: #ef4444;
}
.ht-timeline-event.is-success .ht-timeline-icon-wrap {
    border-color: #10b981;
    color: #10b981;
}
.ht-timeline-content {
    background: var(--ht-card);
    border: 1px solid var(--ht-border-light);
    border-radius: 10px;
    padding: 12px 16px;
}
.ht-timeline-title {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--ht-text-heading);
    margin-bottom: 4px;
}
.ht-timeline-detail {
    font-size: 0.82rem;
    color: var(--ht-muted);
}
.ht-timeline-date {
    font-size: 0.75rem;
    color: var(--ht-muted);
    margin-top: 6px;
}

/* 5. Payment Status Timeline Strip (TASK-S9) */
.ht-timeline-strip {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    position: relative;
    margin: 24px 0;
    padding: 10px 4px;
}
.ht-timeline-strip::before {
    content: '';
    position: absolute;
    top: 24px;
    left: 40px;
    right: 40px;
    height: 3px;
    background: var(--ht-border-light);
    z-index: 1;
}
.ht-timeline-step {
    position: relative;
    z-index: 2;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    flex: 1;
}
.ht-step-indicator {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--ht-surface);
    border: 2px solid var(--ht-muted);
    color: var(--ht-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    font-weight: 800;
    margin-bottom: 8px;
    transition: all 0.3s ease;
}
.ht-timeline-step.is-done .ht-step-indicator {
    background: #10b981;
    border-color: #10b981;
    color: #ffffff;
}
.ht-timeline-step.is-active .ht-step-indicator {
    background: #f59e0b;
    border-color: #f59e0b;
    color: #ffffff;
    box-shadow: 0 0 0 4px rgba(245, 158, 11, 0.25);
    animation: ht-pulse 2s infinite;
}
.ht-step-title {
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--ht-text-heading);
}
.ht-step-date {
    font-size: 0.72rem;
    color: var(--ht-muted);
}
@keyframes ht-pulse {
    0% { box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.5); }
    70% { box-shadow: 0 0 0 8px rgba(245, 158, 11, 0); }
    100% { box-shadow: 0 0 0 0 rgba(245, 158, 11, 0); }
}

/* 6. Invoice Paid Stamp & Print Styling (TASK-30) */
.ht-stamp {
    display: inline-block;
    padding: 6px 16px;
    font-size: 1.1rem;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 2px;
    border: 3px solid;
    border-radius: 8px;
    transform: rotate(-7deg);
}
.ht-stamp-paid {
    color: #10b981;
    border-color: #10b981;
    background: rgba(16, 185, 129, 0.08);
}
.ht-stamp-unpaid {
    color: #ef4444;
    border-color: #ef4444;
    background: rgba(239, 68, 68, 0.08);
}

@media print {
    #ht-nav,
    #ht-footer,
    .ht-modal-close,
    .ht-invoice-btn,
    .ht-no-print,
    .ht-impersonation-bar,
    .ht-subtabs,
    .ht-btn-primary,
    .ht-btn-outline {
        display: none !important;
    }
    body {
        background: #ffffff !important;
        color: #000000 !important;
    }
    .ht-modal-backdrop {
        position: static !important;
        background: none !important;
        display: block !important;
        padding: 0 !important;
    }
    .ht-modal {
        position: static !important;
        width: 100% !important;
        max-width: 100% !important;
        box-shadow: none !important;
        border: none !important;
        padding: 0 !important;
    }
    #invoice-modal table { page-break-inside: avoid; }
    #invoice-modal tr { page-break-inside: avoid; }
    a[href]::after { content: "" !important; }
}

/* ==========================================
   TEST ENVIRONMENT BANNER (js/env.js)
   Only under /portal-test/: env.js adds html.ht-env-test and a fixed strip at the very top.
   The page is pushed down by the strip's height so the top bar keeps its own layout and
   never wraps. Sits under drawers/modals (z-index 1200+).
   ========================================== */
:root { --ht-env-banner-h: 0px; }
html.ht-env-test { --ht-env-banner-h: 26px; }
.ht-env-banner {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--ht-env-banner-h);
    z-index: 1150;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 0 12px;
    background: repeating-linear-gradient(135deg, #ea580c 0 14px, #f97316 14px 28px);
    color: #ffffff;
    font-size: 12.5px;
    font-weight: 600;
    line-height: 1;
    white-space: nowrap;
    overflow: hidden;
    box-shadow: 0 1px 0 rgba(0, 0, 0, 0.25);
    text-shadow: 0 1px 1px rgba(0, 0, 0, 0.25);
}
.ht-env-banner i { flex: 0 0 auto; font-size: 11px; }
.ht-env-banner-text {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
}
.ht-env-banner-text strong { font-weight: 800; letter-spacing: 0.06em; }
html[dir="rtl"] .ht-env-banner-text strong { letter-spacing: 0; }
/* body is the sticky scroll container here (html, body { overflow-x: hidden }), so its padding
   already offsets the sticky .ht-navbar / .ht-impersonation-bar: they keep top: 0. Only the
   viewport-fixed progress bar needs moving. */
html.ht-env-test body { padding-top: var(--ht-env-banner-h); }
html.ht-env-test #ht-top-progress { top: var(--ht-env-banner-h); }
html.ht-env-test .ht-nav-menu { max-height: calc(100dvh - 60px - var(--ht-env-banner-h)); }
@media (max-width: 480px) {
    html.ht-env-test { --ht-env-banner-h: 22px; }
    .ht-env-banner { font-size: 11px; gap: 6px; padding: 0 8px; }
}
@media print {
    .ht-env-banner { display: none !important; }
    html.ht-env-test body { padding-top: 0 !important; }
}

/* ==========================================================================
   LOAD-FAILURE BANNER (admin dashboard, payment page) + INFO NOTE
   A failed endpoint is shown as an error with Retry, never as "no data".
   ========================================================================== */
.ht-load-error-banner {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px 14px;
    padding: 14px 18px;
    margin-bottom: 20px;
    border: 1px solid rgba(239, 68, 68, 0.45);
    border-inline-start: 4px solid #ef4444;
    border-radius: 12px;
    background: rgba(239, 68, 68, 0.08);
    color: var(--ht-text);
    font-size: 0.88rem;
    line-height: 1.45;
}
.ht-load-error-banner > i { color: #ef4444; font-size: 1.1rem; flex: 0 0 auto; }
.ht-load-error-text { flex: 1 1 220px; min-width: 0; overflow-wrap: anywhere; }
.ht-load-error-text strong { color: var(--ht-text-heading); margin-inline-end: 4px; }
.ht-load-error-banner .ht-btn-outline { width: auto; flex: 0 0 auto; padding: 6px 14px; font-size: 0.82rem; }

.ht-info-note {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px 16px;
    margin-bottom: 18px;
    border: 1px solid var(--ht-border-light);
    border-inline-start: 4px solid var(--ht-accent);
    border-radius: 10px;
    background: var(--ht-surface);
    color: var(--ht-muted);
    font-size: 0.86rem;
    line-height: 1.45;
}
.ht-info-note > i { color: var(--ht-accent); margin-top: 2px; flex: 0 0 auto; }

/* ==========================================================================
   PAYMENT PAGE: BILLING-CYCLE SELECTOR
   ========================================================================== */
.ht-pay-grid > * { min-width: 0; }   /* grid columns may shrink below their content width */
.ht-cycle-picker-wrap {
    margin-bottom: 18px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--ht-border-light);
}
.ht-cycle-picker-label {
    display: block;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--ht-muted);
    font-weight: 700;
    margin-bottom: 8px;
}
html[dir="rtl"] .ht-cycle-picker-label { letter-spacing: 0; }
.ht-cycle-picker { display: flex; flex-wrap: wrap; gap: 8px; }
.ht-cycle-opt {
    position: relative;
    flex: 1 1 120px;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 40px;
    padding: 8px 12px;
    border: 1px solid var(--ht-border-light);
    border-radius: 10px;
    background: transparent;
    color: var(--ht-text-heading);
    font-size: 0.85rem;
    font-weight: 600;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.15s ease, background 0.15s ease;
}
.ht-cycle-opt:hover { border-color: var(--ht-accent); }
.ht-cycle-opt.is-selected {
    border-color: var(--ht-accent);
    background: rgba(249, 115, 22, 0.12);
    color: var(--ht-accent);
    box-shadow: 0 0 0 1px var(--ht-accent) inset;
}
.ht-cycle-radio { position: absolute; opacity: 0; width: 1px; height: 1px; margin: 0; pointer-events: none; }
.ht-cycle-opt:focus-within { outline: 2px solid var(--ht-accent); outline-offset: 2px; }
.ht-cycle-picker-note { margin-top: 8px; font-size: 0.78rem; color: var(--ht-muted); line-height: 1.4; }

/* ==========================================================================
   375px PASS: rows that kept a fixed side-by-side layout on phones
   ========================================================================== */
@media (max-width: 768px) {
    /* Needs-attention rows: text on top, buttons below (the nowrap buttons squeezed the text). */
    .ht-attention-item { flex-wrap: wrap; align-items: stretch !important; }
    .ht-attention-item > div:first-child { flex: 1 1 100% !important; }
    .ht-attention-item > div:last-child { width: 100%; flex-wrap: wrap; justify-content: flex-end; }
    .ht-attention-item .ht-btn-primary,
    .ht-attention-item .ht-btn-outline { white-space: normal !important; }
    /* Payment cart rows: long Arabic labels wrap instead of pushing the amount out. */
    .ht-pay-grid [id^="cart-"][style*="justify-content:space-between"] { gap: 10px; }
    .ht-cycle-opt { flex: 1 1 100%; }
}

/* ==========================================================================
   BILLING: drawer Billing tab, Billing Follow-up and Reports tabs, choose dialog
   ========================================================================== */
.ht-badge-sm { padding: 2px 8px; font-size: 0.68rem; gap: 4px; letter-spacing: 0.3px; }
.ht-badge-gray { background: rgba(148, 163, 184, 0.18); color: var(--ht-muted); }

/* PortalUtil.choose(): checkbox list inside the dialog */
.ht-dialog-choices { display: flex; flex-direction: column; gap: 8px; margin-top: 14px; }
.ht-dialog-choice {
    display: flex; align-items: flex-start; gap: 10px; cursor: pointer;
    background: var(--ht-card); border: 1px solid var(--ht-border-light); border-radius: 10px; padding: 10px 12px;
}
.ht-dialog-choice:hover { border-color: var(--ht-accent); }
.ht-dialog-choice.is-disabled { opacity: 0.55; cursor: not-allowed; }
.ht-dialog-choice input { width: 18px; height: 18px; margin: 2px 0 0; flex: 0 0 auto; accent-color: var(--ht-accent); }
.ht-dialog-choice-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.ht-dialog-choice-text strong { color: var(--ht-text-heading); font-size: 0.9rem; }
.ht-dialog-choice-text small { color: var(--ht-muted); font-size: 0.78rem; line-height: 1.35; }

/* Drawer Billing tab */
.ht-bill-section-title {
    display: flex; align-items: center; gap: 8px;
    font-weight: 700; color: var(--ht-text-heading); font-size: 0.88rem;
    margin: 20px 0 6px; padding-top: 14px; border-top: 1px solid var(--ht-border-light);
}
.ht-bill-row {
    display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap;
    gap: 6px 10px; padding: 8px 0; border-bottom: 1px solid var(--ht-border-light);
}
.ht-bill-row:last-child { border-bottom: none; }
.ht-bill-row-main { min-width: 0; flex: 1 1 220px; }
.ht-bill-row-head { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; color: var(--ht-text-heading); overflow-wrap: anywhere; }
.ht-bill-row-side { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; justify-content: flex-end; margin-inline-start: auto; }
.ht-bill-amount { color: var(--ht-accent); white-space: nowrap; margin-inline-end: 4px; }
.ht-bill-meta { color: var(--ht-muted); font-size: 0.76rem; line-height: 1.45; overflow-wrap: anywhere; }
.ht-bill-card { background: var(--ht-surface); border: 1px solid var(--ht-border-light); border-radius: 10px; padding: 12px 14px; }
.ht-bill-dates { display: grid; grid-template-columns: 1fr 1fr auto; gap: 8px; align-items: end; }
.ht-bill-date { display: flex; flex-direction: column; gap: 4px; font-size: 0.76rem; color: var(--ht-muted); font-weight: 600; min-width: 0; }
.ht-bill-date .ht-input { padding: 7px 10px; font-size: 0.82rem; height: 36px; min-width: 0; }
.ht-bill-kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.ht-bill-kpi { background: var(--ht-card); border: 1px solid var(--ht-border-light); border-radius: 8px; padding: 8px 10px; min-width: 0; }
.ht-bill-kpi span { display: block; font-size: 0.7rem; color: var(--ht-muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.3px; }
.ht-bill-kpi strong { display: block; font-size: 0.95rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ht-bill-table-wrap { max-height: 280px; overflow: auto; border: 1px solid var(--ht-border-light); border-radius: 8px; -webkit-overflow-scrolling: touch; }
.ht-bill-table { width: 100%; border-collapse: collapse; font-size: 0.78rem; min-width: 430px; }
.ht-bill-table th {
    position: sticky; top: 0; z-index: 1; background: var(--ht-card); color: var(--ht-muted);
    font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.3px; text-align: start; padding: 7px 8px;
}
.ht-bill-table td { padding: 7px 8px; border-top: 1px solid var(--ht-border-light); vertical-align: top; color: var(--ht-text); }
.ht-bill-table .num { text-align: end; white-space: nowrap; }
.ht-bill-table .ht-bill-opening td { color: var(--ht-muted); font-style: italic; }
@media (max-width: 520px) {
    .ht-bill-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .ht-bill-dates { grid-template-columns: 1fr 1fr; }
    .ht-bill-dates .ht-drawer-btn { grid-column: 1 / -1; width: 100%; }
    .ht-bill-row-side { width: 100%; }
}

/* Billing Follow-up tab */
.ht-dun-filters { display: grid; grid-template-columns: minmax(0, 1fr) 220px; gap: 10px; margin-bottom: 14px; }
.ht-dun-filters .ht-input { padding: 9px 12px; font-size: 0.85rem; }
.ht-dun-reasons { display: flex; flex-wrap: wrap; gap: 4px; max-width: 280px; }
.ht-dun-actions { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; max-width: 330px; }
.ht-dun-btn { width: auto; padding: 4px 10px; font-size: 0.74rem; border-radius: 8px; gap: 5px; white-space: nowrap; min-height: 0; }
.ht-dun-btn.is-danger  { color: #ef4444 !important; border-color: rgba(239, 68, 68, 0.45); }
.ht-dun-btn.is-success { color: #10b981 !important; border-color: rgba(16, 185, 129, 0.5); }
.ht-dun-btn.is-warning { color: #f59e0b !important; border-color: rgba(245, 158, 11, 0.5); }
.ht-link-btn {
    background: none; border: none; padding: 0; margin: 0; cursor: pointer; text-align: start;
    color: var(--ht-text-heading); font: inherit;
}
.ht-link-btn:hover strong { color: var(--ht-accent); text-decoration: underline; }
@media (max-width: 768px) {
    .ht-dun-filters { grid-template-columns: 1fr; }
    .ht-dun-reasons { justify-content: flex-end; max-width: none; }
    .ht-dun-actions { max-width: none; }
    .ht-dun-btn { min-height: 34px !important; flex: 1 1 auto; justify-content: center; }
}

/* Reports tab */
.ht-rev-controls { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.ht-rev-controls .ht-input { width: auto; padding: 8px 12px; font-size: 0.85rem; }
.ht-rev-controls .ht-btn-outline,
.ht-rev-controls .ht-btn-primary { width: auto; padding: 8px 14px; font-size: 0.82rem; }
.ht-kpi-grid.ht-rev-kpis { grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 14px; margin-bottom: 20px; }
.ht-rev-kpis .ht-kpi-card { padding: 16px 18px; }
.ht-rev-kpis .ht-kpi-val { font-size: 1.45rem; overflow-wrap: anywhere; }
@media (max-width: 1199px) { .ht-kpi-grid.ht-rev-kpis { grid-template-columns: repeat(3, minmax(0, 1fr)) !important; } }
@media (max-width: 767px)  { .ht-kpi-grid.ht-rev-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; gap: 10px !important; } }
@media (max-width: 400px)  { .ht-kpi-grid.ht-rev-kpis { grid-template-columns: 1fr !important; } }
.ht-rev-chart-card { background: var(--ht-surface); border: 1px solid var(--ht-border-light); border-radius: 12px; padding: 14px 16px; }
.ht-rev-chart { width: 100%; height: auto; display: block; }
.ht-rev-chart text { fill: var(--ht-muted); font-size: 10px; font-family: inherit; }
.ht-rev-chart .grid { stroke: var(--ht-border-light); stroke-width: 1; }
.ht-rev-chart .bar-card, .ht-rev-legend .bar-card { fill: #3b82f6; background: #3b82f6; }
.ht-rev-chart .bar-wire, .ht-rev-legend .bar-wire { fill: #10b981; background: #10b981; }
.ht-rev-chart .bar-other, .ht-rev-legend .bar-other { fill: #f59e0b; background: #f59e0b; }
.ht-rev-chart .bar-empty { fill: var(--ht-border-light); }
.ht-rev-legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: 0.78rem; color: var(--ht-muted); margin-bottom: 6px; }
.ht-rev-legend span { display: inline-flex; align-items: center; gap: 6px; }
.ht-rev-legend .sw { display: inline-block; width: 10px; height: 10px; border-radius: 2px; }
.ht-table .ht-rev-total td { border-top: 2px solid var(--ht-border-light); background: var(--ht-card); }

/* Cockpit: statement balance notice */
.ht-balance-notice {
    display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px;
    background: rgba(239, 68, 68, 0.10); border: 1px solid rgba(239, 68, 68, 0.45); border-radius: 10px;
    padding: 10px 14px; margin: 0 0 14px; font-size: 0.88rem; color: var(--ht-text);
}
.ht-balance-notice .ht-btn-primary { width: auto; padding: 7px 16px; font-size: 0.82rem; text-decoration: none; }


/* ─────────────────────────────────────────────────────────────────────────────
   Mobile app referral (feature portal-v2, js/modules/app-promo.js + nav.js footer)
   Store badges are official artwork: never recolour; Apple min height 40px on screen. The Google PNG carries its own
   clear space, so it is drawn taller with negative margins to line up with the Apple badge.
   ───────────────────────────────────────────────────────────────────────────── */
.ht-store-badge { display: inline-flex; align-items: center; line-height: 0; border-radius: 8px; }
.ht-store-badge:focus-visible { outline: 2px solid var(--ht-accent); outline-offset: 2px; }
.ht-store-badge-ios img { height: 40px; width: auto; display: block; }
.ht-store-badge-android img { height: 58px; width: auto; display: block; margin: -9px -6px; }

.ht-footer-apps { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.ht-footer-apps-title { color: var(--ht-muted); font-size: 0.85rem; }
@media (max-width: 991px) {
    .ht-footer-apps { justify-content: center; }
    .ht-footer-apps-title { flex-basis: 100%; text-align: center; }
}

/* phone banner: first in <body>, scrolls away with the page */
.ht-app-banner {
    display: flex; align-items: center; gap: 10px;
    padding: 8px 12px; background: var(--ht-surface); color: var(--ht-text);
    border-bottom: 1px solid var(--ht-border-light); font-size: 0.85rem; line-height: 1.25;
}
.ht-app-banner-icon { width: 40px; height: 40px; border-radius: 9px; flex: 0 0 auto; }
.ht-app-banner-text { display: flex; flex-direction: column; min-width: 0; flex: 1 1 auto; }
.ht-app-banner-text strong { color: var(--ht-text-heading); font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ht-app-banner-text span { color: var(--ht-muted); font-size: 0.78rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ht-app-banner-get {
    flex: 0 0 auto; padding: 7px 12px; border-radius: 999px; background: var(--ht-accent); color: #fff;
    font-weight: 700; font-size: 0.8rem; text-decoration: none; white-space: nowrap;
}
.ht-app-banner-get:hover, .ht-app-banner-get:focus-visible { background: var(--ht-accent-hover); color: #fff; }

.ht-app-close {
    flex: 0 0 auto; width: 32px; height: 32px; border: 0; border-radius: 50%; background: transparent;
    color: var(--ht-muted); cursor: pointer; display: inline-flex; align-items: center; justify-content: center;
}
.ht-app-close:hover, .ht-app-close:focus-visible { background: var(--ht-card-hover); color: var(--ht-text); }

/* "Get the app" card (cockpit, admin dashboard; computers only) */
.ht-app-card { position: relative; margin: 0 0 1.25rem; padding: 20px 56px 20px 24px; }
html[dir="rtl"] .ht-app-card { padding: 20px 24px 20px 56px; }
.ht-app-card > .ht-app-close { position: absolute; top: 10px; inset-inline-end: 10px; }
.ht-app-card-body { display: flex; align-items: center; gap: 1.25rem; flex-wrap: wrap; }
.ht-app-card-icon { width: 64px; height: 64px; border-radius: 14px; flex: 0 0 auto; }
.ht-app-card-info { flex: 1 1 260px; min-width: 0; }
.ht-app-card-title { margin: 0 0 0.35rem; font-size: 1.05rem; color: var(--ht-text-heading); }
.ht-app-card-text { margin: 0 0 0.75rem; color: var(--ht-muted); font-size: 0.9rem; }
.ht-app-card-badges { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.ht-app-card-qr { margin: 0; text-align: center; flex: 0 0 auto; }
.ht-app-card-qr img { width: 112px; height: 112px; display: block; margin: 0 auto 6px; border-radius: 8px; background: #fff; }
.ht-app-card-qr figcaption { color: var(--ht-muted); font-size: 0.75rem; max-width: 140px; }

@media print {
    .ht-app-banner, .ht-app-card, .ht-footer-apps { display: none !important; }
}
