:root {
    --bg: #f4f7fb;
    --surface: #ffffff;
    --surface-soft: #f8fafc;
    --text: #14213a;
    --muted: #667085;
    --border: #e4eaf2;
    --primary: #17233b;
    --primary-hover: #243452;
    --accent: #2f6fed;
    --success: #087a55;
    --success-bg: #e7f8f0;
    --warning: #9a6700;
    --warning-bg: #fff6dd;
    --danger: #b42318;
    --danger-bg: #feeceb;
    --info: #175cd3;
    --info-bg: #eaf2ff;
    --sidebar-width: 270px;
    --shadow-sm: 0 1px 3px rgba(16, 24, 40, .06);
    --shadow-md: 0 12px 36px rgba(16, 24, 40, .08);
    font-family: Tahoma, Arial, sans-serif;
}

* { box-sizing: border-box; }
html { min-height: 100%; }
body { margin: 0; min-height: 100vh; color: var(--text); background: var(--bg); }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }

.app-shell { min-height: 100vh; }
.sidebar {
    position: fixed;
    inset: 0 0 0 auto;
    z-index: 50;
    width: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    background: #101a2e;
    color: #d9e2f1;
    border-left: 1px solid rgba(255,255,255,.06);
}
.sidebar-brand { height: 82px; display: flex; align-items: center; padding: 0 22px; border-bottom: 1px solid rgba(255,255,255,.08); }
.sidebar-brand > a { display: flex; align-items: center; gap: 12px; flex: 1; }
.brand-mark { width: 42px; height: 42px; border-radius: 13px; display: grid; place-items: center; background: linear-gradient(145deg,#487ef7,#2757ce); color:#fff; font-size:20px; font-weight:900; box-shadow:0 8px 20px rgba(47,111,237,.28); }
.brand-copy { display:flex; flex-direction:column; gap:3px; }
.brand-copy strong { color:#fff; font-size:19px; }
.brand-copy small { color:#98a8c0; font-size:11px; letter-spacing:.4px; }
.sidebar-close { display:none; border:0; background:transparent; color:#fff; font-size:25px; }
.sidebar-nav { flex:1; overflow:auto; padding:22px 14px; }
.nav-section-label { padding:10px 12px 8px; color:#7486a1; font-size:11px; font-weight:800; }
.nav-item { min-height:46px; display:flex; align-items:center; gap:12px; margin:4px 0; padding:10px 12px; border-radius:11px; color:#bdc9da; transition:.18s ease; }
.nav-item:hover { color:#fff; background:rgba(255,255,255,.06); }
.nav-item.active { color:#fff; background:rgba(61,116,238,.2); box-shadow:inset -3px 0 0 #4b82ff; }
.nav-icon { width:28px; height:28px; display:grid; place-items:center; border-radius:8px; background:rgba(255,255,255,.07); font-size:13px; font-weight:800; }
.sidebar-footer { padding:16px; border-top:1px solid rgba(255,255,255,.08); }
.sidebar-user { display:flex; gap:10px; align-items:center; }
.sidebar-user > div { min-width:0; display:flex; flex-direction:column; gap:3px; }
.sidebar-user strong { color:#fff; font-size:13px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.sidebar-user small { color:#8596b0; font-size:11px; }

.app-content { min-height:100vh; margin-right:var(--sidebar-width); }
.topbar { position:sticky; top:0; z-index:30; height:82px; padding:0 30px; display:flex; align-items:center; justify-content:space-between; gap:20px; background:rgba(255,255,255,.92); backdrop-filter:blur(10px); border-bottom:1px solid var(--border); }
.topbar-start,.topbar-actions,.user-menu { display:flex; align-items:center; gap:12px; }
.topbar-title { display:flex; flex-direction:column; gap:3px; }
.topbar-title small { color:var(--muted); font-size:11px; }
.topbar-title strong { font-size:15px; }
.user-menu-copy { display:flex; flex-direction:column; gap:2px; }
.user-menu-copy strong { font-size:13px; }
.user-menu-copy small { color:var(--muted); font-size:11px; }
.user-avatar { flex:0 0 auto; width:38px; height:38px; border-radius:12px; display:grid; place-items:center; background:#eaf0ff; color:#2b5cc5; font-weight:900; }
.user-avatar.small { width:36px; height:36px; }
.icon-button { border:1px solid var(--border); background:#fff; color:var(--text); padding:9px 13px; border-radius:10px; }
.icon-button.danger:hover { color:var(--danger); border-color:#f3b7b3; background:#fff7f6; }
.mobile-menu-button { display:none; border:0; background:transparent; font-size:23px; color:var(--text); }
.main-content { max-width:1560px; margin:0 auto; padding:30px; }

.page-heading { display:flex; align-items:flex-end; justify-content:space-between; gap:24px; margin-bottom:24px; }
.page-heading h1 { margin:5px 0 6px; font-size:30px; line-height:1.3; letter-spacing:-.3px; }
.page-heading p { margin:0; color:var(--muted); font-size:14px; }
.eyebrow { color:var(--accent); font-size:12px; font-weight:800; }

.button { display:inline-flex; align-items:center; justify-content:center; gap:8px; min-height:43px; border:0; border-radius:11px; padding:10px 17px; font-weight:800; transition:.18s ease; }
.button-primary { background:var(--primary); color:#fff; box-shadow:0 7px 18px rgba(23,35,59,.14); }
.button-primary:hover { background:var(--primary-hover); transform:translateY(-1px); }
.button-secondary { background:#fff; color:var(--text); border:1px solid var(--border); }
.button-icon { font-size:19px; line-height:1; }
.text-link { color:var(--accent); font-size:13px; font-weight:800; }

.stat-grid { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:16px; }
.stat-card { min-height:130px; display:flex; align-items:center; gap:16px; padding:21px; background:var(--surface); border:1px solid var(--border); border-radius:17px; box-shadow:var(--shadow-sm); }
.stat-icon { width:48px; height:48px; flex:0 0 auto; display:grid; place-items:center; border-radius:14px; background:#edf3ff; color:#2d63d2; font-weight:900; }
.stat-card > div:last-child { display:flex; flex-direction:column; gap:4px; }
.stat-card span { color:var(--muted); font-size:12px; }
.stat-card strong { font-size:26px; letter-spacing:-.5px; }
.stat-card small { color:#98a2b3; font-size:11px; }
.warning-card .stat-icon { background:var(--warning-bg); color:var(--warning); }

.dashboard-grid { display:grid; grid-template-columns:minmax(0,2fr) minmax(300px,1fr); gap:18px; margin-top:18px; }
.span-two { grid-column:1; }
.panel { background:var(--surface); border:1px solid var(--border); border-radius:17px; box-shadow:var(--shadow-sm); overflow:hidden; }
.dashboard-panel { min-width:0; }
.panel-heading { min-height:76px; display:flex; align-items:center; justify-content:space-between; gap:18px; padding:18px 22px; border-bottom:1px solid var(--border); }
.panel-heading h2 { margin:0 0 5px; font-size:16px; }
.panel-heading p { margin:0; color:var(--muted); font-size:12px; }
.table-wrap { overflow:auto; }
table { width:100%; border-collapse:collapse; }
th,td { padding:15px 20px; text-align:right; border-bottom:1px solid #eef1f5; white-space:nowrap; }
th { background:#fbfcfe; color:#667085; font-size:12px; font-weight:800; }
td { font-size:13px; }
tbody tr:last-child td { border-bottom:0; }
tbody tr:hover { background:#fbfdff; }
.entity-cell { display:flex; align-items:center; gap:11px; }
.entity-avatar { width:35px; height:35px; flex:0 0 auto; display:grid; place-items:center; border-radius:11px; background:#eff3fa; color:#334a70; font-weight:900; }
.entity-cell > div { display:flex; flex-direction:column; gap:4px; }
.entity-cell small,.table-subtext { display:block; color:#98a2b3; font-size:10px; margin-top:3px; }
.status-badge { display:inline-flex; align-items:center; min-height:25px; padding:4px 9px; border-radius:999px; font-size:11px; font-weight:800; }
.status-success { color:var(--success); background:var(--success-bg); }
.status-warning { color:var(--warning); background:var(--warning-bg); }
.status-danger { color:var(--danger); background:var(--danger-bg); }
.status-info { color:var(--info); background:var(--info-bg); }
.status-neutral { color:#475467; background:#f2f4f7; }

.stack-list,.activity-list,.quick-actions { padding:10px 18px 18px; }
.stack-item { display:flex; align-items:center; justify-content:space-between; gap:12px; padding:13px 2px; border-bottom:1px solid #eef1f5; }
.stack-item:last-child { border-bottom:0; }
.stack-item > div:first-child { display:flex; flex-direction:column; gap:4px; }
.stack-item strong { font-size:13px; }
.stack-item span { color:var(--muted); font-size:11px; }
.days-pill { flex:0 0 auto; padding:5px 9px; border-radius:999px; background:var(--warning-bg); color:var(--warning); font-size:11px; font-weight:800; }
.activity-item { position:relative; display:flex; gap:12px; padding:12px 0; border-bottom:1px solid #eef1f5; }
.activity-item:last-child { border-bottom:0; }
.activity-dot { width:9px; height:9px; flex:0 0 auto; margin-top:5px; border-radius:50%; background:var(--accent); box-shadow:0 0 0 5px #edf3ff; }
.activity-item > div { display:flex; flex-direction:column; gap:4px; }
.activity-item strong { font-size:13px; }
.activity-item span { color:var(--muted); font-size:11px; }
.quick-actions { display:grid; gap:9px; }
.quick-actions > a { display:flex; align-items:center; gap:11px; padding:12px; border:1px solid var(--border); border-radius:12px; transition:.18s ease; }
.quick-actions > a:hover { border-color:#bfd0f6; background:#f8fbff; transform:translateY(-1px); }
.quick-actions > a > span { width:36px; height:36px; flex:0 0 auto; display:grid; place-items:center; border-radius:10px; background:#edf3ff; color:#2d63d2; font-weight:900; }
.quick-actions > a > div { display:flex; flex-direction:column; gap:3px; }
.quick-actions strong { font-size:12px; }
.quick-actions small { color:var(--muted); font-size:10px; }
.empty-state { display:flex; align-items:center; justify-content:center; flex-direction:column; gap:5px; min-height:170px; padding:20px; color:var(--muted); text-align:center; }
.empty-state.compact { min-height:95px; }
.empty-state strong { color:var(--text); }
.empty-state span { font-size:11px; }

.form-panel { padding:24px; }
.form-grid,.grid { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:18px; }
.field { display:flex; flex-direction:column; gap:8px; }
.field label,.form-panel label { font-size:12px; font-weight:800; }
input,select,textarea { width:100%; min-height:44px; border:1px solid #d7dee9; border-radius:10px; padding:10px 12px; color:var(--text); background:#fff; outline:none; }
input:focus,select:focus,textarea:focus { border-color:#7da4ff; box-shadow:0 0 0 3px rgba(47,111,237,.11); }
.form-panel form > .button { margin-top:20px; }
.alert { padding:13px 15px; margin-bottom:18px; border-radius:11px; font-size:13px; }
.alert.success { color:var(--success); background:var(--success-bg); border:1px solid #bee8d5; }
.alert.error { color:var(--danger); background:var(--danger-bg); border:1px solid #f5c5c1; }

.guest-body { background:linear-gradient(145deg,#f4f7fb,#edf2fa); }
.guest-content { min-height:100vh; padding:30px 18px; }
.auth-shell { min-height:calc(100vh - 60px); display:grid; place-items:center; }
.auth-card { width:100%; max-width:450px; padding:38px; background:#fff; border:1px solid var(--border); border-radius:22px; box-shadow:var(--shadow-md); }
.auth-brand { font-weight:900; font-size:20px; }
.auth-brand span { display:inline-block; margin-right:5px; padding:4px 8px; border-radius:7px; background:var(--primary); color:#fff; font-size:10px; }
.auth-card h1 { margin:24px 0 8px; font-size:30px; }
.auth-card p { margin:0 0 24px; color:var(--muted); font-size:13px; }
.auth-card label { display:block; margin:15px 0 7px; font-size:12px; font-weight:800; }
.auth-card .button { width:100%; margin-top:19px; }
.guest-alert { max-width:450px; margin:0 auto 15px; }
.sidebar-backdrop { display:none; }

@media (min-width: 1180px) {
    .dashboard-grid > .dashboard-panel:nth-child(2),
    .quick-actions-panel { grid-column:2; }
}

@media (max-width: 1180px) {
    .stat-grid { grid-template-columns:repeat(2,minmax(0,1fr)); }
    .dashboard-grid { grid-template-columns:1fr; }
    .span-two { grid-column:auto; }
}

@media (max-width: 860px) {
    .sidebar { transform:translateX(105%); transition:transform .22s ease; box-shadow:-20px 0 50px rgba(16,24,40,.18); }
    .sidebar-open .sidebar { transform:translateX(0); }
    .sidebar-close,.mobile-menu-button { display:block; }
    .sidebar-backdrop { position:fixed; inset:0; z-index:40; background:rgba(16,24,40,.42); }
    .sidebar-open .sidebar-backdrop { display:block; }
    .app-content { margin-right:0; }
    .topbar { padding:0 18px; }
    .user-menu-copy { display:none; }
    .main-content { padding:22px 16px; }
}

@media (max-width: 680px) {
    .page-heading { align-items:flex-start; flex-direction:column; }
    .page-heading h1 { font-size:25px; }
    .page-heading .button { width:100%; }
    .stat-grid,.form-grid,.grid { grid-template-columns:1fr; }
    .stat-card { min-height:112px; }
    .topbar-title strong { max-width:180px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
    .auth-card { padding:28px 22px; }
}
