:root {
  --bg: #F6F7F5;
  --paper: #FFFFFF;
  --ink: #1D2422;
  --muted: #6A7370;
  --line: #D8DDD9;
  --accent: #1F5F5B;
  --accent-ink: #FFFFFF;
  --warn: #FFF1B8;
  --bad: #B3261E;
  --ok: #1F5F5B;
  --radius: 6px;
  --font: "IBM Plex Sans", "Noto Sans JP", system-ui, -apple-system, "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.5 var(--font); }
a { color: var(--accent); }
h1 { font-size: 22px; font-weight: 600; margin: 0 0 4px; letter-spacing: -0.01em; }
.muted { color: var(--muted); }
.error { color: var(--bad); }
.ok { color: var(--ok); }
button, .button {
  font: inherit; padding: 7px 14px; border-radius: var(--radius);
  border: 1px solid var(--line); background: var(--paper); color: var(--ink); cursor: pointer;
  text-decoration: none; display: inline-block;
}
button:hover, .button:hover { border-color: var(--accent); }
button.primary, .button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
button.link { border: 0; background: none; color: var(--accent); padding: 0; text-decoration: underline; }
button.small { padding: 3px 8px; font-size: 13px; }
button:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible, a:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}
input, textarea, select {
  font: inherit; color: var(--ink); background: var(--paper);
  border: 1px solid var(--line); border-radius: var(--radius); padding: 6px 8px; width: 100%;
}
label { display: block; margin-bottom: 12px; }
label.inline { display: inline-flex; align-items: center; gap: 6px; margin: 8px 0 0; }
label.inline input { width: 64px; }

/* login / center */
body.center { display: grid; place-items: center; min-height: 100vh; }
.card { background: var(--paper); border: 1px solid var(--line); border-radius: 10px; padding: 28px; }
.login { width: min(360px, 92vw); }
.login h1 { margin-top: 0; }
.login button { width: 100%; margin-top: 6px; }

/* header */
.top { display: flex; align-items: center; justify-content: space-between; padding: 14px 24px; border-bottom: 1px solid var(--line); background: var(--paper); }
.brand { font-weight: 600; color: var(--ink); text-decoration: none; font-size: 17px; }
.top nav { display: flex; gap: 18px; align-items: center; }
main { padding: 20px 24px 60px; }
main.narrow { max-width: 640px; }

/* drop zone */
.drop { border: 1.5px dashed var(--line); border-radius: 10px; background: var(--paper); padding: 26px; text-align: center; transition: border-color .15s, background .15s; }
.drop.over { border-color: var(--accent); background: #EEF4F3; }
.drop-title { font-size: 17px; margin: 0 0 4px; }
.drop .muted { margin: 0; }
.progress { margin-top: 12px; font-size: 14px; color: var(--accent); }

/* toolbar */
.toolbar { display: flex; gap: 12px; align-items: center; margin: 18px 0 10px; }
.toolbar input[type=search] { max-width: 360px; }
.grow { flex: 1; }

/* table */
.tablewrap { overflow-x: auto; background: var(--paper); border: 1px solid var(--line); border-radius: 10px; }
table { border-collapse: collapse; width: 100%; min-width: 1200px; font-size: 14px; }
th, td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; white-space: nowrap; }
th { font-weight: 500; color: var(--muted); background: #FAFBFA; position: sticky; top: 0; }
tbody tr:last-child td { border-bottom: 0; }
td input, td select { padding: 4px 6px; border-color: transparent; background: transparent; min-width: 90px; }
td input:hover, td select:hover { border-color: var(--line); background: var(--paper); }
td input:focus, td select:focus { border-color: var(--accent); background: var(--paper); }
td input.lowconf, td select.lowconf { background: var(--warn); border-color: transparent; }
td.file { min-width: 200px; max-width: 260px; white-space: normal; }
td.file button { max-width: 200px; overflow: hidden; text-overflow: ellipsis; }
td.amount input { text-align: right; width: 110px; }
td.link { font-size: 13px; }
td.link code { user-select: all; }
.status { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--line); }
.status.processing { background: #E0A800; animation: pulse 1s infinite alternate; }
.status.ready { background: var(--ok); }
.status.error { background: var(--bad); }
.status.revoked, .status.expired { background: var(--muted); }
@keyframes pulse { from { opacity: .4 } to { opacity: 1 } }
@media (prefers-reduced-motion: reduce) { .status.processing { animation: none; } }
.empty { padding: 40px; text-align: center; color: var(--muted); margin: 0; }
tr.err td.file small { color: var(--bad); display: block; line-height: 1.3; }
.actions { display: flex; gap: 4px; }

/* preview drawer */
.preview { position: fixed; inset: 0 0 0 auto; width: min(720px, 100vw); background: var(--paper); border-left: 1px solid var(--line); display: flex; flex-direction: column; z-index: 10; box-shadow: -8px 0 24px rgba(0,0,0,.08); }
.preview-bar { display: flex; justify-content: space-between; align-items: center; padding: 10px 14px; border-bottom: 1px solid var(--line); }
.preview iframe { flex: 1; border: 0; width: 100%; }

/* settings */
.settings textarea { font-family: var(--font); }

/* public page */
body.public { background: #EDEFEC; }
.pub { max-width: 960px; margin: 0 auto; padding: 24px 16px 60px; }
.pub-head { background: var(--paper); border: 1px solid var(--line); border-radius: 10px; padding: 22px 24px; margin-bottom: 16px; }
.pub-head h1 { font-size: 20px; margin: 2px 0 12px; }
.meta { display: grid; grid-template-columns: max-content 1fr; gap: 4px 16px; margin: 0 0 18px; }
.meta dt { color: var(--muted); }
.meta dd { margin: 0; }
.viewer { background: var(--paper); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; min-height: 60vh; }
.viewer iframe { width: 100%; height: 80vh; border: 0; }
.viewer img { display: block; max-width: 100%; margin: 0 auto; }
.nopreview { padding: 60px 24px; text-align: center; }
@media (max-width: 640px) {
  main { padding: 14px 12px 40px; }
  .top { padding: 12px 14px; }
  .top nav { gap: 12px; font-size: 14px; }
  .pub-head { padding: 16px; }
  .meta { grid-template-columns: 1fr; gap: 2px; }
  .meta dt { margin-top: 6px; }
  .viewer iframe { height: 70vh; }
}
