/* ================================================================
   Application Hub — Shared Theme
   Inspired by NERC.com visual identity
   All colours are defined here as CSS custom properties.
   Override any variable in an app-specific stylesheet to customise.
   ================================================================ */

:root {
    /* --- Brand colours --- */
    --hub-primary:          #003087;   /* dark navy — nav, headings */
    --hub-primary-dark:     #001f5b;   /* hover / active nav items  */
    --hub-primary-light:    #1a4fa0;   /* lighter navy for gradients */
    --hub-accent:           #0066CC;   /* links, buttons, highlights */
    --hub-accent-hover:     #0055AA;
    --hub-gold:             #F5A800;   /* top-bar stripe, badges     */
    --hub-gold-dark:        #d48f00;

    /* --- Surfaces --- */
    --hub-body-bg:          #F5F6F7;
    --hub-surface:          #FFFFFF;
    --hub-surface-alt:      #EEF2F7;   /* alternate table rows, cards */
    --hub-border:           #D1D9E6;
    --hub-border-light:     #E9EDF4;

    /* --- Text --- */
    --hub-text:             #2C2C2C;
    --hub-text-muted:       #6B7280;
    --hub-text-light:       #9CA3AF;
    --hub-text-on-primary:  #FFFFFF;

    /* --- Status --- */
    --hub-success:          #198754;
    --hub-warning:          #F5A800;
    --hub-danger:           #C0392B;
    --hub-info:             #0066CC;

    /* --- Layout --- */
    --hub-nav-height:       68px;
    --hub-topbar-height:    6px;
    --hub-sidebar-width:    240px;
    --hub-content-max:      1280px;
    --hub-radius:           4px;
    --hub-radius-lg:        8px;
    --hub-shadow:           0 1px 3px rgba(0,0,0,.12), 0 1px 2px rgba(0,0,0,.08);
    --hub-shadow-md:        0 4px 6px rgba(0,0,0,.10), 0 2px 4px rgba(0,0,0,.06);

    /* --- Typography --- */
    --hub-font:             'Open Sans', Arial, Helvetica, sans-serif;
    --hub-font-mono:        'Consolas', 'Courier New', monospace;
    --hub-font-size-base:   0.9375rem;  /* 15px */
    --hub-font-size-sm:     0.8125rem;  /* 13px */
    --hub-font-size-lg:     1.0625rem;  /* 17px */
    --hub-line-height:      1.6;

    /* --- Z-index layers --- */
    --hub-z-nav:            100;
    --hub-z-dropdown:       200;
    --hub-z-modal:          300;
}

/* ================================================================
   Reset & base
   ================================================================ */

*, *::before, *::after {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    margin: 0;
    font-family: var(--hub-font);
    font-size: var(--hub-font-size-base);
    line-height: var(--hub-line-height);
    color: var(--hub-text);
    background-color: var(--hub-body-bg);
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, h5, h6 {
    font-family: var(--hub-font);
    color: var(--hub-primary);
    font-weight: 600;
    margin-top: 0;
    line-height: 1.3;
}

h1 { font-size: 1.75rem; }
h2 { font-size: 1.375rem; }
h3 { font-size: 1.125rem; }
h4 { font-size: 1rem; }

a {
    color: var(--hub-accent);
    text-decoration: none;
}
a:hover {
    color: var(--hub-accent-hover);
    text-decoration: underline;
}

p { margin: 0 0 1rem; }

img { max-width: 100%; height: auto; }

/* ================================================================
   Top gold stripe
   ================================================================ */

.hub-topbar {
    height: var(--hub-topbar-height);
    background: linear-gradient(90deg, var(--hub-gold) 0%, var(--hub-gold-dark) 100%);
    width: 100%;
}

/* ================================================================
   Navigation
   ================================================================ */

.hub-nav {
    background-color: var(--hub-primary);
    height: var(--hub-nav-height);
    display: flex;
    align-items: center;
    padding: 0 1.5rem;
    position: sticky;
    top: 0;
    z-index: var(--hub-z-nav);
    box-shadow: 0 2px 6px rgba(0,0,0,.25);
}

.hub-nav__brand {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    color: var(--hub-text-on-primary);
    font-weight: 700;
    font-size: 1.125rem;
    letter-spacing: 0.01em;
    text-decoration: none;
    white-space: nowrap;
}

.hub-nav__brand:hover {
    color: var(--hub-gold);
    text-decoration: none;
}

.hub-nav__brand-icon {
    width: 32px;
    height: 32px;
    background: var(--hub-gold);
    border-radius: var(--hub-radius);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.875rem;
    font-weight: 800;
    color: var(--hub-primary-dark);
    flex-shrink: 0;
}

.hub-nav__links {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    margin-left: 2rem;
    flex: 1;
    list-style: none;
    padding: 0;
    margin-top: 0;
    margin-bottom: 0;
}

.hub-nav__links a {
    display: block;
    padding: 0.5rem 0.875rem;
    color: rgba(255,255,255,.85);
    font-size: var(--hub-font-size-sm);
    font-weight: 500;
    border-radius: var(--hub-radius);
    transition: background .15s, color .15s;
    text-decoration: none;
    letter-spacing: 0.01em;
    text-transform: uppercase;
}

.hub-nav__links a:hover,
.hub-nav__links a.active {
    background: rgba(255,255,255,.12);
    color: #fff;
    text-decoration: none;
}

.hub-nav__links a.active {
    border-bottom: 3px solid var(--hub-gold);
}

/* --- Nav dropdown menus --- */

.hub-nav__dropdown {
    position: relative;
}

.hub-nav__dropdown-toggle {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.5rem 0.875rem;
    color: rgba(255,255,255,.85);
    font-size: var(--hub-font-size-sm);
    font-weight: 500;
    border-radius: var(--hub-radius);
    transition: background .15s, color .15s;
    letter-spacing: 0.01em;
    text-transform: uppercase;
    cursor: default;
    user-select: none;
    white-space: nowrap;
}

.hub-nav__dropdown-toggle::after {
    content: '▾';
    font-size: 0.65rem;
    opacity: .65;
    margin-left: 0.1rem;
}

.hub-nav__dropdown:hover .hub-nav__dropdown-toggle,
.hub-nav__dropdown-toggle.active {
    background: rgba(255,255,255,.12);
    color: #fff;
}

.hub-nav__dropdown-toggle.active {
    border-bottom: 3px solid var(--hub-gold);
}

.hub-nav__dropdown-menu {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    padding-top: 6px;
    min-width: 190px;
    background: var(--hub-primary-dark);
    border: 1px solid rgba(255,255,255,.12);
    border-radius: var(--hub-radius);
    box-shadow: var(--hub-shadow-md);
    z-index: var(--hub-z-dropdown);
    padding: 0.3rem 0;
    list-style: none;
    margin: 0;
}

.hub-nav__dropdown:hover .hub-nav__dropdown-menu {
    display: block;
}

.hub-nav__dropdown-menu a {
    display: block;
    padding: 0.5rem 1rem;
    color: rgba(255,255,255,.82);
    font-size: var(--hub-font-size-sm);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.01em;
    text-decoration: none;
    transition: background .12s, color .12s;
    border-radius: 0;
    border-left: 3px solid transparent;
}

.hub-nav__dropdown-menu a:hover {
    background: rgba(255,255,255,.09);
    color: #fff;
    text-decoration: none;
}

.hub-nav__dropdown-menu a.active {
    background: rgba(255,255,255,.09);
    color: #fff;
    border-left-color: var(--hub-gold);
}

.hub-nav__dropdown-menu .hub-nav__menu-divider {
    height: 1px;
    background: rgba(255,255,255,.1);
    margin: 0.3rem 0;
}

.hub-nav__right {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-left: auto;
}

.hub-nav__user {
    color: rgba(255,255,255,.85);
    font-size: var(--hub-font-size-sm);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.hub-nav__user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--hub-primary-light);
    border: 2px solid rgba(255,255,255,.3);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 700;
    color: #fff;
}

/* ================================================================
   Page header / breadcrumb area
   ================================================================ */

.hub-page-header {
    background: var(--hub-surface);
    border-bottom: 1px solid var(--hub-border);
    padding: 1.25rem 1.5rem;
}

.hub-page-header__title {
    font-size: 1.375rem;
    font-weight: 700;
    color: var(--hub-primary);
    margin: 0 0 0.25rem;
}

.hub-breadcrumb {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: var(--hub-font-size-sm);
    color: var(--hub-text-muted);
    list-style: none;
    padding: 0;
    margin: 0;
}

.hub-breadcrumb li:not(:last-child)::after {
    content: '›';
    margin-left: 0.5rem;
    color: var(--hub-border);
}

.hub-breadcrumb a {
    color: var(--hub-accent);
}

/* ================================================================
   Main content wrapper
   ================================================================ */

.hub-layout {
    display: flex;
    min-height: calc(100vh - var(--hub-nav-height) - var(--hub-topbar-height));
}

.hub-main {
    flex: 1;
    padding: 1.5rem;
    max-width: 100%;
    min-width: 0;
}

/* ================================================================
   Contextual submenu (opt-in — apps that render <aside class="hub-sidebar">
   inside .hub-layout get a left submenu for the active top-nav section.
   Apps that don't render it are unaffected.)
   ================================================================ */

.hub-sidebar {
    width: var(--hub-sidebar-width);
    flex-shrink: 0;
    background: var(--hub-surface);
    border-right: 1px solid var(--hub-border);
    padding: 1rem 0.75rem;
    align-self: stretch;
}

.hub-sidebar__nav {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    position: sticky;
    top: calc(var(--hub-nav-height) + 1rem);
}

.hub-sidebar__item {
    display: block;
    padding: 0.5rem 0.75rem;
    color: var(--hub-text);
    font-size: var(--hub-font-size-sm);
    font-weight: 500;
    border-radius: var(--hub-radius);
    text-decoration: none;
    border-left: 3px solid transparent;
    transition: background .12s, color .12s;
}

.hub-sidebar__item:hover {
    background: var(--hub-surface-alt);
    color: var(--hub-primary);
    text-decoration: none;
}

.hub-sidebar__item.active {
    background: var(--hub-surface-alt);
    color: var(--hub-primary);
    border-left-color: var(--hub-gold);
    font-weight: 600;
}

/* Section heading above the submenu items (the active top-nav group). */
.hub-sidebar__title {
    padding: 0.4rem 0.75rem;
    margin-bottom: 0.15rem;
    color: var(--hub-text-muted);
    font-size: var(--hub-font-size-sm);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

/* ================================================================
   Cards
   ================================================================ */

.hub-card {
    background: var(--hub-surface);
    border: 1px solid var(--hub-border-light);
    border-radius: var(--hub-radius-lg);
    box-shadow: var(--hub-shadow);
    overflow: hidden;
}

.hub-card__header {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--hub-border-light);
    background: var(--hub-surface);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.hub-card__title {
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--hub-primary);
    margin: 0;
}

.hub-card__body {
    padding: 1.25rem;
}

.hub-card__footer {
    padding: 0.875rem 1.25rem;
    border-top: 1px solid var(--hub-border-light);
    background: var(--hub-surface-alt);
    font-size: var(--hub-font-size-sm);
}

/* ================================================================
   Stat cards (dashboard)
   ================================================================ */

.hub-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.hub-stat {
    background: var(--hub-surface);
    border: 1px solid var(--hub-border-light);
    border-left: 4px solid var(--hub-primary);
    border-radius: var(--hub-radius);
    padding: 1.125rem 1.25rem;
    box-shadow: var(--hub-shadow);
}

.hub-stat--accent  { border-left-color: var(--hub-accent); }
.hub-stat--gold    { border-left-color: var(--hub-gold); }
.hub-stat--success { border-left-color: var(--hub-success); }
.hub-stat--danger  { border-left-color: var(--hub-danger); }

.hub-stat__label {
    font-size: var(--hub-font-size-sm);
    color: var(--hub-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 600;
    margin-bottom: 0.375rem;
}

.hub-stat__value {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--hub-primary);
    line-height: 1.1;
}

.hub-stat__delta {
    font-size: var(--hub-font-size-sm);
    color: var(--hub-text-muted);
    margin-top: 0.25rem;
}

/* ================================================================
   Buttons
   ================================================================ */

.hub-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.5rem 1.125rem;
    font-family: var(--hub-font);
    font-size: var(--hub-font-size-sm);
    font-weight: 600;
    line-height: 1.4;
    border: 1px solid transparent;
    border-radius: var(--hub-radius);
    cursor: pointer;
    text-decoration: none;
    transition: background .15s, border-color .15s, color .15s, box-shadow .15s;
    white-space: nowrap;
}

.hub-btn:disabled { opacity: .55; cursor: not-allowed; }

.hub-btn--primary {
    background: var(--hub-primary);
    color: #fff;
    border-color: var(--hub-primary);
}
.hub-btn--primary:hover:not(:disabled) {
    background: var(--hub-primary-dark);
    border-color: var(--hub-primary-dark);
    color: #fff;
    text-decoration: none;
}

.hub-btn--accent {
    background: var(--hub-accent);
    color: #fff;
    border-color: var(--hub-accent);
}
.hub-btn--accent:hover:not(:disabled) {
    background: var(--hub-accent-hover);
    border-color: var(--hub-accent-hover);
    color: #fff;
    text-decoration: none;
}

.hub-btn--outline {
    background: transparent;
    color: var(--hub-primary);
    border-color: var(--hub-primary);
}
.hub-btn--outline:hover:not(:disabled) {
    background: var(--hub-primary);
    color: #fff;
    text-decoration: none;
}

.hub-btn--ghost {
    background: transparent;
    color: var(--hub-text-muted);
    border-color: var(--hub-border);
}
.hub-btn--ghost:hover:not(:disabled) {
    background: var(--hub-surface-alt);
    color: var(--hub-text);
}

.hub-btn--danger {
    background: var(--hub-danger);
    color: #fff;
    border-color: var(--hub-danger);
}

.hub-btn--sm { padding: 0.3125rem 0.75rem; font-size: 0.75rem; }
.hub-btn--lg { padding: 0.75rem 1.5rem; font-size: 1rem; }

/* ================================================================
   Tables
   ================================================================ */

.hub-table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.hub-table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--hub-font-size-sm);
}

.hub-table thead {
    background: var(--hub-primary);
    color: var(--hub-text-on-primary);
}

.hub-table thead th {
    padding: 0.75rem 1rem;
    text-align: left;
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    white-space: nowrap;
    border: none;
}

.hub-table tbody tr {
    border-bottom: 1px solid var(--hub-border-light);
    transition: background .1s;
}

.hub-table tbody tr:last-child { border-bottom: none; }
.hub-table tbody tr:nth-child(even) { background: var(--hub-surface-alt); }
.hub-table tbody tr:hover { background: #E8EFF8; }

.hub-table tbody td {
    padding: 0.75rem 1rem;
    color: var(--hub-text);
    vertical-align: middle;
}

/* Sortable headers (enhanced by hub-tables.js) */
.hub-table thead th.hub-sortable {
    cursor: pointer;
    user-select: none;
    padding-right: 1.6rem;
    position: relative;
}

.hub-table thead th.hub-sortable::after {
    content: "↕";
    position: absolute;
    right: 0.6rem;
    opacity: 0.4;
    font-size: 0.85em;
}

.hub-table thead th.hub-sort-asc::after  { content: "↑"; opacity: 1; }
.hub-table thead th.hub-sort-desc::after { content: "↓"; opacity: 1; }

.hub-table thead th.hub-sortable:hover::after { opacity: 0.9; }

.hub-table thead th.hub-sortable:focus-visible {
    outline: 2px solid var(--hub-text-on-primary);
    outline-offset: -2px;
}

/* Per-grid toolbar (holds the AJAX refresh button injected by hub-tables.js) */
.hub-grid-toolbar {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 0.5rem;
}

.hub-grid-refresh .hub-grid-refresh__icon {
    display: inline-block;
}

.hub-grid-refresh.is-loading .hub-grid-refresh__icon {
    animation: hub-spin 0.7s linear infinite;
}

@keyframes hub-spin {
    to { transform: rotate(360deg); }
}

/* ================================================================
   Badges
   ================================================================ */

.hub-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.2rem 0.6rem;
    font-size: 0.6875rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-radius: 100px;
}

.hub-badge--primary  { background: #D6E4F5; color: var(--hub-primary); }
.hub-badge--accent   { background: #D6E9FF; color: var(--hub-accent); }
.hub-badge--gold     { background: #FEF3C7; color: #92400E; }
.hub-badge--success  { background: #D1FAE5; color: #065F46; }
.hub-badge--danger   { background: #FEE2E2; color: #991B1B; }
.hub-badge--info     { background: #DBEAFE; color: #1D4ED8; }
.hub-badge--muted    { background: var(--hub-surface-alt); color: var(--hub-text-muted); }

/* ================================================================
   Forms
   ================================================================ */

.hub-form-group {
    margin-bottom: 1.125rem;
}

.hub-label {
    display: block;
    font-size: var(--hub-font-size-sm);
    font-weight: 600;
    color: var(--hub-text);
    margin-bottom: 0.375rem;
}

.hub-label--required::after {
    content: ' *';
    color: var(--hub-danger);
}

.hub-input,
.hub-select,
.hub-textarea {
    display: block;
    width: 100%;
    padding: 0.5rem 0.75rem;
    font-family: var(--hub-font);
    font-size: var(--hub-font-size-base);
    color: var(--hub-text);
    background: var(--hub-surface);
    border: 1px solid var(--hub-border);
    border-radius: var(--hub-radius);
    transition: border-color .15s, box-shadow .15s;
    outline: none;
}

.hub-input:focus,
.hub-select:focus,
.hub-textarea:focus {
    border-color: var(--hub-accent);
    box-shadow: 0 0 0 3px rgba(0,102,204,.15);
}

.hub-input.is-invalid,
.hub-select.is-invalid,
.hub-textarea.is-invalid {
    border-color: var(--hub-danger);
}

.hub-field-error {
    font-size: var(--hub-font-size-sm);
    color: var(--hub-danger);
    margin-top: 0.25rem;
}

/* ================================================================
   Alerts
   ================================================================ */

.hub-alert {
    padding: 0.875rem 1.125rem;
    border-radius: var(--hub-radius);
    border-left: 4px solid currentColor;
    font-size: var(--hub-font-size-sm);
    margin-bottom: 1rem;
    display: flex;
    gap: 0.5rem;
    align-items: flex-start;
}

.hub-alert--info    { background: #EFF6FF; color: var(--hub-accent); }
.hub-alert--success { background: #F0FDF4; color: var(--hub-success); }
.hub-alert--warning { background: #FFFBEB; color: #B45309; }
.hub-alert--danger  { background: #FEF2F2; color: var(--hub-danger); }

.hub-alert p { margin: 0; color: var(--hub-text); }
.hub-alert strong { color: inherit; }

/* ASP.NET's asp-validation-summary always renders its wrapper div and tags it
   `validation-summary-valid` when there are no errors. Hide that empty state so
   forms styling it as a .hub-alert--danger don't show an empty red box on load. */
.validation-summary-valid { display: none; }

/* ================================================================
   Footer
   ================================================================ */

.hub-footer {
    background: var(--hub-primary-dark);
    color: rgba(255,255,255,.65);
    padding: 1.25rem 1.5rem;
    font-size: var(--hub-font-size-sm);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: auto;
}

.hub-footer a {
    color: rgba(255,255,255,.75);
}
.hub-footer a:hover {
    color: var(--hub-gold);
}

/* The footer holds a single centered block: two office lines plus the copyright. */
.hub-footer__content {
    width: 100%;
    text-align: center;
    line-height: 1.6;
}

.hub-footer__office,
.hub-footer__copyright {
    margin: 0;
}

/* Pipe separators are drawn between the office spans so they collapse away
   with the spans themselves when a line wraps on narrow screens. */
.hub-footer__office span + span::before {
    content: "|";
    padding: 0 0.5rem;
    color: rgba(255,255,255,.35);
}

.hub-footer__copyright {
    margin-top: 0.5rem;
    color: rgba(255,255,255,.55);
}

/* ================================================================
   Utility classes
   ================================================================ */

.hub-flex        { display: flex; }
.hub-flex-center { display: flex; align-items: center; }
.hub-gap-sm      { gap: 0.5rem; }
.hub-gap-md      { gap: 1rem; }
.hub-ml-auto     { margin-left: auto; }
.hub-mt-0        { margin-top: 0; }
.hub-mb-0        { margin-bottom: 0; }
.hub-mb-1        { margin-bottom: 0.5rem; }
.hub-mb-2        { margin-bottom: 1rem; }
.hub-mb-3        { margin-bottom: 1.5rem; }
.hub-text-muted  { color: var(--hub-text-muted); }
.hub-text-sm     { font-size: var(--hub-font-size-sm); }
.hub-fw-bold     { font-weight: 700; }
.hub-w-100       { width: 100%; }
.hub-sr-only     { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }

/* ================================================================
   Responsive
   ================================================================ */

@media (max-width: 768px) {
    .hub-nav__links   { display: none; }
    .hub-layout       { flex-direction: column; }
    .hub-sidebar      { width: 100%; border-right: none; border-bottom: 1px solid var(--hub-border); padding: 0.5rem 0.75rem; }
    .hub-sidebar__nav { position: static; }
    .hub-main         { padding: 1rem; }
    .hub-stats        { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 480px) {
    .hub-stats { grid-template-columns: 1fr; }
}
