:root {
  --navy: #0b2b55;
  --navy-2: #174878;
  --blue: #1768d4;
  --green: #34a83b;
  --green-dark: #23852c;
  --lime: #9bc64b;
  --paper: #fff;
  --canvas: #f4f7fb;
  --sky: #eef6ff;
  --ink: #0a2550;
  --muted: #5a6c86;
  --line: #dbe4ef;
  --warning: #f0a61a;
  --danger: #cf3e48;
  --shadow: 0 15px 42px rgba(22, 60, 102, .1);
  --radius: 18px;
}

* { box-sizing: border-box; }
html { min-height: 100%; }
body { margin: 0; min-height: 100%; color: var(--ink); background: var(--canvas); font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; }
a { color: var(--blue); }
img { max-width: 100%; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.skip-link { position: fixed; top: -4rem; left: 1rem; z-index: 1000; padding: .7rem 1rem; color: #fff; background: var(--navy); border-radius: 8px; }
.skip-link:focus { top: 1rem; }

.brand { display: inline-flex; align-items: center; gap: .85rem; color: var(--navy); text-decoration: none; line-height: 1.05; }
.brand-mark { display: grid; width: 58px; height: 58px; place-items: center; flex: 0 0 auto; border: 3px solid #2589d9; border-bottom-color: var(--lime); border-radius: 50%; background: #fff; font-size: 31px; box-shadow: 0 5px 16px rgba(20, 70, 110, .1); }
.brand strong { display: block; font-size: 1.28rem; letter-spacing: -.03em; }
.brand small { display: block; margin-top: .3rem; color: var(--navy); font-size: .67rem; font-weight: 650; }
.brand-compact { color: #fff; }
.brand-compact .brand-mark { width: 42px; height: 42px; font-size: 22px; border-width: 2px; }
.brand-compact strong { color: #fff; font-size: .86rem; }
.brand-compact small { display: none; }

.public-page { min-height: 100vh; background: linear-gradient(#f5f9ff, #fff 68%, #eff7e8); }
.public-shell { position: relative; display: grid; min-height: 100vh; place-items: center; overflow: hidden; padding: 4.4rem 1rem 7rem; }
.public-domain { position: absolute; top: 1.5rem; left: 1.7rem; color: #1455bb; font-size: .83rem; font-weight: 800; }
.auth-card { position: relative; z-index: 2; width: min(100%, 540px); padding: 2.5rem 2.8rem 2.8rem; border: 1px solid rgba(210, 224, 239, .8); border-radius: 24px; background: rgba(255, 255, 255, .95); box-shadow: var(--shadow); }
.auth-card > .brand { display: flex; width: max-content; max-width: 100%; margin: 0 auto 2rem; }
.auth-card h1 { margin: 0 0 .45rem; text-align: center; font-size: clamp(1.65rem, 5vw, 2rem); letter-spacing: -.035em; }
.auth-intro { margin: 0 auto 1.5rem; color: var(--muted); text-align: center; }
.home-page .auth-card { text-align: center; }
.home-status { display: inline-flex; min-height: 30px; align-items: center; margin: 0 0 1rem; padding: .25rem .7rem; color: #48617a; border: 1px solid #d6e2ee; border-radius: 999px; background: #f5f8fb; font-size: .74rem; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; }
.home-actions { display: flex; justify-content: center; margin-top: 1.4rem; }
.home-actions .button { min-width: min(100%, 260px); }
.home-note { margin: 1.2rem 0 0; color: var(--muted); font-size: .78rem; }
.landscape { position: absolute; inset: auto 0 0; height: 120px; background: radial-gradient(70% 130% at 50% 120%, #7eb335 0 46%, transparent 47%), radial-gradient(65% 100% at 18% 125%, #a9cf57 0 54%, transparent 55%), radial-gradient(70% 100% at 83% 135%, #95c445 0 58%, transparent 59%); opacity: .95; }
.landscape span { position: absolute; bottom: 40px; width: 16px; height: 70px; border-radius: 50% 50% 40% 40%; background: #3a8f2f; box-shadow: 0 48px 0 -6px #7a4a28; }
.landscape span:nth-child(1) { left: 4%; }
.landscape span:nth-child(2) { right: 8%; height: 92px; }
.landscape span:nth-child(3) { right: 4%; bottom: 34px; height: 58px; }

.field { margin-bottom: .9rem; }
.field label { display: block; margin-bottom: .34rem; font-weight: 720; font-size: .9rem; }
.field input, .field select, .field textarea { width: 100%; min-height: 46px; padding: .72rem .8rem; color: var(--ink); border: 1px solid #ccd8e6; border-radius: 9px; background: #fff; outline: none; }
.field textarea { min-height: 150px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(23, 104, 212, .13); }
.field-hint { display: block; margin-top: .25rem; color: var(--muted); font-size: .78rem; }
.password-field { position: relative; }
.password-field input { padding-right: 5.3rem; }
.password-toggle { position: absolute; right: .5rem; top: 50%; transform: translateY(-50%); padding: .3rem .45rem; color: var(--blue); border: 0; background: transparent; font-size: .78rem; cursor: pointer; }
.checkbox-row { display: flex; align-items: flex-start; gap: .55rem; margin: .8rem 0; font-size: .88rem; }
.checkbox-row input { width: 18px; height: 18px; margin-top: .1rem; flex: 0 0 auto; accent-color: var(--green); }
.highlight-checkbox { padding: .8rem; border: 1px solid #f0b43c; border-radius: 10px; background: #fffaf0; }
.form-split { display: flex; justify-content: space-between; gap: 1rem; align-items: center; margin: .7rem 0 1rem; font-size: .82rem; }
.button { display: inline-flex; min-height: 44px; align-items: center; justify-content: center; gap: .35rem; padding: .65rem 1rem; border: 1px solid transparent; border-radius: 8px; font-weight: 760; text-decoration: none; cursor: pointer; }
.button-primary { color: #fff; background: linear-gradient(135deg, var(--green), var(--green-dark)); }
.button-blue { color: #fff; background: linear-gradient(135deg, #1572df, #145ac0); }
.button-outline { color: var(--blue); border-color: var(--blue); background: #fff; }
.button-danger { color: #fff; background: var(--danger); }
.button-small { min-height: 34px; padding: .35rem .55rem; font-size: .79rem; }
.button-block { width: 100%; }
.button-disabled { color: #627188; border-color: #cbd5e1; background: #eef2f6; cursor: not-allowed; }
.separator { display: flex; align-items: center; gap: .8rem; margin: 1rem 0; color: var(--muted); font-size: .83rem; }
.separator::before, .separator::after { content: ""; height: 1px; flex: 1; background: var(--line); }
.form-footer { margin: 1rem 0 0; text-align: center; font-size: .87rem; }
.account-note { margin: 1rem 0 0; color: var(--muted); text-align: center; font-size: .82rem; }
.public-footer { position: absolute; left: 1rem; right: 1rem; bottom: .8rem; z-index: 3; display: flex; min-height: 48px; align-items: center; justify-content: center; flex-wrap: wrap; gap: .35rem .55rem; color: #31536e; font-size: .78rem; }
.public-footer a { display: inline-flex; min-height: 44px; align-items: center; color: #174f86; font-weight: 720; text-underline-offset: .18em; }
.legal-shell { align-items: start; padding-top: 5rem; padding-bottom: 10rem; }
.legal-card { position: relative; z-index: 2; width: min(100%, 840px); padding: clamp(1.4rem, 4vw, 3.2rem); border: 1px solid rgba(210, 224, 239, .88); border-radius: 24px; background: rgba(255, 255, 255, .97); box-shadow: var(--shadow); }
.legal-card > .brand { margin-bottom: 2.5rem; }
.legal-card h1 { margin: 0 0 2rem; font-size: clamp(2rem, 6vw, 3rem); letter-spacing: -.045em; }
.legal-card h2 { margin: 0 0 .55rem; font-size: 1.2rem; }
.legal-card section { padding: 1.35rem 0; border-top: 1px solid var(--line); }
.legal-card p { margin: .45rem 0; color: #314963; }
.legal-card code { overflow-wrap: anywhere; padding: .08rem .25rem; border-radius: 4px; background: #eef3f8; }
.legal-kicker { margin-bottom: .3rem !important; color: var(--green-dark) !important; font-size: .76rem; font-weight: 850; letter-spacing: .08em; text-transform: uppercase; }
.legal-notice { margin: 1rem 0 1.5rem; padding: 1rem 1.1rem; border: 1px solid #bcd6ef; border-radius: 12px; background: #f0f7ff; }
.legal-notice p { margin-bottom: 0; }
.legal-notice-warning { border-color: #e8c269; background: #fffaf0; }
.back-link { display: inline-flex; min-height: 44px; align-items: center; margin-top: 1rem; font-weight: 760; }

.alert { margin: 0 0 1rem; padding: .75rem .9rem; border: 1px solid #bdd5ee; border-radius: 9px; color: #174f86; background: #eff7ff; }
.alert ul { margin: .35rem 0 0; padding-left: 1.2rem; }
.alert-success { color: #216b29; border-color: #b9dfbd; background: #f0faf1; }
.alert-warning { color: #7d5708; border-color: #f2ce7c; background: #fff9e8; }
.alert-error { color: #8e2530; border-color: #efb5bc; background: #fff2f3; }
.status-panel { margin: 1.4rem 0; padding: 1rem; border: 1px solid #e8b23a; border-radius: 11px; background: #fffaf0; text-align: center; }
.status-panel strong { display: block; font-size: 1rem; }
.status-icon { display: grid; width: 100px; height: 100px; place-items: center; margin: .8rem auto 1.5rem; border-radius: 24px; color: var(--green); background: #edf3fc; font-size: 3.3rem; }

.app-shell { display: grid; min-height: 100vh; grid-template-columns: 244px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; display: flex; height: 100vh; flex-direction: column; z-index: 50; padding: 1.1rem .8rem; color: #fff; background: linear-gradient(160deg, #0b2a50, #164d7d); box-shadow: 7px 0 28px rgba(11, 42, 80, .12); }
.sidebar-brand { padding: .3rem .55rem 1.35rem; }
.sidebar nav { display: grid; gap: .25rem; overflow-y: auto; }
.nav-item { display: flex; min-height: 44px; align-items: center; gap: .7rem; padding: .65rem .75rem; color: #fff; border-radius: 8px; text-decoration: none; font-size: .91rem; font-weight: 620; }
.nav-item:hover, .nav-item:focus-visible { background: rgba(255, 255, 255, .12); }
.nav-item.is-active { background: linear-gradient(135deg, #3ab941, #2f9c36); box-shadow: 0 7px 18px rgba(15, 50, 30, .18); }
.nav-item > span:first-child { display: inline-grid; width: 22px; place-items: center; font-size: 1rem; }
.nav-label { margin: 1.2rem .75rem .35rem; color: #b8d2e8; font-size: .68rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.logout-form { margin-top: auto; }
.logout-form button { display: flex; width: 100%; align-items: center; gap: .7rem; padding: .75rem; color: #fff; border: 0; border-radius: 8px; background: transparent; cursor: pointer; }
.logout-form button:hover { background: rgba(255, 255, 255, .12); }
.app-content { min-width: 0; }
.topbar { position: sticky; top: 0; display: flex; min-height: 76px; align-items: center; gap: 1rem; z-index: 40; padding: .8rem 1.5rem; border-bottom: 1px solid var(--line); background: rgba(255, 255, 255, .94); backdrop-filter: blur(12px); }
.topbar-title { display: grid; }
.topbar-title small { color: var(--muted); }
.user-chip { display: flex; align-items: center; gap: .5rem; margin-left: auto; }
.user-chip > span { display: grid; width: 38px; height: 38px; place-items: center; border-radius: 50%; background: #e3ddff; font-size: .82rem; font-weight: 800; }
.menu-toggle { display: none; width: 42px; height: 42px; place-items: center; color: var(--navy); border: 1px solid var(--line); border-radius: 8px; background: #fff; }
.main-content { width: min(1280px, 100%); min-height: calc(100vh - 120px); padding: clamp(1.1rem, 3vw, 2.3rem); }
.app-footer { padding: 0 2rem 1.5rem; color: var(--muted); font-size: .78rem; }
.page-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; margin-bottom: 1.4rem; }
.page-heading h1 { margin: 0; font-size: clamp(1.65rem, 4vw, 2.25rem); letter-spacing: -.04em; }
.page-heading p { margin: .25rem 0 0; color: var(--muted); }
.breadcrumbs { margin-bottom: .8rem; color: var(--muted); font-size: .85rem; }

.grid { display: grid; gap: 1rem; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.card { padding: 1.2rem; border: 1px solid #e1e8f1; border-radius: var(--radius); background: #fff; box-shadow: 0 8px 24px rgba(30, 70, 110, .055); }
.card.is-pending { border-style: dashed; background: #fbfcfe; }
.card h2, .card h3 { margin-top: 0; }
.card h2 { font-size: 1.18rem; }
.card h3 { margin-bottom: .4rem; font-size: 1.02rem; }
.card p { color: var(--muted); }
.card-link { display: flex; min-height: 150px; flex-direction: column; color: var(--ink); text-decoration: none; }
.card-link:hover { border-color: #b6cce6; transform: translateY(-2px); box-shadow: var(--shadow); }
.card-link .card-action { margin-top: auto; color: var(--blue); font-weight: 750; }
.card-icon { display: grid; width: 48px; height: 48px; place-items: center; margin-bottom: 1rem; border-radius: 12px; color: var(--blue); background: #edf5ff; font-size: 1.5rem; }
.card-icon.green { color: var(--green-dark); background: #edf9ee; }
.card-icon.gold { color: #9a6a09; background: #fff6df; }
.section-heading { display: flex; justify-content: space-between; gap: 1rem; align-items: center; margin: 2rem 0 .9rem; }
.section-heading h2 { margin: 0; font-size: 1.3rem; }
.empty-state { padding: 2rem; border: 1px dashed #bfcddd; border-radius: 14px; color: var(--muted); background: rgba(255,255,255,.65); text-align: center; }
.meta { color: var(--muted); font-size: .8rem; }
.tag { display: inline-flex; min-height: 25px; align-items: center; padding: .16rem .48rem; border-radius: 99px; color: #1f5f26; background: #e8f7e9; font-size: .72rem; font-weight: 750; }
.tag-warning { color: #7e5706; background: #fff3d7; }
.tag-muted { color: #55677d; background: #edf1f6; }
.tag-danger { color: #8b2530; background: #fde8eb; }
.card-topline { display: flex; justify-content: space-between; gap: .6rem; align-items: flex-start; }
.inline-actions { display: flex; flex-wrap: wrap; gap: .45rem; align-items: center; }
.favorite-form { margin-left: auto; }
.favorite-button { width: 36px; height: 36px; border: 1px solid var(--line); border-radius: 50%; color: #8a6c04; background: #fff; cursor: pointer; }

.material-card { overflow: hidden; padding: 0; }
.material-card img { display: block; width: 100%; aspect-ratio: 4 / 3; object-fit: cover; object-position: top; background: #edf3f9; }
.material-card-body { padding: 1rem; }
.material-card .button { width: 100%; margin-top: .55rem; }
.preview-layout { display: grid; grid-template-columns: minmax(300px, .95fr) minmax(320px, 1.05fr); gap: 1.2rem; }
.preview-image { min-height: 520px; padding: 1rem; text-align: center; }
.preview-image img { max-height: 640px; border: 1px solid var(--line); box-shadow: var(--shadow); }
.download-option { margin-bottom: .8rem; }
.viewer-shell { display: grid; height: calc(100vh - 170px); min-height: 540px; grid-template-rows: auto minmax(0, 1fr); }
.viewer-toolbar { display: flex; justify-content: space-between; gap: .7rem; align-items: center; padding: .75rem; border: 1px solid var(--line); border-bottom: 0; border-radius: 12px 12px 0 0; background: #fff; }
.pdf-frame { width: 100%; height: 100%; border: 1px solid var(--line); border-radius: 0 0 12px 12px; background: #dce3ea; }

.stats-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .8rem; margin-bottom: 1.4rem; }
.stat { padding: 1rem; border: 1px solid var(--line); border-radius: 13px; background: #fff; }
.stat strong { display: block; margin-top: .2rem; font-size: 1.7rem; }
.table-card { overflow: hidden; padding: 0; }
.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .87rem; }
th, td { padding: .75rem; border-bottom: 1px solid #e8edf3; text-align: left; vertical-align: middle; }
th { color: #42546e; background: #f7f9fc; font-size: .76rem; }
tr:last-child td { border-bottom: 0; }
.table-actions { display: flex; flex-wrap: wrap; gap: .35rem; min-width: 190px; }
.table-actions form { margin: 0; }
.password-reset-form { display: flex; width: 100%; gap: .35rem; }
.password-reset-form input { min-width: 160px; min-height: 34px; padding: .35rem .5rem; border: 1px solid var(--line); border-radius: 7px; }
.tabs { display: flex; gap: .35rem; overflow-x: auto; margin-bottom: 1rem; border-bottom: 1px solid var(--line); }
.tabs a { flex: 0 0 auto; padding: .65rem .8rem; color: var(--muted); border-bottom: 2px solid transparent; text-decoration: none; font-weight: 700; }
.tabs a.is-active { color: var(--blue); border-color: var(--blue); }
.admin-form { max-width: 820px; }
.danger-zone { border-color: #efb5bc; }

.error-shell { display: grid; min-height: 100vh; place-items: center; padding: 1rem; }
.error-card { width: min(100%, 520px); padding: 2rem; border-radius: 20px; background: #fff; box-shadow: var(--shadow); text-align: center; }
.error-card .brand { margin-bottom: 1.5rem; }
.error-symbol { display: grid; width: 68px; height: 68px; place-items: center; margin: 0 auto 1rem; border-radius: 50%; color: #fff; background: var(--danger); font-size: 2rem; font-weight: 900; }

@media (max-width: 1040px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 820px) {
  .app-shell { display: block; }
  .sidebar { position: fixed; left: 0; top: 0; width: min(310px, 88vw); transform: translateX(-105%); transition: transform .2s ease; }
  .sidebar.is-open { transform: translateX(0); }
  .menu-toggle { display: grid; }
  .menu-backdrop { position: fixed; inset: 0; z-index: 45; background: rgba(4, 20, 40, .48); }
  body.menu-open { overflow: hidden; }
  .preview-layout { grid-template-columns: 1fr; }
  .preview-image { min-height: auto; }
}

@media (max-width: 620px) {
  .public-shell { align-items: start; padding: 4rem .65rem 6rem; }
  .public-domain { left: 1rem; }
  .auth-card { padding: 1.5rem 1.05rem 1.8rem; border-radius: 17px; }
  .legal-shell { padding-bottom: 10rem; }
  .legal-card { padding: 1.35rem 1rem 1.6rem; border-radius: 17px; }
  .legal-card > .brand { margin-bottom: 1.7rem; }
  .public-footer { bottom: .35rem; }
  .auth-card > .brand { margin-bottom: 1.5rem; }
  .brand strong { font-size: 1.04rem; }
  .brand small { font-size: .58rem; }
  .brand-mark { width: 50px; height: 50px; font-size: 26px; }
  .topbar { padding: .65rem .8rem; }
  .topbar-title small, .user-chip strong { display: none; }
  .main-content { padding: 1rem .75rem 1.5rem; }
  .page-heading { align-items: flex-start; flex-direction: column; }
  .grid-2, .grid-3, .grid-4, .stats-grid { grid-template-columns: 1fr; }
  .form-split { align-items: flex-start; flex-direction: column; gap: .4rem; }
  .viewer-shell { height: calc(100vh - 135px); }
  .viewer-toolbar { align-items: flex-start; flex-direction: column; }
  table.responsive-table thead { display: none; }
  table.responsive-table, table.responsive-table tbody, table.responsive-table tr, table.responsive-table td { display: block; width: 100%; }
  table.responsive-table tr { padding: .7rem; border-bottom: 1px solid var(--line); }
  table.responsive-table td { display: grid; grid-template-columns: 115px minmax(0, 1fr); gap: .7rem; padding: .4rem 0; border: 0; }
  table.responsive-table td::before { content: attr(data-label); color: var(--muted); font-size: .72rem; font-weight: 800; }
  .table-actions { min-width: 0; }
  .password-reset-form { flex-direction: column; }
}
