:root {
    --hd-primary: #0d9488;
    --hd-primary-hover: #0f766e;
    --hd-sidebar: #1e293b;
    --hd-sidebar-text: #e2e8f0;
    --hd-internal-note: #fef9c3;
    --hd-border: #e2e8f0;
    --hd-text: #0f172a;
    --hd-muted: #64748b;
    --hd-danger: #dc2626;
    --hd-success-bg: #ecfdf5;
    --hd-success-text: #047857;
    --hd-error-bg: #fef2f2;
    --hd-error-text: #b91c1c;
    --hd-radius: 10px;
    --hd-shadow: 0 4px 24px rgba(15, 23, 42, 0.08);
    --hd-font: "Plus Jakarta Sans", system-ui, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }

body.helpdesk-body {
    margin: 0;
    font-family: var(--hd-font);
    color: var(--hd-text);
    background: #f8fafc;
    line-height: 1.5;
}

a { color: var(--hd-primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Shell / sidebar (agent) */
.helpdesk-shell { display: flex; min-height: 100vh; }
.helpdesk-sidebar {
    width: 260px;
    flex-shrink: 0;
    background: var(--hd-sidebar);
    color: var(--hd-sidebar-text);
    display: flex;
    flex-direction: column;
    padding: 20px 0;
}
.helpdesk-sidebar__brand {
    font-weight: 700;
    font-size: 1.1rem;
    padding: 0 20px 16px;
    border-bottom: 1px solid rgba(255,255,255,.08);
}
.helpdesk-sidebar__nav {
    flex: 1;
    padding: 16px 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.helpdesk-sidebar__nav a {
    color: var(--hd-sidebar-text);
    padding: 10px 12px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
}
.helpdesk-sidebar__nav a:hover { background: rgba(255,255,255,.08); }
.helpdesk-sidebar__divider { border: none; border-top: 1px solid rgba(255,255,255,.1); margin: 12px 0; }
.helpdesk-sidebar__footer { padding: 16px 20px; border-top: 1px solid rgba(255,255,255,.08); font-size: .875rem; }
.helpdesk-sidebar__user { font-weight: 600; }
.helpdesk-sidebar__role { color: #94a3b8; margin-bottom: 8px; text-transform: capitalize; }
.helpdesk-main-wrap { flex: 1; min-width: 0; }
.helpdesk-main { padding: 24px; max-width: 1200px; }

/* Portal topbar */
.helpdesk-topbar--portal {
    background: var(--hd-primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 24px;
}
.helpdesk-topbar__brand a { color: #fff; font-weight: 700; text-decoration: none; }
.helpdesk-topbar__nav { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.helpdesk-topbar__nav a { color: #fff; text-decoration: none; font-size: .9rem; }
.helpdesk-body--portal .helpdesk-main { margin: 0 auto; }

/* Panel */
.helpdesk-panel {
    background: #fff;
    border: 1px solid var(--hd-border);
    border-radius: var(--hd-radius);
    padding: 20px;
    margin-bottom: 16px;
    box-shadow: var(--hd-shadow);
}
.helpdesk-panel--auth { max-width: 420px; width: 100%; }

/* Buttons */
.helpdesk-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 16px;
    border-radius: 8px;
    border: 1px solid transparent;
    font: inherit;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
}
.helpdesk-btn--primary { background: var(--hd-primary); color: #fff; }
.helpdesk-btn--primary:hover { background: var(--hd-primary-hover); color: #fff; text-decoration: none; }
.helpdesk-btn--secondary { background: #fff; border-color: var(--hd-border); color: var(--hd-text); }
.helpdesk-btn--ghost { background: transparent; border-color: var(--hd-border); color: inherit; }
.helpdesk-btn--danger { background: var(--hd-danger); color: #fff; }
.helpdesk-btn--sm { padding: 6px 10px; font-size: .8125rem; }
.helpdesk-btn--block { width: 100%; }
.helpdesk-sidebar .helpdesk-btn--ghost { color: var(--hd-sidebar-text); border-color: rgba(255,255,255,.2); }

/* Forms */
.helpdesk-form { display: flex; flex-direction: column; gap: 14px; }
.helpdesk-form--panel { max-width: 640px; }
.helpdesk-form__actions { display: flex; gap: 10px; justify-content: flex-end; }
.helpdesk-label { display: flex; flex-direction: column; gap: 6px; font-size: .875rem; font-weight: 600; }
.helpdesk-input {
    padding: 10px 12px;
    border: 1px solid var(--hd-border);
    border-radius: 8px;
    font: inherit;
    background: #fff;
}
.helpdesk-input--sm { padding: 6px 10px; font-size: .875rem; }
.helpdesk-input:focus { outline: none; border-color: var(--hd-primary); box-shadow: 0 0 0 3px rgba(13,148,136,.15); }
.helpdesk-checkbox { display: flex; align-items: center; gap: 8px; font-weight: 400; }
.helpdesk-fieldset { border: 1px solid var(--hd-border); border-radius: 8px; padding: 12px 16px; margin: 0 0 12px; }
.helpdesk-fieldset legend { font-weight: 600; padding: 0 6px; }
.helpdesk-inline-form { display: inline; margin: 0; }

/* Alerts */
.helpdesk-alert {
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 16px;
    font-size: .9rem;
}
.helpdesk-alert--success { background: var(--hd-success-bg); color: var(--hd-success-text); }
.helpdesk-alert--error { background: var(--hd-error-bg); color: var(--hd-error-text); }
.helpdesk-alert--info { background: #eff6ff; color: #1d4ed8; }

/* Table */
.helpdesk-table-wrap { overflow-x: auto; }
.helpdesk-table {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
    border: 1px solid var(--hd-border);
    border-radius: var(--hd-radius);
    overflow: hidden;
}
.helpdesk-table th, .helpdesk-table td {
    padding: 10px 14px;
    text-align: left;
    border-bottom: 1px solid var(--hd-border);
    font-size: .9rem;
}
.helpdesk-table th { background: #f1f5f9; font-weight: 600; }
.helpdesk-table tr:last-child td { border-bottom: none; }

/* Badges — SLA priority */
.helpdesk-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: .75rem;
    font-weight: 700;
    text-transform: uppercase;
}
.helpdesk-badge--p1 { background: #fee2e2; color: #991b1b; }
.helpdesk-badge--p2 { background: #ffedd5; color: #c2410c; }
.helpdesk-badge--p3 { background: #dbeafe; color: #1d4ed8; }
.helpdesk-badge--p4 { background: #f1f5f9; color: #475569; }
.helpdesk-badge--alert { background: #ef4444; color: #fff; min-width: 18px; text-align: center; }

/* Notes */
.helpdesk-notes { list-style: none; padding: 0; margin: 0; }
.helpdesk-note { padding: 12px 0; border-bottom: 1px solid var(--hd-border); }
.helpdesk-note--internal { background: var(--hd-internal-note); margin: 0 -20px; padding: 12px 20px; border-radius: 6px; }
.helpdesk-note__meta { font-size: .75rem; color: var(--hd-muted); margin-bottom: 4px; }

/* Layout helpers */
.helpdesk-page-title { margin: 0 0 8px; font-size: 1.5rem; }
.helpdesk-page-header { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.helpdesk-muted { color: var(--hd-muted); font-size: .9rem; }
.helpdesk-meta { color: var(--hd-muted); font-size: .875rem; }
.helpdesk-kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 16px; margin-bottom: 20px; }
.helpdesk-kpi__value { font-size: 2rem; font-weight: 700; line-height: 1; }
.helpdesk-kpi__label { color: var(--hd-muted); font-size: .875rem; margin-top: 4px; }
.helpdesk-kpi--danger .helpdesk-kpi__value { color: var(--hd-danger); }
.helpdesk-grid-2 { display: grid; grid-template-columns: 1fr 320px; gap: 16px; }
@media (max-width: 900px) {
    .helpdesk-grid-2 { grid-template-columns: 1fr; }
    .helpdesk-shell { flex-direction: column; }
    .helpdesk-sidebar { width: 100%; }
}

/* Auth / landing */
.helpdesk-auth { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: #f1f5f9; }
.helpdesk-auth--portal { --hd-auth-accent: var(--hd-primary); }
.helpdesk-auth--agent { --hd-auth-accent: var(--hd-sidebar); }
.helpdesk-auth__wrap { padding: 24px; width: 100%; max-width: 480px; text-align: center; }
.helpdesk-auth__brand { display: inline-block; margin-bottom: 20px; }
.helpdesk-auth__logo { max-width: 200px; height: auto; display: block; margin: 0 auto; }
.helpdesk-auth__back { margin-top: 16px; font-size: .875rem; }

.helpdesk-auth-login__switch {
    position: relative;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4px;
    padding: 4px;
    margin-bottom: 20px;
    background: #e2e8f0;
    border-radius: 10px;
}
.helpdesk-auth-login__tab {
    position: relative;
    z-index: 1;
    border: 0;
    background: transparent;
    padding: 10px 12px;
    border-radius: 8px;
    font: inherit;
    font-size: .9rem;
    font-weight: 600;
    color: var(--hd-muted);
    cursor: pointer;
    transition: color .25s ease;
}
.helpdesk-auth-login__tab.is-active { color: var(--hd-text); }
.helpdesk-auth-login__indicator {
    position: absolute;
    top: 4px;
    left: 4px;
    width: calc(50% - 4px);
    height: calc(100% - 8px);
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(15, 23, 42, .12);
    transition: transform .3s cubic-bezier(.4, 0, .2, 1);
    pointer-events: none;
}
.helpdesk-auth-login[data-auth-mode="agent"] .helpdesk-auth-login__indicator {
    transform: translateX(100%);
}
.helpdesk-auth-login__panels {
    position: relative;
    overflow: hidden;
    min-height: 280px;
}
.helpdesk-auth-login__panel {
    opacity: 0;
    visibility: hidden;
    transform: translateX(24px);
    transition: opacity .3s ease, transform .3s ease, visibility .3s;
    position: absolute;
    inset: 0;
    text-align: left;
}
.helpdesk-auth-login__panel.is-active {
    opacity: 1;
    visibility: visible;
    transform: translateX(0);
    position: relative;
}
.helpdesk-auth-login[data-auth-mode="agent"] .helpdesk-auth-login__panel[data-auth-panel="portal"]:not(.is-active) {
    transform: translateX(-24px);
}
.helpdesk-auth-login[data-auth-mode="portal"] .helpdesk-auth-login__panel[data-auth-panel="agent"]:not(.is-active) {
    transform: translateX(24px);
}

.helpdesk-landing { min-height: 100vh; display: flex; align-items: center; justify-content: center; }
.helpdesk-landing__wrap { text-align: center; padding: 32px; max-width: 520px; }
.helpdesk-landing__title { font-size: 2rem; margin: 0 0 8px; color: var(--hd-primary); }
.helpdesk-landing__subtitle { color: var(--hd-muted); margin-bottom: 24px; }
.helpdesk-landing__actions { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }

/* Tabs / subnav */
.helpdesk-tabs, .helpdesk-subnav { display: flex; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; }
.helpdesk-tabs a, .helpdesk-subnav a {
    padding: 8px 14px;
    border-radius: 8px;
    background: #fff;
    border: 1px solid var(--hd-border);
    color: var(--hd-text);
    text-decoration: none;
    font-size: .875rem;
}
.helpdesk-tabs a.is-active, .helpdesk-subnav a.is-active {
    background: var(--hd-primary);
    border-color: var(--hd-primary);
    color: #fff;
}

/* Notifications list */
.helpdesk-notifications { list-style: none; padding: 0; margin: 0; }
.helpdesk-notification {
    background: #fff;
    border: 1px solid var(--hd-border);
    border-radius: var(--hd-radius);
    padding: 14px 16px;
    margin-bottom: 10px;
}
.helpdesk-notification--unread { border-left: 4px solid var(--hd-primary); }
.helpdesk-notification__title { font-weight: 600; }
.helpdesk-notification__meta { font-size: .75rem; color: var(--hd-muted); margin-top: 4px; }

.helpdesk-mfa-qr { max-width: 200px; margin: 12px auto; display: block; }
.helpdesk-code { display: block; padding: 12px; background: #f1f5f9; border-radius: 8px; word-break: break-all; margin: 12px 0; }
