/* Socioscope Gate — green & beige theme. Warm, calm, readable. */

:root {
  --fg: #24291f;
  --muted: #6f7268;
  --bg: #f3efe6;         /* beige page */
  --bg-card: #ffffff;
  --bg-soft: #faf8f1;    /* warm off-white for fieldsets/cards */
  --border: #e4ddce;     /* warm border */
  --border-soft: #efe9dd;
  --brand: #2f6a4a;      /* Socioscope green */
  --brand-dark: #26543b;
  --brand-tint: #e7f0ea;
  --accent: #3f7a58;
  --push: #9a6a2f;       /* earthy amber for publish actions */
  --warn: #8a1c1c;
  --err: #b00020;
  --ok: #2e6b3e;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(40,50,35,.05), 0 2px 8px rgba(40,50,35,.04);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  font-size: 15px; line-height: 1.55; color: var(--fg); background: var(--bg);
}

/* --- top bar --- */
.topbar {
  display: flex; align-items: center; gap: 20px; flex-wrap: wrap;
  padding: 12px 24px; background: var(--brand); color: #f4f1ea;
  box-shadow: var(--shadow);
}
.brand { font-weight: 700; color: #fff; text-decoration: none; font-size: 17px; letter-spacing: .2px; }
.topbar nav { display: flex; flex-wrap: wrap; gap: 4px; }
.topbar nav a { color: #e8efe9; margin-right: 12px; text-decoration: none; font-size: 14px; opacity: .92; }
.topbar nav a:hover { color: #fff; opacity: 1; text-decoration: underline; }
.topbar .spacer { flex: 1; }
.topbar .logout { display: flex; align-items: center; gap: .6rem; }
.topbar .who { color: #d7e4da; font-size: .82rem; }
.topbar .logout button { background: rgba(255,255,255,.14); color: #fff; border: 1px solid rgba(255,255,255,.3);
  border-radius: 6px; padding: .3rem .7rem; cursor: pointer; font: inherit; font-size: 13px; }
.topbar .logout button:hover { background: rgba(255,255,255,.24); }

.container { max-width: 1120px; margin: 0 auto; padding: 28px 24px 60px; }
.container.narrow { max-width: 28rem; }
.hero { padding: 20px 0; }
.muted { color: var(--muted); }
.small { font-size: .82rem; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }

h1 { font-size: 25px; margin: 0 0 10px; letter-spacing: -.2px; }
h2 { font-size: 18px; margin-top: 30px; }
h3 { font-size: 16px; margin-top: 22px; }
h4 { font-size: 15px; margin-top: 16px; }
.subhead { color: var(--muted); font-weight: 600; }

a { color: var(--brand); }
a:hover { color: var(--brand-dark); }
code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px;
  background: var(--brand-tint); color: #235238; padding: 1px 5px; border-radius: 4px; }

/* --- buttons --- */
.btn {
  display: inline-block; background: var(--brand); color: #fff; padding: .5rem .9rem;
  border-radius: 8px; border: 1px solid var(--brand); font-size: 14px; font-weight: 500;
  cursor: pointer; text-decoration: none; margin-right: 8px; line-height: 1.3;
  transition: background .12s ease;
}
.btn:hover { background: var(--brand-dark); border-color: var(--brand-dark); color: #fff; }
.btn.primary { font-weight: 600; }
.btn.small { padding: .25rem .55rem; font-size: .8rem; border-radius: 6px; }
.btn.push { background: var(--push); border-color: var(--push); }
.btn.push:hover { background: #855b26; border-color: #855b26; }
.btn.warn { background: var(--warn); border-color: var(--warn); }
.btn.warn:hover { background: #6d1414; border-color: #6d1414; }
button.link, a.link { background: none; border: 0; color: var(--brand); cursor: pointer;
  text-decoration: underline; padding: 0; font: inherit; }
button.link:hover, a.link:hover { color: var(--brand-dark); }

/* --- tables --- */
table { width: 100%; border-collapse: collapse; background: var(--bg-card); margin-top: 8px; }
th, td { padding: 8px 12px; text-align: left; border-bottom: 1px solid var(--border-soft); vertical-align: top; }
th { background: var(--bg-soft); font-size: 13px; color: var(--muted); font-weight: 600; }
td.wrap { max-width: 400px; }
table.grid { border-collapse: collapse; width: 100%; background: var(--bg-card);
  border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
table.grid th, table.grid td { border: 0; border-bottom: 1px solid var(--border-soft); padding: .45rem .6rem; text-align: left; vertical-align: top; }
table.grid th { background: var(--bg-soft); }
table.grid.kv th { width: 12rem; }
th.sortable:hover { text-decoration: underline; cursor: pointer; }
tr.done td { opacity: .55; }
.actions a { margin-right: .6rem; }

/* --- forms --- */
form label { display: block; margin: 12px 0; font-size: 13px; color: var(--muted); }
form label.check { display: flex; gap: 8px; align-items: center; }
form input[type=text], form input[type=date], form input[type=email], form input[type=number],
form input[type=file], form select, form textarea {
  display: block; width: 100%; padding: 7px 9px; margin-top: 4px; background: #fff;
  border: 1px solid var(--border); border-radius: 7px; font-size: 14px; font: inherit; color: var(--fg);
}
form input:focus, form select:focus, form textarea:focus {
  outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-tint);
}
form .row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
form details { margin: 16px 0; padding: 14px 16px; background: var(--bg-soft); border: 1px solid var(--border); border-radius: var(--radius); }
form details > summary { cursor: pointer; font-weight: 600; color: var(--fg); }

fieldset.opts { border: 1px solid var(--border); border-radius: var(--radius); margin: 1rem 0; padding: .8rem 1rem; background: var(--bg-soft); }
fieldset.opts legend { color: var(--brand-dark); font-size: .85rem; font-weight: 600; padding: 0 .4rem; }
fieldset.opts label.check { display: inline-flex; margin: .3rem 1rem .3rem 0; }

.stack { display: flex; flex-direction: column; gap: .75rem; max-width: 22rem; }
.stack label { display: flex; flex-direction: column; gap: .25rem; }
.inline { display: inline-flex; gap: .5rem; align-items: center; }
.rowbar { display: flex; gap: .75rem; align-items: center; margin: 1rem 0; flex-wrap: wrap; }
.rowbar.sticky { position: sticky; top: 0; background: var(--bg); padding: .5rem 0; z-index: 5; border-bottom: 1px solid var(--border); }
.filter { margin: 1rem 0; }

/* --- cards --- */
.card { border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem 1.2rem;
  margin: 1rem 0; background: var(--bg-card); box-shadow: var(--shadow); }
.card h2 { margin-top: 0; font-size: 1.05rem; }
.estimate { margin: 1rem 0; padding: .7rem .9rem; border: 1px solid var(--border);
  border-left: 4px solid var(--brand); border-radius: var(--radius); background: var(--brand-tint); }
.estimate .small { margin-top: .35rem; }

/* --- status + chips --- */
.status { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.status-pending   { background: #f6ecc9; color: #7a5c00; }
.status-running   { background: #d9e8dd; color: #1f5a3a; }
.status-completed { background: #dbeee1; color: var(--ok); }
.status-failed    { background: #f6dcd9; color: #8a1c1c; }
.status-open { background:#eceadf; color:#5a5648; }
.status-in_progress { background:#f6ecc9; color:#7a5c00; }
.status-done { background:#dbeee1; color:var(--ok); }
.status-open,.status-in_progress,.status-done { padding:.1rem .55rem; border-radius:999px; font-size:.78rem; }

.chip { display:inline-block; padding:.12rem .55rem; border-radius:999px; font-size:.78rem;
  background:#eceadf; color:#4c4a3f; white-space:nowrap; }
.chip-live { background:#dbeee1; color:var(--ok); }
.chip-paused { background:#f6ecc9; color:#7a5c00; }
.chip-dead { background:#f6dcd9; color:#842029; }
.chip .inline { display:inline; }
.chip-x { border:none; background:transparent; color:#842029; cursor:pointer; font-weight:700; padding:0 0 0 .2rem; font-size:.85rem; line-height:1; }
.chip-x:hover { color:#000; }

.badge { display: inline-block; padding: 2px 7px; border-radius: 999px; font-size: 11px; font-weight: 600; margin: 1px 2px; }
.badge.draft { background: #f6ecc9; color: #7a5b00; }
.badge.push { background: #efe0cb; color: var(--push); }
.flag-likely_garbled    { background: #f6dcd9; color: #991b1b; }
.flag-grammar_break     { background: #f6ecc9; color: #92400e; }
.flag-truncation        { background: #e7e3f3; color: #5b21b6; }
.flag-unrecognized_token{ background: #f6dced; color: #9d174d; }
.flag-speaker_overlap   { background: #d6eef2; color: #155e75; }
.badges { list-style: none; padding: 0; }
.badges li { display: inline-block; margin-right: 12px; }

.ok { color: var(--ok); }
.error { color: var(--err); }
pre.log { background: #1c2b22; color: #dfe7e0; padding: 12px; border-radius: var(--radius);
  overflow: auto; max-height: 360px; font-size: 12px; line-height: 1.45; }
pre.error { background: #fbeeee; color: var(--err); padding: 12px; border-radius: var(--radius); }

dl.meta { display: grid; grid-template-columns: 170px 1fr; gap: 4px 16px; }
dl.meta dt { color: var(--muted); font-size: 13px; }
dl.meta dd { margin: 0; }

/* --- corpus case browser --- */
.caselist { display: flex; flex-wrap: wrap; gap: .4rem; margin: .6rem 0 1.2rem; }
.casechip { padding: .25rem .65rem; border: 1px solid var(--border); border-radius: 999px;
  background: var(--bg-soft); text-decoration: none; color: var(--brand-dark); font-size: .85rem; }
.casechip:hover { background: var(--brand-tint); border-color: var(--brand); }

/* --- case detail: statuses + event log --- */
.statusgrid { display: flex; flex-wrap: wrap; gap: .8rem; margin: .5rem 0 1rem; }
.statuscard { border: 1px solid var(--border); border-radius: var(--radius); padding: .7rem .9rem; min-width: 220px; background: var(--bg-card); box-shadow: var(--shadow); }
.statuscard .dimlabel { font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.statuscard .dimval { font-size: 1.05rem; margin: .2rem 0 .5rem; }
.statuscard select { font: inherit; }
section.logevent { border: 1px solid var(--border); border-radius: var(--radius); padding: .9rem 1.1rem; background: var(--bg-soft); margin: 1rem 0; }
table.log td { vertical-align: top; }
table.log td.small { font-size: .8rem; }

/* --- tasks / transactions / social contracts --- */
.taskform { gap: .5rem; flex-wrap: wrap; align-items: center; margin: .6rem 0; }
.taskform input, .taskform select { font: inherit; padding: .3rem .45rem; margin-top: 0; width: auto; }

/* --- transcript editor bits --- */
.segcard { border: 1px solid var(--border); border-radius: var(--radius); padding: .75rem 1rem; margin: .75rem 0; background: var(--bg-card); }
.segcard legend { color: var(--muted); font-size: .85rem; }
.fieldrow { display: flex; gap: 1rem; flex-wrap: wrap; }
.segcard label { display: flex; flex-direction: column; gap: .2rem; margin: .35rem 0; }
.segcard label.full { width: 100%; }
.segcard textarea { width: 100%; font: inherit; }

/* admin grant adder */
details.grant-add { display:inline-block; margin-left:.4rem; vertical-align:middle; }
details.grant-add > summary { cursor:pointer; list-style:none; }

/* button-styled disclosure (case page add/set forms) */
details.act { margin: .5rem 0; }
details.act > summary { display: inline-block; cursor: pointer; list-style: none; }
details.act > summary::-webkit-details-marker { display: none; }
details.act > summary::marker { content: ""; }
details.act[open] > summary { margin-bottom: .6rem; }
details.act .taskform, details.act form { margin-top: 0; }

@media (max-width: 640px) {
  form .row { grid-template-columns: 1fr; }
  .container { padding: 20px 16px 48px; }
}
