:root {
    --ink: #17221f;
    --muted: #68736f;
    --paper: #f7f5ef;
    --surface: #fffefa;
    --line: #deddd5;
    --forest: #143e35;
    --forest-soft: #e4eee9;
    --gold: #d69b3e;
    --gold-soft: #f6ead5;
    --shadow: 0 14px 40px rgba(28, 42, 37, 0.08);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    color: var(--ink);
    background: var(--paper);
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; background: var(--paper); }
button, input { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }

.topbar {
    height: 76px;
    padding: 0 32px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--forest);
    color: white;
}

.brand { display: inline-flex; align-items: center; gap: 12px; color: white; text-decoration: none; }
.brand-mark { display: grid; place-items: center; width: 38px; height: 38px; border: 1px solid rgba(255,255,255,.35); border-radius: 10px; color: var(--gold); font-family: Georgia, serif; font-size: 25px; }
.brand strong, .brand small { display: block; }
.brand strong { font-family: Georgia, serif; font-size: 20px; letter-spacing: .01em; }
.brand small { margin-top: 1px; color: #b8c9c4; font-size: 10px; font-weight: 700; letter-spacing: .16em; text-transform: uppercase; }
.topbar-actions { display: flex; align-items: center; gap: 12px; }
.icon-button, .avatar, .more-button { border: 0; cursor: pointer; }
.icon-button { width: 38px; height: 38px; border-radius: 10px; background: rgba(255,255,255,.08); color: white; font-size: 23px; }
.avatar {
    width: 38px;
    height: 38px;
    min-width: 38px;
    min-height: 38px;
    flex: 0 0 38px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    padding: 0;
    border-radius: 50%;
    background: var(--gold);
    color: #2f281d;
    font-family: Inter, ui-sans-serif, system-ui, sans-serif;
    font-size: 12px;
    font-weight: 800;
    line-height: 1;
    text-align: center;
    text-decoration: none;
    white-space: nowrap;
    vertical-align: middle;
}

.app-shell { min-height: calc(100vh - 76px); display: grid; grid-template-columns: 230px minmax(0, 1fr); }
.sidebar { padding: 34px 20px 24px; display: flex; flex-direction: column; justify-content: space-between; border-right: 1px solid var(--line); background: #f1efe8; }
.sidebar nav { display: grid; gap: 6px; }
.nav-item { padding: 11px 13px; display: flex; align-items: center; gap: 12px; border-radius: 9px; color: #56615d; font-size: 14px; font-weight: 650; text-decoration: none; }
.nav-item span { width: 20px; color: #74807b; font-size: 19px; text-align: center; }
.nav-item:hover, .nav-item.is-active { background: var(--surface); color: var(--forest); box-shadow: 0 1px 2px rgba(20, 62, 53, .06); }
.nav-item.is-active span { color: var(--gold); }
.sidebar-foot { padding: 16px 13px; border-top: 1px solid var(--line); color: var(--muted); font-size: 12px; line-height: 1.5; }
.sidebar-foot p { margin: 0 0 4px; }
.sidebar-foot strong { color: var(--forest); }

.content { width: min(1040px, 100%); margin: 0 auto; padding: 54px 48px 80px; }
.page-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; }
.eyebrow { margin: 0 0 10px; color: #9a681c; font-size: 11px; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; }
h1 { margin: 0; font-family: Georgia, serif; font-size: clamp(36px, 5vw, 52px); font-weight: 500; letter-spacing: -.025em; }
.lede { max-width: 600px; margin: 10px 0 0; color: var(--muted); line-height: 1.6; }
.primary-button { min-height: 44px; padding: 0 17px; border: 0; border-radius: 9px; background: var(--forest); color: white; cursor: pointer; font-weight: 750; box-shadow: 0 5px 14px rgba(20, 62, 53, .18); }
.primary-button:hover { background: #0d312a; }

.toolbar { margin: 38px 0 32px; display: grid; grid-template-columns: minmax(240px, 1fr) auto auto; gap: 10px; }
.search-field { height: 46px; display: flex; align-items: center; gap: 9px; padding: 0 13px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface); color: var(--muted); }
.search-field input { width: 100%; border: 0; outline: 0; background: transparent; color: var(--ink); }
.search-field:focus-within { border-color: #8ca9a1; box-shadow: 0 0 0 3px rgba(20,62,53,.08); }
.filter-button { padding: 0 14px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface); color: #49544f; cursor: pointer; font-size: 13px; font-weight: 650; }
.section-heading { margin-bottom: 12px; display: flex; align-items: baseline; justify-content: space-between; }
.section-heading h2 { margin: 0; font-family: Georgia, serif; font-size: 21px; font-weight: 600; }
.section-heading span { color: var(--muted); font-size: 12px; }
.document-list { overflow: hidden; border: 1px solid var(--line); border-radius: 13px; background: var(--surface); box-shadow: var(--shadow); }
.document-row { min-height: 82px; padding: 15px 18px; display: grid; grid-template-columns: 44px minmax(0, 1fr) auto 36px; align-items: center; gap: 14px; border-bottom: 1px solid #e8e6df; }
.document-row:last-child { border-bottom: 0; }
.document-row:hover { background: #fcfaf4; }
.file-icon { width: 40px; height: 48px; display: grid; place-items: end center; padding-bottom: 7px; border-radius: 4px 9px 4px 4px; background: var(--gold-soft); color: #8b5c18; font-size: 9px; font-weight: 900; letter-spacing: .04em; }
.document-info { min-width: 0; }
.document-info h3 { overflow: hidden; margin: 0 0 6px; font-size: 14px; font-weight: 750; text-overflow: ellipsis; white-space: nowrap; }
.document-info p { margin: 0; color: var(--muted); font-size: 12px; }
.status-badge { padding: 5px 8px; border-radius: 999px; background: var(--forest-soft); color: #2c6658; font-size: 10px; font-weight: 800; text-transform: uppercase; }
.status-badge.is-neutral { background: #eeece6; color: #66625a; }
.more-button { width: 34px; height: 34px; border-radius: 8px; background: transparent; color: #7c827f; letter-spacing: 2px; }
.more-button:hover { background: #efede6; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; }
.user-area { display:flex; align-items:center; gap:12px; font-size:13px; color:#dbe5e1; }
.user-area form { margin:0; }
.document-info a { color:inherit; text-decoration:none; }
.document-info a:hover { color:var(--forest); text-decoration:underline; }
.empty-state { padding:58px 20px; text-align:center; color:var(--muted); }
.empty-state strong { color:var(--ink); font-family:Georgia,serif; font-size:20px; }
.alert { margin:24px 0 -18px; padding:12px 14px; border-radius:8px; font-size:13px; }
.alert.is-error { background:#f8e5df; color:#823a2c; }
.alert.is-success { background:var(--forest-soft); color:#275d50; }
.login-page { min-height:100vh; display:grid; place-items:center; padding:24px; background:linear-gradient(140deg,#e8e4d9,var(--paper) 55%); }
.login-card { width:min(440px,100%); display:grid; gap:34px; padding:42px; border:1px solid var(--line); border-radius:18px; background:var(--surface); box-shadow:var(--shadow); }
.brand-dark { color:var(--forest); }
.brand-dark .brand-mark { border-color:#a9bab5; }
.brand-dark small { color:var(--muted); }
.login-form,.upload-form { display:grid; gap:17px; }
.login-form label,.upload-form label { display:grid; gap:7px; color:#4d5854; font-size:12px; font-weight:750; }
.login-form input,.upload-form input,.upload-form textarea { width:100%; min-height:44px; padding:10px 12px; border:1px solid var(--line); border-radius:8px; background:white; color:var(--ink); }
.upload-form textarea { resize:vertical; }
dialog { width:min(580px,calc(100% - 28px)); padding:0; border:0; border-radius:16px; background:var(--surface); box-shadow:0 24px 80px rgba(12,28,24,.28); }
dialog::backdrop { background:rgba(13,32,27,.54); backdrop-filter:blur(2px); }
.upload-form { padding:30px; }
.dialog-heading { display:flex; align-items:start; justify-content:space-between; }
.dialog-heading h2 { margin:0; font-family:Georgia,serif; font-size:28px; }
.close-button { width:36px;height:36px;border:0;border-radius:8px;background:#f0eee8;cursor:pointer;font-size:22px; }
.form-grid { display:grid; grid-template-columns:1fr 1fr; gap:12px; }
.account-content { max-width:820px; margin-left:0; }
.settings-card { margin-top:38px; display:grid; grid-template-columns:minmax(0,.8fr) minmax(280px,1fr); gap:42px; padding:30px; border:1px solid var(--line); border-radius:13px; background:var(--surface); box-shadow:var(--shadow); }
.settings-card h2 { margin:0 0 8px; font-family:Georgia,serif; font-size:22px; }
.settings-card p { margin:0; color:var(--muted); font-size:13px; line-height:1.6; }
.text-button { padding:0; border:0; background:transparent; color:#6a4431; cursor:pointer; font-weight:700; }
.document-page { width:min(1440px,100%); margin:0 auto; padding:38px 42px 70px; }
.back-link { display:inline-block; margin-bottom:28px; color:var(--forest); font-size:13px; font-weight:750; text-decoration:none; }
.back-link:hover { text-decoration:underline; }
.detail-heading { display:flex; align-items:flex-end; justify-content:space-between; gap:22px; }
.detail-heading h1 { font-size:clamp(30px,4vw,44px); }
.secondary-button { min-height:42px; padding:0 16px; display:inline-flex; align-items:center; justify-content:center; border:1px solid #9ca7a2; border-radius:9px; background:var(--surface); color:var(--forest); font-size:13px; font-weight:750; text-decoration:none; }
.secondary-button:hover { border-color:var(--forest); }
.detail-layout { margin-top:30px; display:grid; grid-template-columns:minmax(0,1.65fr) minmax(320px,.75fr); gap:20px; align-items:start; }
.preview-card,.details-card { overflow:hidden; border:1px solid var(--line); border-radius:13px; background:var(--surface); box-shadow:var(--shadow); }
.preview-card { min-height:720px; background:#e7e5de; }
.preview-card iframe { display:block; width:100%; height:78vh; min-height:720px; border:0; background:white; }
.preview-unavailable { min-height:620px; display:grid; place-items:center; align-content:center; gap:13px; padding:30px; text-align:center; }
.preview-unavailable h2,.details-card h2 { margin:0; font-family:Georgia,serif; font-size:22px; }
.preview-unavailable p,.details-card > div > p { margin:0; color:var(--muted); font-size:13px; line-height:1.55; }
.button-link { display:inline-flex; align-items:center; text-decoration:none; }
.details-card { padding:25px; }
.details-card > div { margin-bottom:22px; }
.detail-form { padding:0; }
.file-facts { margin:26px 0 0; padding-top:20px; display:grid; gap:10px; border-top:1px solid var(--line); }
.file-facts div { display:grid; grid-template-columns:90px minmax(0,1fr); gap:10px; font-size:11px; }
.file-facts dt { color:var(--muted); }
.file-facts dd { overflow-wrap:anywhere; margin:0; color:#48514e; }

@media (max-width: 760px) {
    .topbar { height: 66px; padding: 0 18px; }
    .app-shell { min-height: calc(100vh - 66px); display: block; }
    .sidebar { padding: 10px 14px; border-right: 0; border-bottom: 1px solid var(--line); }
    .sidebar nav { display: flex; overflow-x: auto; }
    .sidebar-foot { display: none; }
    .nav-item { flex: 0 0 auto; }
    .content { padding: 36px 18px 64px; }
    .page-heading { display: grid; }
    .primary-button { width: 100%; }
    .toolbar { margin-top: 26px; grid-template-columns: 1fr 1fr; }
    .search-field { grid-column: 1 / -1; }
    .filter-button { min-height: 42px; }
    .document-row { grid-template-columns: 40px minmax(0, 1fr) 32px; padding: 14px; }
    .status-badge { display: none; }
    .user-area > span { display:none; }
    .login-card { padding:30px 24px; }
    .form-grid { grid-template-columns:1fr; }
    .settings-card { grid-template-columns:1fr; gap:24px; padding:22px; }
    .document-page { padding:28px 18px 50px; }
    .detail-heading { display:grid; }
    .detail-heading .secondary-button { width:100%; }
    .detail-layout { grid-template-columns:1fr; }
    .preview-card,.preview-card iframe { min-height:520px; height:62vh; }
}

@media (min-width:761px) and (max-width:1080px) {
    .detail-layout { grid-template-columns:1fr; }
}
