:root {
  --ink: #20242b;
  --muted: #858a91;
  --line: #e7e5df;
  --surface: #ffffff;
  --canvas: #f4f1eb;
  --soft: #faf9f6;
  --coral: #ec705d;
  --coral-dark: #ce5d4e;
  --sage: #dbe7dc;
  --sage-ink: #42735b;
  --amber: #efc378;
  --mono: "DM Mono", monospace;
  --sans: "Manrope", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { scroll-behavior: smooth; }
body { margin: 0; background: var(--canvas); color: var(--ink); font-family: var(--sans); -webkit-font-smoothing: antialiased; }
button, input, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
a { color: inherit; text-decoration: none; }
h1, h2, h3, p { margin: 0; }

.main-content { min-width: 0; }
.topbar { height: 72px; padding: 0 5.1vw; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; }
.mobile-brand { display: flex; align-items: center; gap: 10px; font-size: 17px; font-weight: 800; letter-spacing: -0.06em; }
.topbar-actions { display: flex; align-items: center; gap: 4px; }
.icon-button { border: 0; background: transparent; color: #8f8f88; display: grid; place-items: center; width: 34px; height: 34px; border-radius: 8px; }
.icon-button:hover { color: var(--ink); background: #f1eee8; }
.brand-mark { display: grid; place-items: center; width: 27px; height: 27px; border-radius: 8px; color: white; background: var(--coral); font-family: Georgia, serif; font-size: 17px; font-weight: 700; letter-spacing: -0.1em; }
.brand-light { color: var(--coral); font-weight: 500; }

.page-wrap { max-width: 1100px; margin: 0 auto; padding: 46px 5.1vw 70px; }
.hero { display: flex; align-items: end; justify-content: space-between; margin-bottom: 32px; }
.section-kicker { display: block; margin-bottom: 14px; color: #9b9a94; font: 500 10px/1 var(--mono); letter-spacing: .12em; }
h1 { max-width: 600px; font-size: clamp(30px, 3.6vw, 46px); letter-spacing: -0.075em; line-height: .99; }
.hero p { margin-top: 15px; color: #898a87; font-size: 13px; max-width: 430px; }
.hero-decoration { display: flex; gap: 7px; align-items: end; margin: 0 6px 6px 0; }
.hero-decoration span { width: 10px; height: 10px; border-radius: 3px; background: var(--coral); transform: rotate(45deg); }
.hero-decoration span:nth-child(2) { width: 16px; height: 16px; background: #c9d5cb; }
.hero-decoration span:nth-child(3) { width: 7px; height: 7px; background: #e6bd76; }

.request-panel { border: 1px solid var(--line); border-radius: 14px; background: var(--surface); overflow: hidden; }
.panel-heading { min-height: 84px; display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 18px 27px; border-bottom: 1px solid var(--line); }
.title-with-status { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.title-with-status h2 { font-size: 17px; letter-spacing: -.04em; }
.status-pill { display: inline-flex; align-items: center; gap: 5px; padding: 5px 8px; border-radius: 99px; background: var(--sage); color: var(--sage-ink); font: 500 9px var(--mono); }
.status-pill span { width: 5px; height: 5px; border-radius: 50%; background: #6aa880; }
.panel-actions { display: flex; gap: 9px; }
.primary-button, .filter-button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border-radius: 8px; font-size: 10px; font-weight: 800; transition: .2s ease; }
.filter-button { border: 1px solid var(--line); background: white; color: #71736e; padding: 10px 13px; }
.filter-button:hover { border-color: #c9c5bb; background: var(--soft); }
select.filter-button { display: inline-block; padding-right: 8px; }
.primary-button { border: 1px solid var(--coral); background: var(--coral); color: white; padding: 10px 14px; box-shadow: 0 5px 12px rgba(236,112,93,.15); }
.primary-button:hover { background: var(--coral-dark); border-color: var(--coral-dark); transform: translateY(-1px); }
.primary-button span { font-size: 15px; font-weight: 400; }

.add-paper-form { padding: 22px 27px 24px; background: #fffaf5; border-bottom: 1px solid var(--line); }
.form-intro { display: flex; gap: 14px; align-items: flex-start; margin-bottom: 17px; }
.form-number { display: grid; place-items: center; width: 27px; height: 27px; border-radius: 8px; background: #f7dfd6; color: var(--coral-dark); font: 500 10px/1 var(--mono); }
.form-intro h3 { font-size: 13px; }
.form-intro p { margin-top: 5px; color: #989892; font-size: 10px; }
.add-paper-form textarea { display: block; width: 100%; border: 1px solid #e4dfd6; border-radius: 9px; outline: 0; resize: vertical; padding: 12px; background: white; color: var(--ink); font: 11px/1.6 var(--mono); }
.add-paper-form textarea:focus, .search-box:focus-within { border-color: var(--coral); box-shadow: 0 0 0 3px rgba(236,112,93,.1); }
.form-footer { display: flex; align-items: center; justify-content: space-between; margin-top: 14px; color: #aaa79e; font-size: 10px; }

.table-toolbar { display: flex; align-items: center; justify-content: space-between; padding: 22px 27px 17px; }
.table-title { display: flex; align-items: center; gap: 9px; }
.table-title h3 { font-size: 13px; }
.table-title span { padding: 4px 7px; border-radius: 99px; background: #f2f0eb; color: #a09f98; font: 500 9px var(--mono); }
.table-tools { display: flex; gap: 9px; }
.search-box { display: flex; align-items: center; gap: 7px; border: 1px solid var(--line); border-radius: 8px; padding: 0 10px; color: #aaa9a2; transition: .2s ease; }
.search-box input { width: 113px; border: 0; outline: 0; padding: 9px 0; color: var(--ink); font-size: 10px; background: transparent; }
.search-box input::placeholder { color: #aaa9a2; }

.files-table { width: 100%; }
.table-row { display: grid; grid-template-columns: minmax(210px, 1.4fr) .6fr .64fr .72fr .76fr 22px; align-items: center; gap: 16px; padding: 0 24px; }
.table-header { min-height: 35px; background: #fbfaf8; border-top: 1px solid #f0eee9; border-bottom: 1px solid #f0eee9; color: #9b9a94; font: 500 9px/1 var(--mono); letter-spacing: .12em; }
.col-sort { border: 0; padding: 0; background: transparent; font: inherit; color: inherit; letter-spacing: inherit; text-align: left; display: inline-flex; align-items: center; }
.col-sort:hover { color: var(--ink); }
.sort-caret { font-size: 8px; letter-spacing: 0; }
.sort-caret:not(:empty) { margin-left: 4px; }
.col-requested { color: #a09f99; font: 9px var(--mono); }
.row-delete { display: flex; justify-content: flex-end; }
.row-x { border: 0; background: transparent; color: #bcbab2; font-size: 15px; line-height: 1; padding: 2px 3px; }
.row-x:hover { color: var(--coral-dark); }
.paper-row { min-height: 81px; border-bottom: 1px solid #f0eee9; }
.paper-row:last-child { border-bottom: 0; }
.file-info { min-width: 0; display: flex; align-items: center; gap: 12px; }
.paper-type { display: grid; place-items: center; flex: 0 0 31px; width: 31px; height: 36px; border: 1px solid #e9d5ca; border-radius: 7px; background: #fff4ef; color: var(--coral); font: 500 8px var(--mono); position: relative; }
.paper-type:after { content: ""; width: 7px; height: 7px; position: absolute; right: -1px; top: -1px; border-top: 1px solid var(--coral); border-right: 1px solid var(--coral); border-radius: 0 7px 0 4px; background: #fff4ef; }
.paper-copy { min-width: 0; }
.paper-copy strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 11px; letter-spacing: -.01em; }
.paper-copy span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-top: 6px; color: #a09f99; font: 9px var(--mono); }
.source-link { display: inline-flex; align-items: center; gap: 5px; width: fit-content; color: #767974; font-size: 10px; font-weight: 700; }
.source-link:hover { color: var(--coral-dark); }
.source-link span { color: #b2afa7; font-size: 14px; }
.row-status { width: fit-content; display: inline-flex; align-items: center; gap: 6px; padding: 6px 8px; border-radius: 99px; font: 500 9px var(--mono); }
.row-status.ready { color: var(--sage-ink); background: var(--sage); }
.row-status.waiting { color: #9b7a42; background: #f9ebcf; }
.row-status span { width: 5px; height: 5px; border-radius: 50%; background: currentColor; }
.row-action { display: flex; justify-content: flex-start; }
.download-button, .upload-button { border: 0; border-radius: 7px; font-size: 10px; font-weight: 800; padding: 8px 10px; }
.download-button { color: var(--sage-ink); background: #eef5ee; }
.download-button:hover { background: #daeade; }
.upload-button { color: white; background: var(--ink); }
.upload-button:hover { background: #434850; }
.upload-wrap { display: flex; align-items: center; gap: 7px; }
.upload-count { color: #9d9a91; font: 9px var(--mono); }
.empty-state { padding: 55px 20px; text-align: center; border-top: 1px solid var(--line); }
.empty-icon { color: var(--coral); font-size: 27px; }
.empty-state h3 { margin-top: 10px; font-size: 14px; }
.empty-state p { margin-top: 6px; color: #999a95; font-size: 11px; }

.toast { position: fixed; z-index: 10; right: 24px; bottom: 24px; display: flex; align-items: center; gap: 9px; padding: 12px 15px; border: 1px solid #dce9dc; border-radius: 9px; background: #f4fbf4; color: var(--sage-ink); box-shadow: 0 10px 30px rgba(33,39,39,.12); font-size: 11px; transform: translateY(20px); opacity: 0; pointer-events: none; transition: .25s ease; }
.toast.is-visible { transform: translateY(0); opacity: 1; }
.toast-icon { display: grid; place-items: center; width: 17px; height: 17px; border-radius: 50%; background: #bcdcc1; font-size: 10px; }
.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; }

body.modal-open { overflow: hidden; }
.ghost-button { display: inline-flex; align-items: center; justify-content: center; border: 1px solid var(--line); border-radius: 8px; background: white; color: #71736e; padding: 10px 14px; font-size: 10px; font-weight: 800; }
.ghost-button:hover { border-color: #c9c5bb; background: var(--soft); }

.auth-overlay { position: fixed; inset: 0; z-index: 30; display: grid; place-items: center; padding: 20px; background: var(--canvas); }
.auth-card { width: min(100%, 360px); display: grid; gap: 12px; border: 1px solid var(--line); border-radius: 16px; background: #fffefa; padding: 30px 28px; box-shadow: 0 20px 60px rgba(32,36,43,.12); }
.auth-card h2 { font-size: 22px; letter-spacing: -.04em; margin-top: 6px; }
.auth-card > p { color: #8b8c87; font-size: 12px; margin-bottom: 4px; }
.auth-error { color: var(--coral-dark); font-size: 11px; }

.modal-backdrop { position: fixed; inset: 0; z-index: 30; display: grid; place-items: center; padding: 20px; background: rgba(32,36,43,.33); backdrop-filter: blur(5px); overflow-y: auto; }
.settings-card { width: min(100%, 460px); position: relative; border: 1px solid rgba(255,255,255,.65); border-radius: 16px; background: #fffefa; padding: 30px; box-shadow: 0 25px 70px rgba(32,36,43,.2); }
.settings-card h2 { font-size: 21px; letter-spacing: -.04em; }
.modal-close { position: absolute; top: 16px; right: 18px; width: 26px; height: 26px; border: 0; border-radius: 50%; background: #f0eee8; color: #8c8b84; font-size: 19px; line-height: 1; }
.modal-close:hover { color: var(--ink); background: #e6e3db; }
.settings-section { margin-top: 22px; padding-top: 20px; border-top: 1px solid var(--line); display: grid; gap: 10px; }
.settings-section h3 { font-size: 12px; }
.settings-section > p { color: #8b8c87; font-size: 11px; line-height: 1.5; }
.settings-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.form-msg { color: #7a8b7f; font-size: 10px; }
.auth-card label, .settings-section label { display: grid; gap: 5px; font-size: 10px; font-weight: 700; color: #7c7d78; letter-spacing: .02em; }
.auth-card input, .settings-section input { border: 1px solid #e4dfd6; border-radius: 8px; outline: 0; padding: 9px 10px; background: white; color: var(--ink); font-size: 12px; }
.auth-card input:focus, .settings-section input:focus { border-color: var(--coral); box-shadow: 0 0 0 3px rgba(236,112,93,.1); }
.twofa-qr { display: flex; justify-content: center; }
.twofa-qr img, .twofa-qr canvas { border: 9px solid #fff; border-radius: 10px; box-shadow: 0 4px 14px rgba(32,36,43,.1); }
.twofa-manual { font-size: 10px; color: #8b8c87; }
.twofa-secret { font: 500 11px var(--mono); letter-spacing: .04em; word-break: break-all; color: var(--ink); }
.twofa-link { color: var(--coral-dark); font-size: 10px; font-weight: 800; }
.twofa-actions { display: flex; gap: 8px; }

@media (max-width: 980px) {
  .topbar, .page-wrap { padding-left: 4vw; padding-right: 4vw; }
  .table-row { grid-template-columns: minmax(190px, 1.3fr) .58fr .62fr .68fr .7fr 20px; gap: 11px; padding-left: 18px; padding-right: 18px; }
  .panel-heading, .table-toolbar, .add-paper-form { padding-left: 18px; padding-right: 18px; }
}

@media (max-width: 760px) {
  .topbar { height: 62px; padding: 0 18px; }
  .page-wrap { padding: 32px 16px 48px; }
  .hero { margin-bottom: 24px; }
  .hero-decoration { display: none; }
  .panel-heading { display: block; padding-top: 18px; padding-bottom: 18px; }
  .panel-actions { margin-top: 15px; }
  .panel-actions button { flex: 1; }
  .table-toolbar { display: block; padding-top: 16px; }
  .table-tools { margin-top: 12px; }
  .search-box { flex: 1; }
  .search-box input { width: 100%; }
  .files-table { overflow-x: auto; }
  .table-row { min-width: 800px; }
}

@media (max-width: 430px) {
  h1 { font-size: 33px; }
  .form-footer { align-items: flex-start; gap: 15px; flex-direction: column; }
  .form-footer .primary-button { width: 100%; }
  .toast { right: 14px; left: 14px; bottom: 14px; }
}
