/* ======================================================================
   03-LAYOUT  -  Main app frame: sidebar, top bar, page grid, dashboard stats
   ====================================================================== */

/* Main application frame: sidebar, top bar, page grid, and dashboard statistics. */
.shell { min-height: 100vh; }
.sidebar { width: var(--sidebar-width); position: fixed; inset: 0 auto 0 0; z-index: 20; display: flex; flex-direction: column; background: var(--navy-dark); color: white; }
.sidebar-head { padding: 19px 20px; border-bottom: 1px solid #ffffff18; }
.sidebar .brand-mark { width: 36px; height: 36px; border: 1px solid #ffffff26; background: #ffffff0c; }
.sidebar .brand-initial { font-size: 20px; }
.sidebar nav { flex: 1; overflow: auto; padding: 18px 12px; scrollbar-color: #465968 transparent; scrollbar-width: thin; }
.sidebar nav::-webkit-scrollbar { width: 6px; }
.sidebar nav::-webkit-scrollbar-thumb { border-radius: 99px; background: #465968; }
.sidebar nav::-webkit-scrollbar-button { display: none; height: 0; }
.nav-group + .nav-group { margin-top: 21px; }
.nav-caption { margin: 0 10px 7px; color: #a9bac5; text-transform: uppercase; font-size: 10px; font-weight: 650; letter-spacing: .08em; }
.nav-btn { width: 100%; min-height: 40px; display: flex; align-items: center; gap: 11px; margin: 2px 0; padding: 0 10px; text-align: left; border: 1px solid transparent; border-radius: 6px; color: #d0dbe2; background: transparent; font-size: 13px; font-weight: 500; transition: background-color .16s ease, color .16s ease; }
.nav-btn:hover { color: white; background: #ffffff0d; }
.nav-btn.active { color: white; border-color: #ffffff14; background: #ffffff12; font-weight: 650; }
.nav-icon { width: 20px; height: 20px; flex: none; display: grid; place-items: center; color: #9bb1c0; }
.nav-btn.active .nav-icon { color: #d4e5ef; }
.nav-icon svg, .mini-icon svg { display: block; width: 18px; height: 18px; }
.mini-icon { display: inline-grid; place-items: center; }
.file-chip { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 8px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--blue-pale); font-size: 13px; }
.file-chip[hidden] { display: none; }
.file-chip-name { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-chip-remove { flex: none; padding: 5px 11px; }
.sidebar-user { display: grid; grid-template-columns: 36px 1fr; align-items: center; gap: 9px; padding: 14px; border-top: 1px solid #ffffff16; }
.sidebar-user .logout-btn { grid-column: 1 / -1; display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; min-width: 0; height: 36px; padding: 0 12px; line-height: 1; color: #d0dbe2; border: 1px solid #ffffff24; border-radius: 6px; background: transparent; font-size: 12px; font-weight: 600; }
.sidebar-user .logout-btn:hover { color: white; border-color: #ffffff44; background: #ffffff0d; }
.code-row { display: flex; gap: 8px; }
.code-row input { flex: 1; min-width: 0; }
.code-row .btn { white-space: nowrap; }
.logout-overlay { position: fixed; inset: 0; z-index: 200; display: grid; place-items: center; background: #091a36cc; }
.logout-box { display: grid; justify-items: center; gap: 8px; padding: 26px 34px; color: var(--ink); background: white; border-radius: 12px; box-shadow: var(--shadow); }
.logout-box .spinner { width: 28px; height: 28px; border: 3px solid var(--blue-pale); border-top-color: var(--blue-dark); border-radius: 50%; animation: logout-spin 0.8s linear infinite; }
@keyframes logout-spin { to { transform: rotate(360deg); } }
.avatar { display: grid; place-items: center; width: 36px; height: 36px; color: var(--blue-dark); background: var(--blue-pale); border-radius: 10px; font-size: 11px; font-weight: 800; }
.sidebar-user strong, .sidebar-user small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-user strong { font-size: 11px; }
.sidebar-user small { color: #b0bfca; font-size: 10px; margin-top: 2px; }
.sidebar-user button { width: 31px; height: 31px; color: #91a5bd; border: 0; border-radius: 7px; background: transparent; font-size: 16px; }
.sidebar-user button:hover { color: white; background: #ffffff12; }
.main { min-height: 100vh; margin-left: var(--sidebar-width); }
.topbar { height: 62px; position: sticky; top: 0; z-index: 10; display: flex; align-items: center; justify-content: space-between; padding: 0 28px; border-bottom: 1px solid var(--line); background: #fff; }
.crumb { display: flex; align-items: center; gap: 9px; min-width: 0; color: var(--muted); font-size: 12px; }
.crumb strong { color: var(--ink); font-weight: 650; }
.crumb-sep { color: #9ba9b2; }
.role-label { display: inline-flex; align-items: center; color: #425e72; font-size: 12px; font-weight: 600; }
.top-actions { display: flex; align-items: center; gap: 17px; }
.top-user { display: flex; align-items: center; gap: 9px; }
.top-user strong, .top-user small { display: block; }
.top-user strong { font-size: 12px; }
.top-user small { color: var(--muted); font-size: 10px; }
.page { max-width: 1500px; padding: 28px clamp(18px, 3vw, 42px) 50px; margin: auto; }
.page-heading { display: flex; justify-content: space-between; align-items: flex-end; gap: 20px; margin-bottom: 23px; }
.page-heading h1 { margin: 0 0 6px; color: var(--navy); font-family: "Crimson Pro", Georgia, serif; font-size: clamp(30px, 2.7vw, 36px); font-weight: 600; letter-spacing: -.02em; line-height: 1.15; }
.page-heading p { max-width: 68ch; margin: 0; color: var(--muted); font-size: 13px; }
.heading-actions, .button-row { display: flex; flex-wrap: wrap; gap: 8px; }
.section-title { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin: 25px 0 13px; }
.section-title h2 { margin: 0; color: var(--navy); font-size: 16px; }
.section-title p { margin: 3px 0 0; color: var(--muted); font-size: 12px; }
.subject-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; margin-top: 14px; }
.subject-card { display: flex; align-items: center; gap: 11px; padding: 13px; border: 1px solid var(--line); border-radius: 9px; color: var(--ink); background: white; text-align: left; cursor: pointer; }
.subject-card:hover { border-color: var(--blue); background: var(--blue-pale); }
.subject-card .stat-icon { width: 28px; height: 28px; border-radius: 0; color: #5c7d92; background: transparent; }
.subject-card .stat-icon svg { width: 24px; height: 24px; }
.subject-card > span:nth-child(2) { flex: 1; }
.subject-card strong, .subject-card small { display: block; }
.subject-card strong { font-size: 13px; }
.subject-card small { margin-top: 4px; color: var(--muted); font-size: 11px; }
.subject-arrow { color: #708594; }
.subject-arrow svg { width: 17px; height: 17px; display: block; }
.subject-item { display: flex; flex-direction: column; gap: 6px; }
.subject-item .subject-card { width: 100%; }
.subject-delete { align-self: flex-end; display: inline-flex; align-items: center; gap: 4px; padding: 2px 4px; border: 0; background: transparent; color: var(--muted); font-size: 11px; cursor: pointer; }
.subject-delete:hover { color: var(--red); }
.subject-delete svg { width: 12px; height: 12px; }
.file-row > div:last-child { display: flex; gap: 6px; justify-content: flex-end; align-items: center; white-space: nowrap; }
.btn-delete { display: inline-flex; align-items: center; gap: 5px; padding: 6px 10px; font-size: 11px; }
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0; margin-bottom: 24px; overflow: hidden; border: 1px solid var(--line); border-radius: 8px; background: white; }
.stat { display: flex; align-items: center; gap: 11px; min-height: 82px; padding: 15px 17px; border: 0; border-radius: 0; background: transparent; }
.stat + .stat { border-left: 1px solid var(--line); }
.stat .stat-icon, .stat-icon { display: grid; place-items: center; flex: none; width: 28px; height: 28px; border-radius: 0; color: #5c7d92; background: transparent; font-size: 22px; }
.stat .stat-icon svg { width: 24px; height: 24px; display: block; }
.stat-icon.cyan, .stat-icon.purple, .stat-icon.amber { color: #5c7d92; background: transparent; }
.stat small, .stat strong, .stat span { display: block; }
.stat span { color: var(--muted); font-size: 11px; }
.stat strong { margin-top: 1px; color: var(--navy); font-size: 23px; line-height: 1.2; }
.stat small { color: var(--muted); font-size: 10px; }
.saved-item .stat-icon { width: 28px; height: 28px; flex: none; border-radius: 0; color: #5c7d92; background: transparent; }
.saved-item .stat-icon svg { width: 23px; height: 23px; }
.subject-group > summary .stat-icon svg { width: 20px; height: 20px; }
