/* APCalign-app look, matching austraits.org and the AusTraits Data Portal
   (colours and spacing follow the Shiny app's apcalign-app.css). */
:root {
  --ink:#2b332f; --muted:#64726b; --green:#2f7d55; --green-dark:#235c43; --blue:#2a7f9e; --gold:#d9a441;
  --cream:#f7f7f4; --mint:#f2f6f3; --line:#e5e8e5; --white:#fff; --radius:8px;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; font: 15px/1.5 "Open Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; color: var(--ink); background: #fdfdfc; display: flex; flex-direction: column; min-height: 100vh; }
a { color: var(--green-dark); } a:hover { color: var(--blue); }
.hide { display: none !important; }
.muted { color: var(--muted); font-size: 13px; }

/* brand bar */
.brand { position: relative; display: flex; align-items: center; gap: .6rem; background: var(--green-dark); color: #fff; font-size: 1.15rem; font-weight: 600; padding: 10px 16px 12px; box-shadow: 0 1px 8px rgba(30,55,42,.12); }
.brand::after { content: ""; position: absolute; inset: auto 0 0; height: 4px; background: linear-gradient(90deg, var(--green), var(--blue), var(--gold)); }
.brand img { height: 30px; width: auto; }

.layout { display: grid; grid-template-columns: 340px minmax(0, 1fr); flex: 1; min-height: 0; }

/* sidebar */
.sidebar { background: var(--cream); border-right: 1px solid var(--line); padding: 16px; overflow-y: auto; }
.sidebar p { margin: 0 0 10px; }
.sidebar h5 { color: var(--green-dark); font-size: .95rem; font-weight: 600; margin: 18px 0 8px; }
fieldset { border: 0; padding: 0; margin: 0 0 8px; }
legend { padding: 0; margin-bottom: 4px; font-weight: 500; }
.opt { display: flex; align-items: flex-start; gap: 8px; margin: 4px 0; cursor: pointer; }
.opt input { margin-top: 5px; accent-color: var(--green); }
.field { display: block; margin: 12px 0 6px; font-weight: 500; }
input[type=text], input[type=search], select { width: 100%; font: inherit; padding: 6px 10px; border: 1px solid #ced4da; border-radius: var(--radius); background: #fff; color: var(--ink); margin-top: 4px; }
input[type=search] { width: auto; margin-top: 0; } .tblctl select { width: auto; margin-top: 0; }
input:focus, select:focus { outline: none; border-color: var(--green); box-shadow: 0 0 0 .2rem rgba(47,125,85,.2); }
.filebtn { display: flex; align-items: center; gap: 8px; margin: 6px 0; }
.filebtn input { display: none; }
.btn-file { display: inline-block; padding: 6px 12px; border: 1px solid #ced4da; border-radius: var(--radius); background: #fff; cursor: pointer; }
.btn { display: block; width: 100%; font: inherit; font-weight: 600; padding: 8px 12px; border-radius: var(--radius); cursor: pointer; margin-top: 12px; }
.btn.primary { background: var(--green-dark); color: #fff; border: 1px solid var(--green-dark); }
.btn.primary:hover:not(:disabled) { background: var(--green); }
.btn.outline { background: transparent; color: var(--green-dark); border: 1px solid var(--green-dark); }
.btn.outline:hover:not(:disabled) { background: var(--green-dark); color: #fff; }
.btn:disabled { opacity: .55; cursor: default; }

/* tabs */
.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.tabs { display: flex; gap: 4px; background: #fff; border-bottom: 1px solid var(--line); padding: 0 12px; }
.tab { font: inherit; font-weight: 500; color: var(--muted); background: none; border: 0; border-bottom: 3px solid transparent; padding: 12px 14px 9px; cursor: pointer; }
.tab:hover { color: var(--green-dark); }
.tab.active { color: var(--green-dark); border-bottom-color: var(--green); }

.card { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 6px 18px rgba(30,45,38,.06); margin: 16px; padding: 16px; flex: 0 0 auto; }
.cardhead { margin: -16px -16px 16px; padding: 12px 16px; background: var(--cream); border-bottom: 1px solid var(--line); font-size: 1rem; font-weight: 600; border-radius: var(--radius) var(--radius) 0 0; }

/* ready box */
.ready { background: var(--mint); border-left: 4px solid var(--green); padding: 20px; margin: 4px 0 12px; border-radius: 4px; }
.readyhead { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.readyhead h4 { margin: 0; color: var(--green-dark); }
.info { display: inline-flex; width: 24px; height: 24px; align-items: center; justify-content: center; border-radius: 50%; background: var(--green); color: #fff; font-weight: 700; font-style: italic; font-family: serif; }
.ready p { margin: 0 0 10px; } .ready ol { margin: 0; padding-left: 20px; }
.loading { background: var(--sky, #f3f7f8); border-left: 4px solid var(--blue); border-radius: 4px; padding: 14px 16px; margin-bottom: 12px; }
.errorbox { background: #fdecea; border-left: 4px solid #b3261e; color: #8c1d18; border-radius: 4px; padding: 12px 16px; margin-bottom: 12px; white-space: pre-wrap; }
progress { width: 100%; height: 10px; accent-color: var(--green); margin: 8px 0; }

/* table */
.tblctl { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; }
.tablewrap { overflow: auto; border-top: 1px solid var(--line); }
table { border-collapse: collapse; width: 100%; font-size: 14px; }
th { color: var(--green-dark); text-align: left; padding: 8px 10px; border-bottom: 2px solid var(--line); white-space: nowrap; cursor: pointer; user-select: none; position: sticky; top: 0; background: #fff; }
th .arrow { color: var(--muted); margin-left: 4px; font-size: 11px; }
td { padding: 8px 10px; border-bottom: 1px solid var(--line); }
td.truncated { max-width: 22rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
tbody tr:nth-child(even) { background: #fafbfa; }
.tblfoot { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 8px; margin-top: 10px; color: var(--muted); font-size: 13px; }
.pager { display: flex; gap: 4px; }
.pager button { font: inherit; padding: 4px 10px; border: 1px solid var(--line); background: #fff; border-radius: 6px; cursor: pointer; color: var(--ink); }
.pager button.cur { border-color: var(--green); font-weight: 600; }
.pager button:disabled { opacity: .45; cursor: default; }

/* prose tabs */
.prose { max-width: 62rem; }
.prose h4 { color: var(--green-dark); border-bottom: 2px solid var(--green); padding-bottom: .4rem; margin: 1.75rem 0 .9rem; }
.prose h4:first-of-type { margin-top: 1rem; }
.prose samp { background: var(--mint); border-radius: 4px; padding: .05rem .3rem; font-size: .9em; }

details.card summary { cursor: pointer; font-weight: 600; }
textarea { width: 100%; height: 130px; font: 12px ui-monospace, monospace; margin-top: 8px; }

.foot { margin-top: auto; color: var(--muted); border-top: 1px solid var(--line); background: var(--cream); font-size: .9rem; padding: 14px 24px; text-align: right; }
.foot a { color: var(--green-dark); }

@media (max-width: 800px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { border-right: 0; border-bottom: 1px solid var(--line); }
}
