:root {
    --primary:      #F07820;
    --primary-dark: #D4641A;
    --primary-light:#FEF0E6;
    --green:        #5C9E40;
    --yellow:       #F5C518;
    --magenta:      #D4297A;
    --cyan:         #00BFBF;

    --text:         #1E1E1E;
    --muted:        #6B7280;
    --bg:           #F4F6F9;
    --card:         #FFFFFF;
    --border:       #E5E7EB;

    --red:          #DC2626;
    --red-light:    #FEF2F2;
    --green-light:  #F0FDF4;
    --yellow-light: #FEFCE8;

    --sidebar-w:    240px;
    --sidebar-c:    64px;
    --topbar-h:     56px;
    --radius:       8px;
    --radius-lg:    12px;
    --shadow:       0 1px 4px rgba(0,0,0,.08);
    --shadow-md:    0 4px 16px rgba(0,0,0,.10);

    --font:         'Inter', system-ui, sans-serif;
}

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

html { font-size: 15px; }

body {
    font-family: var(--font);
    background:  var(--bg);
    color:       var(--text);
    line-height: 1.6;
    min-height:  100vh;
    -webkit-font-smoothing: antialiased;
}

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

img { max-width: 100%; height: auto; display: block; }

.sg-wrapper {
    display: flex;
    min-height: 100vh;
}

.sg-sidebar {
    width: var(--sidebar-w);
    background: var(--card);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 200;
    transition: width .22s ease;
    overflow: hidden;
}

.sg-sidebar.collapsed { width: var(--sidebar-c); }

.sg-sidebar-logo {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 14px;
    height: var(--topbar-h);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.sg-sidebar.collapsed .sg-sidebar-logo {
    flex-direction: column;
    justify-content: center;
    gap: 4px;
    height: 82px;
    padding: 8px 0;
}

.sg-brand-link {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
}

.sg-brand-logo {
    width: 32px;
    height: 32px;
    object-fit: contain;
    flex-shrink: 0;
}

.sg-brand-text {
    font-size: 15px;
    font-weight: 800;
    color: var(--primary);
    letter-spacing: -.3px;
    white-space: nowrap;
}

.sg-brand-compact {
    display: none;
    width: 28px;
    height: 28px;
    object-fit: contain;
    flex-shrink: 0;
}

.sg-sidebar.collapsed .sg-brand-text    { display: none; }
.sg-sidebar.collapsed .sg-brand-compact { display: block; }
.sg-sidebar.collapsed .sg-brand-link {
    justify-content: center;
    gap: 0;
    width: 100%;
}
.sg-sidebar.collapsed .sg-brand-logo { display: none; }

.sg-sidebar-collapse-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--muted);
    padding: 6px;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background .15s, color .15s;
    flex-shrink: 0;
}
.sg-sidebar-collapse-btn:hover { background: var(--primary-light); color: var(--primary); }
.sg-sidebar-collapse-btn svg {
    width: 18px;
    height: 18px;
}
.sg-sidebar-collapse-btn .collapse-open { display: none; }
.sg-sidebar.collapsed .sg-sidebar-collapse-btn .collapse-close { display: none; }
.sg-sidebar.collapsed .sg-sidebar-collapse-btn .collapse-open  { display: block; }
.sg-sidebar.collapsed .sg-sidebar-collapse-btn {
    width: 32px;
    height: 30px;
    padding: 0;
}

.sg-nav {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 8px 0;
}

.sg-nav-section {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--muted);
    padding: 16px 16px 4px;
    white-space: nowrap;
    overflow: hidden;
}

.sg-sidebar.collapsed .sg-nav-section { visibility: hidden; height: 24px; }

.sg-nav a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 14px;
    color: var(--text);
    font-size: 13.5px;
    font-weight: 500;
    border-radius: 0;
    text-decoration: none;
    transition: background .14s, color .14s;
    white-space: nowrap;
    overflow: hidden;
    margin: 1px 8px;
    border-radius: var(--radius);
}

.sg-nav a:hover { background: var(--primary-light); color: var(--primary); }
.sg-nav a.active {
    background: var(--primary-light);
    color: var(--primary);
    font-weight: 600;
}
.sg-nav a.active .nav-icon { color: var(--primary); }

.nav-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    color: var(--muted);
}
.sg-nav a:hover .nav-icon,
.sg-nav a.active .nav-icon { color: var(--primary); }

.nav-label { flex: 1; }
.sg-sidebar.collapsed .nav-label { display: none; }
.sg-sidebar.collapsed .sg-nav a { justify-content: center; padding: 9px; }
.sg-sidebar.collapsed .sg-nav a { margin: 1px 6px; }

.sg-sidebar-footer {
    padding: 10px 14px;
    border-top: 1px solid var(--border);
    font-size: 11px;
    color: var(--muted);
    display: flex;
    align-items: center;
    gap: 8px;
}
.sg-sidebar.collapsed .sg-sidebar-footer .sg-sf-text { display: none; }

.sg-main {
    flex: 1;
    margin-left: var(--sidebar-w);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    transition: margin-left .22s ease;
}

.sg-sidebar.collapsed ~ .sg-main { margin-left: var(--sidebar-c); }

.sg-topbar {
    height: var(--topbar-h);
    background: var(--card);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 20px;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow);
}

.sg-topbar-right {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-left: auto;
}

.sg-mobile-menu-btn {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--muted);
    padding: 6px;
    border-radius: var(--radius);
}

.sg-user-badge {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    line-height: 1.2;
}

.sg-user-badge-link {
    padding: 5px 8px;
    border-radius: var(--radius);
    text-decoration: none;
    transition: background .14s, color .14s;
}

.sg-user-badge-link:hover {
    background: var(--primary-light);
    color: var(--primary);
    text-decoration: none;
}

.sg-user-badge-link svg {
    width: 18px;
    height: 18px;
    color: var(--muted);
}

.sg-user-badge-link:hover svg {
    color: var(--primary);
}

.sg-user-badge-copy {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

.sg-btn-logout {
    background: none;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    color: var(--muted);
    font-size: 12px;
    padding: 5px 12px;
    font-family: var(--font);
    transition: background .14s, color .14s;
}
.sg-btn-logout:hover { background: var(--red-light); color: var(--red); border-color: var(--red); }

.sg-btn-logout svg {
    width: 14px;
    height: 14px;
}

.sg-content {
    flex: 1;
    padding: 24px;
    max-width: 1400px;
    width: 100%;
}

.sg-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 24px;
    border-top: 1px solid var(--border);
    background: var(--card);
    font-size: 11px;
    color: var(--muted);
}

.sg-footer__right {
    display: flex;
    align-items: center;
    gap: 6px;
}

.sg-footer__logo {
    height: 16px;
    width: auto;
    opacity: .7;
    transition: opacity .15s;
}
.sg-footer__logo:hover { opacity: 1; }

.sg-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px;
    box-shadow: var(--shadow);
}

.sg-card-title {
    font-size: 14px;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 4px;
}

.sg-card-subtitle {
    font-size: 12px;
    color: var(--muted);
    margin-bottom: 16px;
}

.sg-modules-panel {
    max-width: 980px;
}

.sg-module-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}

.sg-module-grid--norms {
    grid-template-columns: 1fr;
}

.sg-module-item {
    display: grid;
    grid-template-columns: 38px minmax(0, 1fr) auto;
    align-items: center;
    gap: 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px;
    min-height: 78px;
    background: #fff;
}

.sg-module-item--norms {
    align-items: flex-start;
}

.sg-module-icon {
    width: 38px;
    height: 38px;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--primary-light);
    color: var(--primary);
}

.sg-module-icon svg {
    width: 19px;
    height: 19px;
}

.sg-module-copy {
    min-width: 0;
}

.sg-module-name {
    font-size: 13px;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 3px;
}

.sg-module-desc {
    font-size: 12px;
    color: var(--muted);
    line-height: 1.35;
}

.sg-norm-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 8px;
}

.sg-norm-chip {
    display: inline-flex;
    align-items: center;
    min-height: 24px;
    padding: 3px 8px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg);
    color: var(--text);
    font-size: 11px;
    font-weight: 600;
    line-height: 1.2;
}

.sg-module-action {
    display: flex;
    justify-content: flex-end;
}

.sg-test-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
    max-width: 980px;
}

.sg-check-row {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--text);
}

.sg-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: var(--radius);
    border: none;
    font-size: 13px;
    font-weight: 600;
    font-family: var(--font);
    cursor: pointer;
    transition: background .14s, transform .1s;
    text-decoration: none;
}
.sg-btn:active { transform: scale(.97); }
.sg-btn:disabled,
.sg-btn.loading {
    opacity: .68;
    cursor: wait;
    transform: none;
}

.sg-btn-primary {
    background: var(--primary);
    color: #fff;
}
.sg-btn-primary:hover { background: var(--primary-dark); color: #fff; text-decoration: none; }

.sg-btn-secondary {
    background: var(--bg);
    color: var(--text);
    border: 1px solid var(--border);
}
.sg-btn-secondary:hover { background: var(--border); }

.sg-btn-danger {
    background: var(--red);
    color: #fff;
}
.sg-btn-danger:hover { background: #b91c1c; }

.sg-btn-sm { padding: 5px 10px; font-size: 12px; }

.sg-form-group { margin-bottom: 16px; }

.sg-label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 5px;
}

.sg-input,
.sg-select,
.sg-textarea {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 13px;
    font-family: var(--font);
    color: var(--text);
    background: var(--card);
    transition: border-color .14s, box-shadow .14s;
    outline: none;
}

.sg-input:focus,
.sg-select:focus,
.sg-textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(240,120,32,.12);
}

.sg-input::placeholder { color: var(--muted); }
.sg-textarea { resize: vertical; min-height: 80px; }

.sg-table-wrap { overflow-x: auto; border-radius: var(--radius-lg); }

.sg-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.sg-table thead th {
    background: var(--bg);
    color: var(--muted);
    font-weight: 700;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .06em;
    padding: 10px 14px;
    text-align: left;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

.sg-table tbody td {
    padding: 11px 14px;
    border-bottom: 1px solid var(--border);
    color: var(--text);
    vertical-align: middle;
}

.sg-table tbody tr:last-child td { border-bottom: none; }
.sg-table tbody tr:hover td { background: var(--primary-light); }

.sg-badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
}

.sg-badge-primary  { background: var(--primary-light); color: var(--primary); }
.sg-badge-success  { background: var(--green-light);   color: var(--green); }
.sg-badge-warning  { background: var(--yellow-light);  color: #92400e; }
.sg-badge-danger   { background: var(--red-light);     color: var(--red); }
.sg-badge-muted    { background: var(--bg);            color: var(--muted); }
.sg-badge-cyan     { background: #e0fafa;              color: var(--cyan); }
.sg-badge-magenta  { background: #fce7f3;              color: var(--magenta); }

.sg-flash {
    padding: 12px 16px;
    border-radius: var(--radius);
    font-size: 13px;
    font-weight: 500;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.sg-flash-success { background: var(--green-light);  color: var(--green);  border-left: 3px solid var(--green); }
.sg-flash-error   { background: var(--red-light);    color: var(--red);    border-left: 3px solid var(--red); }
.sg-flash-info    { background: var(--primary-light); color: var(--primary); border-left: 3px solid var(--primary); }

.sg-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.sg-stat {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 18px 20px;
    box-shadow: var(--shadow);
}

.sg-stat__label {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--muted);
    margin-bottom: 6px;
}

.sg-stat__value {
    font-size: 26px;
    font-weight: 800;
    color: var(--text);
    line-height: 1;
}

.sg-stat__sub {
    font-size: 11px;
    color: var(--muted);
    margin-top: 4px;
}

.sg-stat--primary { border-top: 3px solid var(--primary); }
.sg-stat--green   { border-top: 3px solid var(--green); }
.sg-stat--yellow  { border-top: 3px solid var(--yellow); }
.sg-stat--cyan    { border-top: 3px solid var(--cyan); }
.sg-stat--magenta { border-top: 3px solid var(--magenta); }

.sg-norm-calidad    { color: var(--primary); }
.sg-norm-sst        { color: var(--green); }
.sg-norm-ambiente   { color: #059669; }
.sg-norm-seginfo    { color: var(--cyan); }
.sg-norm-continuidad{ color: var(--magenta); }
.sg-norm-energia    { color: var(--yellow); }
.sg-norm-inocuidad  { color: #0284c7; }
.sg-norm-activos    { color: #7c3aed; }
.sg-norm-antisoborn { color: #dc2626; }
.sg-norm-vial       { color: #ea580c; }

.sg-topbar-icon-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    width: 36px;
    height: 36px;
    border-radius: var(--radius);
    border: none;
    background: none;
    cursor: pointer;
    color: var(--muted);
    text-decoration: none;
    transition: background .14s, color .14s;
    flex-shrink: 0;
}
.sg-topbar-icon-btn:hover { background: var(--primary-light); color: var(--primary); text-decoration: none; }
.sg-topbar-icon-btn.active { background: var(--green-light); color: var(--green); }
.sg-topbar-icon-btn svg  { width: 18px; height: 18px; }

.sg-notif-btn { position: relative; }
#sg-notif-badge {
    position: absolute;
    top: 2px; right: 2px;
    background: var(--red);
    color: #fff;
    font-size: 9px;
    font-weight: 700;
    min-width: 16px;
    height: 16px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 3px;
    line-height: 1;
}

.sg-body-auth {
    background: #0f1117;
    margin: 0;
    overflow: hidden;
    height: 100vh;
}

.sg-login-split {
    display: grid;
    grid-template-columns: 1fr 460px;
    height: 100vh;
    overflow: hidden;
}

.sg-login-brand {
    position: relative;
    background: linear-gradient(135deg, #0f1117 0%, #1a1f2e 60%, #0f1117 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    padding: 48px;
}

.sg-login-brand__inner {
    position: relative;
    z-index: 2;
    max-width: 500px;
}

.sg-login-brand__logo {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 48px;
}

.sg-login-brand__logo img {
    width: 52px;
    height: 52px;
    object-fit: contain;
}

.sg-login-brand__name {
    font-size: 22px;
    font-weight: 800;
    color: #ffffff;
    letter-spacing: .5px;
}

.sg-login-brand__headline {
    font-size: 38px;
    font-weight: 800;
    color: #ffffff;
    line-height: 1.2;
    margin-bottom: 18px;
    letter-spacing: -.5px;
}

.sg-login-brand__headline em {
    color: var(--primary);
    font-style: normal;
}

.sg-login-brand__sub {
    font-size: 15px;
    color: rgba(255,255,255,.52);
    line-height: 1.7;
    margin-bottom: 44px;
}

.sg-login-brand__norms {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.sg-login-norm {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: rgba(255,255,255,.06);
    border: 1px solid rgba(255,255,255,.1);
    border-radius: 20px;
    padding: 4px 10px 4px 8px;
    backdrop-filter: blur(4px);
    transition: background .2s;
}

.sg-login-norm:hover {
    background: rgba(255,255,255,.1);
}

.sg-login-norm__dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--norm-color, var(--primary));
    flex-shrink: 0;
}

.sg-login-norm__code {
    font-size: 11px;
    font-weight: 700;
    color: #fff;
    letter-spacing: .3px;
}

.sg-login-norm__label {
    font-size: 10px;
    color: rgba(255,255,255,.45);
}

.sg-login-brand__deco {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 1;
}

.sg-login-brand__deco span {
    position: absolute;
    display: block;
    border-radius: 50%;
    filter: blur(40px);
}

.sg-login-form-panel {
    background: var(--card);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    position: relative;
}

.sg-login-form-wrap {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 32px 44px 24px;
    min-height: 0;
}

.sg-login-form__header {
    margin-bottom: 22px;
    text-align: center;
}

.sg-login-form__icon {
    width: 52px;
    height: 52px;
    background: var(--primary-light);
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 12px;
    color: var(--primary);
}

.sg-login-form__icon svg {
    width: 24px;
    height: 24px;
}

.sg-login-form__title {
    font-size: 22px;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 6px;
}

.sg-login-form__sub {
    font-size: 13px;
    color: var(--muted);
}

.sg-login-field {
    margin-bottom: 13px;
}

.sg-login-label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    font-weight: 600;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: .6px;
    margin-bottom: 7px;
}

.sg-login-label__icon {
    width: 13px;
    height: 13px;
    display: inline-flex;
}

.sg-login-label__icon svg {
    width: 13px;
    height: 13px;
}

.sg-login-input-wrap {
    position: relative;
}

.sg-login-input {
    width: 100%;
    padding: 11px 14px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    font-family: var(--font);
    font-size: 14px;
    color: var(--text);
    background: var(--bg);
    transition: border-color .18s, box-shadow .18s;
    outline: none;
    display: block;
}

.sg-login-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(240,120,32,.12);
    background: #fff;
}

.sg-login-input::placeholder { color: #c4c9d4; }

.sg-login-input-wrap--pwd .sg-login-input {
    padding-right: 44px;
}

.sg-login-pwd-toggle {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    cursor: pointer;
    color: var(--muted);
    display: flex;
    align-items: center;
    padding: 4px;
    border-radius: 4px;
    transition: color .15s;
}

.sg-login-pwd-toggle:hover { color: var(--primary); }
.sg-login-pwd-toggle svg   { width: 16px; height: 16px; }

.sg-field-error {
    display: block;
    font-size: 11px;
    color: var(--red);
    margin-top: 4px;
}

.sg-login-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    gap: 8px;
}

.sg-login-check {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    user-select: none;
}

.sg-login-check__input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.sg-login-check__box {
    width: 17px;
    height: 17px;
    border: 1.5px solid var(--border);
    border-radius: 4px;
    background: var(--bg);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all .15s;
}

.sg-login-check__input:checked ~ .sg-login-check__box {
    background: var(--primary);
    border-color: var(--primary);
}

.sg-login-check__input:checked ~ .sg-login-check__box::after {
    content: '';
    width: 9px;
    height: 5px;
    border-left: 2px solid #fff;
    border-bottom: 2px solid #fff;
    transform: rotate(-45deg) translateY(-1px);
    display: block;
}

.sg-login-check__label {
    font-size: 13px;
    color: var(--muted);
}

.sg-login-forgot {
    font-size: 12px;
    color: var(--primary);
    text-decoration: none;
    font-weight: 500;
    white-space: nowrap;
}

.sg-login-forgot:hover {
    color: var(--primary-dark);
    text-decoration: underline;
}

.sg-login-btn {
    width: 100%;
    padding: 13px;
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: var(--radius);
    font-family: var(--font);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: background .18s, transform .12s, box-shadow .18s;
    letter-spacing: .2px;
    position: relative;
    overflow: hidden;
    margin-bottom: 14px;
}

.sg-login-btn::before {
    content: 'Ingresar al sistema';
}

.sg-login-btn:hover {
    background: var(--primary-dark);
    box-shadow: 0 4px 14px rgba(240,120,32,.35);
    transform: translateY(-1px);
}

.sg-login-btn:active { transform: translateY(0); }

.sg-login-btn.loading::before { content: ''; }
.sg-login-btn.loading::after  {
    content: '';
    width: 18px;
    height: 18px;
    border: 2.5px solid rgba(255,255,255,.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: sg-spin .7s linear infinite;
}

@keyframes sg-spin { to { transform: rotate(360deg); } }

.sg-spin { animation: sg-spin .8s linear infinite; }

.sg-login-divider {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
    color: var(--muted);
    font-size: 12px;
}

.sg-login-divider span {
    flex: 1;
    height: 1px;
    background: var(--border);
}

.sg-login-passkey-btn {
    width: 100%;
    padding: 11px;
    background: transparent;
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    font-family: var(--font);
    font-size: 13px;
    font-weight: 500;
    color: var(--text);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: border-color .18s, background .18s, color .18s;
}

.sg-login-passkey-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: var(--primary-light);
}

.sg-login-passkey-btn svg { width: 17px; height: 17px; }

.sg-login-footer {
    padding: 12px 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    font-size: 12px;
    color: var(--muted);
    border-top: 1px solid var(--border);
    flex-shrink: 0;
}

.sg-login-footer a { display: flex; align-items: center; }

.sg-login-footer img { height: 20px !important; width: auto; }

@media (max-width: 860px) {
    .sg-login-split {
        grid-template-columns: 1fr;
        height: auto;
        min-height: 100vh;
    }

    .sg-login-brand {
        display: none;
    }

    .sg-body-auth {
        background: var(--bg);
        height: auto;
        overflow: auto;
    }

    .sg-login-form-panel {
        min-height: 100vh;
    }

    .sg-login-form-wrap {
        padding: 40px 28px 24px;
    }
}

.sg-page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 24px;
    flex-wrap: wrap;
}

.sg-page-title {
    font-size: 20px;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 2px;
}

.sg-page-sub {
    font-size: 13px;
    color: var(--muted);
}

.sg-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    margin-bottom: 20px;
    overflow: hidden;
}

.sg-card-header {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 18px 22px;
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
}

.sg-card-header__icon {
    width: 40px;
    height: 40px;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.sg-card-header__icon svg { width: 20px; height: 20px; }

.sg-card-header__title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
}

.sg-card-header__sub {
    font-size: 12px;
    color: var(--muted);
    margin-top: 1px;
}

.sg-card-body { padding: 22px; }

.sg-badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: .3px;
}

.sg-badge-primary { background: var(--primary-light); color: var(--primary); }
.sg-badge-green   { background: var(--green-light);   color: var(--green); }
.sg-badge-red     { background: var(--red-light);     color: var(--red); }
.sg-badge-muted   { background: var(--bg);            color: var(--muted); border: 1px solid var(--border); }

.sg-table-wrap { overflow-x: auto; }

.sg-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.sg-table th {
    text-align: left;
    padding: 10px 14px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .5px;
    color: var(--muted);
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

.sg-table td {
    padding: 11px 14px;
    border-bottom: 1px solid var(--border);
    color: var(--text);
    vertical-align: middle;
}

.sg-table tbody tr:last-child td { border-bottom: none; }
.sg-table tbody tr:hover td { background: var(--bg); }

.sg-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: var(--radius);
    font-family: var(--font);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    border: none;
    transition: background .15s, color .15s, border-color .15s, box-shadow .15s;
    text-decoration: none;
    white-space: nowrap;
}

.sg-btn svg { width: 15px; height: 15px; flex-shrink: 0; }

.sg-btn-primary {
    background: var(--primary);
    color: #fff;
}
.sg-btn-primary:hover {
    background: var(--primary-dark);
    color: #fff;
    text-decoration: none;
    box-shadow: 0 3px 10px rgba(240,120,32,.3);
}

.sg-btn-outline {
    background: transparent;
    color: var(--text);
    border: 1.5px solid var(--border);
}
.sg-btn-outline:hover {
    border-color: var(--primary);
    color: var(--primary);
    text-decoration: none;
}

.sg-btn-ghost {
    background: transparent;
    color: var(--muted);
    border: none;
}
.sg-btn-ghost:hover { color: var(--red); background: var(--red-light); text-decoration: none; }

.sg-btn-danger {
    background: var(--red-light);
    color: var(--red);
    border: 1.5px solid transparent;
}
.sg-btn-danger:hover { background: var(--red); color: #fff; text-decoration: none; }

.sg-btn-sm { padding: 5px 10px; font-size: 12px; }
.sg-btn-sm svg { width: 13px; height: 13px; }

.sg-btn-logout {
    background: none;
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-family: var(--font);
    font-size: 12px;
    font-weight: 500;
    color: var(--muted);
    cursor: pointer;
    padding: 5px 12px;
    transition: color .15s, border-color .15s;
}
.sg-btn-logout:hover { color: var(--red); border-color: var(--red); }

.sg-form-group { margin-bottom: 14px; }

.sg-label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: .5px;
    margin-bottom: 6px;
}

.sg-input {
    width: 100%;
    padding: 9px 12px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    font-family: var(--font);
    font-size: 13px;
    color: var(--text);
    background: var(--bg);
    outline: none;
    transition: border-color .15s, box-shadow .15s;
    display: block;
}

.sg-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(240,120,32,.1);
    background: #fff;
}

.sg-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 48px 24px;
    color: var(--muted);
    text-align: center;
    gap: 8px;
    font-size: 13px;
}

.sg-perfil-grid { display: flex; flex-direction: column; gap: 0; }

.sg-avatar-form {
    display: grid;
    grid-template-columns: 76px minmax(0, 1fr);
    gap: 16px;
    align-items: center;
    margin-bottom: 18px;
    padding-bottom: 18px;
    border-bottom: 1px solid var(--border);
}
.sg-avatar-preview {
    width: 76px;
    height: 76px;
    border-radius: 50%;
    background: var(--primary-light);
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 20px;
    overflow: hidden;
}
.sg-avatar-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.sg-avatar-fields { min-width: 0; }
.sg-avatar-actions {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 10px;
    align-items: center;
}
.sg-help-text {
    margin-top: 6px;
    font-size: 11px;
    color: var(--muted);
}

.sg-perfil-info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 20px;
}

.sg-perfil-info-item { display: flex; flex-direction: column; gap: 4px; }
.sg-perfil-info-label { font-size: 11px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; }
.sg-perfil-info-value { font-size: 14px; color: var(--text); font-weight: 500; }

.sg-perfil-pwd-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 14px;
}

.sg-notif-list { list-style: none; }

.sg-notif-item {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    padding: 16px 22px;
    border-bottom: 1px solid var(--border);
    transition: background .15s;
}

.sg-notif-item:last-child { border-bottom: none; }
.sg-notif-item:hover { background: var(--bg); }

.sg-notif-item--unread { background: var(--primary-light); }
.sg-notif-item--unread:hover { background: #fde8d4; }

.sg-notif-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--border);
    flex-shrink: 0;
    margin-top: 5px;
}

.sg-notif-item--unread .sg-notif-dot { background: var(--primary); }

.sg-notif-body { flex: 1; min-width: 0; }
.sg-notif-title { font-size: 13px; font-weight: 600; color: var(--text); margin-bottom: 2px; }
.sg-notif-msg   { font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.sg-notif-time  { display: flex; align-items: center; gap: 4px; font-size: 11px; color: var(--muted); }

.sg-notif-actions { display: flex; gap: 6px; flex-shrink: 0; align-items: flex-start; }

.sg-flash {
    padding: 12px 16px;
    border-radius: var(--radius);
    margin-bottom: 18px;
    font-size: 13px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 8px;
}

.sg-flash-success { background: var(--green-light); color: var(--green); border: 1px solid #bbf7d0; }
.sg-flash-error   { background: var(--red-light);   color: var(--red);   border: 1px solid #fecaca; }
.sg-flash-info    { background: #EFF6FF;             color: #3B82F6;      border: 1px solid #bfdbfe; }

.sg-rbac-roles-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 16px;
    margin-bottom: 20px;
}

.sg-rbac-role-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.sg-rbac-role-card__header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
}

.sg-rbac-role-card__icon {
    width: 36px;
    height: 36px;
    border-radius: var(--radius);
    background: rgba(255,255,255,.6);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.sg-rbac-role-card__icon svg { width: 18px; height: 18px; }

.sg-rbac-role-card__name {
    font-size: 13px;
    font-weight: 700;
    color: var(--text);
}

.sg-rbac-role-card__desc {
    font-size: 11px;
    color: var(--muted);
    margin-top: 1px;
}

.sg-rbac-role-card__body {
    padding: 12px 16px 14px;
    border-top: 1px solid var(--border);
}

.sg-rbac-role-card__stat {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 11px;
    color: var(--muted);
    margin-bottom: 10px;
}

.sg-rbac-role-card__perms {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
}

.sg-rbac-perm-chip {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 10px;
    font-weight: 500;
    color: var(--muted);
    font-family: 'Courier New', monospace;
    letter-spacing: .2px;
}

.sg-rbac-perm-chip--more {
    background: var(--primary-light);
    border-color: var(--primary);
    color: var(--primary);
}

.sg-rbac-perms-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 20px;
}

.sg-rbac-perm-group__title {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    font-weight: 700;
    color: var(--text);
    text-transform: uppercase;
    letter-spacing: .6px;
    margin-bottom: 10px;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--border);
}

.sg-rbac-perm-row {
    display: flex;
    flex-direction: column;
    gap: 3px;
    margin-bottom: 8px;
}

.sg-dialog {
    position: fixed;
    inset: 0;
    z-index: 12000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.sg-dialog.visible {
    display: flex;
}

.sg-dialog__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(17, 24, 39, .58);
    backdrop-filter: blur(4px);
}

.sg-dialog__box {
    position: relative;
    width: min(92vw, 420px);
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    padding: 22px;
}

.sg-dialog__icon {
    width: 42px;
    height: 42px;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--primary-light);
    color: var(--primary);
    margin-bottom: 14px;
}

.sg-dialog__icon svg {
    width: 22px;
    height: 22px;
}

.sg-dialog__title {
    font-size: 16px;
    font-weight: 800;
    color: var(--text);
    margin-bottom: 6px;
}

.sg-dialog__message {
    font-size: 13px;
    color: var(--muted);
    line-height: 1.5;
}

.sg-dialog__actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 20px;
}

#sg-lock-screen {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: rgba(10,10,10,.92);
    backdrop-filter: blur(6px);
    align-items: center;
    justify-content: center;
}

.sg-lock-box {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 36px;
    width: 100%;
    max-width: 360px;
    text-align: center;
    box-shadow: var(--shadow-md);
}

.sg-lock-icon {
    width: 44px;
    height: 44px;
    margin: 0 auto 12px;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--primary-light);
    color: var(--primary);
}

.sg-lock-icon svg {
    width: 24px;
    height: 24px;
}

.sg-mobile-quicknav {
    display: none;
    position: fixed;
    bottom: 0; left: 0; right: 0;
    background: var(--card);
    border-top: 1px solid var(--border);
    justify-content: space-around;
    padding: 4px 0 env(safe-area-inset-bottom, 0);
    z-index: 300;
}

.sg-mobile-quicknav a {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 8px 12px;
    font-size: 10px;
    font-weight: 600;
    color: var(--muted);
    text-decoration: none;
    min-width: 44px;
    min-height: 44px;
}
.sg-mobile-quicknav a.active,
.sg-mobile-quicknav a:hover { color: var(--primary); }
.sg-mobile-quicknav a .quick-icon { width: 22px; height: 22px; }

.sg-sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.4);
    z-index: 199;
}

@media (max-width: 768px) {
    .sg-sidebar {
        transform: translateX(-100%);
        width: var(--sidebar-w);
    }

    .sg-sidebar.collapsed {
        width: var(--sidebar-w);
    }

    .sg-sidebar.collapsed .sg-sidebar-logo {
        flex-direction: row;
        justify-content: space-between;
        gap: 10px;
        height: var(--topbar-h);
        padding: 0 14px;
    }

    .sg-sidebar.collapsed .sg-brand-logo { display: block; }
    .sg-sidebar.collapsed .sg-brand-text { display: block; }
    .sg-sidebar.collapsed .sg-brand-compact { display: none; }
    .sg-sidebar.collapsed .nav-label { display: inline; }
    .sg-sidebar.collapsed .sg-nav a { justify-content: flex-start; padding: 9px 12px; margin: 1px 10px; }
    .sg-sidebar.collapsed .sg-nav-section { visibility: visible; height: auto; }

    .sg-sidebar.mobile-open {
        transform: translateX(0);
    }

    .sg-sidebar-backdrop.visible { display: block; }

    .sg-main { margin-left: 0 !important; padding-bottom: 60px; }

    .sg-mobile-menu-btn { display: flex; }

    .sg-mobile-quicknav { display: flex; }

    .sg-content { padding: 16px; }

    .sg-stats { grid-template-columns: repeat(2, 1fr); }

    .sg-module-grid {
        grid-template-columns: 1fr;
    }

    .sg-module-item {
        grid-template-columns: 34px minmax(0, 1fr);
    }

    .sg-module-action {
        grid-column: 2;
        justify-content: flex-start;
    }

    .sg-test-grid {
        grid-template-columns: 1fr;
    }

    .sg-avatar-form {
        grid-template-columns: 1fr;
        justify-items: flex-start;
    }

    .sg-avatar-actions {
        grid-template-columns: 1fr;
    }

    .sg-table-wrap { border-radius: 0; }
}

@media (max-width: 480px) {
    .sg-stats { grid-template-columns: 1fr; }
    .sg-auth-box { padding: 24px 20px; }
}

.sg-btn[data-download-loader] {
    min-width: 118px;
}

.sg-btn[data-download-loader].loading {
    pointer-events: none;
    opacity: .75;
}
