:root {
  color: #202522;
  background: #f5f7f5;
  font-family: Inter, "Segoe UI", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.45;
  letter-spacing: 0;
  --border: #d7ddd8;
  --muted: #626b65;
  --green: #146c43;
  --green-dark: #0e5031;
  --blue: #245b9e;
  --red: #a12a2a;
  --amber: #8a5a00;
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; }
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }

.topbar {
  min-height: 58px;
  display: flex;
  align-items: center;
  gap: 26px;
  padding: 0 28px;
  border-bottom: 1px solid var(--border);
  background: #fff;
}
.brand { color: #17231c; font-size: 18px; font-weight: 700; white-space: nowrap; }
.brand:hover { text-decoration: none; }
.nav { display: flex; gap: 20px; flex: 1; }
.nav a { color: #38413b; }
.account { display: flex; align-items: center; gap: 12px; }
.account form { margin: 0; }

.page { max-width: 1240px; margin: 0 auto; padding: 32px 28px 70px; }
.page-heading { margin-bottom: 24px; }
.page-heading h1 { margin: 4px 0 4px; font-size: 28px; line-height: 1.2; }
.page-heading p { margin: 0; color: var(--muted); }
.heading-actions { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; }
.back-link { display: inline-block; margin-bottom: 8px; font-size: 14px; }

.button {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
  color: #242a26;
  font: inherit;
  cursor: pointer;
  text-decoration: none;
}
.button:hover { border-color: #9ca69f; text-decoration: none; }
.button:disabled { opacity: .55; cursor: wait; }
.button-primary { border-color: var(--green); background: var(--green); color: #fff; }
.button-primary:hover { border-color: var(--green-dark); background: var(--green-dark); }
.button-secondary { border-color: #9cafb8; background: #edf4f7; color: #173d54; }
.button-quiet { min-height: 34px; padding: 6px 10px; background: #fff; }
.button-row, .form-actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.button-row form { margin: 0; }

.auth-panel, .narrow-panel, .tool-panel {
  max-width: 600px;
  margin: 7vh auto 0;
  padding: 28px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
}
.tool-panel { max-width: 760px; margin-top: 0; margin-left: 0; }
.auth-panel h1 { margin-top: 0; }
.form-stack { display: grid; gap: 18px; }
label { display: grid; gap: 6px; color: #313833; font-weight: 600; }
input, select {
  width: 100%;
  min-height: 42px;
  padding: 9px 11px;
  border: 1px solid #aeb7b0;
  border-radius: 5px;
  background: #fff;
  color: #202522;
  font: inherit;
}
input:focus, select:focus { outline: 3px solid #cfe6d9; border-color: var(--green); }
input[type="checkbox"] { width: 18px; min-height: 18px; margin-top: 2px; }
.field-note { color: var(--muted); font-size: 13px; font-weight: 400; }
.check-row { grid-template-columns: 20px 1fr; align-items: start; font-weight: 400; }

.alert { margin: 16px 0; padding: 13px 15px; border: 1px solid; border-radius: 6px; background: #fff; }
.alert-error { border-color: #d9a6a6; background: #fff3f3; color: #721f1f; }
.alert-success { border-color: #9bc5aa; background: #f0faf3; color: #174d2e; }
.copy-row { display: flex; gap: 8px; margin-top: 10px; }
.credential-line { display: flex; gap: 10px; align-items: center; margin: 9px 0; }
.service-strip { display: flex; justify-content: space-between; gap: 18px; margin-bottom: 18px; padding: 10px 13px; border: 1px solid var(--border); background: #fff; color: var(--muted); }
.service-strip > span { display: flex; align-items: center; gap: 8px; }
.service-dot { width: 9px; height: 9px; border-radius: 50%; background: #929a95; }
.service-ready { border-color: #a7cbb4; background: #f2faf4; }
.service-ready .service-dot { background: var(--green); }
.service-failed { border-color: #d7aaaa; background: #fff3f3; }
.service-failed .service-dot { background: var(--red); }

.upload-progress { margin-top: 24px; }
.progress-track { height: 10px; overflow: hidden; border-radius: 5px; background: #e0e5e1; }
.progress-bar { width: 0; height: 100%; background: var(--green); transition: width .2s ease; }
#upload-progress-text { margin-top: 8px; color: var(--muted); }

.table-wrap { overflow-x: auto; border: 1px solid var(--border); background: #fff; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 12px 13px; border-bottom: 1px solid #e3e7e4; text-align: left; vertical-align: top; }
th { background: #f0f3f1; color: #465049; font-size: 13px; font-weight: 700; }
tbody tr:last-child td { border-bottom: 0; }
.empty { padding: 32px; color: var(--muted); text-align: center; }
.nowrap { white-space: nowrap; }
.audit-table code { display: block; max-width: 460px; overflow-wrap: anywhere; white-space: normal; }

.status { display: inline-block; padding: 3px 8px; border-radius: 5px; background: #e8ece9; color: #3d4640; font-size: 13px; white-space: nowrap; }
.status-completed { background: #dff2e5; color: #14532d; }
.status-failed { background: #f8dddd; color: #842323; }
.status-running, .status-handoff { background: #e0eaf8; color: #1f4f83; }
.status-queued, .status-uploaded { background: #fff0ce; color: var(--amber); }

.details-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); border-top: 1px solid var(--border); border-left: 1px solid var(--border); background: #fff; }
.details-grid > div { min-width: 0; padding: 15px; border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.detail-label { display: block; margin-bottom: 5px; color: var(--muted); font-size: 13px; }
.details-grid code { overflow-wrap: anywhere; }
.action-band { margin-top: 28px; padding-top: 20px; border-top: 1px solid var(--border); }
.action-band h2 { margin: 0 0 14px; font-size: 20px; }
.inline-form { display: flex; flex-wrap: wrap; gap: 14px; align-items: end; }
.inline-form label { min-width: 220px; }
.transcript-text { min-height: 360px; margin: 0; padding: 22px; border: 1px solid var(--border); background: #fff; white-space: pre-wrap; overflow-wrap: anywhere; font: 16px/1.65 "Segoe UI", Arial, sans-serif; }

@media (max-width: 820px) {
  .topbar { align-items: flex-start; flex-wrap: wrap; gap: 12px; padding: 14px 18px; }
  .nav { order: 3; width: 100%; overflow-x: auto; }
  .account { margin-left: auto; }
  .page { padding: 24px 16px 56px; }
  .heading-actions { align-items: flex-start; flex-direction: column; }
  .details-grid { grid-template-columns: 1fr; }
  .auth-panel, .narrow-panel, .tool-panel { margin-top: 18px; padding: 20px; }
  .copy-row { flex-direction: column; }
}

@media (max-width: 520px) {
  .nav { gap: 14px; font-size: 14px; }
  .account > span { display: none; }
  .page-heading h1 { font-size: 24px; overflow-wrap: anywhere; }
  .button-row, .form-actions { align-items: stretch; flex-direction: column; }
  .service-strip { align-items: flex-start; flex-direction: column; }
  .button-row .button, .button-row form, .button-row form .button, .form-actions .button { width: 100%; }
}
