:root {
  color-scheme: light;
  --bg: #ece7df;
  --panel: #fbfaf7;
  --panel-2: #f4efe7;
  --ink: #111111;
  --ink-2: #2d2a26;
  --muted: #756d63;
  --line: #d8cfc3;
  --line-2: #c9b9a5;
  --copper: #b7793a;
  --copper-dark: #8f5520;
  --success: #166534;
  --success-bg: #eaf5ed;
  --danger: #a11d33;
  --danger-bg: #fff0f2;
  --warning: #7a4d00;
  --warning-bg: #fff5dc;
  --shadow: 0 24px 60px rgba(17, 17, 17, .12);
}

* { box-sizing: border-box; }
html, body { height: 100%; overflow: hidden; }
body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at 12% 0%, rgba(183,121,58,.20), transparent 32rem),
    linear-gradient(135deg, #f8f5ef 0%, var(--bg) 100%);
  color: var(--ink);
}
button, input { font: inherit; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: clamp(28px, 3.5vw, 42px); letter-spacing: -.055em; line-height: .95; }
h2 { margin-bottom: 5px; font-size: 26px; letter-spacing: -.035em; }
h3 { margin-bottom: 6px; font-size: 18px; letter-spacing: -.02em; }
p { color: var(--muted); line-height: 1.4; }

.page-shell { height: 100dvh; padding: 18px; }
.hidden { display: none !important; }

.portal {
  height: calc(100dvh - 36px);
  background: rgba(251,250,247,.94);
  border: 1px solid var(--line);
  border-radius: 24px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.auth-panel {
  width: min(430px, 100%);
  height: auto;
  min-height: 0;
  margin: min(10vh, 80px) auto 0;
  padding: 28px;
  display: grid;
  gap: 18px;
  align-content: start;
}
.auth-logo { margin: 0 auto 4px; width: 184px; }
.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel-2);
}
.tab-btn {
  border: 0;
  border-radius: 10px;
  padding: 10px 12px;
  background: transparent;
  color: var(--muted);
  font-weight: 900;
  cursor: pointer;
}
.tab-btn.active { background: var(--ink); color: #f7f1e8; }
.login-form, .auth-form {
  padding: 0;
  display: grid;
  gap: 14px;
  width: 100%;
}
.auth-form .btn { width: 100%; height: 48px; }
.portal { display: grid; grid-template-rows: 72px 1fr; padding: 16px; gap: 14px; }
.portal-header {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 18px;
  border-bottom: 1px solid var(--line);
  padding: 0 4px 14px;
}
.header-title { display: grid; gap: 2px; }
.header-title span, .eyebrow {
  color: var(--copper-dark);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: .14em;
  text-transform: uppercase;
}
.header-title strong { font-size: 18px; letter-spacing: -.02em; }

.portal-grid {
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(360px, .82fr) minmax(460px, 1.18fr);
  gap: 14px;
}
.work-card, .result-card, .summary-card, .decision-card, .technical-details {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 20px;
}
.work-card, .result-card {
  min-height: 0;
  padding: 16px;
  overflow: hidden;
}
.work-card { display: grid; grid-template-rows: auto 1fr auto auto; gap: 12px; }
.card-head { display: flex; justify-content: space-between; align-items: start; gap: 12px; }
.card-head small { color: var(--muted); font-weight: 750; }
.verify-form { min-height: 0; display: grid; grid-template-rows: 1fr auto; gap: 12px; }
.capture-grid { min-height: 0; display: grid; grid-template-columns: 1fr; gap: 10px; }
.capture-card {
  min-height: 0;
  display: grid;
  grid-template-rows: auto auto 1fr;
  gap: 8px;
  padding: 12px;
  border: 1px dashed var(--line-2);
  border-radius: 16px;
  background: linear-gradient(180deg, #fffdfa, var(--panel-2));
  cursor: pointer;
  position: relative;
  overflow: hidden;
  transition: border-color .15s ease, background .15s ease, transform .15s ease;
}
.capture-card:hover, .capture-card.is-dragging { border-color: var(--copper); background: #fff8ef; transform: translateY(-1px); }
.capture-title { font-weight: 900; color: var(--ink); }
.capture-card input[type="file"] {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
  z-index: 5;
}
.preview-placeholder {
  position: relative;
  z-index: 1;
  min-height: 96px;
  border-radius: 12px;
  border: 1px solid var(--line);
  display: grid;
  place-items: center;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  background: rgba(255,255,255,.58);
}
.capture-card img { position: relative; z-index: 1; display: none; width: 100%; height: 118px; object-fit: contain; border-radius: 12px; background: white; border: 1px solid var(--line); }
.capture-card.has-file .preview-placeholder { display: none; }
.capture-card img.has-image { display: block; }

.field { display: grid; gap: 7px; width: 100%; }
.field span { font-weight: 850; color: var(--ink-2); font-size: 13px; }
input[type="text"],
input[type="password"] {
  width: 100%;
  height: 48px;
  border: 1px solid var(--line);
  background: white;
  color: var(--ink);
  border-radius: 13px;
  padding: 0 14px;
  outline: none;
  display: block;
}
input[type="text"]:focus,
input[type="password"]:focus {
  border-color: var(--copper);
  box-shadow: 0 0 0 4px rgba(183,121,58,.12);
}

.btn {
  border: 0;
  border-radius: 13px;
  padding: 12px 16px;
  font-weight: 900;
  cursor: pointer;
}
.btn-primary { background: var(--ink); color: #f7f1e8; box-shadow: 0 12px 24px rgba(17,17,17,.18); }
.btn-primary:hover { background: #2a2119; }
.btn-ghost { background: var(--panel-2); color: var(--ink); border: 1px solid var(--line); }
.submit-btn { width: 100%; min-height: 48px; }

.result-card { display: grid; grid-template-rows: auto minmax(0, auto) minmax(0, auto) auto auto; gap: 10px; }
.decision-card { padding: 15px; display: flex; justify-content: space-between; gap: 14px; }
.decision-card p { margin-bottom: 0; font-size: 14px; }
.decision-approved { background: var(--success-bg); border-color: #b8dbc3; }
.decision-rejected { background: var(--danger-bg); border-color: #ffc6cf; }
.decision-resubmission, .decision-pending { background: var(--warning-bg); border-color: #efd08f; }
.decision-completed, .decision-neutral { background: #f5f0e8; }
.status-pill { white-space: nowrap; align-self: flex-start; border-radius: 999px; padding: 8px 10px; background: white; border: 1px solid var(--line); font-size: 12px; font-weight: 950; }
.status-approved { color: var(--success); }
.status-rejected { color: var(--danger); }
.status-resubmission, .status-pending { color: var(--warning); }
.summary-card { padding: 14px; overflow: hidden; }
.summary-card p { margin-bottom: 0; font-size: 14px; }
.summary-list { margin: 9px 0 0; padding-left: 18px; display: grid; gap: 6px; color: var(--ink-2); font-size: 13px; line-height: 1.35; }
.meta-card { display: grid; grid-template-columns: 1.4fr .8fr .55fr; border: 1px solid var(--line); border-radius: 16px; overflow: hidden; background: var(--line); gap: 1px; }
.meta-card > div { min-width: 0; background: white; padding: 10px; display: grid; gap: 3px; }
.meta-card span { color: var(--muted); font-size: 10px; font-weight: 900; letter-spacing: .1em; text-transform: uppercase; }
.meta-card strong { min-width: 0; color: var(--ink); font-size: 12px; word-break: break-word; }
.result-actions { display: grid; grid-template-columns: auto 1fr; gap: 10px; align-items: start; }
.technical-details { padding: 11px; max-height: 112px; overflow: auto; opacity: .72; }
.technical-details[open] { max-height: 210px; opacity: 1; }
summary { cursor: pointer; font-size: 12px; font-weight: 950; }
.probe-list { display: grid; gap: 6px; margin-top: 8px; }
.probe { border: 1px solid var(--line); border-radius: 10px; padding: 8px; background: var(--panel-2); font-size: 11px; }
.probe span { display: block; color: var(--muted); word-break: break-all; }
.probe em { font-style: normal; font-weight: 900; }
pre { max-height: 120px; overflow: auto; background: #111; color: #f7f1e8; border-radius: 10px; padding: 10px; white-space: pre-wrap; word-break: break-word; font-size: 10px; }
.alert { padding: 10px 12px; border-radius: 12px; font-weight: 760; font-size: 13px; }
.alert-error { color: var(--danger); background: var(--danger-bg); border: 1px solid #ffd0d7; }
.status-note { color: var(--muted); font-size: 13px; }

@media (max-width: 900px) {
  html, body { overflow: auto; }
  .page-shell { height: auto; min-height: 100dvh; padding: 10px; }
  .portal { height: auto; min-height: calc(100dvh - 20px); }
  .portal-grid { grid-template-columns: 1fr; }
  .auth-panel { margin-top: 24px; }
  .portal { grid-template-rows: auto 1fr; }
  .portal-header { grid-template-columns: 1fr auto; }
  .header-title { display: none; }
}
