/* ============================================================
   HAGE ICT MANAGEMENT SYSTEM — core design tokens, layout, shell
   See docs/UI_DESIGN_SYSTEM.md
   ============================================================ */

:root {
    --hage-primary: #2563EB;
    --hage-primary-hover: #1D4ED8;
    --hage-navy: #0B1220;
    --hage-navy-2: #111827;
    --hage-primary-soft: #EFF4FF;
    --hage-bg: #F3F5F9;
    --hage-surface: #FFFFFF;
    --hage-text: #0F172A;
    --hage-text-secondary: #64748B;
    --hage-muted: #94A3B8;
    --hage-border: #E8ECF1;
    --hage-border-card: #EEF1F6;
    --hage-input-border: #D8DEE6;
    --hage-success: #12B76A;
    --hage-warning: #F79009;
    --hage-danger: #F04438;
    --hage-info: #2E90FA;
    --hage-purple: #6941C6;

    --hage-soft-blue: #EEF3FF;
    --hage-soft-green: #E7F7EF;
    --hage-soft-violet: #F1EDFB;
    --hage-soft-orange: #FEF3E9;
    --hage-soft-emerald: #E4F8EF;
    --hage-soft-cyan: #E6F6FE;
    --hage-soft-red: #FDEDEC;
    --hage-soft-gray: #F2F4F7;

    --hage-sidebar-width: 360px;
    --hage-sidebar-width-collapsed: 76px;
    --hage-topbar-height: 64px;
    --hage-radius: 10px;
    --hage-radius-lg: 16px;
    --hage-shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.04);
    --hage-shadow: 0 8px 24px rgba(15, 23, 42, 0.06);
}

* { box-sizing: border-box; }

html, body {
    max-width: 100%;
    overflow-x: hidden;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--hage-bg);
    color: var(--hage-text);
    font-size: 14px;
    -webkit-font-smoothing: antialiased;
}

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

h1, h2, h3, h4, h5, h6 { color: var(--hage-text); }

/* Typography scale */
.hage-text-page-title { font-size: 26px; font-weight: 700; line-height: 1.2; letter-spacing: -0.02em; }
.hage-text-section { font-size: 18px; font-weight: 600; }
.hage-text-card-title { font-size: 15px; font-weight: 600; }
.hage-text-small { font-size: 13px; color: var(--hage-text-secondary); }
.hage-text-xs { font-size: 12px; color: var(--hage-muted); }

/* Focus states */
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, [tabindex]:focus-visible {
    outline: 2px solid var(--hage-primary);
    outline-offset: 2px;
}

/* Form controls */
.form-control, .form-select {
    height: 42px;
    border-color: var(--hage-input-border);
    border-radius: var(--hage-radius);
    font-size: 14px;
    background-color: var(--hage-surface);
}
textarea.form-control { height: auto; }
.form-control:focus, .form-select:focus {
    border-color: var(--hage-primary);
    box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.12);
}
.form-label { font-size: 13px; font-weight: 600; color: var(--hage-text); margin-bottom: 6px; }

/* ---------------------------------------------------------------
   Application shell
   --------------------------------------------------------------- */
.hage-shell { display: flex; min-height: 100vh; }

.hage-main {
    flex: 1;
    margin-inline-start: var(--hage-sidebar-width);
    display: flex;
    flex-direction: column;
    min-width: 0;
    transition: margin-inline-start 0.2s ease;
}

.hage-content { padding: 24px 28px 40px; flex: 1; }

.hage-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(7, 26, 61, 0.45);
    z-index: 1025;
}
.hage-shell.is-mobile-open .hage-backdrop { display: block; }

@media (min-width: 1200px) {
    .hage-shell.is-collapsed .hage-main { margin-inline-start: var(--hage-sidebar-width-collapsed); }
}
@media (min-width: 768px) and (max-width: 1199.98px) {
    .hage-main { margin-inline-start: var(--hage-sidebar-width); }
}
@media (max-width: 767.98px) {
    .hage-main { margin-inline-start: 0; }
    .hage-content { padding: 20px; }
}

/* ---------------------------------------------------------------
   Sidebar
   --------------------------------------------------------------- */
.hage-sidebar {
    width: var(--hage-sidebar-width);
    flex-shrink: 0;
    /* A brighter, more saturated blue than the login/error screens'
       --hage-navy tokens — a deliberately separate value (not those
       shared tokens) so this sidebar-only brightening never bleeds into
       the login/403/404 brand panels, which are out of scope here. */
    background: #0B1220;
    color: rgba(255, 255, 255, 0.72);
    border-inline-end: 1px solid rgba(255, 255, 255, 0.06);
    display: flex;
    flex-direction: column;
    position: fixed;
    inset-block: 0;
    inset-inline-start: 0;
    z-index: 1030;
    transition: width 0.2s ease, transform 0.2s ease;
    overflow-y: auto;
    overflow-x: hidden;
}
.hage-sidebar__brand {
    display: flex; align-items: center; justify-content: center;
    padding: 18px 16px; color: #fff;
    white-space: nowrap; border-bottom: 1px solid rgba(255,255,255,0.08);
    flex-shrink: 0; background: #000;
}
/* Collapsed-rail fallback only. Hidden in the expanded sidebar. */
.hage-sidebar__brand-mark {
    display: none;
    width: 36px; height: 36px; border-radius: 10px;
    background: #000;
    align-items: center; justify-content: center;
    font-weight: 800; font-size: 15px; color: #fff; flex-shrink: 0;
}
.hage-sidebar__logo-full {
    display: flex; align-items: center; justify-content: center;
    background: transparent; padding: 0; flex: 1; max-width: 100%;
}
.hage-sidebar__logo-full img { width: 100%; height: auto; object-fit: contain; display: block; }
.hage-sidebar__nav { padding: 16px 14px; flex: 1; }
.hage-sidebar__group { margin-top: 24px; }
.hage-sidebar__group:first-child { margin-top: 6px; }
.hage-sidebar__group-label {
    font-size: 11px; font-weight: 700; letter-spacing: 0.09em; text-transform: uppercase;
    color: rgba(139, 197, 255, 0.45); padding: 0 12px; margin-bottom: 8px; white-space: nowrap;
}
.hage-sidebar__link {
    display: flex; align-items: center; gap: 12px;
    height: 46px; padding-inline: 14px; border-radius: 10px;
    color: rgba(255, 255, 255, 0.68); font-size: 15px; font-weight: 500;
    white-space: nowrap; margin-bottom: 1px;
    transition: background-color 0.15s ease, color 0.15s ease;
}
.hage-sidebar__link svg { width: 20px; height: 20px; flex-shrink: 0; }
.hage-sidebar__link:hover { background-color: rgba(255, 255, 255, 0.1); color: #fff; }
.hage-sidebar__link.is-active {
    background-color: rgba(37, 99, 235, 0.22); color: #fff; font-weight: 600;
    box-shadow: inset 3px 0 0 #60A5FA;
}
.hage-sidebar__link.is-disabled { cursor: default; opacity: 0.5; pointer-events: none; }
.hage-sidebar__link-label { flex: 1; overflow: hidden; text-overflow: ellipsis; }
.hage-sidebar__soon-badge {
    font-size: 9px; font-weight: 600; color: rgba(255,255,255,0.38);
    text-transform: uppercase; letter-spacing: 0.04em;
    flex-shrink: 0;
}

/* Bottom help/support block */
.hage-sidebar__help {
    margin: 8px 12px 16px; padding: 14px;
    background: rgba(46, 144, 250, 0.12);
    border: 1px solid rgba(139, 197, 255, 0.18);
    border-radius: 12px;
    display: flex; align-items: flex-start; gap: 10px;
    flex-shrink: 0;
}
.hage-sidebar__help-icon {
    width: 30px; height: 30px; border-radius: 8px; flex-shrink: 0;
    background: rgba(255,255,255,0.1); color: #fff;
    display: flex; align-items: center; justify-content: center;
}
.hage-sidebar__help-icon svg { width: 15px; height: 15px; }
.hage-sidebar__help-title { font-size: 12.5px; font-weight: 700; color: #fff; margin-bottom: 2px; }
.hage-sidebar__help-text { font-size: 11.5px; color: rgba(255,255,255,0.6); overflow-wrap: anywhere; }
.hage-sidebar__help-text a { color: rgba(255,255,255,0.85); }

@media (min-width: 1200px) {
    .hage-shell.is-collapsed .hage-sidebar { width: var(--hage-sidebar-width-collapsed); }
    .hage-shell.is-collapsed .hage-sidebar__logo-full,
    .hage-shell.is-collapsed .hage-sidebar__group-label,
    .hage-shell.is-collapsed .hage-sidebar__link-label,
    .hage-shell.is-collapsed .hage-sidebar__soon-badge,
    .hage-shell.is-collapsed .hage-sidebar__help { display: none; }
    .hage-shell.is-collapsed .hage-sidebar__brand-mark { display: flex; }
    .hage-shell.is-collapsed .hage-sidebar__brand { justify-content: center; padding-inline: 0; }
    .hage-shell.is-collapsed .hage-sidebar__link { justify-content: center; }
}
@media (min-width: 768px) and (max-width: 1199.98px) {
    .hage-sidebar { width: var(--hage-sidebar-width); }
}
@media (max-width: 767.98px) {
    .hage-sidebar { transform: translateX(-100%); width: var(--hage-sidebar-width); }
    .hage-shell.is-mobile-open .hage-sidebar { transform: translateX(0); }
}

/* ---------------------------------------------------------------
   Topbar
   --------------------------------------------------------------- */
.hage-topbar {
    height: var(--hage-topbar-height);
    background: rgba(255, 255, 255, 0.86);
    backdrop-filter: blur(14px);
    border-bottom: 1px solid rgba(232, 236, 241, 0.9);
    display: flex; align-items: center; gap: 16px; padding-inline: 24px;
    position: sticky; top: 0; z-index: 1020;
}
.hage-icon-btn {
    display: inline-flex; align-items: center; justify-content: center;
    width: 38px; height: 38px; border-radius: var(--hage-radius);
    border: 1px solid var(--hage-input-border); background: var(--hage-surface);
    color: #475467; flex-shrink: 0; position: relative;
}
.hage-icon-btn svg { width: 18px; height: 18px; }
.hage-icon-btn:hover { background: var(--hage-primary-soft); border-color: var(--hage-primary); color: var(--hage-primary); }
.hage-icon-btn.is-static:hover { background: var(--hage-surface); border-color: var(--hage-input-border); color: #475467; cursor: default; }
.hage-icon-btn:disabled { opacity: 0.7; }

.hage-topbar__search { flex: 1; max-width: 480px; min-width: 0; }
.hage-search { position: relative; display: flex; align-items: center; }
.hage-search svg { position: absolute; inset-inline-start: 14px; width: 17px; height: 17px; color: var(--hage-muted); pointer-events: none; }
.hage-search input {
    width: 100%; height: 40px; padding-inline-start: 40px; padding-inline-end: 62px;
    border: 1px solid var(--hage-input-border); border-radius: var(--hage-radius);
    background: var(--hage-bg); font-size: 13px; color: var(--hage-text);
}
.hage-search input::placeholder { color: var(--hage-muted); }
.hage-search input:disabled { cursor: not-allowed; }
.hage-search__kbd {
    position: absolute; inset-inline-end: 10px; top: 50%; transform: translateY(-50%);
    font-family: inherit; font-size: 11px; font-weight: 600; color: var(--hage-muted);
    background: var(--hage-surface); border: 1px solid var(--hage-border); border-radius: 6px;
    padding: 2px 7px; pointer-events: none;
}
@media (max-width: 991.98px) { .hage-search__kbd { display: none; } }

.hage-topbar__actions { display: flex; align-items: center; gap: 10px; margin-inline-start: auto; }
.hage-topbar__user {
    display: flex; align-items: center; gap: 10px;
    padding: 5px 9px 5px 5px; border-radius: 10px; border: 1px solid transparent; cursor: pointer;
}
.hage-topbar__user:hover { background: var(--hage-bg); border-color: var(--hage-border); }
.hage-topbar__user-name { font-size: 13px; font-weight: 600; color: var(--hage-text); line-height: 1.25; }
.hage-topbar__user-role { font-size: 11px; color: var(--hage-text-secondary); line-height: 1.25; }

@media (max-width: 767.98px) {
    .hage-topbar__search { display: none; }
    .hage-topbar { padding-inline: 16px; gap: 8px; }
}
@media (max-width: 575.98px) {
    .hage-topbar__user-name, .hage-topbar__user-role { display: none; }
}

.btn-primary {
    background-color: var(--hage-primary);
    border-color: var(--hage-primary);
}
.btn-primary:hover, .btn-primary:focus, .btn-primary:active {
    background-color: var(--hage-primary-hover) !important;
    border-color: var(--hage-primary-hover) !important;
}

/* ---------------------------------------------------------------
   Login / auth split layout
   --------------------------------------------------------------- */
.hage-auth { min-height: 100vh; display: flex; }
.hage-auth__brand-panel {
    flex: 1 1 52%;
    background: linear-gradient(160deg, var(--hage-navy) 0%, var(--hage-navy-2) 55%, var(--hage-primary-hover) 130%);
    color: #fff; display: flex; flex-direction: column; justify-content: space-between;
    padding: 48px; position: relative; overflow: hidden;
}
@media (max-width: 1023.98px) { .hage-auth__brand-panel { display: none; } }

.hage-auth__glow-a {
    position: absolute; inset-inline-end: -120px; inset-block-start: -120px;
    width: 420px; height: 420px; border-radius: 50%;
    background: radial-gradient(circle, rgba(46, 144, 250, 0.35), transparent 70%); filter: blur(10px);
}
.hage-auth__glow-b {
    position: absolute; inset-inline-start: -100px; inset-block-end: -140px;
    width: 380px; height: 380px; border-radius: 50%;
    background: radial-gradient(circle, rgba(18, 60, 216, 0.4), transparent 70%); filter: blur(10px);
}
.hage-auth__grid {
    position: absolute; inset: 0;
    background-image: linear-gradient(rgba(255,255,255,0.05) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,0.05) 1px, transparent 1px);
    background-size: 44px 44px;
    mask-image: radial-gradient(ellipse 80% 60% at 50% 40%, black 40%, transparent 85%);
}
.hage-auth__rings {
    position: absolute; inset-inline-end: 6%; inset-block-start: 50%; transform: translateY(-50%);
    width: 320px; height: 320px; pointer-events: none;
}
@media (max-width: 1439.98px) { .hage-auth__rings { display: none; } }
.hage-auth__ring { position: absolute; inset: 0; border-radius: 50%; border: 1px solid rgba(255,255,255,0.12); }
.hage-auth__ring::before {
    content: ''; position: absolute; width: 8px; height: 8px; border-radius: 50%;
    background: var(--hage-info); box-shadow: 0 0 12px 2px rgba(46,144,250,0.8);
    top: -4px; left: 50%; margin-inline-start: -4px;
}
.hage-auth__ring--md { inset: 14%; border-color: rgba(255,255,255,0.18); }
.hage-auth__ring--sm { inset: 30%; border-color: rgba(255,255,255,0.26); }
.hage-auth__ring--sm::before { background: #fff; box-shadow: 0 0 12px 2px rgba(255,255,255,0.6); }

.hage-auth__brand { display: flex; align-items: center; gap: 12px; position: relative; z-index: 1; }
.hage-auth__logo-card {
    display: inline-flex; align-items: center; justify-content: center;
    background: #000; border-radius: 10px; padding: 8px 12px;
}
.hage-auth__logo-card img { height: 52px; width: auto; object-fit: contain; display: block; }
.hage-auth__copy { position: relative; z-index: 1; max-width: 460px; }
.hage-auth__copy h1 { font-size: 36px; font-weight: 700; line-height: 1.2; margin-bottom: 14px; letter-spacing: -0.01em; color: #fff; }
.hage-auth__copy p { color: rgba(255,255,255,0.68); font-size: 15px; line-height: 1.6; margin-bottom: 24px; }
.hage-auth__tagline { display: inline-flex; align-items: center; gap: 8px; font-size: 12px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; color: rgba(255,255,255,0.55); }
.hage-auth__tagline::before { content: ''; width: 22px; height: 1px; background: rgba(255,255,255,0.4); }
.hage-auth__footnote { position: relative; z-index: 1; color: rgba(255,255,255,0.4); font-size: 13px; }

.hage-auth__form-panel { flex: 1 1 48%; display: flex; align-items: center; justify-content: center; padding: 32px; background: var(--hage-bg); }
.hage-auth__form-card { width: 100%; max-width: 400px; }
/* Mobile-only fallback brand mark (<1024px, where the dark brand panel
   with the full logo is hidden) — light form background, so the logo
   can sit directly on it with no card needed. */
.hage-auth__logo-mark { margin-bottom: 24px; }
.hage-auth__logo-mark img { height: 52px; width: auto; object-fit: contain; display: block; background: #000; border-radius: 8px; }
.text-center .hage-auth__logo-mark img { margin-inline: auto; }
@media (min-width: 1024px) { .hage-auth__logo-mark { display: none; } }
.hage-auth__form-footer { text-align: center; color: var(--hage-muted); font-size: 12px; margin-top: 32px; }

/* ---------------------------------------------------------------
   Dashboard page header + chart placeholder
   --------------------------------------------------------------- */
.hage-page-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.hage-page-header__title { font-size: 26px; font-weight: 700; color: var(--hage-text); margin-bottom: 4px; line-height: 1.2; letter-spacing: -0.02em; }
.hage-page-header__subtitle { color: var(--hage-text-secondary); font-size: 14px; margin-bottom: 0; }

.hage-back-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 36px;
    padding: 0 14px;
    margin-bottom: 12px;
    border: 1px solid var(--hage-border);
    border-radius: 8px;
    background: var(--hage-surface);
    color: var(--hage-navy);
    font-size: 13.5px;
    font-weight: 600;
    text-decoration: none;
    transition: background-color .15s ease, border-color .15s ease, color .15s ease;
}
.hage-back-link svg { width: 16px; height: 16px; flex-shrink: 0; }
.hage-back-link:hover {
    background: var(--hage-primary-soft);
    border-color: var(--hage-primary);
    color: var(--hage-primary);
    text-decoration: none;
}

.hage-chart-placeholder {
    height: 220px; border-radius: var(--hage-radius);
    background: linear-gradient(180deg, rgba(18,60,216,0.03), transparent 70%),
        repeating-linear-gradient(to top, transparent, transparent calc(25% - 1px), var(--hage-border) calc(25% - 1px), var(--hage-border) 25%);
    display: flex; align-items: center; justify-content: center; position: relative; overflow: hidden;
}
