/* Axis Mundi — clean clinical look: white cards on cool grey, deep teal accent,
   red reserved for money owed and alerts. */

:root {
  --ink: #15202b;
  --muted: #5b6673;
  --faint: #8a94a0;
  --line: #e2e6eb;
  --bg: #f4f6f8;
  --card: #ffffff;
  --accent: #0e5a5a;
  --accent-ink: #0b4747;
  --accent-soft: #e4f0ef;
  --red: #c62828;
  --red-soft: #fdecea;
  --amber: #9a5b00;
  --amber-soft: #fff4e0;
  --green: #1e7a46;
  --green-soft: #e6f4ec;
  --blue: #1d5fa8;
  --blue-soft: #e8f0fa;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; line-height: 1.2; }
h1 { font-size: 26px; letter-spacing: -.01em; }
h2 { font-size: 18px; }
h3 { font-size: 15px; }
[hidden] { display: none !important; }

/* ------------------------------------------------------------------ boot & login */

.boot { display: grid; place-items: center; min-height: 100vh; color: var(--muted); padding: 24px; }
.login { display: grid; place-items: center; min-height: 100vh; padding: 16px;
         background: linear-gradient(160deg, #0e5a5a 0%, #0b3f47 100%); }
.login-card { background: var(--card); border-radius: 16px; padding: 32px 28px; width: 100%; max-width: 360px;
              display: grid; gap: 14px; box-shadow: 0 20px 50px rgba(0,0,0,.25); }
.login-card .mark { display: flex; justify-content: center; }
.login-card h1 { text-align: center; font-size: 24px; }
.login-card .sub { text-align: center; margin: -8px 0 6px; color: var(--muted); font-size: 14px; }
.login-card label { display: grid; gap: 4px; font-size: 13px; color: var(--muted); font-weight: 500; }
.login-card .error { color: var(--red); margin: 0; font-size: 14px; }

/* ------------------------------------------------------------------ chrome */

.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 18px;
          padding: 0 20px; height: 56px; background: var(--accent); color: #fff; }
.brand { display: flex; align-items: center; gap: 9px; color: #fff; font-weight: 650; font-size: 16px;
         white-space: nowrap; }
.brand:hover { text-decoration: none; }
#nav { display: flex; gap: 2px; flex: 1; overflow-x: auto; scrollbar-width: none; }
#nav::-webkit-scrollbar { display: none; }
#nav a { position: relative; color: rgba(255,255,255,.78); padding: 8px 12px; border-radius: 8px;
         font-weight: 550; font-size: 14px; white-space: nowrap; }
#nav a:hover { color: #fff; background: rgba(255,255,255,.08); text-decoration: none; }
#nav a.on { color: #fff; background: rgba(255,255,255,.16); }
#nav .count { display: inline-block; margin-left: 6px; min-width: 18px; padding: 0 5px; border-radius: 9px;
              background: #fff; color: var(--accent); font-size: 11px; font-weight: 700; text-align: center; line-height: 18px; }
#nav .count.red { background: #ff5a4f; color: #fff; }
.who { display: flex; align-items: center; gap: 10px; font-size: 13px; color: rgba(255,255,255,.85); white-space: nowrap; }
.who .link { color: rgba(255,255,255,.85); }
.squarebar { background: var(--amber-soft); color: var(--amber); padding: 8px 20px; font-size: 13px;
             border-bottom: 1px solid #f3dfb8; }

.view { max-width: 1180px; margin: 0 auto; padding: 22px 20px 60px; }

.pagehead { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap;
            margin-bottom: 16px; }
.pagehead .sub { color: var(--muted); margin-top: 4px; font-size: 14px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

.toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); z-index: 1000;
         background: #1f2a36; color: #fff; padding: 11px 18px; border-radius: 10px; max-width: min(92vw, 640px);
         box-shadow: 0 8px 24px rgba(0,0,0,.2); font-size: 14px; }
.toast.bad { background: var(--red); }

/* ------------------------------------------------------------------ controls */

button { font: inherit; cursor: pointer; border-radius: 8px; border: 1px solid var(--line); background: #fff;
         color: var(--ink); padding: 8px 14px; font-weight: 550; font-size: 14px; }
button:hover { border-color: #c9d0d8; background: #fafbfc; }
button:disabled { opacity: .55; cursor: default; }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.primary:hover { background: var(--accent-ink); }
button.send { background: #1a1a1a; border-color: #1a1a1a; color: #fff; }
button.send:hover { background: #000; }
button.danger { color: var(--red); border-color: #f1c7c3; }
button.danger:hover { background: var(--red-soft); }
button.ghost { background: transparent; border-color: transparent; color: var(--muted); }
button.ghost:hover { background: #eef1f4; }
button.link { background: none; border: none; padding: 0; color: var(--accent); font-weight: 500; }
button.link:hover { text-decoration: underline; background: none; }
button.small { padding: 5px 10px; font-size: 13px; }
button.big { padding: 12px 20px; font-size: 16px; }

input, select, textarea { font: inherit; font-size: 15px; color: var(--ink); background: #fff;
  border: 1px solid #d5dbe2; border-radius: 8px; padding: 8px 10px; width: 100%; min-width: 0; }
input:focus, select:focus, textarea:focus, button:focus-visible { outline: 2px solid rgba(14,90,90,.35);
  outline-offset: 1px; border-color: var(--accent); }
textarea { resize: vertical; min-height: 70px; line-height: 1.4; }
input.money { text-align: right; font-variant-numeric: tabular-nums; }
input[type=checkbox] { width: auto; accent-color: var(--accent); }

.f { display: grid; gap: 5px; align-content: start; }
.f .caption { font-size: 12.5px; font-weight: 600; color: var(--muted); text-transform: none; }
.f .hint { font-size: 12.5px; color: var(--faint); }
.check { display: inline-flex; gap: 8px; align-items: center; font-size: 14px; cursor: pointer; }
.row { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.stack { display: grid; gap: 14px; }

/* ------------------------------------------------------------------ cards, tables */

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
        padding: 18px; }
.card + .card { margin-top: 14px; }
.card h2 { margin-bottom: 12px; display: flex; align-items: center; gap: 8px; }
.card h2 .spacer { flex: 1; }
.empty { color: var(--faint); padding: 18px; text-align: center; font-size: 14px; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: 13px; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.nowrap { white-space: nowrap; }

.tablewrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase;
     letter-spacing: .04em; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 10px; border-bottom: 1px solid #eef1f4; vertical-align: top; }
tr:last-child td { border-bottom: none; }
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: #f7f9fa; }
tr.total td { font-weight: 700; border-top: 2px solid var(--line); }

.tag { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 12px; font-weight: 600;
       white-space: nowrap; line-height: 20px; }
.tag.grey { background: #eef1f4; color: var(--muted); }
.tag.red { background: var(--red-soft); color: var(--red); }
.tag.amber { background: var(--amber-soft); color: var(--amber); }
.tag.green { background: var(--green-soft); color: var(--green); }
.tag.blue { background: var(--blue-soft); color: var(--blue); }
.tag.teal { background: var(--accent-soft); color: var(--accent); }

.bang { display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 50%;
        background: var(--red); color: #fff; font-weight: 900; font-size: 18px; line-height: 1; flex: none;
        box-shadow: 0 0 0 3px var(--red-soft); }

.avatar { --h: 180; display: inline-grid; place-items: center; width: 38px; height: 38px; border-radius: 50%;
          background: hsl(var(--h) 45% 92%); color: hsl(var(--h) 55% 28%); font-weight: 700; font-size: 14px; flex: none; }
.avatar.lg { width: 64px; height: 64px; font-size: 24px; }

.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { border-radius: 999px; padding: 5px 12px; font-size: 13px; font-weight: 550; background: #fff; }
.chip.on { background: var(--accent); border-color: var(--accent); color: #fff; }

.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin: 18px 0 16px; overflow-x: auto; }
.tabs a { padding: 9px 14px; color: var(--muted); font-weight: 600; font-size: 14px; border-bottom: 2px solid transparent;
          margin-bottom: -1px; white-space: nowrap; }
.tabs a:hover { color: var(--ink); text-decoration: none; }
.tabs a.on { color: var(--accent); border-bottom-color: var(--accent); }
.tabs .n { margin-left: 5px; color: var(--faint); font-weight: 500; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; margin-bottom: 14px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px;
        box-shadow: var(--shadow); }
.stat .label { font-size: 12.5px; color: var(--muted); font-weight: 600; }
.stat .value { font-size: 26px; font-weight: 700; margin-top: 2px; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.stat .sub { font-size: 12.5px; color: var(--faint); }
.stat.red .value { color: var(--red); }
.stat.amber .value { color: var(--amber); }
.stat.green .value { color: var(--green); }

.aging { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.aging .b { padding: 10px 12px; border-radius: 8px; background: #f6f8fa; }
.aging .b .label { font-size: 12px; color: var(--muted); font-weight: 600; }
.aging .b .value { font-size: 17px; font-weight: 700; font-variant-numeric: tabular-nums; }
.aging .b.hot .value { color: var(--red); }

/* ------------------------------------------------------------------ horse finder */

.finder { display: grid; gap: 12px; margin-bottom: 14px; }
.search { position: relative; }
.search input { padding: 13px 14px 13px 42px; font-size: 17px; border-radius: 12px; box-shadow: var(--shadow); }
.search svg { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); width: 18px; height: 18px;
              stroke: var(--faint); fill: none; stroke-width: 2; }
.horselist { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
             overflow: hidden; }
.hrow { display: flex; align-items: center; gap: 12px; padding: 11px 16px; border-bottom: 1px solid #eef1f4;
        cursor: pointer; color: var(--ink); }
.hrow:last-child { border-bottom: none; }
.hrow:hover, .hrow.sel { background: #f3f8f7; text-decoration: none; }
.hrow .main { flex: 1; min-width: 0; }
.hrow .name { font-weight: 650; font-size: 15.5px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.hrow .meta { color: var(--muted); font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hrow .right { text-align: right; font-size: 13px; color: var(--faint); white-space: nowrap; }
.hrow .alertline { color: var(--red); font-size: 12.5px; }
.groupname { padding: 8px 16px; background: #f6f8fa; font-size: 12px; font-weight: 700; color: var(--muted);
             text-transform: uppercase; letter-spacing: .05em; border-bottom: 1px solid var(--line); }

/* ------------------------------------------------------------------ horse page */

.hhead { display: flex; gap: 16px; align-items: flex-start; flex-wrap: wrap; }
.hhead .main { flex: 1; min-width: 240px; }
.hhead h1 { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.hhead .reg { color: var(--muted); font-size: 14px; margin-top: 2px; }
.hhead .facts { display: flex; gap: 6px 16px; flex-wrap: wrap; margin-top: 8px; color: var(--muted); font-size: 14px; }
.hhead .facts b { color: var(--ink); font-weight: 600; }
.alerts { margin-top: 10px; padding: 8px 12px; border-radius: 8px; background: var(--red-soft); color: var(--red);
          font-weight: 600; font-size: 14px; white-space: pre-wrap; }

.owed { display: flex; gap: 18px; align-items: flex-start; margin: 16px 0 0; padding: 16px 18px; border-radius: 12px;
        background: var(--red-soft); border: 2px solid var(--red); color: #7a1414; }
.owed .bigbang { display: grid; place-items: center; width: 64px; height: 64px; border-radius: 50%; background: var(--red);
                 color: #fff; font-size: 44px; font-weight: 900; flex: none; line-height: 1; }
.owed h2 { color: var(--red); font-size: 19px; }
.owed ul { margin: 6px 0 0; padding: 0; list-style: none; display: grid; gap: 3px; font-size: 14px; }
.owed a { color: #7a1414; text-decoration: underline; }

.owner-card { display: grid; gap: 4px; font-size: 14px; min-width: 230px; }
.owner-card .label { font-size: 12px; color: var(--faint); font-weight: 600; text-transform: uppercase; letter-spacing: .05em; }
.owner-card .oname { font-weight: 650; font-size: 15px; }

.visit { padding: 13px 4px; border-bottom: 1px solid #eef1f4; display: grid; grid-template-columns: 110px 1fr auto;
         gap: 12px; cursor: pointer; }
.visit:last-child { border-bottom: none; }
.visit:hover { background: #f7f9fa; }
.visit .date { font-weight: 650; font-size: 14px; }
.visit .date .faint { font-weight: 400; font-size: 12.5px; display: block; }
.visit .svcs { font-size: 14px; }
.visit .flags { display: flex; gap: 6px; margin-top: 4px; flex-wrap: wrap; }
.visit .amt { text-align: right; font-weight: 650; font-variant-numeric: tabular-nums; }
.visit .amt .tag { margin-top: 4px; }

.files { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; }
.file { border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: #fff; display: grid;
        grid-template-rows: 120px auto; cursor: pointer; }
.file:hover { border-color: #c4ccd5; }
.file .thumb { background: #eef1f4; display: grid; place-items: center; overflow: hidden; color: var(--faint);
               font-weight: 700; font-size: 13px; letter-spacing: .05em; }
.file .thumb img { width: 100%; height: 100%; object-fit: cover; }
.file .cap { padding: 8px 10px; font-size: 13px; }
.file .cap b { display: block; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.prose { white-space: pre-wrap; font-size: 14.5px; }
.notebox { border-radius: 8px; padding: 10px 12px; font-size: 14px; white-space: pre-wrap; }
.notebox.customer { background: var(--blue-soft); }
.notebox.private { background: var(--amber-soft); }
.notebox.summary { background: var(--accent-soft); }
.notebox .lbl { display: block; font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em;
                margin-bottom: 3px; opacity: .75; }

/* ------------------------------------------------------------------ log visit */

.logvisit { display: grid; grid-template-columns: minmax(260px, 340px) 1fr; gap: 16px; align-items: start; }
.catalogue { max-height: calc(100vh - 140px); overflow-y: auto; position: sticky; top: 70px; padding: 12px; }
.catalogue .search input { padding: 9px 10px 9px 34px; font-size: 14.5px; box-shadow: none; border-radius: 8px; }
.catalogue .search svg { left: 11px; width: 15px; height: 15px; }
.catalogue h3 { font-size: 11.5px; color: var(--faint); text-transform: uppercase; letter-spacing: .06em; margin: 14px 4px 4px; }
.svc { display: flex; justify-content: space-between; gap: 8px; width: 100%; text-align: left; border: none; border-radius: 7px;
       padding: 8px 8px; font-weight: 500; background: none; }
.svc:hover { background: var(--accent-soft); }
.svc .p { color: var(--muted); font-variant-numeric: tabular-nums; }
.svc.added { color: var(--accent); }
.svc.added span:first-child::before { content: '✓ '; }

.lines { display: grid; gap: 0; }
.line { display: grid; grid-template-columns: 1fr 70px 110px 100px 32px; gap: 8px; align-items: center;
        padding: 8px 0; border-bottom: 1px solid #eef1f4; }
.line .desc { display: grid; gap: 4px; }
.line .desc input.note { font-size: 13px; padding: 5px 8px; color: var(--muted); }
.line .amount { text-align: right; font-weight: 650; font-variant-numeric: tabular-nums; }
.line input { padding: 7px 8px; }
.linehead { display: grid; grid-template-columns: 1fr 70px 110px 100px 32px; gap: 8px; font-size: 11.5px; font-weight: 700;
            color: var(--faint); text-transform: uppercase; letter-spacing: .05em; padding-bottom: 4px;
            border-bottom: 1px solid var(--line); }
.linehead span:nth-child(n+2) { text-align: right; }
.totalbar { display: flex; justify-content: space-between; align-items: center; padding: 12px 0 0; font-size: 18px; font-weight: 700; }
.x { border: none; background: none; color: var(--faint); font-size: 20px; padding: 0; line-height: 1; }
.x:hover { color: var(--red); background: none; }

/* ------------------------------------------------------------------ invoice preview */

.invoice { border: 1px solid var(--line); border-radius: 12px; padding: 22px; background: #fff; }
.invoice .ihead { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 16px; }
.invoice .practice { font-weight: 750; font-size: 18px; color: var(--accent); }
.invoice .billto { font-size: 14px; }
.invoice .billto .label, .invoice .meta .label { font-size: 11.5px; color: var(--faint); font-weight: 700;
  text-transform: uppercase; letter-spacing: .05em; }
.invoice .meta { text-align: right; font-size: 14px; }
.invoice .hblock { margin-top: 14px; }
.invoice .hblock h3 { font-size: 14px; display: flex; justify-content: space-between; border-bottom: 1px solid var(--line);
                      padding-bottom: 5px; }
.invoice .hblock h3 .faint { font-weight: 500; }
.invoice .il { display: grid; grid-template-columns: 1fr auto; gap: 10px; font-size: 14px; padding: 5px 0; }
.invoice .il .n { color: var(--muted); font-size: 12.5px; }
.invoice .cnote { font-size: 13.5px; color: var(--muted); font-style: italic; margin-top: 4px; white-space: pre-wrap; }
.invoice .itotal { display: flex; justify-content: space-between; font-size: 20px; font-weight: 750; margin-top: 16px;
                   padding-top: 12px; border-top: 2px solid var(--ink); }
.invoice .msg { margin-top: 14px; font-size: 13.5px; color: var(--muted); white-space: pre-wrap; }
.problems { background: var(--amber-soft); color: var(--amber); border-radius: 8px; padding: 10px 14px; font-size: 14px;
            margin-bottom: 12px; }
.problems ul { margin: 4px 0 0; padding-left: 18px; }
.errorbox { background: var(--red-soft); color: var(--red); border-radius: 8px; padding: 10px 14px; font-size: 14px;
            margin-bottom: 12px; white-space: pre-wrap; }
.others { margin-top: 14px; border: 1px dashed #cdd5dd; border-radius: 10px; padding: 12px 14px; }
.others .check { display: flex; padding: 4px 0; }

/* ------------------------------------------------------------------ dialogs */

dialog { border: none; border-radius: 14px; padding: 0; width: min(560px, calc(100vw - 24px)); max-height: calc(100vh - 32px);
         box-shadow: 0 24px 60px rgba(0,0,0,.25); color: var(--ink); }
dialog.wide { width: min(860px, calc(100vw - 24px)); }
dialog::backdrop { background: rgba(15, 25, 35, .45); }
dialog form { padding: 16px 20px 18px; display: grid; gap: 14px; }
.dhead { position: sticky; top: 0; z-index: 2; background: #fff; display: flex; justify-content: space-between;
         align-items: center; padding: 16px 20px 12px; font-weight: 700; font-size: 17px; border-bottom: 1px solid var(--line); }
.dclose { border: none; background: none; font-size: 24px; line-height: 1; color: var(--faint); padding: 0 4px; }
.dclose:hover { color: var(--ink); background: none; }
.dfoot { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; padding-top: 4px; position: sticky; bottom: 0;
         background: #fff; margin: 0 -20px -18px; padding: 12px 20px 16px; border-top: 1px solid var(--line); }

.split { display: grid; grid-template-columns: 1fr 320px; gap: 16px; align-items: start; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 14px; font-size: 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }

/* ------------------------------------------------------------------ phone width */

@media (max-width: 820px) {
  .logvisit, .split { grid-template-columns: 1fr; }
  .catalogue { position: static; max-height: 320px; }
}

@media (max-width: 640px) {
  body { font-size: 15px; }
  .topbar { flex-wrap: wrap; height: auto; padding: 8px 12px 0; gap: 6px 12px; }
  .brand { order: 1; }
  .who { order: 2; margin-left: auto; }
  .who #whoami, .who #password { display: none; }
  #nav { order: 3; flex-basis: 100%; padding-bottom: 6px; }
  #nav a { padding: 7px 10px; }
  .view { padding: 14px 12px 50px; }
  h1 { font-size: 22px; }
  .card { padding: 14px; }
  .row2 { grid-template-columns: 1fr; }
  .aging { grid-template-columns: 1fr 1fr; }
  .stat .value { font-size: 22px; }
  .visit { grid-template-columns: 1fr auto; }
  .visit .date { grid-column: 1 / -1; }
  .line, .linehead { grid-template-columns: 1fr 56px 86px 32px; }
  .line .amount, .linehead span:nth-child(4) { display: none; }
  .owed { padding: 12px; gap: 12px; }
  .owed .bigbang { width: 48px; height: 48px; font-size: 32px; }
  .hrow .right .lv { display: none; }
  /* Tables become stacked cards on a phone. */
  table.stack-sm thead { display: none; }
  table.stack-sm tr { display: block; border-bottom: 1px solid var(--line); padding: 6px 0; }
  table.stack-sm td { display: flex; justify-content: space-between; gap: 12px; border: none; padding: 4px 6px; text-align: right; }
  table.stack-sm td::before { content: attr(data-label); color: var(--faint); font-size: 12px; font-weight: 600; text-align: left; }
  .invoice { padding: 14px; }
  .invoice .meta { text-align: left; }
}
