:root {
  --navy: #0f172a;
  --navy-soft: #1e293b;
  --slate: #64748b;
  --slate-light: #94a3b8;
  --line: #e2e8f0;
  --bg: #f6f8fb;
  --card: #ffffff;
  --brand: #1d4ed8;
  --brand-dark: #1e40af;
  --ok: #15803d;
  --ok-bg: #ecfdf5;
  --warn: #b45309;
  --warn-bg: #fffbeb;
  --ko: #b91c1c;
  --ko-bg: #fef2f2;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .04), 0 8px 24px rgba(15, 23, 42, .06);
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.6;
  color: var(--navy);
  background: var(--bg);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

a { color: var(--brand); }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .5em; letter-spacing: -.01em; }
h1 { font-size: 1.75rem; }
h2 { font-size: 1.15rem; }
p { margin: 0 0 1rem; }

.mono { font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace; }
.small { font-size: .82rem; }
.muted { color: var(--slate); }
.center { text-align: center; }
.nowrap { white-space: nowrap; }
.break { word-break: break-all; }
.hidden { display: none !important; }

/* ------------------------------ Header ---------------------------------- */

.site-header {
  background: var(--navy);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: .75rem clamp(1rem, 4vw, 2.5rem);
  flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: .8rem; color: #fff; text-decoration: none; }
.brand-logo {
  display: block;
  height: 58px;
  width: auto;
  border-radius: 7px;
  background: #fff;
  padding: 4px;
}
@media (max-width: 640px) { .brand-logo { height: 46px; } }
.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
  padding-left: .8rem;
  border-left: 1px solid rgba(255, 255, 255, .18);
}
.brand-text strong { font-size: .95rem; font-weight: 600; }
.brand-text small { color: var(--slate-light); font-size: .74rem; }

.site-nav { display: flex; align-items: center; gap: .25rem; flex-wrap: wrap; }
.site-nav a {
  color: #cbd5e1;
  text-decoration: none;
  font-size: .88rem;
  padding: .45rem .7rem;
  border-radius: 8px;
}
.site-nav a:hover { background: rgba(255, 255, 255, .08); color: #fff; }
.site-nav a.active { background: rgba(255, 255, 255, .12); color: #fff; }
.site-nav a.nav-cta { background: var(--brand); color: #fff; }
.site-nav a.nav-cta:hover { background: #2563eb; }

.site-main { flex: 1; width: 100%; max-width: 1180px; margin: 0 auto; padding: clamp(1.25rem, 3vw, 2.25rem) clamp(1rem, 4vw, 2rem) 3rem; }
body.page-result .site-main, body.page-login .site-main { max-width: 780px; }

.site-footer {
  border-top: 1px solid var(--line);
  background: #fff;
  color: var(--slate);
  font-size: .82rem;
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  padding: 1rem clamp(1rem, 4vw, 2.5rem);
}

/* ------------------------------ Buttons --------------------------------- */

.btn, button, .verify-form button {
  display: inline-block;
  background: var(--brand);
  color: #fff;
  border: 1px solid transparent;
  border-radius: 9px;
  padding: .6rem 1.05rem;
  font: inherit;
  font-size: .92rem;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  transition: background .15s ease, border-color .15s ease;
}
.btn:hover, button:hover { background: var(--brand-dark); }
.btn-secondary { background: #fff; color: var(--navy); border-color: var(--line); }
.btn-secondary:hover { background: #f1f5f9; }
.btn-ghost { background: transparent; color: var(--slate); border-color: transparent; }
.btn-ghost:hover { background: #eef2f7; color: var(--navy); }
.btn-danger { background: var(--ko); }
.btn-danger:hover { background: #991b1b; }
.link { color: var(--brand); text-decoration: none; font-size: .85rem; margin-right: .6rem; }
.link:hover { text-decoration: underline; }

input[type=text], input[type=search], input[type=password], input[type=date],
input[type=number], input[type=email], select, textarea {
  width: 100%;
  font: inherit;
  font-size: .93rem;
  color: var(--navy);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: .55rem .7rem;
}
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(29, 78, 216, .35); outline-offset: 1px; border-color: var(--brand); }
label { display: block; font-size: .8rem; font-weight: 600; color: var(--navy-soft); margin-bottom: .85rem; }
label input, label select, label textarea { margin-top: .3rem; font-weight: 400; }
label.check { display: flex; align-items: center; gap: .5rem; font-weight: 400; font-size: .88rem; }
label.check input { width: auto; margin: 0; }

/* -------------------------------- Hero ---------------------------------- */

.hero { background: var(--card); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow); padding: clamp(1.5rem, 4vw, 3rem); }
.hero-inner { max-width: 640px; margin: 0 auto; text-align: center; }
.eyebrow { text-transform: uppercase; letter-spacing: .1em; font-size: .7rem; font-weight: 700; color: var(--brand); margin-bottom: .6rem; }
.hero h1 { font-size: clamp(1.6rem, 4vw, 2.2rem); }
.lead { color: var(--slate); font-size: 1rem; }

.verify-form { display: flex; gap: .5rem; margin: 1.5rem 0 .75rem; flex-wrap: wrap; }
.verify-form input {
  flex: 1 1 260px;
  text-align: center;
  letter-spacing: .06em;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  text-transform: uppercase;
  padding: .75rem;
}
.verify-form button { padding: .75rem 1.5rem; }

.file-check { margin-top: 1rem; text-align: left; border-top: 1px solid var(--line); padding-top: 1rem; }
.file-check summary { cursor: pointer; font-size: .88rem; color: var(--brand); }
.file-check form { margin-top: .9rem; display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; }
.file-check input[type=file] { flex: 1 1 240px; font-size: .85rem; }
.hint { font-size: .78rem; color: var(--slate); margin: .4rem 0 0; flex-basis: 100%; }

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 1rem; margin-top: 1.5rem; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.25rem; }
.card h3 { font-size: .95rem; }
.card p { margin: 0; font-size: .88rem; color: var(--slate); }

.prose { background: var(--card); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow); padding: clamp(1.5rem, 4vw, 2.5rem); }
.prose li { margin-bottom: .4rem; }

/* ------------------------------- Result --------------------------------- */

.result { background: var(--card); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow); padding: clamp(1.5rem, 4vw, 2.25rem); border-top: 5px solid var(--slate); }
.result-ok { border-top-color: var(--ok); }
.result-warn { border-top-color: var(--warn); }
.result-ko { border-top-color: var(--ko); }
.result-head { display: flex; gap: 1.1rem; align-items: flex-start; margin-bottom: 1.5rem; }
.result-head h1 { margin-bottom: .25rem; }
.result-head p { margin: 0; color: var(--slate); }
.result-icon { width: 46px; height: 46px; border-radius: 50%; flex: none; position: relative; }
.result-ok .result-icon { background: var(--ok-bg); }
.result-warn .result-icon { background: var(--warn-bg); }
.result-ko .result-icon { background: var(--ko-bg); }
.result-icon::after {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font-size: 1.4rem; font-weight: 700;
}
.result-ok .result-icon::after { content: "✓"; color: var(--ok); }
.result-warn .result-icon::after { content: "!"; color: var(--warn); }
.result-ko .result-icon::after { content: "✕"; color: var(--ko); }
.code-line { margin-top: .6rem !important; font-size: .95rem; letter-spacing: .05em; color: var(--navy); }

.detail-list { margin: 0 0 1.25rem; border-top: 1px solid var(--line); }
.detail-list > div { display: flex; gap: 1rem; padding: .7rem 0; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.detail-list dt { flex: 0 0 190px; font-size: .74rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--slate); margin: 0; padding-top: .15rem; }
.detail-list dd { margin: 0; flex: 1 1 220px; word-break: break-word; }
.timestamp { font-size: .78rem; color: var(--slate-light); margin: 1.25rem 0 0; }

.alert { border-radius: 10px; padding: .7rem .95rem; font-size: .88rem; margin: 0 0 1rem; border: 1px solid; }
.alert-ok { background: var(--ok-bg); border-color: #bbf7d0; color: var(--ok); }
.alert-warn { background: var(--warn-bg); border-color: #fde68a; color: var(--warn); }
.alert-ko { background: var(--ko-bg); border-color: #fecaca; color: var(--ko); }

/* -------------------------------- Login --------------------------------- */

.login-card { background: var(--card); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow); padding: 2rem; max-width: 420px; margin: 2rem auto; }
.login-card button { width: 100%; margin-top: .5rem; padding: .7rem; }

/* -------------------------------- Admin --------------------------------- */

.page-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.25rem; }
.page-head h1 { margin: 0; }
.head-actions { display: flex; gap: .5rem; flex-wrap: wrap; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: .9rem; margin-bottom: 1.5rem; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.1rem; display: flex; flex-direction: column; gap: .15rem; }
.stat-num { font-size: 1.75rem; font-weight: 700; letter-spacing: -.02em; }
.stat-lbl { font-size: .78rem; color: var(--slate); }
.stat-ok .stat-num { color: var(--ok); }
.stat-warn .stat-num { color: var(--warn); }
.stat-ko .stat-num { color: var(--ko); }

.panel { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.25rem; margin-bottom: 1.25rem; }
.panel > h2:first-child { margin-top: 0; }
.two-col { display: grid; grid-template-columns: repeat(auto-fit, minmax(330px, 1fr)); gap: 1.25rem; align-items: start; }
.detail-grid { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(280px, 1fr); gap: 1.25rem; align-items: start; }
@media (max-width: 860px) { .detail-grid { grid-template-columns: 1fr; } }

.table { width: 100%; border-collapse: collapse; font-size: .88rem; }
.table th { text-align: left; font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; color: var(--slate); font-weight: 700; padding: .45rem .5rem; border-bottom: 1px solid var(--line); }
.table td { padding: .6rem .5rem; border-bottom: 1px solid #f1f5f9; vertical-align: top; }
.table tr:last-child td { border-bottom: none; }
.table-list { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.table-list th { background: #f8fafc; padding: .6rem .75rem; }
.table-list td { padding: .65rem .75rem; }
.tick { width: 32px; }

.badge { display: inline-block; font-size: .7rem; font-weight: 700; padding: .15rem .5rem; border-radius: 999px; text-transform: uppercase; letter-spacing: .04em; }
.badge-ok { background: var(--ok-bg); color: var(--ok); }
.badge-warn { background: var(--warn-bg); color: var(--warn); }
.badge-ko { background: var(--ko-bg); color: var(--ko); }

.filters { display: flex; gap: .5rem; flex-wrap: wrap; margin-bottom: 1rem; }
.filters input[type=search] { flex: 1 1 260px; }
.filters select { flex: 0 0 auto; width: auto; }

.bulk-bar { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; margin-bottom: .75rem; padding: .6rem .75rem; background: #eef2f7; border-radius: var(--radius); }
.bulk-bar select, .bulk-bar input[type=text] { width: auto; flex: 0 1 auto; }
.pager { display: flex; align-items: center; justify-content: center; gap: 1rem; margin-top: 1.25rem; }

.grid-form { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 0 1rem; }
.grid-form .full { grid-column: 1 / -1; }
.form-actions { display: flex; gap: .6rem; margin-top: .5rem; }
.meta-panel summary { cursor: pointer; font-weight: 600; font-size: .95rem; margin-bottom: 1rem; }
.meta-list { margin: 0; }
.meta-list > div { padding: .45rem 0; border-bottom: 1px solid #f1f5f9; }
.meta-list dt { font-size: .7rem; text-transform: uppercase; letter-spacing: .05em; color: var(--slate); font-weight: 700; }
.meta-list dd { margin: .1rem 0 0; }
.file-list { padding-left: 1.1rem; font-size: .9rem; }
.file-list li { margin-bottom: .4rem; }
.qr-preview { display: block; margin: 0 auto .5rem; border: 1px solid var(--line); border-radius: 10px; padding: 8px; background: #fff; }

/* ------------------------------ Dropzone -------------------------------- */

.dropzone {
  border: 2px dashed #cbd5e1;
  border-radius: 16px;
  background: var(--card);
  padding: clamp(1.5rem, 5vw, 3rem) 1.5rem;
  text-align: center;
  transition: border-color .15s ease, background .15s ease;
  margin-bottom: 1.25rem;
}
.dropzone.dragover { border-color: var(--brand); background: #eff6ff; }
.dz-inner { display: flex; flex-direction: column; gap: .5rem; align-items: center; }
.dz-inner strong { font-size: 1.05rem; }
.dz-buttons { display: flex; gap: .5rem; flex-wrap: wrap; justify-content: center; margin-top: .75rem; }

.queue-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: .75rem; }
.queue-head h2 { margin: 0; }
.queue-actions { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.queue { max-height: 340px; overflow-y: auto; border: 1px solid var(--line); border-radius: 10px; }
.queue-item { display: flex; justify-content: space-between; gap: 1rem; padding: .5rem .75rem; border-bottom: 1px solid #f1f5f9; font-size: .85rem; }
.queue-item:last-child { border-bottom: none; }
.queue-item .qi-name { word-break: break-all; }
.queue-item .qi-size { color: var(--slate); white-space: nowrap; font-size: .78rem; }
.queue-item button { background: none; color: var(--slate); border: none; padding: 0 .25rem; font-size: 1rem; line-height: 1; }
.queue-item button:hover { background: none; color: var(--ko); }

.progress { height: 8px; background: #e2e8f0; border-radius: 999px; overflow: hidden; margin-bottom: .75rem; }
.progress-bar { height: 100%; width: 0; background: var(--brand); transition: width .2s ease; }

.summary { display: flex; gap: .6rem; flex-wrap: wrap; margin-bottom: 1rem; }
.summary span { font-size: .85rem; font-weight: 600; padding: .35rem .75rem; border-radius: 999px; }
.results { max-height: 420px; overflow-y: auto; border: 1px solid var(--line); border-radius: 10px; }
.res-item { display: flex; gap: .75rem; align-items: baseline; padding: .5rem .75rem; border-bottom: 1px solid #f1f5f9; font-size: .85rem; }
.res-item:last-child { border-bottom: none; }
.res-item .res-code { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: .78rem; white-space: nowrap; }
.res-item .res-file { flex: 1; word-break: break-all; }
.res-ok { color: var(--ok); }
.res-dup { color: var(--warn); }
.res-ko { color: var(--ko); }

@media (max-width: 640px) {
  .table-list, .table-list thead, .table-list tbody, .table-list th, .table-list td, .table-list tr { display: block; }
  .table-list thead { display: none; }
  .table-list tr { border-bottom: 1px solid var(--line); padding: .5rem 0; }
  .table-list td { border: none; padding: .2rem .75rem; }
  .detail-list dt { flex-basis: 100%; }
}
