:root {
    --hd-primary: #0f766e;
    --hd-primary-dark: #115e59;
    --hd-sidebar: #0b2027;
    --hd-sidebar-text: #cbd5e1;
    --hd-sidebar-muted: #64748b;
    --hd-bg: #f4f6fb;
    --hd-border: #e5e7eb;
    --bs-primary: #0f766e;
    --bs-primary-rgb: 15, 118, 110;
    --bs-link-color: #0f766e;
    --bs-link-color-rgb: 15, 118, 110;
    --bs-link-hover-color: #115e59;
}

body { background: var(--hd-bg); font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; font-size: .92rem; color: #1f2937; }
.btn-primary { --bs-btn-bg: var(--hd-primary); --bs-btn-border-color: var(--hd-primary); --bs-btn-hover-bg: var(--hd-primary-dark); --bs-btn-hover-border-color: var(--hd-primary-dark); --bs-btn-active-bg: var(--hd-primary-dark); }
.btn-outline-primary { --bs-btn-color: var(--hd-primary); --bs-btn-border-color: var(--hd-primary); --bs-btn-hover-bg: var(--hd-primary); --bs-btn-hover-border-color: var(--hd-primary); }
.text-bg-primary { background-color: var(--hd-primary) !important; }
.form-control:focus, .form-select:focus { border-color: #5eead4; box-shadow: 0 0 0 .2rem rgba(15, 118, 110, .15); }

/* ---------- App shell ---------- */
.hd-sidebar { position: fixed; inset: 0 auto 0 0; width: 248px; background: var(--hd-sidebar); color: var(--hd-sidebar-text); display: flex; flex-direction: column; z-index: 1040; transition: transform .2s; }
.hd-brand { display: flex; align-items: center; gap: .6rem; padding: 1.1rem 1.25rem; color: #fff; font-weight: 700; font-size: 1.05rem; text-decoration: none; border-bottom: 1px solid rgba(255,255,255,.06); }
.hd-brand .logo { width: 34px; height: 34px; border-radius: 9px; background: linear-gradient(135deg, #14b8a6, #0ea5e9); display: grid; place-items: center; font-size: 1.1rem; }
.hd-nav { padding: .75rem .65rem; overflow-y: auto; flex: 1; }
.hd-nav .section { font-size: .68rem; letter-spacing: .08em; text-transform: uppercase; color: var(--hd-sidebar-muted); padding: .9rem .75rem .35rem; }
.hd-nav a { display: flex; align-items: center; gap: .7rem; color: var(--hd-sidebar-text); text-decoration: none; padding: .52rem .75rem; border-radius: 8px; margin-bottom: 2px; }
.hd-nav a i { font-size: 1.05rem; width: 1.2rem; text-align: center; opacity: .85; }
.hd-nav a:hover { background: rgba(255,255,255,.06); color: #fff; }
.hd-nav a.active { background: rgba(45,212,191,.16); color: #fff; }
.hd-nav a .count { margin-left: auto; font-size: .7rem; background: rgba(255,255,255,.12); padding: .1rem .45rem; border-radius: 99px; }
.hd-sidebar-foot { padding: .9rem 1.25rem; border-top: 1px solid rgba(255,255,255,.06); font-size: .78rem; color: var(--hd-sidebar-muted); }

.hd-main { margin-left: 248px; min-height: 100vh; display: flex; flex-direction: column; }
.hd-topbar { position: sticky; top: 0; z-index: 1030; background: #fff; border-bottom: 1px solid var(--hd-border); height: 60px; display: flex; align-items: center; gap: 1rem; padding: 0 1.5rem; }
.hd-topbar .search { max-width: 380px; flex: 1; }
.hd-topbar .search .form-control { background: #f3f4f6; border-color: transparent; padding-left: 2.2rem; }
.hd-topbar .search i { position: absolute; left: .8rem; top: 50%; transform: translateY(-50%); color: #9ca3af; }
.hd-content { padding: 1.5rem; flex: 1; }
.hd-footer { padding: 1rem 1.5rem; color: #9ca3af; font-size: .78rem; }

@media (max-width: 991.98px) {
    .hd-sidebar { transform: translateX(-100%); }
    body.sidebar-open .hd-sidebar { transform: none; }
    .hd-main { margin-left: 0; }
    .hd-content { padding: 1rem; }
    .hd-topbar { padding: 0 1rem; }
}

/* Portal top nav */
.hd-portal-nav { background: #fff; border-bottom: 1px solid var(--hd-border); }
.hd-portal-nav .navbar-brand { font-weight: 700; display: flex; align-items: center; gap: .55rem; }
.hd-portal-nav .logo { width: 30px; height: 30px; border-radius: 8px; background: linear-gradient(135deg, #14b8a6, #0ea5e9); color: #fff; display: grid; place-items: center; font-size: .95rem; }
.hd-portal-hero { background: linear-gradient(135deg, #0f766e, #0369a1); color: #fff; border-radius: 16px; padding: 2rem; }

/* ---------- Components ---------- */
.card { border: 1px solid var(--hd-border); border-radius: 12px; box-shadow: 0 1px 2px rgba(16,24,40,.04); }
.card-header { background: #fff; border-bottom: 1px solid var(--hd-border); font-weight: 600; padding: .85rem 1.1rem; border-radius: 12px 12px 0 0 !important; }
.page-title { font-size: 1.35rem; font-weight: 700; margin: 0; }
.page-sub { color: #6b7280; font-size: .85rem; }

.stat-card { padding: 1.1rem 1.2rem; display: flex; gap: 1rem; align-items: center; height: 100%; }
.stat-card .icon { width: 44px; height: 44px; border-radius: 11px; display: grid; place-items: center; font-size: 1.25rem; flex-shrink: 0; }
.stat-card .value { font-size: 1.5rem; font-weight: 700; line-height: 1.1; }
.stat-card .label { color: #6b7280; font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; }
.stat-card a.stretched-link:hover ~ * { opacity: .9; }
.bg-soft-primary { background: #f0fdfa; color: #0f766e; }
.bg-soft-danger { background: #fef2f2; color: #dc2626; }
.bg-soft-warning { background: #fffbeb; color: #d97706; }
.bg-soft-success { background: #ecfdf5; color: #059669; }
.bg-soft-info { background: #ecfeff; color: #0891b2; }
.bg-soft-secondary { background: #f3f4f6; color: #4b5563; }

.table-tickets { margin: 0; }
.table-tickets th { font-size: .72rem; text-transform: uppercase; letter-spacing: .04em; color: #6b7280; font-weight: 600; background: #f9fafb; white-space: nowrap; }
.table-tickets td { vertical-align: middle; }
.table-tickets .subject { font-weight: 600; color: #111827; text-decoration: none; }
.table-tickets .subject:hover { color: var(--hd-primary); }
.ticket-no { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .78rem; color: #6b7280; }

.queue-tabs .nav-link { color: #4b5563; border-radius: 8px; padding: .4rem .8rem; font-size: .85rem; }
.queue-tabs .nav-link.active { background: var(--hd-primary); color: #fff; }
.queue-tabs .nav-link .badge { font-weight: 500; }

.avatar { width: 34px; height: 34px; border-radius: 50%; display: inline-grid; place-items: center; font-weight: 600; font-size: .78rem; background: #ccfbf1; color: #115e59; flex-shrink: 0; }
.avatar.staff { background: #dcfce7; color: #15803d; }
.avatar.sm { width: 26px; height: 26px; font-size: .68rem; }

/* Conversation */
.thread-item { display: flex; gap: .85rem; margin-bottom: 1.1rem; }
.thread-bubble { flex: 1; background: #fff; border: 1px solid var(--hd-border); border-radius: 12px; padding: .85rem 1rem; min-width: 0; }
.thread-bubble.staff { border-left: 3px solid #22c55e; }
.thread-bubble.requester { border-left: 3px solid #3b82f6; }
.thread-bubble.internal { background: #fffbeb; border-color: #fde68a; border-left: 3px solid #f59e0b; }
.thread-meta { font-size: .78rem; color: #6b7280; margin-bottom: .4rem; display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.thread-meta strong { color: #111827; font-size: .85rem; }
.thread-body { white-space: normal; word-wrap: break-word; line-height: 1.55; }
.attach-chip { display: inline-flex; align-items: center; gap: .35rem; border: 1px solid var(--hd-border); border-radius: 8px; padding: .25rem .6rem; font-size: .78rem; margin: .4rem .35rem 0 0; text-decoration: none; color: #374151; background: #fafafa; }
.attach-chip:hover { border-color: #5eead4; color: var(--hd-primary); }

.detail-list dt { font-size: .72rem; text-transform: uppercase; letter-spacing: .04em; color: #6b7280; font-weight: 600; }
.detail-list dd { margin-bottom: .75rem; }

.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li { position: relative; padding: 0 0 .9rem 1.4rem; font-size: .8rem; color: #4b5563; }
.timeline li::before { content: ""; position: absolute; left: 5px; top: 6px; width: 8px; height: 8px; border-radius: 50%; background: #99f6e4; }
.timeline li::after { content: ""; position: absolute; left: 8.5px; top: 16px; bottom: 0; width: 1px; background: #e5e7eb; }
.timeline li:last-child::after { display: none; }
.timeline .when { color: #9ca3af; font-size: .72rem; }

.sla-box { border-radius: 10px; padding: .75rem .9rem; background: #f9fafb; border: 1px solid var(--hd-border); }
.sla-box .due { font-weight: 700; }
.level-pill { display: inline-flex; gap: 3px; }
.level-pill span { width: 18px; height: 6px; border-radius: 3px; background: #e5e7eb; }
.level-pill span.on { background: #f97316; }

/* Notifications dropdown */
.bell-menu { width: 360px; max-height: 460px; overflow-y: auto; padding: 0; }
.bell-menu .item { display: block; padding: .7rem 1rem; border-bottom: 1px solid #f3f4f6; text-decoration: none; color: #374151; font-size: .82rem; }
.bell-menu .item.unread { background: #f0fdfa; }
.bell-menu .item:hover { background: #f9fafb; }
.bell-menu .item .t { font-weight: 600; color: #111827; }
.bell-badge { position: absolute; top: 2px; right: 0; font-size: .6rem; }

/* Auth */
.auth-wrap { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.auth-side { background: linear-gradient(140deg, #134e4a, #0f766e 55%, #0369a1); color: #fff; padding: 3rem; display: flex; flex-direction: column; justify-content: space-between; }
.auth-side h1 { font-weight: 800; font-size: 2.1rem; line-height: 1.2; }
.auth-side .feature { display: flex; gap: .8rem; margin-bottom: 1rem; opacity: .95; }
.auth-side .feature i { font-size: 1.3rem; }
.auth-form { display: flex; align-items: center; justify-content: center; padding: 2rem; background: #fff; }
.auth-form .inner { width: 100%; max-width: 400px; }
@media (max-width: 991.98px) { .auth-wrap { grid-template-columns: 1fr; } .auth-side { display: none; } }

.rating-stars { direction: rtl; display: inline-flex; gap: .2rem; }
.rating-stars input { display: none; }
.rating-stars label { font-size: 1.6rem; color: #d1d5db; cursor: pointer; }
.rating-stars input:checked ~ label, .rating-stars label:hover, .rating-stars label:hover ~ label { color: #f59e0b; }

.empty-state { text-align: center; padding: 3rem 1rem; color: #6b7280; }
.empty-state i { font-size: 2.5rem; color: #99f6e4; }
.cat-tree .child { padding-left: 2rem; }
.form-label { font-weight: 500; font-size: .85rem; }
.required::after { content: " *"; color: #dc2626; }
