/* Phynventory - self-contained stylesheet, no external dependencies. */

:root {
  --bg: #f4f5f7;
  --panel: #ffffff;
  --ink: #1d2430;
  --muted: #6b7684;
  --line: #dfe3e8;
  --accent: #1f6feb;
  --accent-dark: #1a5ac4;
  --danger: #c0392b;
  --ok: #217a42;
  --radius: 10px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
        "Helvetica Neue", Arial, sans-serif;
}

a { color: var(--accent); }

/* ---------- top bar ---------- */

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; flex-wrap: wrap;
  padding: .7rem 1.2rem;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}
.brandbox { display: flex; align-items: center; gap: .7rem; }
.logolink { display: block; line-height: 0; }
.logo {
  display: block; object-fit: contain;
  /* the mm size comes from an inline style in base.html */
}
.brand {
  font-size: 1.15rem; font-weight: 700; letter-spacing: .02em;
  color: var(--ink); text-decoration: none;
}
.topnav { display: flex; align-items: center; gap: .35rem; flex-wrap: wrap; }
.topnav .btn { padding: .4rem .65rem; }
.who { color: var(--muted); margin-right: .3rem; }
.role {
  background: #eef2f7; color: var(--muted); border-radius: 999px;
  padding: .1rem .5rem; font-size: .78rem; text-transform: uppercase;
  letter-spacing: .04em;
}

/* ---------- layout ---------- */

.page { max-width: 1180px; margin: 0 auto; padding: 1.4rem 1.2rem 3rem; }
.foot { text-align: center; color: var(--muted); font-size: .8rem; padding: 1rem 0 2rem; }

.card {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 1.1rem 1.3rem; margin-bottom: 1.2rem;
}
.card-narrow { max-width: 460px; }

.columns { display: grid; grid-template-columns: 1fr 1fr; gap: 1.2rem; align-items: start; }
@media (max-width: 860px) { .columns { grid-template-columns: 1fr; } }

h1 { font-size: 1.5rem; margin: .2rem 0 .8rem; }
h2 { font-size: 1rem; text-transform: uppercase; letter-spacing: .05em;
     color: var(--muted); margin: 1.4rem 0 .6rem; }
.card > h2:first-of-type, .card > h1 + h2 { margin-top: .2rem; }

.page-head {
  display: flex; justify-content: space-between; align-items: flex-start;
  gap: 1rem; flex-wrap: wrap;
}
.page-head-actions { display: flex; gap: .5rem; align-items: center; }
.page-head-actions form { display: inline; }
.breadcrumb { margin: 0 0 .6rem; font-size: .9rem; }
.inv-big { color: var(--muted); font-weight: 500; }

/* ---------- buttons and forms ---------- */

.btn {
  display: inline-block; padding: .45rem .85rem; border-radius: 7px;
  border: 1px solid var(--line); background: var(--panel); color: var(--ink);
  font-size: .9rem; text-decoration: none; cursor: pointer; line-height: 1.3;
}
.btn:hover { background: #f0f2f5; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-dark); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover { filter: brightness(.92); }
.btn-quiet { color: var(--muted); }
.btn-small { padding: .25rem .55rem; font-size: .82rem; }

label { display: block; margin: .7rem 0; font-size: .88rem; color: var(--muted); }
input[type=text], input[type=password], input[type=number], input[type=date],
input[type=search], select, textarea {
  display: block; width: 100%; margin-top: .25rem;
  padding: .45rem .6rem; font: inherit; color: var(--ink);
  background: #fff; border: 1px solid var(--line); border-radius: 7px;
}
textarea { resize: vertical; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .85rem; }
.req { color: var(--danger); }
.formactions { display: flex; gap: .6rem; margin-top: 1rem; }
.itemform { display: grid; grid-template-columns: 1fr 1fr; gap: 0 1.2rem; }
.itemform > .wide, .itemform > p, .itemform > .formactions { grid-column: 1 / -1; }
@media (max-width: 700px) { .itemform { grid-template-columns: 1fr; } }

.filters {
  display: flex; gap: .5rem; flex-wrap: wrap; align-items: center;
  margin: .8rem 0 .4rem;
}
.filters input[type=search] { flex: 2 1 240px; width: auto; margin: 0; }
.filters select { flex: 1 1 170px; width: auto; margin: 0; }

/* ---------- flashes ---------- */

.flashes { margin-bottom: 1rem; }
.flash {
  padding: .55rem .8rem; border-radius: 7px; margin-bottom: .4rem;
  border: 1px solid var(--line); background: var(--panel);
}
.flash-error { border-color: #f0c2bb; background: #fdf1ef; color: var(--danger); }
.flash-success { border-color: #bfe3cd; background: #f0faf4; color: var(--ok); }
.flash-info { border-color: #c7d7ee; background: #f2f7fd; color: var(--accent-dark); }

/* ---------- item grid ---------- */

.count { margin: .4rem 0 1rem; }
.grid {
  list-style: none; margin: 0; padding: 0; display: grid; gap: 1rem;
  grid-template-columns: repeat(auto-fill, minmax(185px, 1fr));
}
.tile {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); overflow: hidden;
}
/* Lets the browser skip layout and painting for off-screen tiles.  A clear win
   in Chrome, but WebKit's implementation has been the opposite often enough
   that it is off by default - switch TILE_CONTENT_VISIBILITY in constants.py
   on if it helps your browsers. */
.grid-cv .tile { content-visibility: auto; contain-intrinsic-size: auto 260px; }
.tile:hover { border-color: #bcc6d2; }
.tile a { text-decoration: none; color: inherit; display: block; }
.thumb {
  height: 150px; background: #eceff3; display: flex;
  align-items: center; justify-content: center; overflow: hidden;
}
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
/* Not fetched yet - keep the tile grey instead of showing a broken image. */
.thumb img.lazyimg:not([src]) { visibility: hidden; }
.thumb-empty { color: #a3adb9; font-size: .82rem; }
.tile-body { padding: .55rem .7rem .7rem; }
.inv { color: var(--muted); font-size: .78rem; }
.tile-name { font-weight: 600; margin: .1rem 0 .2rem; }
.tile-meta { color: var(--muted); font-size: .8rem; }
.empty { color: var(--muted); padding: 2rem 0; text-align: center; }
.gridend {
  display: flex; gap: .8rem; align-items: center; justify-content: center;
  padding: 1.4rem 0 .4rem;
}

/* ---------- detail ---------- */

.attrs { width: 100%; border-collapse: collapse; }
.attrs th {
  text-align: left; font-weight: 500; color: var(--muted);
  padding: .35rem .8rem .35rem 0; vertical-align: top; width: 40%;
  border-bottom: 1px solid var(--line); font-size: .88rem;
}
.attrs td { padding: .35rem 0; border-bottom: 1px solid var(--line); }
.pre { white-space: pre-wrap; }

.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: .8rem; }
.gallery figure { margin: 0; }
.gallery img {
  width: 100%; height: 120px; object-fit: cover; display: block;
  border-radius: 7px; border: 1px solid var(--line); background: #eceff3;
}
.gallery figcaption {
  font-size: .76rem; color: var(--muted); margin-top: .25rem;
  display: flex; gap: .4rem; align-items: center; flex-wrap: wrap;
}
.gallery figcaption form { display: inline; }

.filelist { list-style: none; margin: 0; padding: 0; }
.filelist li {
  padding: .4rem 0; border-bottom: 1px solid var(--line);
  display: flex; gap: .5rem; align-items: baseline; flex-wrap: wrap;
}
.filelist .muted { font-size: .76rem; }

.link-quiet { color: var(--muted); }
.link-danger {
  background: none; border: none; padding: 0; cursor: pointer;
  color: var(--danger); font: inherit; font-size: .76rem; text-decoration: underline;
}

.upload-form { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.upload-form select { width: auto; flex: 1 1 240px; margin: 0; }
.upload-form input[type=file] { flex: 1 1 200px; font-size: .85rem; }

.commentlog { list-style: none; margin: 0 0 1rem; padding: 0; }
.commentlog li {
  padding: .35rem .6rem; border-left: 3px solid var(--line);
  background: #fafbfc; margin-bottom: .25rem; border-radius: 0 6px 6px 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: .84rem; white-space: pre-wrap;
}

/* ---------- users ---------- */

.userlist { width: 100%; border-collapse: collapse; }
.userlist th {
  text-align: left; font-weight: 500; color: var(--muted); font-size: .82rem;
  border-bottom: 1px solid var(--line); padding: .4rem .6rem .4rem 0;
}
.userlist td { padding: .5rem .6rem .5rem 0; border-bottom: 1px solid var(--line); }
.row-actions { display: flex; gap: .4rem; align-items: center; flex-wrap: wrap; }
.row-actions input { width: 150px; margin: 0; }

/* ---------- navbar selection ---------- */

.topnav .spacer { flex: 1 1 12px; }
.btn-active { border-color: var(--accent); color: var(--accent); font-weight: 600; }
.selbar { display: inline-flex; gap: .4rem; align-items: center; }
.selbar form { display: inline; }
.selbar-empty #createExpBtn {
  pointer-events: none; opacity: .4; background: #e7eaee;
  border-color: var(--line); color: var(--muted);
}
.selbar-empty form { display: none; }
.badge {
  background: rgba(255,255,255,.28); border-radius: 999px;
  padding: 0 .4rem; font-size: .78rem; margin-left: .15rem;
}
.selbar-empty .badge { display: none; }

/* ---------- selectable tiles ---------- */

.tile { position: relative; }
.tile-select {
  position: absolute; top: .4rem; left: .4rem; z-index: 2; margin: 0;
  background: rgba(255,255,255,.9); border: 1px solid var(--line);
  border-radius: 6px; padding: .15rem .25rem; line-height: 0; cursor: pointer;
}
.tile-select input { width: 17px; height: 17px; margin: 0; cursor: pointer; }
.tile-selected { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(31,111,235,.25); }

/* ---------- item count form on the detail page ---------- */

.countform {
  display: flex; gap: .5rem; align-items: center; flex-wrap: wrap;
  margin-top: .9rem; padding-top: .8rem; border-top: 1px solid var(--line);
}
.countform label { margin: 0; flex: 1 1 100%; }
.countform input { width: 110px; margin: 0; }

/* ---------- experiment item table ---------- */

.itemtable { width: 100%; border-collapse: collapse; margin-bottom: .6rem; }
.itemtable td {
  padding: .3rem .4rem .3rem 0; border-bottom: 1px solid var(--line);
  vertical-align: middle;
}
.itemtable .pos { color: var(--muted); width: 1.8rem; font-size: .82rem; }
.itemtable .nr {
  color: var(--muted); width: 5.5rem; font-size: .82rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
.itemtable .ord { width: 8.5rem; text-align: right; white-space: nowrap; }
.itemtable .ord .btn { padding: .15rem .4rem; }

/* Backup list: the file name may be long, the other columns are narrow. */
.backuptable th {
  text-align: left; font-size: .78rem; color: var(--muted);
  font-weight: 600; text-transform: uppercase; letter-spacing: .03em;
  padding: 0 .4rem .3rem 0; border-bottom: 1px solid var(--line);
}
.backuptable th:nth-child(2), .backuptable th:nth-child(3) { text-align: left; }
.backuptable .nm {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: .82rem; word-break: break-all;
}
.backuptable .nr { width: 7rem; white-space: nowrap; }
.backuptable .when { width: 11rem; white-space: nowrap; color: var(--muted);
  font-size: .82rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.backuptable .ord { width: 9.5rem; }
.additem { display: flex; gap: .5rem; align-items: center; }
.additem input { margin: 0; }

.expmain img {
  max-width: 100%; border-radius: 7px; border: 1px solid var(--line);
  display: block;
}
.expmain figcaption {
  font-size: .78rem; color: var(--muted); margin-top: .3rem;
  display: flex; gap: .5rem; align-items: center;
}
.expmain figcaption form { display: inline; }
.expmain { margin: 0 0 .8rem; }

.docthumb {
  width: 46px; height: 46px; object-fit: cover; border-radius: 5px;
  border: 1px solid var(--line); display: block;
}

.adminlog { margin-top: 1rem; }
.adminlog summary { cursor: pointer; color: var(--muted); font-size: .85rem; }
.adminlog textarea { margin: .6rem 0; }

/* ---------- What's new ---------- */

.newbar {
  display: flex; gap: .6rem; align-items: center; flex-wrap: wrap;
  margin: .2rem 0 .6rem;
}
.badge-quiet { background: #e7ecf3; color: var(--muted); }

/* ---------- drag and drop ---------- */

[data-dropzone] { position: relative; }
.dropnote {
  display: none; position: absolute; inset: 0; z-index: 5;
  align-items: center; justify-content: center;
  /* Nearly opaque: the card's own text must not show through the label. */
  background: rgba(238, 243, 251, .96); border: 2px dashed var(--accent);
  border-radius: var(--radius); color: var(--accent);
  font-size: 1.05rem; font-weight: 600; pointer-events: none;
}
[data-dropzone].dropping .dropnote { display: flex; }
[data-dropzone].uploading { opacity: .6; }
.hiddenform { display: none; }

/* ---------- field help ---------- */

.helpmark {
  display: inline-block; width: 1.05em; height: 1.05em; line-height: 1.05em;
  text-align: center; border-radius: 50%; background: #e7ecf3;
  color: var(--muted); font-size: .72rem; cursor: help; vertical-align: middle;
}

/* ---------- comment log tools ---------- */

.logtools {
  display: flex; gap: .7rem; align-items: center; flex-wrap: wrap;
  margin-top: .9rem; padding-top: .7rem; border-top: 1px solid var(--line);
}
.logtools form { display: inline; }
.loginline {
  margin: 0; max-height: 14rem; overflow: auto; white-space: pre-wrap;
  background: #fafbfc; border: 1px solid var(--line); border-radius: 7px;
  padding: .5rem .6rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: .8rem; color: var(--ink);
}

/* ---------- logfile view ---------- */

.logcard { padding: .6rem; }
.logview {
  margin: 0; max-height: 72vh; overflow: auto;
  background: #fbfcfd; border: 1px solid var(--line); border-radius: 7px;
  padding: .7rem .8rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: .78rem; line-height: 1.45; white-space: pre;
  color: var(--ink);
}

/* ---------- misc ---------- */

.muted { color: var(--muted); }
.small { font-size: .8rem; }
button[disabled] { opacity: .35; cursor: default; }
