/* style.css — DocExchange */
:root {
  --paper: #f4efe6;
  --sheet: #fffdf9;
  --ink: #1d2a30;
  --muted: #5f6b70;
  --line: #ddd4c4;
  --sea: #1f4e5f;
  --sea-soft: #dbe8ec;
  --amber: #9a6a12;
  --amber-soft: #f6e7c8;
  --green: #2e6b47;
  --green-soft: #dcebdf;
  --red: #a23b2a;
  --red-soft: #f5dcd6;
  --shadow: 0 1px 2px rgba(29, 42, 48, .06), 0 4px 16px rgba(29, 42, 48, .06);
  --radius: 10px;
  --font-heading: "Iowan Old Style", "Charter", "Palatino Linotype", Georgia, serif;
  --font-body: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #151b1e; --sheet: #1d2529; --ink: #e8e4dc; --muted: #9aa5a9; --line: #334046;
    --sea: #7fb6c7; --sea-soft: #233a43; --amber: #e3b25a; --amber-soft: #3d3220;
    --green: #86c39c; --green-soft: #1f3428; --red: #e88a78; --red-soft: #3f2420;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3); color-scheme: dark;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--paper); color: var(--ink); font: 15px/1.5 var(--font-body); }
a { color: var(--sea); }
h1, h2 { font-family: var(--font-heading); font-weight: 600; letter-spacing: -.01em; }
h1 { font-size: 1.75rem; margin: 0; line-height: 1.2; }
h2 { font-size: 1.15rem; margin: 2rem 0 .75rem; }
code { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: .9em; background: var(--sea-soft); padding: .1em .35em; border-radius: 4px; word-break: break-all; }

/* top bar */
.topbar { display: flex; align-items: center; gap: 1.5rem; padding: .75rem max(16px, calc((100vw - 1040px) / 2)); background: var(--sheet); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: .55rem; font-family: var(--font-heading); font-size: 1.2rem; font-weight: 600; color: var(--ink); text-decoration: none; }
#nav { display: flex; gap: .25rem; flex: 1; }
#nav a { padding: .4rem .8rem; border-radius: 999px; text-decoration: none; color: var(--muted); font-weight: 500; }
#nav a:hover { color: var(--ink); background: var(--paper); }
#nav a.active { color: var(--sea); background: var(--sea-soft); }
#user { display: flex; align-items: center; gap: .75rem; margin-left: auto; font-size: .9rem; }
.who { color: var(--muted); }

main { max-width: 1040px; margin: 0 auto; padding: 2rem 16px 4rem; }
main.narrow { max-width: 720px; }

/* buttons and fields */
button { font: inherit; font-weight: 600; cursor: pointer; border: 1px solid var(--sea); background: var(--sea); color: var(--sheet); padding: .5rem 1rem; border-radius: 8px; }
button:hover { filter: brightness(1.08); }
button:disabled { opacity: .5; cursor: wait; }
button.secondary { background: transparent; color: var(--sea); border-color: var(--line); }
button.secondary:hover { border-color: var(--sea); filter: none; }
button.red, button.secondary.red { color: var(--red); border-color: var(--red-soft); background: transparent; }
button.red:hover { background: var(--red-soft); }
button.link-button { background: none; border: none; color: var(--sea); padding: 0; font-weight: 500; text-decoration: underline; text-underline-offset: 3px; }
button.icon { background: none; border: none; color: var(--muted); padding: .25rem .5rem; }
button.icon:hover { color: var(--red); }
select.lang-picker { width: auto; border: none; background: transparent; color: var(--muted); padding: .25rem; cursor: pointer; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 2px solid var(--amber); outline-offset: 2px; }

label { display: flex; flex-direction: column; gap: .3rem; font-weight: 500; font-size: .9rem; margin-bottom: 1rem; }
label small { font-weight: 400; color: var(--muted); }
label.check { flex-direction: row; align-items: center; gap: .5rem; font-weight: 400; }
input:not([type=checkbox]), select, textarea { font: inherit; color: inherit; background: var(--sheet); border: 1px solid var(--line); border-radius: 8px; padding: .5rem .65rem; width: 100%; min-width: 0; }
textarea { resize: vertical; }
input[type=checkbox] { width: 1.05rem; height: 1.05rem; accent-color: var(--sea); }
.two-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.inline { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.inline input:not([type=checkbox]) { flex: 1 1 14rem; width: auto; }
.inline select { width: auto; }
.inline label { margin: 0; }
.actions { display: flex; gap: 1rem; align-items: center; margin-top: .5rem; }

/* text */
.muted { color: var(--muted); }
.small { font-size: .82rem; color: var(--muted); }
.empty { color: var(--muted); padding: 2rem; text-align: center; border: 1px dashed var(--line); border-radius: var(--radius); }
.banner { background: var(--amber-soft); border-radius: 8px; padding: .6rem .9rem; font-size: .9rem; }

/* page */
.page-title { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; margin-bottom: 1.25rem; flex-wrap: wrap; }
.page-title input[type=search] { max-width: 18rem; }
.buttons { display: flex; gap: .5rem; flex-wrap: wrap; }
.back { display: inline-block; margin-bottom: .35rem; font-size: .9rem; text-decoration: none; color: var(--muted); }
.back:hover { color: var(--sea); }

/* sign-in */
.signin { max-width: 26rem; margin: 6vh auto 0; background: var(--sheet); padding: 2rem; border-radius: 14px; box-shadow: var(--shadow); border: 1px solid var(--line); }
.signin h1 { margin-bottom: .5rem; }
.step { margin-top: 1.5rem; }
.step .note { background: var(--green-soft); padding: .6rem .8rem; border-radius: 8px; font-size: .9rem; }
.step input[inputmode=numeric] { font-size: 1.4rem; letter-spacing: .3em; text-align: center; font-variant-numeric: tabular-nums; }

/* lists */
.list { display: flex; flex-direction: column; background: var(--sheet); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.row { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: .9rem 1.1rem; text-decoration: none; color: inherit; border-top: 1px solid var(--line); flex-wrap: wrap; }
.row:first-child { border-top: none; }
.row:hover { background: var(--paper); }
.row.dimmed { opacity: .6; }
.row-title { font-weight: 600; display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.row-meta { display: flex; gap: 1rem; color: var(--muted); font-size: .88rem; flex-wrap: wrap; }

.tag { display: inline-block; font-size: .72rem; font-weight: 600; padding: .1rem .5rem; border-radius: 999px; background: var(--sea-soft); color: var(--sea); white-space: nowrap; vertical-align: middle; font-family: var(--font-body); letter-spacing: 0; }
.tag.to_client { background: var(--sea-soft); color: var(--sea); }
.tag.from_client, .tag.client { background: var(--amber-soft); color: var(--amber); }
.tag.staff { background: var(--green-soft); color: var(--green); }
.tag.red { background: var(--red-soft); color: var(--red); }

/* tables */
.table { width: 100%; border-collapse: collapse; background: var(--sheet); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.table td, .table th { padding: .7rem .9rem; border-top: 1px solid var(--line); text-align: left; vertical-align: top; }
.table tr:first-child td { border-top: none; }
.table th { font-size: .8rem; color: var(--muted); font-weight: 600; border-top: none; background: var(--paper); }
.table.compact td { padding: .4rem .7rem; font-size: .88rem; }
.file-name a { font-weight: 600; text-decoration: none; word-break: break-word; }
.file-name a:hover { text-decoration: underline; }
.row-actions { text-align: right; width: 1%; white-space: nowrap; }

/* uploads */
.dropzone { border: 2px dashed var(--line); border-radius: var(--radius); padding: 1.5rem; text-align: center; background: var(--sheet); margin: 1rem 0 0; transition: border-color .15s, background .15s; }
.dropzone.over { border-color: var(--sea); background: var(--sea-soft); }
.dropzone-text { color: var(--muted); }
.queue { display: flex; flex-direction: column; gap: .4rem; margin-top: .75rem; text-align: left; }
.queue:empty { display: none; }
.queue-row { display: grid; grid-template-columns: 1fr auto 8rem; gap: .75rem; align-items: center; font-size: .88rem; }
.queue-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.queue-size { color: var(--muted); }
.bar { height: 6px; background: var(--paper); border-radius: 3px; overflow: hidden; }
.bar-fill { height: 100%; width: 0; background: var(--sea); transition: width .2s; }
.queue-row.done .bar-fill { background: var(--green); }
.queue-row.failed .bar { display: none; }
.queue-status { color: var(--red); grid-column: 1 / -1; }

/* members and audit */
.members { list-style: none; padding: 0; margin: 0 0 1rem; background: var(--sheet); border: 1px solid var(--line); border-radius: var(--radius); }
.members li { display: grid; grid-template-columns: 1fr auto auto auto; gap: 1rem; align-items: center; padding: .6rem 1rem; border-top: 1px solid var(--line); }
.members li:first-child { border-top: none; }
.audit { margin-top: 2rem; }
.audit summary { cursor: pointer; font-family: var(--font-heading); font-weight: 600; font-size: 1.1rem; }
.audit table { margin-top: .75rem; }

/* links */
.link-card { background: var(--sheet); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.1rem; display: flex; flex-direction: column; gap: .6rem; box-shadow: var(--shadow); }
.link-card.fresh { border-color: var(--green); background: var(--green-soft); }
.link-card p { margin: 0; }
.link-card .url { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: .88rem; }
.link-files { list-style: none; padding: 0; margin: 0; background: var(--sheet); border: 1px solid var(--line); border-radius: var(--radius); }
.dropzone + .link-files { margin-top: 1rem; }
.link-files li { display: flex; flex-wrap: wrap; gap: .25rem 1rem; align-items: baseline; padding: .8rem 1rem; border-top: 1px solid var(--line); }
.link-files li:first-child { border-top: none; }
.link-files a { font-weight: 600; word-break: break-word; }
.link-files details { width: 100%; }
.link-files summary { cursor: pointer; }

/* dialogs */
.dialog { border: none; border-radius: 14px; padding: 0; width: min(36rem, calc(100vw - 32px)); background: var(--sheet); color: var(--ink); box-shadow: 0 20px 60px rgba(0, 0, 0, .25); }
.dialog::backdrop { background: rgba(20, 30, 35, .45); }
.dialog form { padding: 1.5rem; }
.dialog h2 { margin-top: 0; }
.danger { border-top: 1px solid var(--line); padding-top: 1rem; margin-top: .5rem; }

/* toast */
.toast { position: fixed; left: 50%; bottom: 1.5rem; transform: translate(-50%, 1rem); background: var(--ink); color: var(--paper); padding: .7rem 1.1rem; border-radius: 10px; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; max-width: calc(100vw - 32px); z-index: 10; }
.toast.visible { opacity: 1; transform: translate(-50%, 0); }
.toast.error { background: var(--red); color: #fff; }

@media (max-width: 640px) {
  .topbar { gap: .75rem; }
  #nav { order: 3; flex-basis: 100%; }
  .who { display: none; }
  .two-cols { grid-template-columns: 1fr; }
  .members li { grid-template-columns: 1fr auto; }
  .table td:nth-child(3) { display: none; }
  .queue-row { grid-template-columns: 1fr auto; }
  .queue-row .bar { grid-column: 1 / -1; }
}

/* test outbox */
.outbox { display: flex; flex-direction: column; gap: 1rem; margin-top: 1.25rem; }
.mail { background: var(--sheet); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.1rem; box-shadow: var(--shadow); }
.mail-head { display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.mail-body { white-space: pre-wrap; font: inherit; margin: .75rem 0 0; }
mark.code { background: var(--amber-soft); color: var(--ink); font: 600 1.3em/1 ui-monospace, Menlo, Consolas, monospace; letter-spacing: .15em; padding: .1em .3em; border-radius: 4px; }

.inline + .members { margin-top: 1rem; }
