:root {
  color-scheme: light;
  --ink: #15294c;
  --muted: #526682;
  --edge: #dce6f5;
  --green: #235cce;
  --dark: #12264a;
  --surface: #fff;
  --wash: #f2f6fd;
  font-family: "Inter", system-ui, -apple-system, sans-serif;
  line-height: 1.45;
  color: var(--ink);
  background: var(--wash);
}
* { box-sizing: border-box; }
body { margin: 0; }
button, input, select, textarea { font: inherit; }
button, select { cursor: pointer; }
button, a.secondary { min-height: 44px; }
button:disabled { opacity: .55; cursor: default; }
:focus-visible { outline: 3px solid #3d77d6; outline-offset: 2px; }
h1, h2, h3, p { margin: 0; }
h1 { font-size: clamp(2rem, 4vw, 3rem); letter-spacing: -.055em; line-height: 1.08; }
h2 { font-size: 1.35rem; }
small { font-size: .875rem; }
.primary, .secondary, .danger {
  border: 1px solid transparent; border-radius: 11px; padding: 9px 15px;
  font-weight: 650; text-decoration: none; display: inline-flex; align-items: center;
  justify-content: center; gap: 5px;
}
.primary { background: var(--green); color: white; }
.primary:not(:disabled):hover { background: var(--dark); }
.secondary { color: var(--ink); background: var(--surface); border-color: var(--edge); }
.secondary:not(:disabled):hover { background: var(--wash); }
.danger { color: white; background: #9b3c32; }
.shell { min-height: 100vh; display: grid; grid-template-columns: 236px minmax(0, 1fr); }
.sidebar { display: flex; flex-direction: column; gap: 40px; padding: 30px 18px 22px; background: var(--dark); color: white; }
.brand { display: flex; align-items: center; gap: 12px; }
.brand strong { display: block; font-size: 1.15rem; }
.brand small { display: block; opacity: .82; }
.brand-mark { width: 42px; height: 42px; display: grid; place-items: center; border-radius: 13px; background: #d9e9ff; color: #1d53b3; font-size: 1.5rem; font-weight: 800; }
nav { display: grid; gap: 7px; }
.nav-link, .logout { border: 0; background: transparent; color: #edf4ff; border-radius: 10px; text-align: left; padding: 10px 13px; font-weight: 600; }
.nav-link span { display: inline-block; width: 29px; font-size: 1.15rem; }
.nav-link[aria-current], .nav-link:hover, .logout:hover { background: #203d67; }
.logout { margin-top: auto; }
.top { display: flex; justify-content: space-between; gap: 12px; border-bottom: 1px solid var(--edge); padding: 19px clamp(18px, 4vw, 56px); background: white; color: var(--muted); font-size: .875rem; }
.content { padding: clamp(18px, 4vw, 56px); max-width: 1400px; margin: auto; }
.page-head { display: flex; justify-content: space-between; align-items: end; gap: 12px; margin-bottom: 26px; }
.page-head p { margin-top: 9px; color: var(--muted); }
.metrics { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; margin-bottom: 24px; }
.metric { min-width: 0; display: flex; align-items: center; gap: 13px; background: white; border: 1px solid var(--edge); border-radius: 14px; padding: 17px; }
.metric > span, .record-icon, .empty > span { display: grid; place-items: center; flex: none; width: 41px; height: 41px; border-radius: 12px; background: #e6efff; color: var(--green); font-size: 1.25rem; }
.metric small, .record-main small, .history small { display: block; color: var(--muted); }
.metric strong { display: block; font-size: clamp(1.1rem, 2.3vw, 1.7rem); overflow-wrap: anywhere; }
.records { border: 1px solid var(--edge); border-radius: 15px; background: white; overflow: hidden; }
.toolbar { display: flex; justify-content: space-between; gap: 12px; border-bottom: 1px solid var(--edge); padding: 15px; }
.search { display: flex; align-items: center; gap: 7px; border: 1px solid var(--edge); border-radius: 10px; padding-inline: 11px; width: min(100%, 410px); min-width: 0; }
.search > span { font-size: 1.35rem; }
.search input { border: 0; padding-inline: 0; }
input, select, textarea { border: 1px solid #bbcae0; border-radius: 9px; min-height: 45px; width: 100%; min-width: 0; padding: 9px 10px; background: white; color: var(--ink); }
textarea { resize: vertical; }
select { appearance: none; padding-right: 31px; background-image: linear-gradient(45deg, transparent 50%, #526682 50%), linear-gradient(135deg, #526682 50%, transparent 50%); background-position: calc(100% - 15px) 52%, calc(100% - 10px) 52%; background-size: 5px 5px; background-repeat: no-repeat; }
.toolbar select { width: auto; max-width: 53%; flex: none; }
.record-count { padding: 10px 17px; background: #f6f9fd; font-size: .875rem; color: var(--muted); }
.record-row { color: var(--ink); background: white; border: 0; border-top: 1px solid var(--edge); width: 100%; display: flex; align-items: center; gap: 12px; padding: 14px 16px; text-align: left; }
.record-row:hover { background: #f6f9ff; }
.record-row:focus-visible { outline-offset: -3px; }
.record-icon { font-size: .92rem; font-weight: 750; }
.record-main { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.record-side { display: grid; justify-items: end; gap: 6px; flex-basis: auto; max-width: 44%; text-align: right; overflow-wrap: anywhere; }
.badge { padding: 3px 8px; border-radius: 20px; font-size: .875rem; font-weight: 650; text-align: center; background: #edf2fa; color: #425570; }
.badge.green { background: #e4efff; color: #235cce; }
.badge.amber { background: #fff0d3; color: #71521b; }
.empty { display: grid; justify-items: center; text-align: center; gap: 10px; padding: 46px 16px; }
.empty p, .muted { color: var(--muted); }
.login { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: linear-gradient(150deg, #dfeafb, #f3f7fe 56%, #e6eefa); }
.login-card { width: min(100%, 420px); padding: 30px; background: white; border: 1px solid var(--edge); border-radius: 19px; box-shadow: 0 14px 45px #17345c11; }
.login h1 { margin-block: 30px 19px; }
.login button { width: 100%; }
dialog { border: 1px solid var(--edge); color: var(--ink); border-radius: 17px; width: min(720px, calc(100% - 24px)); max-height: 90dvh; padding: 20px; }
dialog::backdrop { background: #0d1e3ca3; }
.dialog-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 16px; }
.dialog-head h2 { overflow-wrap: anywhere; }
.close { min-width: 44px; font-size: 1.4rem; padding: 0; }
.form-grid, dl { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 13px; }
label { display: grid; gap: 5px; font-weight: 600; font-size: .9rem; }
label input, label select, label textarea { font-size: 1rem; font-weight: 400; }
.wide { grid-column: 1 / -1; }
.check { display: flex; align-items: center; gap: 10px; }
.check[hidden] { display: none; }
.check input { width: 20px; }
.form-actions, .links { display: flex; flex-wrap: wrap; gap: 8px; }
.form-actions { justify-content: flex-end; margin-top: 14px; }
.links { margin-block: 10px 18px; }
.error { color: #943528; margin-block: 10px; }
.error:empty, .links:empty { display: none; }
dt { color: var(--muted); font-size: .875rem; }
dd { margin: 3px 0 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.sale-line { margin-block: 14px; padding: 14px; border-radius: 12px; border: 1px solid var(--edge); background: var(--wash); }
.line-top, .total { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.line-top { margin-bottom: 10px; }
.total { padding: 12px; border-radius: 10px; background: #e6efff; margin-top: 14px; font-weight: 650; }
.history { display: block; width: 100%; text-align: left; padding: 10px; margin-top: 8px; border: 1px solid var(--edge); border-radius: 9px; background: white; color: var(--ink); overflow-wrap: anywhere; }
#notice:not(:empty) { position: fixed; bottom: 16px; right: 16px; z-index: 2; background: var(--dark); color: white; padding: 12px 16px; border-radius: 10px; max-width: calc(100% - 32px); }
@media (max-width: 780px) {
  .shell { display: block; }
  .sidebar { padding: 12px 15px; flex-direction: row; align-items: center; justify-content: space-between; gap: 12px; }
  .logout { margin: 0; }
  nav { position: fixed; z-index: 1; bottom: 0; left: 0; right: 0; grid-template-columns: repeat(3, 1fr); padding: 5px 9px calc(5px + env(safe-area-inset-bottom)); background: var(--dark); }
  .nav-link { text-align: center; padding: 4px; font-size: .875rem; }
  .nav-link span { display: block; margin: auto; }
  .top { padding: 10px 15px; }
  .content { padding: 18px 14px calc(80px + env(safe-area-inset-bottom)); }
  #notice:not(:empty) { bottom: 74px; }
}
@media (max-width: 510px) {
  .page-head { align-items: start; flex-wrap: wrap; margin-bottom: 16px; }
  .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-bottom: 16px; }
  .metric { gap: 8px; padding: 10px; align-items: start; }
  .metric:last-child { grid-column: 1 / -1; }
  .metric > span { width: 30px; height: 30px; font-size: 1rem; }
  .toolbar, .record-row { padding: 10px; gap: 8px; }
  .record-icon { display: none; }
  .form-grid, dl { grid-template-columns: 1fr; gap: 10px; }
  .sale-line .form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .sale-line .form-grid label:nth-child(-n+2) { grid-column: 1 / -1; }
  dialog { padding: 14px; }
}
