:root {
    --hd-bg: #f4f7fb;
    --hd-surface: #ffffff;
    --hd-surface-soft: #f8fafc;
    --hd-ink: #172033;
    --hd-muted: #64748b;
    --hd-line: #dbe4ee;
    --hd-brand: #0f8f90;
    --hd-brand-dark: #0b686b;
    --hd-brand-soft: #e8f8f8;
    --hd-warn: #c47a12;
    --hd-danger: #c2410c;
    --hd-success: #15803d;
    --hd-purple: #6d4bc2;
    --hd-shadow: 0 12px 30px rgba(15, 23, 42, 0.08);
}

* {
    box-sizing: border-box;
}

html {
    min-height: 100%;
}

body {
    margin: 0;
    min-height: 100vh;
    background: var(--hd-bg);
    color: var(--hd-ink);
    font-family: "Open Sans", Arial, sans-serif;
    line-height: 1.5;
}

a {
    color: inherit;
}

button,
input,
select,
textarea {
    font: inherit;
}

.hd-app-shell {
    display: flex;
    min-height: 100vh;
}

.hd-sidebar {
    width: 268px;
    background: #103f40;
    color: #ffffff;
    display: flex;
    flex-direction: column;
    padding: 22px 18px;
    position: sticky;
    top: 0;
    height: 100vh;
}

.hd-brand-lockup {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
    text-decoration: none;
}

.hd-brand-lockup img {
    height: 44px;
    width: auto;
    max-width: 120px;
    object-fit: contain;
    flex: 0 0 auto;
}

.hd-brand-lockup strong {
    display: block;
    font-family: "Montserrat", Arial, sans-serif;
    font-size: 1rem;
    line-height: 1.2;
}

.hd-brand-lockup > div > span {
    display: block;
    color: rgba(255, 255, 255, 0.72);
    font-size: 0.78rem;
    line-height: 1.3;
    margin-top: 2px;
}

.hd-nav {
    display: grid;
    gap: 6px;
    margin-top: 34px;
}

.hd-nav a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 8px;
    color: rgba(255, 255, 255, 0.82);
    font-weight: 700;
    font-size: 0.88rem;
    text-decoration: none;
}

.hd-nav a:hover,
.hd-nav a.active {
    background: rgba(255, 255, 255, 0.12);
    color: #ffffff;
}

.hd-sidebar-foot {
    margin-top: auto;
    padding-top: 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.16);
}

.hd-user-mini {
    display: flex;
    align-items: center;
    gap: 10px;
}

.hd-avatar,
.hd-initials {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
    flex: 0 0 auto;
}

.hd-initials {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--hd-brand);
    color: #ffffff;
    font-weight: 800;
}

.hd-user-mini strong {
    display: block;
    font-size: 0.86rem;
    line-height: 1.2;
}

.hd-user-mini > div > span {
    display: block;
    color: rgba(255, 255, 255, 0.66);
    font-size: 0.76rem;
    line-height: 1.2;
    margin-top: 2px;
}

.hd-signout {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-top: 16px;
    color: rgba(255, 255, 255, 0.72);
    font-size: 0.82rem;
    font-weight: 700;
    text-decoration: none;
}

.hd-signout:hover {
    color: #ffffff;
}

.hd-main {
    flex: 1;
    min-width: 0;
}

.hd-topbar {
    min-height: 70px;
    background: rgba(255, 255, 255, 0.92);
    border-bottom: 1px solid var(--hd-line);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 14px 28px;
    position: sticky;
    top: 0;
    z-index: 10;
    backdrop-filter: blur(12px);
}

.hd-topbar-title {
    min-width: 0;
}

.hd-topbar-title span {
    display: block;
    color: var(--hd-muted);
    font-size: 0.78rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.hd-topbar-title strong {
    display: block;
    color: var(--hd-ink);
    font-family: "Montserrat", Arial, sans-serif;
    font-size: 1.05rem;
    line-height: 1.25;
    margin-top: 2px;
}

.hd-topbar-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.hd-content {
    width: min(1180px, calc(100% - 36px));
    margin: 0 auto;
    padding: 30px 0 44px;
}

.hd-content-wide {
    width: min(1320px, calc(100% - 36px));
}

.hd-page-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 18px;
    margin-bottom: 22px;
}

.hd-eyebrow {
    color: var(--hd-brand-dark);
    font-size: 0.78rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.hd-page-header h1,
.hd-section-head h2,
.hd-panel-title {
    font-family: "Montserrat", Arial, sans-serif;
}

.hd-page-header h1 {
    margin: 4px 0 6px;
    font-size: clamp(1.55rem, 3vw, 2.25rem);
    line-height: 1.14;
}

.hd-page-header p {
    max-width: 680px;
    margin: 0;
    color: var(--hd-muted);
    font-size: 0.98rem;
}

.hd-section-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin: 24px 0 12px;
}

.hd-section-head h2 {
    margin: 0;
    font-size: 1.12rem;
}

.hd-section-head span {
    color: var(--hd-muted);
    font-size: 0.88rem;
}

.hd-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 38px;
    padding: 9px 15px;
    border: 1px solid transparent;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 800;
    font-size: 0.88rem;
    line-height: 1;
    text-decoration: none;
    white-space: nowrap;
}

.hd-btn-primary {
    background: var(--hd-brand);
    color: #ffffff;
}

.hd-btn-primary:hover {
    background: var(--hd-brand-dark);
}

.hd-btn-secondary {
    background: #ffffff;
    border-color: var(--hd-line);
    color: var(--hd-ink);
}

.hd-btn-secondary:hover {
    border-color: var(--hd-brand);
    color: var(--hd-brand-dark);
}

.hd-btn-resolve {
    background: #16a34a;
    color: #ffffff;
    width: 100%;
    justify-content: center;
    margin-top: 8px;
}

.hd-btn-resolve:hover { background: #15803d; }

.hd-btn-reopen {
    background: #f59e0b;
    color: #ffffff;
    width: 100%;
    justify-content: center;
    margin-top: 8px;
}

.hd-btn-reopen:hover { background: #d97706; }

.hd-btn-ghost {
    background: transparent;
    color: var(--hd-muted);
}

.hd-btn-ghost:hover {
    background: var(--hd-surface-soft);
    color: var(--hd-ink);
}

.hd-title-icon {
    color: var(--hd-brand);
}

.hd-text-link {
    color: var(--hd-brand-dark);
    font-weight: 800;
}

.hd-card,
.hd-panel,
.hd-stat,
.hd-empty,
.hd-ticket-row,
.hd-auth-panel {
    background: var(--hd-surface);
    border: 1px solid var(--hd-line);
    border-radius: 8px;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

.hd-panel {
    overflow: hidden;
}

.hd-panel-pad {
    padding: 24px;
}

.hd-panel-title {
    margin: 0 0 10px;
    font-size: 1rem;
}

.hd-panel-copy {
    margin: 0 0 16px;
    color: var(--hd-muted);
    font-size: 0.92rem;
}

.hd-stat-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
    margin-bottom: 18px;
}

.hd-stat-grid-compact {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.hd-stat {
    padding: 17px 18px;
}

.hd-stat span {
    display: block;
    color: var(--hd-muted);
    font-size: 0.78rem;
    font-weight: 800;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.hd-stat strong {
    display: block;
    margin-top: 6px;
    color: var(--hd-ink);
    font-family: "Montserrat", Arial, sans-serif;
    font-size: 1.85rem;
    line-height: 1;
}

.hd-stat.is-danger strong {
    color: var(--hd-danger);
}

.hd-stat.is-success strong {
    color: var(--hd-success);
}

.hd-filterbar {
    padding: 16px;
    margin-bottom: 18px;
}

.hd-filterbar form {
    display: grid;
    grid-template-columns: repeat(4, minmax(130px, 1fr)) minmax(180px, 1.4fr) auto auto;
    gap: 10px;
    align-items: end;
}

.hd-field label,
.hd-form-group label,
.hd-admin-tools label {
    display: block;
    margin-bottom: 6px;
    color: var(--hd-ink);
    font-size: 0.78rem;
    font-weight: 800;
}

.hd-field input,
.hd-field select,
.hd-form-group input,
.hd-form-group select,
.hd-form-group textarea,
.hd-admin-tools select {
    width: 100%;
    min-height: 42px;
    border: 1px solid #cfd9e5;
    border-radius: 6px;
    background: #ffffff;
    color: var(--hd-ink);
    padding: 9px 11px;
    font-size: 0.92rem;
}

.hd-field input:focus,
.hd-field select:focus,
.hd-form-group input:focus,
.hd-form-group select:focus,
.hd-form-group textarea:focus,
.hd-admin-tools select:focus {
    border-color: var(--hd-brand);
    box-shadow: 0 0 0 3px rgba(15, 143, 144, 0.14);
    outline: none;
}

.hd-ticket-list {
    display: grid;
    gap: 9px;
}

.hd-ticket-row {
    display: grid;
    grid-template-columns: 76px minmax(0, 1fr) auto;
    gap: 14px;
    align-items: center;
    min-height: 78px;
    padding: 14px 16px;
    border-left: 5px solid var(--hd-brand);
    color: inherit;
    text-decoration: none;
}

.hd-ticket-row:hover {
    border-color: var(--hd-brand-dark);
    box-shadow: var(--hd-shadow);
}

.hd-ticket-row.priority-urgent {
    border-left-color: var(--hd-danger);
}

.hd-ticket-row.priority-high {
    border-left-color: var(--hd-warn);
}

.hd-ticket-number {
    color: var(--hd-muted);
    font-weight: 800;
    font-size: 0.9rem;
}

.hd-ticket-title {
    display: block;
    overflow-wrap: anywhere;
    color: var(--hd-ink);
    font-weight: 800;
}

.hd-ticket-subline {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
    margin-top: 4px;
    color: var(--hd-muted);
    font-size: 0.82rem;
}

.hd-ticket-meta {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    flex-wrap: wrap;
}

.hd-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 24px;
    border-radius: 999px;
    padding: 3px 9px;
    color: #ffffff;
    font-size: 0.74rem;
    font-weight: 800;
    line-height: 1;
    white-space: nowrap;
}

.hd-status-open {
    background: #2563eb;
}

.hd-status-in-progress {
    background: #d97706;
}

.hd-status-waiting {
    background: var(--hd-purple);
}

.hd-status-resolved {
    background: var(--hd-success);
}

.hd-status-closed {
    background: #64748b;
}

.hd-priority-low {
    background: #64748b;
}

.hd-priority-normal {
    background: var(--hd-brand);
}

.hd-priority-high {
    background: var(--hd-warn);
}

.hd-priority-urgent {
    background: var(--hd-danger);
}

.hd-empty {
    padding: 42px 24px;
    text-align: center;
    color: var(--hd-muted);
}

.hd-empty i {
    color: var(--hd-brand);
    font-size: 2rem;
    opacity: 0.7;
}

.hd-empty h3,
.hd-empty h4 {
    margin: 12px 0 5px;
    color: var(--hd-ink);
    font-family: "Montserrat", Arial, sans-serif;
}

.hd-empty p {
    margin: 0 0 16px;
}

.hd-tabs {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 18px;
}

.hd-tabs a {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 36px;
    border: 1px solid var(--hd-line);
    border-radius: 999px;
    background: #ffffff;
    color: var(--hd-muted);
    padding: 7px 14px;
    font-size: 0.84rem;
    font-weight: 800;
    text-decoration: none;
}

.hd-tabs a:hover,
.hd-tabs a.active {
    border-color: var(--hd-brand);
    background: var(--hd-brand-soft);
    color: var(--hd-brand-dark);
}

.hd-portal-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.2fr) minmax(280px, 0.8fr);
    gap: 18px;
    align-items: start;
}

.hd-intake-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 320px;
    gap: 18px;
    align-items: start;
}

.hd-form-panel {
    padding: 26px;
}

.hd-form-panel h2 {
    margin: 0 0 20px;
    font-family: "Montserrat", Arial, sans-serif;
    font-size: 1.22rem;
}

.hd-form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}

.hd-form-group {
    margin-bottom: 18px;
}

.hd-form-group textarea {
    min-height: 178px;
    resize: vertical;
}

.hd-form-group.full {
    grid-column: 1 / -1;
}

.hd-help-text {
    margin: 6px 0 0;
    color: var(--hd-muted);
    font-size: 0.8rem;
}

.hd-form-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 6px;
}

.hd-side-panel {
    padding: 22px;
}

.hd-side-panel h3 {
    margin: 0 0 12px;
    font-family: "Montserrat", Arial, sans-serif;
    font-size: 1rem;
}

.hd-support-list {
    display: grid;
    gap: 12px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.hd-support-list li {
    display: grid;
    grid-template-columns: 28px minmax(0, 1fr);
    gap: 10px;
    align-items: start;
    color: var(--hd-muted);
    font-size: 0.9rem;
}

.hd-support-list i {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--hd-brand-soft);
    color: var(--hd-brand-dark);
}

.hd-support-list strong {
    display: block;
    color: var(--hd-ink);
    font-size: 0.9rem;
}

.hd-errors,
.hd-success-banner,
.hd-closed-notice {
    border-radius: 8px;
    padding: 14px 16px;
    margin-bottom: 18px;
    font-size: 0.92rem;
}

.hd-errors {
    background: #fff1f2;
    border: 1px solid #fecdd3;
    color: #9f1239;
}

.hd-errors ul {
    margin: 8px 0 0 20px;
    padding: 0;
}

.hd-success-banner {
    display: flex;
    align-items: center;
    gap: 10px;
    background: #ecfdf3;
    border: 1px solid #bbf7d0;
    color: #166534;
}

.hd-back-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--hd-brand-dark);
    font-size: 0.88rem;
    font-weight: 800;
    text-decoration: none;
    margin-bottom: 18px;
}

.hd-back-link:hover {
    color: var(--hd-ink);
}

.hd-ticket-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(340px, 380px);
    gap: 18px;
    align-items: start;
}

.hd-ticket-detail {
    overflow: hidden;
}

.hd-ticket-header {
    padding: 24px 26px;
    border-bottom: 1px solid var(--hd-line);
}

.hd-ticket-header h1 {
    margin: 10px 0 12px;
    font-family: "Montserrat", Arial, sans-serif;
    font-size: 1.45rem;
    overflow-wrap: anywhere;
}

.hd-ticket-description {
    padding: 22px 26px;
    border-bottom: 1px solid var(--hd-line);
    color: #334155;
    font-size: 0.96rem;
    line-height: 1.75;
    white-space: pre-wrap;
}

.hd-admin-tools {
    padding: 18px;
}

.hd-admin-tools h2 {
    margin: 0 0 14px;
    font-family: "Montserrat", Arial, sans-serif;
    font-size: 1rem;
}

.hd-admin-tools form {
    display: grid;
    gap: 12px;
}

.hd-comments {
    display: grid;
}

.hd-comment {
    display: grid;
    grid-template-columns: 42px minmax(0, 1fr);
    gap: 13px;
    padding: 18px 26px;
    border-bottom: 1px solid #edf2f7;
}

.hd-comment.internal {
    background: #fff8e7;
}

.hd-comment-head {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 7px;
    margin-bottom: 6px;
}

.hd-comment-author {
    color: var(--hd-ink);
    font-weight: 800;
    font-size: 0.92rem;
}

.hd-comment-time {
    color: var(--hd-muted);
    font-size: 0.78rem;
}

.hd-comment-text {
    color: #334155;
    font-size: 0.92rem;
    line-height: 1.7;
    white-space: pre-wrap;
}

.hd-role-badge,
.hd-internal-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    border-radius: 999px;
    color: #ffffff;
    padding: 3px 8px;
    font-size: 0.68rem;
    font-weight: 800;
}

.hd-role-badge {
    background: var(--hd-brand);
}

.hd-internal-badge {
    background: var(--hd-warn);
}

.hd-reply-section {
    padding: 22px 26px 26px;
}

.hd-reply-section h2 {
    margin: 0 0 13px;
    font-family: "Montserrat", Arial, sans-serif;
    font-size: 1rem;
}

.hd-reply-section textarea {
    width: 100%;
    min-height: 118px;
    border: 1px solid #cfd9e5;
    border-radius: 6px;
    padding: 12px;
    resize: vertical;
}

.hd-reply-section textarea:focus {
    border-color: var(--hd-brand);
    box-shadow: 0 0 0 3px rgba(15, 143, 144, 0.14);
    outline: none;
}

.hd-reply-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    margin-top: 12px;
}

.hd-check-label {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    color: var(--hd-muted);
    font-size: 0.86rem;
    cursor: pointer;
}

.hd-closed-notice {
    background: var(--hd-surface-soft);
    border: 1px solid var(--hd-line);
    color: var(--hd-muted);
}

.hd-auth-page {
    min-height: 100vh;
    background:
        linear-gradient(135deg, rgba(16, 63, 64, 0.92), rgba(8, 34, 44, 0.9)),
        url("../../images/Calvary-enhanced_color.jpg") center / cover no-repeat;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 28px;
}

.hd-auth-shell {
    width: min(960px, 100%);
    display: grid;
    grid-template-columns: minmax(0, 1fr) 390px;
    background: rgba(255, 255, 255, 0.94);
    border: 1px solid rgba(255, 255, 255, 0.35);
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 24px 70px rgba(0, 0, 0, 0.34);
}

.hd-auth-intro {
    padding: 46px;
    background: rgba(248, 250, 252, 0.78);
}

.hd-auth-intro img {
    width: 120px;
    height: auto;
    object-fit: contain;
    margin-bottom: 24px;
}

/* AI assistant panel */
.hd-admin-aside {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.hd-ai-panel {
    padding: 18px;
    border-color: #b7dfe1;
    background: linear-gradient(180deg, #ffffff 0%, #f6fbfb 100%);
}

.hd-ai-head {
    display: grid;
    grid-template-columns: 42px minmax(0, 1fr);
    gap: 12px;
    align-items: center;
    margin-bottom: 16px;
}

.hd-ai-mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    border-radius: 8px;
    background: var(--hd-brand);
    color: #ffffff;
    box-shadow: 0 10px 24px rgba(15, 143, 144, 0.2);
}

.hd-ai-kicker {
    display: block;
    color: var(--hd-brand-dark);
    font-size: 0.7rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    line-height: 1;
    text-transform: uppercase;
}

.hd-ai-panel h2 {
    margin: 4px 0 0;
    color: var(--hd-ink);
    font-family: "Montserrat", Arial, sans-serif;
    font-size: 1.05rem;
    line-height: 1.2;
}

.hd-ai-actions {
    display: grid;
    gap: 10px;
    margin-bottom: 16px;
}

.hd-ai-btn {
    display: grid;
    grid-template-columns: 38px minmax(0, 1fr);
    gap: 10px;
    align-items: center;
    width: 100%;
    min-height: 68px;
    padding: 10px 12px;
    background: #ffffff;
    border: 1px solid #cfe2e8;
    border-radius: 8px;
    color: var(--hd-ink);
    cursor: pointer;
    font-family: inherit;
    text-align: left;
    transition: border-color 0.15s, box-shadow 0.15s, transform 0.15s;
}

.hd-ai-btn:hover,
.hd-ai-btn:focus-visible {
    border-color: var(--hd-brand);
    box-shadow: 0 8px 20px rgba(15, 23, 42, 0.08);
    outline: none;
    transform: translateY(-1px);
}

.hd-ai-btn:disabled {
    cursor: wait;
    opacity: 0.72;
    transform: none;
}

.hd-ai-btn-primary-action {
    border-color: #9ad6d8;
    background: var(--hd-brand-soft);
}

.hd-ai-btn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border-radius: 8px;
    background: #e9f2f5;
    color: var(--hd-brand-dark);
}

.hd-ai-btn-primary-action .hd-ai-btn-icon {
    background: var(--hd-brand);
    color: #ffffff;
}

.hd-ai-btn strong {
    display: block;
    font-size: 0.9rem;
    line-height: 1.15;
}

.hd-ai-btn small {
    display: block;
    margin-top: 3px;
    color: var(--hd-muted);
    font-size: 0.76rem;
    line-height: 1.25;
}

.hd-ai-output {
    background: #ffffff;
    border: 1px solid #b7dfe1;
    border-radius: 8px;
    overflow: hidden;
    margin-bottom: 16px;
}

.hd-ai-output-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    padding: 13px 14px;
    border-bottom: 1px solid #dbecef;
    background: #f8fcfc;
}

.hd-ai-output-head span {
    display: block;
    color: var(--hd-muted);
    font-size: 0.68rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    line-height: 1;
    text-transform: uppercase;
}

.hd-ai-output-head strong {
    display: block;
    margin-top: 4px;
    color: var(--hd-ink);
    font-size: 0.9rem;
    line-height: 1.2;
}

.hd-ai-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    background: #ffffff;
    border: 1px solid var(--hd-line);
    border-radius: 6px;
    color: var(--hd-muted);
    cursor: pointer;
}

.hd-ai-close:hover {
    color: var(--hd-ink);
}

.hd-ai-output-text {
    font-size: 0.88rem;
    line-height: 1.65;
    color: #334155;
    white-space: pre-wrap;
    max-height: 260px;
    overflow-y: auto;
    padding: 14px;
}

.hd-ai-output-actions {
    display: flex;
    justify-content: flex-end;
    padding: 0 14px 14px;
}

.hd-ai-error {
    color: var(--hd-danger);
    font-weight: 700;
}

.hd-ai-loading {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--hd-muted);
    font-weight: 700;
}

.hd-ai-chat {
    border-top: 1px solid #dbecef;
    padding-top: 14px;
}

.hd-ai-chat-label {
    display: block;
    color: var(--hd-ink);
    font-size: 0.78rem;
    font-weight: 800;
    margin-bottom: 8px;
}

.hd-ai-chat-log {
    min-height: 72px;
    max-height: 220px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 10px;
    padding: 10px;
    border: 1px solid #dbecef;
    border-radius: 8px;
    background: #ffffff;
}

.hd-chat-bubble {
    padding: 9px 11px;
    border-radius: 8px;
    font-size: 0.85rem;
    line-height: 1.5;
    max-width: 92%;
    white-space: pre-wrap;
    word-break: break-word;
}

.hd-chat-user {
    background: var(--hd-brand);
    color: #ffffff;
    align-self: flex-end;
    border-bottom-right-radius: 3px;
}

.hd-chat-ai {
    background: #eef5f7;
    color: #334155;
    align-self: flex-start;
    border-bottom-left-radius: 3px;
}

.hd-ai-chat-input {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 42px;
    gap: 6px;
}

.hd-ai-chat-input input {
    min-width: 0;
    min-height: 42px;
    padding: 9px 11px;
    border: 1px solid #cfd9e5;
    border-radius: 6px;
    font-size: 0.85rem;
}

.hd-ai-chat-input input:focus {
    outline: none;
    border-color: var(--hd-brand);
    box-shadow: 0 0 0 3px rgba(15, 143, 144, 0.14);
}

.hd-ai-chat-input button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--hd-brand);
    color: #ffffff;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.85rem;
}

.hd-ai-chat-input button:hover {
    background: var(--hd-brand-dark);
}

/* Auth intro */
.hd-auth-intro h1 {
    margin: 0 0 12px;
    font-family: "Montserrat", Arial, sans-serif;
    font-size: clamp(2rem, 4vw, 3rem);
    line-height: 1.05;
}

.hd-auth-intro p {
    max-width: 470px;
    margin: 0;
    color: var(--hd-muted);
    font-size: 1rem;
}

.hd-auth-panel {
    border: 0;
    border-left: 1px solid var(--hd-line);
    border-radius: 0;
    box-shadow: none;
    padding: 42px 34px;
}

.hd-auth-panel h2 {
    margin: 0 0 8px;
    font-family: "Montserrat", Arial, sans-serif;
    font-size: 1.35rem;
}

.hd-auth-panel p {
    margin: 0 0 22px;
    color: var(--hd-muted);
    font-size: 0.92rem;
}

.hd-google-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    width: 100%;
    min-height: 46px;
    border: 1px solid #cfd9e5;
    border-radius: 6px;
    background: #ffffff;
    color: var(--hd-ink);
    font-weight: 800;
    text-decoration: none;
}

.hd-google-btn:hover {
    border-color: var(--hd-brand);
    box-shadow: 0 0 0 3px rgba(15, 143, 144, 0.12);
}

.hd-google-btn img {
    width: 22px;
    height: 22px;
}

.hd-auth-note {
    margin-top: 18px;
    padding-top: 18px;
    border-top: 1px solid var(--hd-line);
    color: var(--hd-muted);
    font-size: 0.82rem;
}

@media (max-width: 980px) {
    .hd-app-shell {
        display: block;
    }

    .hd-sidebar {
        position: static;
        width: auto;
        height: auto;
        padding: 16px;
    }

    .hd-nav {
        display: flex;
        gap: 8px;
        overflow-x: auto;
        margin-top: 18px;
        padding-bottom: 2px;
    }

    .hd-nav a {
        flex: 0 0 auto;
    }

    .hd-sidebar-foot {
        display: none;
    }

    .hd-filterbar form {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .hd-intake-layout,
    .hd-ticket-layout,
    .hd-portal-grid,
    .hd-auth-shell {
        grid-template-columns: 1fr;
    }

    .hd-auth-panel {
        border-left: 0;
        border-top: 1px solid var(--hd-line);
    }
}

@media (max-width: 700px) {
    .hd-topbar,
    .hd-page-header,
    .hd-section-head {
        align-items: stretch;
        flex-direction: column;
    }

    .hd-topbar-actions,
    .hd-form-actions {
        justify-content: flex-start;
    }

    .hd-content,
    .hd-content-wide {
        width: min(100% - 24px, 1180px);
        padding: 22px 0 34px;
    }

    .hd-stat-grid,
    .hd-form-grid {
        grid-template-columns: 1fr;
    }

    .hd-filterbar form {
        grid-template-columns: 1fr;
    }

    .hd-ticket-row {
        grid-template-columns: 1fr;
        gap: 8px;
    }

    .hd-ticket-meta {
        justify-content: flex-start;
    }

    .hd-form-panel,
    .hd-panel-pad,
    .hd-ticket-header,
    .hd-ticket-description,
    .hd-comment,
    .hd-reply-section,
    .hd-auth-intro,
    .hd-auth-panel {
        padding: 20px;
    }

    .hd-auth-page {
        padding: 14px;
    }
}
