/* Ayalytical brand, from ayalytical.com: red #b31a17 (hover #b10215),
   near-black #111111 / #212122, Nunito, pill buttons. Light mode only. */
:root {
  color-scheme: light;
  --ink: #212122;
  --muted: #666666;
  --line: #e4e4e6;
  --bg: #f6f6f7;
  --card: #ffffff;
  --brand: #b31a17;
  --brand-dark: #8f1512;
  --black: #111111;
  --accent: #fbeeed;
  --ok: #1d7a46;
  --warn: #9a5b00;
  --bad: #b10215;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body { font: 16px/1.55 "Nunito", Helvetica, Arial, sans-serif; }
a { color: var(--brand); }
h1 { font-size: 1.6rem; font-weight: 800; color: var(--black); margin: 0 0 .25rem; }
h2 { font-size: 1.1rem; font-weight: 800; color: var(--black); margin: 1.5rem 0 .5rem; }
.muted { color: var(--muted); }

.topbar { display: flex; flex-wrap: wrap; gap: .75rem; align-items: center; justify-content: space-between;
  padding: .8rem 16px; background: var(--card); border-bottom: 3px solid var(--brand); }
.brand { display: flex; align-items: center; gap: .8rem; color: var(--ink); text-decoration: none; }
.brand img { height: 30px; width: auto; display: block; }
.brand .sub { font-weight: 700; color: var(--muted); padding-left: .8rem; border-left: 1px solid var(--line);
  text-transform: uppercase; letter-spacing: .06em; font-size: .78rem; }
@media (max-width: 480px) { .brand img { height: 24px; } .brand .sub { display: none; } }
.topbar nav { display: flex; flex-wrap: wrap; gap: .75rem; align-items: center; }
.topbar nav a { text-decoration: none; font-weight: 700; }
.topbar nav a.btn { color: #fff; }
.who { color: var(--muted); font-size: .9rem; }
.topbar form { margin: 0; }

.page { max-width: 920px; margin: 0 auto; padding: 1.5rem 16px 3rem; }
.foot { text-align: center; color: #cfcfd2; background: var(--black); font-size: .85rem; padding: 1.5rem 16px; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 1.25rem; margin-bottom: 1rem; }
.narrow { max-width: 420px; margin: 2rem auto; }

.btn { display: inline-block; background: var(--brand); color: #fff; border: 0; border-radius: 70px;
  padding: .65rem 1.5rem; font: inherit; font-weight: 800; cursor: pointer; text-decoration: none;
  transition: background .2s ease-in-out; }
.btn:hover { background: var(--brand-dark); }
.btn.small { padding: .4rem 1.1rem; font-size: .9rem; }
.btn.secondary { background: var(--accent); color: var(--brand); }
button.link { background: none; border: 0; color: var(--brand); font: inherit; cursor: pointer; padding: 0; }

label { display: block; font-weight: 700; margin: .9rem 0 .3rem; }
input[type=text], input[type=email], input[type=password], select, textarea {
  width: 100%; padding: .6rem .75rem; border: 1px solid #d4d4d8; border-radius: 8px; font: inherit; background: #fff; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand); outline-offset: 0; border-color: var(--brand); }
input[type=checkbox] { accent-color: var(--brand); }
textarea { resize: vertical; }
.check { display: flex; gap: .5rem; align-items: center; font-weight: 400; }
.check input { width: auto; }
.help { color: var(--muted); font-size: .85rem; margin: .25rem 0 0; }
.errorlist { color: var(--bad); margin: .3rem 0; padding-left: 1.1rem; font-size: .9rem; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 1rem; }
@media (max-width: 600px) { .row2 { grid-template-columns: 1fr; } }

.flash { border-radius: 8px; padding: .7rem 1rem; margin-bottom: 1rem; background: #ececee; }
.flash.success { background: #e6f4ec; color: var(--ok); }
.flash.error { background: #fbeaea; color: var(--bad); }

.tickets { list-style: none; margin: 0; padding: 0; }
.tickets li a { display: grid; grid-template-columns: 1fr auto; gap: .2rem 1rem; padding: .9rem 1rem;
  text-decoration: none; color: inherit; border-bottom: 1px solid var(--line); }
.tickets li:last-child a { border-bottom: 0; }
.tickets li a:hover { background: var(--accent); }
.tickets .title { font-weight: 600; }
.tickets .meta { color: var(--muted); font-size: .85rem; }

.pill { display: inline-block; padding: .1rem .65rem; border-radius: 999px; font-size: .8rem; font-weight: 700;
  background: #ececee; color: var(--black); white-space: nowrap; }
.pill.status-received { background: #e9f1fb; color: #1d4f86; }
.pill.status-progress { background: #fdf1dd; color: var(--warn); }
.pill.status-waiting { background: var(--accent); color: var(--brand); }
.pill.status-closed { background: #ececee; color: var(--muted); }
.pill.Urgent { background: var(--brand); color: #fff; }
.pill.High { background: var(--accent); color: var(--brand); }

.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: .75rem; margin: 1rem 0 0; }
.facts div { background: var(--bg); border-radius: 8px; padding: .6rem .8rem; }
.facts dt { color: var(--muted); font-size: .8rem; }
.facts dd { margin: 0; font-weight: 600; }

.thread { list-style: none; padding: 0; margin: 0; }
.msg { border: 1px solid var(--line); border-radius: 10px; padding: .8rem 1rem; margin-bottom: .75rem; background: #fff; }
.msg.mine { background: #f6f6f7; border-color: #e4e4e6; }
.msg.staff { border-left: 4px solid var(--brand); }
.msg .head { display: flex; justify-content: space-between; gap: 1rem; font-size: .85rem; color: var(--muted); margin-bottom: .3rem; }
.msg .body { white-space: pre-wrap; overflow-wrap: anywhere; }
.files { list-style: none; padding: 0; margin: 0; }
.files li { display: flex; justify-content: space-between; gap: 1rem; padding: .5rem 0; border-bottom: 1px solid var(--line); overflow-wrap: anywhere; }
.orders td, .orders th { text-align: left; padding: .4rem .6rem .4rem 0; }
.drop { border: 2px dashed var(--line); border-radius: 10px; padding: 1rem; text-align: center; color: var(--muted); }
.drop.over { border-color: var(--brand); background: var(--accent); }
.drop input { margin-top: .5rem; }

.instrument-fields .or { color: var(--muted); font-size: .85rem; margin: .4rem 0 0; }
.btn.secondary { background: #fff; color: var(--brand); box-shadow: inset 0 0 0 2px var(--brand); }
.btn.secondary:hover { background: var(--accent); }
/* Footer stays at the bottom on short pages. */
body { min-height: 100vh; display: flex; flex-direction: column; }
main.page { flex: 1 0 auto; width: 100%; }
/* File picker button in brand style. */
input[type=file] { font: inherit; font-size: .9rem; color: var(--muted); }
input[type=file]::file-selector-button { font: inherit; font-weight: 800; color: var(--brand); background: #fff;
  border: 2px solid var(--brand); border-radius: 70px; padding: .35rem 1rem; margin-right: .6rem; cursor: pointer; }
input[type=file]::file-selector-button:hover { background: var(--accent); }
/* Staff page */
.tabs { display: flex; flex-wrap: wrap; gap: .4rem; margin: 1rem 0; }
.tabs a { padding: .4rem 1rem; border-radius: 70px; text-decoration: none; font-weight: 700; color: var(--ink); background: #fff; border: 1px solid var(--line); }
.tabs a.on { background: var(--black); color: #fff; border-color: var(--black); }
table.grid { width: 100%; border-collapse: collapse; }
table.grid th, table.grid td { text-align: left; padding: .7rem 1rem; border-bottom: 1px solid var(--line); vertical-align: top; }
table.grid th { font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
table.grid tr:last-child td { border-bottom: 0; }
table.grid td a { text-decoration: none; color: var(--ink); }
.meta { color: var(--muted); font-size: .85rem; }
.meta.needs { color: var(--brand); font-weight: 700; }
.msg.internal { background: #fff9ea; border-color: #f0dfb0; }
.actions { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: 1rem; }
@media (max-width: 700px) { table.grid thead { display: none; } table.grid td { display: block; padding: .3rem 1rem; } table.grid tr { display: block; padding: .5rem 0; border-bottom: 1px solid var(--line); } table.grid td { border: 0; } }

.banner { background: var(--accent); border: 1px solid var(--line); border-radius: 8px; padding: .6rem .8rem; margin: 0 0 1rem; }
.pill.internal { background: #fff1c7; color: #6b4e00; }
.file-actions { display: flex; align-items: center; gap: .75rem; }
.file-actions form { margin: 0; }

/* Customer main menu: three clear tabs, the current one highlighted. */
.mainnav { display: flex; gap: .25rem; background: var(--bg); border-radius: 70px; padding: .25rem; }
.topbar nav .mainnav a { padding: .45rem 1.1rem; border-radius: 70px; color: var(--ink); font-weight: 800; }
.topbar nav .mainnav a:hover { background: #fff; }
.topbar nav .mainnav a.on { background: var(--black); color: #fff; }
.topbar nav .mainnav a.new { color: var(--brand); }
.topbar nav .mainnav a.new.on, .topbar nav .mainnav a.new:hover { background: var(--brand); color: #fff; }
@media (max-width: 600px) { .mainnav { width: 100%; justify-content: space-between; } .topbar nav .mainnav a { padding: .45rem .7rem; font-size: .9rem; } }

/* Home */
.page-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; margin-bottom: .5rem; }
.section-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; margin: 1.5rem 0 .6rem; }
.section-head h2 { margin: 0; }
.count { display: inline-block; min-width: 1.6rem; padding: 0 .5rem; border-radius: 999px; background: #ececee; color: var(--muted); font-size: .8rem; text-align: center; vertical-align: middle; }
input.filter { width: 260px; max-width: 100%; padding: .45rem .8rem; border: 1px solid #d4d4d8; border-radius: 70px; font: inherit; }
.instruments { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: .9rem; } /* no script: all shown */
.instrument { position: relative; background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 1rem;
  display: flex; flex-direction: column; gap: .5rem; transition: border-color .15s, box-shadow .15s; }
.instrument:hover { border-color: var(--brand); box-shadow: 0 2px 10px rgba(0,0,0,.06); }
.instrument[hidden] { display: none; }
.instrument-link { text-decoration: none; color: var(--black); display: flex; flex-direction: column; }
.instrument-link::after { content: ""; position: absolute; inset: 0; border-radius: 10px; } /* whole card opens the instrument */
.instrument-link .name { font-weight: 800; font-size: 1.05rem; overflow-wrap: anywhere; }
.instrument-link .serial { color: var(--muted); font-size: .9rem; }
.instrument-facts { display: flex; flex-wrap: wrap; gap: .3rem; }
.instrument .meta { margin: 0; }
.pill.status-ok { background: #e6f4ec; color: var(--ok); }
details.menu { position: relative; z-index: 2; margin-top: auto; }
details.menu summary { list-style: none; }
details.menu summary::-webkit-details-marker { display: none; }
details.menu summary::after { content: " \25BE"; }
details.menu ul { margin-top: .4rem !important; list-style: none; margin: 0; padding: .3rem;
  background: #fff; border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 6px 20px rgba(0,0,0,.12); min-width: 230px; }
details.menu li a { display: block; padding: .5rem .8rem; border-radius: 6px; text-decoration: none; color: var(--ink); font-weight: 600; }
details.menu li a:hover { background: var(--accent); color: var(--brand); }
details.closed summary { cursor: pointer; list-style: none; margin: 1.5rem 0 .6rem; }
details.closed summary::-webkit-details-marker { display: none; }
details.closed summary h2 { display: inline; margin: 0; }
details.closed summary::before { content: "\25B8  "; color: var(--muted); }
details.closed[open] summary::before { content: "\25BE  "; }

/* Instrument location */
.instrument .place { margin: 0; color: var(--ink); font-size: .9rem; font-weight: 600; display: flex; align-items: center; gap: .35rem; }
.pin { flex: none; width: .7rem; height: .7rem; border-radius: 50% 50% 50% 0; transform: rotate(-45deg); background: var(--brand); display: inline-block; }
.location { display: flex; gap: .7rem; align-items: flex-start; margin: 1rem 0 0; padding: .8rem 1rem; background: var(--bg); border-radius: 8px; }
.location .pin { margin-top: .45rem; }
.location .address { white-space: pre-line; font-weight: 600; }
.location .help { margin-top: .3rem; }

/* "New reply" bar on an open ticket page */
.live-bar { position: fixed; left: 50%; transform: translateX(-50%); bottom: 16px; z-index: 50; width: calc(100% - 32px); max-width: 560px;
  display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .75rem .9rem .75rem 1.1rem;
  background: var(--black); color: #fff; border-radius: 12px; box-shadow: 0 8px 28px rgba(0,0,0,.25); font-weight: 700; }
.live-bar[hidden] { display: none; }

/* Fact boxes: long values (emails, addresses) wrap inside the box. */
.facts div { min-width: 0; }
.facts dd { overflow-wrap: anywhere; }
.facts div.wide { grid-column: span 2; }
@media (max-width: 420px) { .facts div.wide { grid-column: auto; } }

/* Scrolling boxes (scroller.js): a few items at a time, the rest scroll. */
.scroll-wrap { position: relative; }
.scroller { scrollbar-width: thin; scrollbar-color: #c9c9ce transparent; }
.scroller.y { overflow-y: auto; overscroll-behavior-y: contain; scroll-snap-type: y proximity; }
.scroller.y > * { scroll-snap-align: start; }
.instruments.scroller.y { display: flex; flex-direction: column; gap: .9rem; }
.instruments.scroller.x { display: grid; grid-template-columns: none; grid-auto-flow: column;
  grid-auto-columns: calc((100% - 1.8rem) / 3); overflow-x: auto; overscroll-behavior-x: contain;
  scroll-snap-type: x mandatory; padding-bottom: .5rem; }
.instruments.scroller.x > .instrument { scroll-snap-align: start; }
.card .scroll-wrap:not(.x)::after { bottom: 3.35rem; }
/* Fade on the side where more items are waiting. */
.scroll-wrap::before, .scroll-wrap::after { content: ""; position: absolute; pointer-events: none; opacity: 0;
  transition: opacity .2s; z-index: 3; }
.scroll-wrap:not(.x)::before { left: 0; right: 0; top: 0; height: 28px; background: linear-gradient(var(--fade, #fff), transparent); }
.scroll-wrap:not(.x)::after { left: 0; right: 0; bottom: 2.8rem; height: 40px; background: linear-gradient(transparent, var(--fade, #fff)); }
.scroll-wrap.x::before { top: 0; bottom: 3.1rem; left: 0; width: 36px; background: linear-gradient(90deg, var(--bg), transparent); }
.scroll-wrap.x::after { top: 0; bottom: 3.1rem; right: 0; width: 56px; background: linear-gradient(270deg, var(--bg), transparent); }
section > .scroll-wrap { --fade: var(--bg); }
.scroll-wrap.more-before::before, .scroll-wrap.more-after::after { opacity: 1; }
.scroll-bar { display: flex; align-items: center; justify-content: space-between; gap: .75rem; padding: .45rem .25rem 0; }
.card .scroll-bar { padding: .5rem .75rem .5rem 1rem; border-top: 1px solid var(--line); }
.scroll-bar[hidden] { display: none; }
.scroll-status { color: var(--muted); font-size: .85rem; font-weight: 700; }
.scroll-buttons { display: flex; gap: .4rem; }
.scroll-btn { width: 2.3rem; height: 2.3rem; border-radius: 50%; border: 2px solid var(--brand); background: #fff; color: var(--brand);
  font: inherit; font-size: 1.25rem; font-weight: 800; line-height: 1; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; }
.scroll-btn:hover:not(:disabled) { background: var(--brand); color: #fff; }
.scroll-btn:disabled { border-color: var(--line); color: #c9c9ce; cursor: default; }

/* Status labels keep their size when a ticket title wraps. */
.tickets li a .pill { align-self: start; justify-self: end; }
