:root {
  color-scheme: light;
  --ink: #17233c;
  --muted: #68758b;
  --line: #e3e8f0;
  --paper: #ffffff;
  --surface: #f5f7fb;
  --nav: #111b30;
  --nav-muted: #9daccc;
  --primary: #3468ed;
  --primary-dark: #2855ca;
  --danger: #d43b52;
  --success: #16855a;
  --shadow: 0 12px 35px rgba(28, 43, 75, 0.07);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--surface); }
body { margin: 0; min-height: 100vh; color: var(--ink); background: var(--surface); font-size: 15px; }
a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-dark); }
button, input, textarea, select { font: inherit; }
button, .button, input[type="checkbox"] { accent-color: var(--primary); }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 8px; font-size: clamp(1.8rem, 3vw, 2.4rem); letter-spacing: -0.04em; }
h2 { margin-bottom: 4px; font-size: 1.15rem; }
h3 { margin: 20px 0 10px; font-size: .95rem; }
small { display: block; color: var(--muted); font-size: .8rem; }

.app-shell { display: flex; }
.sidebar { position: fixed; z-index: 10; inset: 0 auto 0 0; width: 245px; display: flex; flex-direction: column; gap: 18px; padding: 24px 18px; color: #fff; background: var(--nav); box-shadow: 10px 0 35px rgba(11, 20, 37, .08); }
.brand { display: flex; align-items: center; gap: 10px; color: #fff; font-weight: 750; font-size: 1.05rem; letter-spacing: -.02em; }
.brand:hover { color: #fff; }
.brand-mark { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 11px; color: #fff; background: linear-gradient(145deg, #5b82f3, #2e5de0); box-shadow: 0 8px 20px rgba(52,104,237,.32); }
.sidebar nav { display: grid; gap: 5px; }
.nav-link { padding: 10px 12px; border-radius: 9px; color: var(--nav-muted); font-weight: 600; }
.nav-link:hover, .nav-link.active { color: #fff; background: rgba(255,255,255,.09); }
.nav-heading { margin: 18px 12px 3px; color: #7182a5; font-size: .67rem; font-weight: 800; letter-spacing: .13em; text-transform: uppercase; }
.sidebar-account { display: flex; align-items: center; gap: 10px; margin-top: auto; min-width: 0; }
.sidebar-account > div:last-child { min-width: 0; }
.sidebar-account strong, .sidebar-account small { overflow: hidden; max-width: 155px; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-account small { color: var(--nav-muted); }
.avatar { flex: 0 0 auto; display: grid; place-items: center; width: 34px; height: 34px; border: 1px solid rgba(255,255,255,.18); border-radius: 50%; background: rgba(255,255,255,.1); font-weight: 800; }
.workspace { width: 100%; min-width: 0; margin-left: 245px; }
.main-content { width: min(1320px, 100%); margin: 0 auto; padding: 34px; }
.mobile-header { display: none; }

.page-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin-bottom: 26px; }
.header-actions { display: flex; gap: 8px; }
.eyebrow { margin-bottom: 6px; color: var(--primary); font-size: .68rem; font-weight: 800; letter-spacing: .13em; text-transform: uppercase; }
.muted { margin-bottom: 0; color: var(--muted); }
.panel { padding: 22px; border: 1px solid var(--line); border-radius: 15px; background: var(--paper); box-shadow: var(--shadow); }
.panel + .panel { margin-top: 22px; }
.panel-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
.panel-heading h2 { margin: 0; }
.stat-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-bottom: 22px; }
.stat-card { display: grid; gap: 8px; min-height: 132px; padding: 20px; border: 1px solid var(--line); border-radius: 14px; background: var(--paper); box-shadow: var(--shadow); }
.stat-card span { color: var(--muted); font-weight: 650; }
.stat-card strong { font-size: 1.8rem; letter-spacing: -.04em; }
.mini-stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.mini-stat-grid div { display: grid; gap: 3px; padding-left: 12px; border-left: 2px solid #dce4f9; }
.mini-stat-grid span { color: var(--muted); font-size: .8rem; }
.mini-stat-grid strong { font-size: 1.15rem; }
.admin-summary { margin-bottom: 22px; background: linear-gradient(120deg, #fff, #f8faff); }
.dashboard-grid { display: grid; grid-template-columns: 1.2fr .8fr; gap: 22px; }

.file-list { display: grid; }
.file-row { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 12px; padding: 13px 0; color: var(--ink); border-top: 1px solid var(--line); }
.file-row:first-child { border-top: 0; }
.file-row strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-row small { margin-top: 3px; }
.file-badge { display: grid; place-items: center; width: 42px; height: 42px; border: 1px solid #dbe3f5; border-radius: 10px; color: #3c63c3; background: #eff3fd; font-size: .67rem; font-weight: 850; }
.file-name { display: flex; align-items: center; gap: 11px; color: var(--ink); min-width: 230px; }
.file-name strong { display: block; overflow: hidden; max-width: 340px; text-overflow: ellipsis; white-space: nowrap; }
.activity-list { display: grid; gap: 15px; margin: 0; padding: 0; list-style: none; }
.activity-list li { display: flex; align-items: flex-start; gap: 10px; }
.activity-dot { flex: 0 0 auto; width: 8px; height: 8px; margin-top: 6px; border-radius: 50%; background: #7090ed; }
.activity-list strong { display: block; font-size: .87rem; text-transform: capitalize; }

.button { display: inline-flex; align-items: center; justify-content: center; min-height: 39px; padding: 8px 14px; border: 1px solid var(--line); border-radius: 9px; color: var(--ink); background: #fff; cursor: pointer; font-weight: 700; transition: border-color .15s, background .15s, transform .15s; }
.button:hover { border-color: #cbd4e4; color: var(--ink); background: #f9faff; transform: translateY(-1px); }
.button-primary { color: #fff; border-color: var(--primary); background: var(--primary); }
.button-primary:hover { color: #fff; border-color: var(--primary-dark); background: var(--primary-dark); }
.button-danger { color: #fff; border-color: var(--danger); background: var(--danger); }
.button-danger:hover { color: #fff; border-color: #b72940; background: #b72940; }
.button-ghost { background: transparent; }
.sidebar .button-ghost { color: #dbe4fb; border-color: rgba(255,255,255,.16); }
.button-small { min-height: 32px; padding: 5px 9px; font-size: .76rem; }
.button-wide { width: 100%; }
.icon-button { padding: 6px 10px; border: 1px solid var(--line); border-radius: 8px; background: #fff; }

.toolbar { display: flex; align-items: center; gap: 8px; margin-bottom: 18px; }
.search-field { flex: 1; }
.search-field input { width: 100%; }
label { display: grid; gap: 6px; color: #303e58; font-size: .82rem; font-weight: 700; }
input, textarea, select { width: 100%; padding: 10px 11px; border: 1px solid #cfd7e5; border-radius: 9px; outline: none; color: var(--ink); background: #fff; font-weight: 500; }
input:focus, textarea:focus, select:focus { border-color: #7191ec; box-shadow: 0 0 0 3px rgba(52,104,237,.12); }
input[type="checkbox"] { width: 17px; height: 17px; padding: 0; }
textarea { resize: vertical; line-height: 1.5; }
fieldset { margin: 0; padding: 15px; border: 1px solid var(--line); border-radius: 12px; }
legend { padding: 0 7px; font-size: .82rem; font-weight: 750; }
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.form-panel { max-width: 760px; }
.span-2 { grid-column: span 2; }
.stack-lg { display: grid; gap: 17px; }
.check-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 9px; }
.check { display: flex; align-items: center; gap: 8px; min-width: 0; }
.check span { min-width: 0; }
.check small { display: inline; margin-left: 5px; font-weight: 400; }
.check.compact { color: var(--muted); font-size: .75rem; }
.toggle { display: flex; align-items: center; gap: 9px; }
.share-panel { padding: 16px; border: 1px solid #d9e1f2; border-radius: 12px; background: #f8faff; }
.share-panel[hidden] { display: none; }
.permission-table { display: grid; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
.permission-table > div { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 9px 11px; border-top: 1px solid var(--line); }
.permission-table > div:first-child { border-top: 0; }

.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .82rem; }
th { padding: 10px 9px; color: var(--muted); text-align: left; font-size: .7rem; font-weight: 800; letter-spacing: .04em; text-transform: uppercase; white-space: nowrap; }
td { padding: 13px 9px; border-top: 1px solid var(--line); vertical-align: middle; }
td > small { margin-top: 3px; }
.actions { display: flex; justify-content: flex-end; gap: 6px; white-space: nowrap; }
.actions form { display: inline-flex; }
.badge { display: inline-flex; align-items: center; max-width: 145px; padding: 4px 7px; border: 1px solid #dce3f2; border-radius: 999px; overflow: hidden; color: #536887; background: #f8faff; font-size: .68rem; font-weight: 750; text-overflow: ellipsis; text-transform: capitalize; white-space: nowrap; }
.badge-success { color: var(--success); border-color: #bee8d7; background: #f0fbf6; }
.badge-muted { color: #7c8799; }
.pagination { display: flex; justify-content: center; gap: 5px; margin-top: 20px; }
.pagination a { display: grid; place-items: center; width: 34px; height: 34px; border: 1px solid var(--line); border-radius: 8px; color: var(--ink); }
.pagination a.active { color: #fff; border-color: var(--primary); background: var(--primary); }
.empty-state { display: grid; place-items: center; gap: 6px; min-height: 160px; color: var(--muted); text-align: center; }
.empty-state strong { color: var(--ink); }

.detail-grid { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(280px, .7fr); gap: 22px; align-items: start; }
.metadata { display: grid; gap: 0; margin: 0; }
.metadata div { display: grid; grid-template-columns: minmax(85px, .5fr) 1fr; gap: 8px; padding: 10px 0; border-top: 1px solid var(--line); }
.metadata div:first-child { border-top: 0; }
.metadata dt { color: var(--muted); font-size: .76rem; font-weight: 750; }
.metadata dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.metadata-inline { grid-template-columns: repeat(2, 1fr); }
.metadata-inline div { display: block; border: 0; }
code { overflow-wrap: anywhere; color: #445675; font: .75rem ui-monospace, SFMono-Regular, Consolas, monospace; }
code.context { display: block; max-width: 320px; max-height: 70px; overflow: auto; }
.danger-zone { border-color: #f1cbd1; }
.detail-panel { max-width: 900px; }
.description-block { margin-bottom: 20px; padding: 16px; border: 1px solid var(--line); border-radius: 11px; background: #f9faff; }
.description-block p { margin: 8px 0 0; line-height: 1.65; }
.metadata-two-column { grid-template-columns: repeat(2, minmax(0,1fr)); gap: 0 24px; }

.alert { margin-bottom: 18px; padding: 11px 14px; border: 1px solid #cbdaf7; border-radius: 10px; color: #254f9d; background: #f2f6ff; }
.alert-success { color: #12714c; border-color: #bce6d4; background: #effaf5; }
.alert-danger { color: #9d3142; border-color: #f0c6cd; background: #fff3f5; }

dialog { width: min(720px, calc(100% - 30px)); max-height: calc(100vh - 40px); padding: 0; border: 1px solid var(--line); border-radius: 16px; overflow: auto; box-shadow: 0 30px 80px rgba(11,20,37,.24); }
dialog::backdrop { background: rgba(10, 18, 33, .62); backdrop-filter: blur(3px); }
dialog form { padding: 22px; }
.dialog-heading { display: flex; justify-content: space-between; align-items: flex-start; }
.dialog-close { border: 0; color: var(--muted); background: transparent; cursor: pointer; font-size: 1.5rem; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }

.login-page { display: grid; place-items: center; padding: 25px; background: radial-gradient(circle at 20% 10%, #edf2ff, transparent 35%), #f6f8fc; }
.login-shell { width: min(430px, 100%); }
.login-card { padding: 34px; border: 1px solid var(--line); border-radius: 18px; background: #fff; box-shadow: 0 25px 60px rgba(28,43,75,.11); }
.brand-login { margin-bottom: 30px; color: var(--ink); }
.brand-login:hover { color: var(--ink); }
.security-note { margin: 22px 0 0; color: var(--muted); font-size: .72rem; text-align: center; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); border: 0; white-space: nowrap; }

@media (max-width: 1080px) {
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .dashboard-grid, .detail-grid { grid-template-columns: 1fr; }
}

@media (max-width: 760px) {
  .sidebar { transform: translateX(-100%); transition: transform .2s ease; }
  .sidebar.open { transform: translateX(0); }
  .workspace { margin-left: 0; }
  .mobile-header { display: flex; position: sticky; z-index: 5; top: 0; align-items: center; justify-content: space-between; padding: 12px 18px; border-bottom: 1px solid var(--line); background: rgba(255,255,255,.94); backdrop-filter: blur(10px); }
  .main-content { padding: 22px 14px; }
  .page-header { display: grid; }
  .page-header .button { width: 100%; }
  .stat-grid, .mini-stat-grid, .form-grid, .check-grid { grid-template-columns: 1fr; }
  .metadata-two-column { grid-template-columns: 1fr; }
  .span-2 { grid-column: auto; }
  .panel { padding: 17px; }
  .toolbar { align-items: stretch; flex-wrap: wrap; }
  .toolbar .search-field { flex-basis: 100%; }
  .file-name strong { max-width: 210px; }
  .login-card { padding: 25px; }
}
