/* SIMDATADIK v1.8.4 — Unified Design System
   Shared tokens and application-shell normalization for every active module. */

:root {
    color-scheme: light;
    --sd-color-canvas: #f3f6fa;
    --sd-color-surface: #ffffff;
    --sd-color-surface-muted: #f7f9fc;
    --sd-color-surface-accent: #edf5ff;
    --sd-color-text: #172b43;
    --sd-color-text-muted: #667b91;
    --sd-color-border: #dce5ef;
    --sd-color-border-strong: #c4d2e1;
    --sd-color-primary: #175ea8;
    --sd-color-primary-hover: #124c89;
    --sd-color-primary-soft: #e7f1fc;
    --sd-color-accent: #087f8c;
    --sd-color-success: #147a4b;
    --sd-color-warning: #a85f00;
    --sd-color-danger: #b4232c;
    --sd-space-1: .25rem;
    --sd-space-2: .5rem;
    --sd-space-3: .75rem;
    --sd-space-4: 1rem;
    --sd-space-5: 1.25rem;
    --sd-space-6: 1.5rem;
    --sd-space-8: 2rem;
    --sd-radius-sm: .45rem;
    --sd-radius-md: .7rem;
    --sd-radius-lg: 1rem;
    --sd-radius-xl: 1.25rem;
    --sd-shadow-xs: 0 1px 2px rgba(16, 42, 67, .05);
    --sd-shadow-sm: 0 7px 22px rgba(16, 42, 67, .07);
    --sd-shadow-md: 0 18px 45px rgba(16, 42, 67, .11);
    --sd-focus-ring: 0 0 0 3px rgba(23, 94, 168, .2);
    --sd-shell-header: 68px;
    --sd-shell-sidebar: 286px;
    --sd-motion-fast: 150ms ease;
    --sd-motion-base: 220ms ease;
}

html { scroll-behavior: smooth; }
body {
    min-width: 320px;
    background:
        radial-gradient(circle at 100% 0, rgba(23, 94, 168, .055), transparent 27rem),
        var(--sd-color-canvas);
    color: var(--sd-color-text);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

body.sd-nav-open { overflow: hidden; }
a { text-underline-offset: .18em; }
:where(a, button, input, select, textarea, [tabindex]):focus-visible {
    outline: 2px solid var(--sd-color-primary);
    outline-offset: 2px;
    box-shadow: var(--sd-focus-ring);
}

.skip-link {
    position: fixed;
    inset: 10px auto auto 10px;
    z-index: 3000;
    transform: translateY(-150%);
    padding: 10px 14px;
    border-radius: var(--sd-radius-md);
    background: var(--sd-color-text);
    color: #fff;
    font-weight: 750;
}
.skip-link:focus { transform: translateY(0); }

.app-header {
    min-height: var(--sd-shell-header);
    border-bottom: 1px solid rgba(196, 210, 225, .88);
    background: rgba(255, 255, 255, .92);
    box-shadow: var(--sd-shadow-xs);
}
.app-header-inner { min-height: var(--sd-shell-header); max-width: 1600px; padding: 10px 24px; }
.brand-logo,
.main-sidebar-brand-badge {
    border-radius: 13px;
    background: linear-gradient(145deg, #1b68b5, #0b7582);
    box-shadow: 0 8px 20px rgba(20, 91, 158, .2);
}
.brand-title { letter-spacing: -.02em; }
.brand-subtitle { font-size: .78rem; }
.header-user { padding: 6px 10px; border: 1px solid var(--sd-color-border); border-radius: var(--sd-radius-lg); background: var(--sd-color-surface-muted); }
.avatar-initial { border: 1px solid #bfd6ef; background: var(--sd-color-primary-soft); }
.sidebar-toggle-btn { display: inline-flex; border-radius: var(--sd-radius-md); box-shadow: none; }

.app-main { padding: 20px 24px 30px; }
.app-main-inner { max-width: 1600px; }
.layout-with-sidebar { grid-template-columns: var(--sd-shell-sidebar) minmax(0, 1fr); gap: 22px; transition: grid-template-columns var(--sd-motion-base); }

.main-sidebar {
    top: calc(var(--sd-shell-header) + 16px);
    min-height: calc(100vh - var(--sd-shell-header) - 36px);
    border: 1px solid rgba(255,255,255,.1);
    border-radius: var(--sd-radius-xl);
    background: linear-gradient(180deg, #123e70 0%, #174f88 58%, #0d5965 125%);
    box-shadow: 0 18px 42px rgba(16, 56, 96, .2);
    transition: opacity var(--sd-motion-base), transform var(--sd-motion-base), visibility var(--sd-motion-base);
}
.main-sidebar-header { padding: 18px 17px 15px; }
.main-sidebar-scroll { scrollbar-color: rgba(255,255,255,.34) transparent; }
.main-sidebar-section-title { color: rgba(255,255,255,.64); font-size: .68rem; letter-spacing: .11em; }
.main-sidebar-dropdown { margin-bottom: 5px; }
.main-sidebar-dropdown-toggle {
    min-height: 44px;
    border: 1px solid transparent;
    border-radius: var(--sd-radius-md);
    font-size: .84rem;
    transition: background var(--sd-motion-fast), border-color var(--sd-motion-fast);
}
.main-sidebar-dropdown-toggle:hover,
.main-sidebar-dropdown-toggle.active { border-color: rgba(255,255,255,.1); background: rgba(255,255,255,.13); }
.main-sidebar-dropdown-caret { font-size: .62rem; }
.main-sidebar-sublink {
    min-height: 38px;
    margin: 2px 0 2px 35px;
    border-radius: var(--sd-radius-sm);
    color: rgba(255,255,255,.79);
    font-size: .79rem;
}
.main-sidebar-sublink.active { color: #0d477e; background: #fff; box-shadow: 0 5px 14px rgba(2,31,61,.16); }
.main-sidebar-footer { background: rgba(0,0,0,.08); }

body[data-sidebar-collapsed="true"] .layout-with-sidebar { grid-template-columns: 0 minmax(0, 1fr); gap: 0; }
body[data-sidebar-collapsed="true"] .main-sidebar { visibility: hidden; opacity: 0; transform: translateX(-18px); pointer-events: none; }

.page-card,
.page-content { min-width: 0; }
.sd-shell-context {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    min-height: 42px;
    margin-bottom: 14px;
    padding: 8px 12px;
    border: 1px solid var(--sd-color-border);
    border-radius: var(--sd-radius-lg);
    background: rgba(255,255,255,.74);
    color: var(--sd-color-text-muted);
    font-size: .76rem;
    backdrop-filter: blur(8px);
}
.sd-shell-context strong { color: var(--sd-color-text); }
.sd-shell-context-group { display: inline-flex; align-items: center; gap: 8px; min-width: 0; }
.sd-shell-context-dot { width: 7px; height: 7px; border-radius: 50%; background: #27a36b; box-shadow: 0 0 0 3px rgba(39,163,107,.13); }

.btn,
button.btn {
    min-height: 38px;
    border-radius: var(--sd-radius-md);
    padding: 8px 14px;
    font-weight: 720;
    letter-spacing: -.005em;
    box-shadow: var(--sd-shadow-xs);
    transition: transform var(--sd-motion-fast), box-shadow var(--sd-motion-fast), background var(--sd-motion-fast), border-color var(--sd-motion-fast);
}
.btn:hover { transform: translateY(-1px); box-shadow: var(--sd-shadow-sm); }
.btn:active { transform: translateY(0); }
.btn-primary { background: var(--sd-color-primary); border-color: var(--sd-color-primary); }
.btn-primary:hover { background: var(--sd-color-primary-hover); border-color: var(--sd-color-primary-hover); }
.btn-outline,
.btn-default,
.btn-outline-secondary { border-color: var(--sd-color-border-strong); background: var(--sd-color-surface); }
.btn-sm { min-height: 32px; padding: 6px 10px; }

:where(.card,.sd-card) {
    border-color: var(--sd-color-border);
    border-radius: var(--sd-radius-lg);
    box-shadow: var(--sd-shadow-sm);
}
:where(.card-header,.sd-card-header) { border-bottom-color: var(--sd-color-border); background: var(--sd-color-surface); }
:where(.card-footer,.sd-card-footer) { border-top-color: var(--sd-color-border); background: var(--sd-color-surface-muted); }
.sd-page-header { border-color: var(--sd-color-border); border-radius: var(--sd-radius-xl); box-shadow: var(--sd-shadow-sm); }
.sd-page-title { color: var(--sd-color-text); letter-spacing: -.025em; }
.sd-page-subtitle { color: var(--sd-color-text-muted); }
.sd-page-icon,.sd-metric-icon { border-radius: var(--sd-radius-md); }
.sd-metric-card { border-color: var(--sd-color-border); border-radius: var(--sd-radius-lg); box-shadow: var(--sd-shadow-sm); }

:where(.form-control, input[type="text"], input[type="email"], input[type="password"], input[type="number"], input[type="date"], input[type="time"], input[type="datetime-local"], input[type="search"], input[type="url"], input[type="file"], select, textarea) {
    min-height: 42px;
    border: 1px solid var(--sd-color-border-strong);
    border-radius: var(--sd-radius-md);
    background: var(--sd-color-surface);
    color: var(--sd-color-text);
    font: inherit;
    transition: border-color var(--sd-motion-fast), box-shadow var(--sd-motion-fast);
}
:where(.form-control, input, select, textarea):focus { border-color: var(--sd-color-primary); box-shadow: var(--sd-focus-ring); }
:where(input,select,textarea):disabled { cursor: not-allowed; opacity: .72; background: #eef2f6; }
:where(label,.form-label) { color: var(--sd-color-text); }

.table-responsive,
.sd-table-responsive { border-radius: var(--sd-radius-lg); scrollbar-color: #9fb1c4 transparent; }
:where(.table, .sd-table) { overflow: hidden; border-color: var(--sd-color-border); background: var(--sd-color-surface); }
:where(.table,.sd-table) thead th { border-color: var(--sd-color-border); background: var(--sd-color-surface-muted); color: #405871; }
:where(.table,.sd-table) tbody td { border-color: #e7edf4; }
:where(.table,.sd-table) tbody tr:hover { background: #f8fbff; }

.alert { border-radius: var(--sd-radius-md); box-shadow: var(--sd-shadow-xs); }
.sd-badge,.badge,.badge-soft { border-radius: 999px; }
.app-footer { border-top-color: var(--sd-color-border); background: rgba(255,255,255,.66); }

@media (max-width: 1100px) {
    .brand-subtitle { display: none; }
    .header-user-info { max-width: 260px; }
    .header-user-role { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
}

@media (max-width: 992px) {
    body[data-sidebar-collapsed="true"] .main-sidebar { visibility: visible; }
    .app-main { padding: 16px; }
    .layout-with-sidebar,
    body[data-sidebar-collapsed="true"] .layout-with-sidebar { display: block; }
    .main-sidebar { top: 0; border-radius: 0 18px 18px 0; }
    .main-sidebar.show { visibility: visible; opacity: 1; transform: translateX(0); }
    .main-sidebar-overlay.show { backdrop-filter: blur(2px); }
}

@media (max-width: 760px) {
    .app-header-inner { padding: 9px 12px; }
    .header-right { gap: 8px; }
    .header-user { width: 100%; justify-content: space-between; }
    .header-actions { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); width: 100%; }
    .header-actions .btn,
    .header-actions form,
    .header-actions form .btn { width: 100%; }
    .sd-shell-context { align-items: flex-start; flex-direction: column; }
    .sd-page-header { padding: 18px; }
}

@media (max-width: 520px) {
    .app-main { padding: 12px; }
    .brand-title { font-size: .92rem; }
    .header-actions { grid-template-columns: 1fr; }
    .sd-page-actions,.sd-page-actions .btn { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
    *,*::before,*::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}

@media print {
    .app-header,.main-sidebar,.main-sidebar-overlay,.app-footer,.sd-shell-context,.skip-link { display: none !important; }
    .app-main { padding: 0; }
    .layout-with-sidebar { display: block; }
    .card,.sd-card { box-shadow: none !important; }
}
