/* Flower shop admin. Quiet working screens; the printed sheets carry the character. */

:root {
  --ink: #1d2a23;
  --ink-soft: #57655c;
  --leaf: #2f5d46;
  --leaf-deep: #213f31;
  --leaf-wash: #e5eee8;
  --petal: #b83a62;
  --petal-wash: #f9e6ec;
  --pollen: #f3d27a;
  --mist: #eef1ec;
  --paper: #ffffff;
  --line: #d4dcd3;
  --line-soft: #e7ece6;

  --radius-s: 6px;
  --radius-m: 10px;

  --font: "Hanken Grotesk", system-ui, -apple-system, "Segoe UI", sans-serif;
  --display: "Young Serif", Georgia, serif;
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--mist);
  color: var(--ink);
  font: 400 15px/1.5 var(--font);
  font-variant-numeric: tabular-nums;
}

a { color: var(--leaf); text-underline-offset: 2px; }
a:hover { color: var(--leaf-deep); }

:focus-visible { outline: 2px solid var(--leaf); outline-offset: 2px; }

h1, h2, h3 { margin: 0; line-height: 1.2; }
h1 { font: 400 30px/1.15 var(--display); letter-spacing: -0.01em; }
h2 { font-size: 18px; font-weight: 600; }
h3 { font-size: 14px; font-weight: 600; color: var(--ink-soft); }

code { font-size: 0.92em; background: var(--line-soft); padding: 1px 5px; border-radius: 4px; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.muted { color: var(--ink-soft); }
.small { font-size: 13px; }
.strong { font-weight: 600; }
.nowrap { white-space: nowrap; }
.pre { white-space: pre-line; }
.num { text-align: right; }
.idno { font-weight: 600; letter-spacing: 0.02em; }
p { margin: 0; }

/* ------------------------------------------------------------- shell */

.shell { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }

.sidebar {
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column; gap: 28px;
  padding: 24px 16px;
  background: var(--leaf-deep);
  color: #dfe9e2;
}

.brand {
  display: flex; align-items: center; gap: 10px;
  padding: 0 8px;
  color: #fff; text-decoration: none;
  font: 400 19px/1.15 var(--display);
}
.brand:hover { color: #fff; }
.brand small { display: block; font: 500 12px/1.4 var(--font); color: #a9c0b2; }
.brand .mark { color: #f2a7bd; flex: none; }

.sidebar nav { display: grid; gap: 2px; }
.sidebar nav a {
  padding: 9px 12px;
  border-radius: var(--radius-s);
  color: #dfe9e2; text-decoration: none; font-weight: 500;
}
.sidebar nav a:hover { background: rgba(255, 255, 255, 0.07); color: #fff; }
.sidebar nav a[aria-current="page"] { background: rgba(255, 255, 255, 0.12); color: #fff; box-shadow: inset 3px 0 0 #f2a7bd; }

.signout { margin-top: auto; padding: 0 12px; display: grid; gap: 4px; font-size: 13px; color: #a9c0b2; }
.signout .link { color: #fff; }

.main { padding: 32px clamp(16px, 4vw, 48px) 64px; min-width: 0; max-width: 1180px; }

.page-head {
  display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between;
  gap: 16px; margin-bottom: 20px;
}
.page-head .muted { margin-top: 6px; }
.crumbs { font-size: 13px; margin-bottom: 6px; color: var(--ink-soft); }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }

/* ----------------------------------------------------------- buttons */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 38px; padding: 0 14px;
  border: 1px solid var(--line); border-radius: var(--radius-s);
  background: var(--paper); color: var(--ink);
  font: 600 14px/1 var(--font); text-decoration: none; cursor: pointer;
}
.btn:hover { border-color: var(--ink-soft); color: var(--ink); }
.btn.primary { background: var(--leaf); border-color: var(--leaf); color: #fff; }
.btn.primary:hover { background: var(--leaf-deep); border-color: var(--leaf-deep); color: #fff; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--ink-soft); }
.btn.ghost:hover { color: var(--ink); text-decoration: underline; }
.btn.danger { background: var(--paper); border-color: #e3b4c3; color: var(--petal); }
.btn.danger:hover { background: var(--petal); border-color: var(--petal); color: #fff; }
.btn.small { min-height: 32px; font-size: 13px; }
.btn.block { width: 100%; }

.link { background: none; border: 0; padding: 0; font: inherit; color: var(--leaf); text-decoration: underline; cursor: pointer; justify-self: start; }

.icon-btn {
  width: 30px; height: 30px; border: 0; border-radius: var(--radius-s);
  background: transparent; color: var(--ink-soft); font-size: 20px; line-height: 1; cursor: pointer;
}
.icon-btn:hover { background: var(--petal-wash); color: var(--petal); }

/* ---------------------------------------------------- messages, empty */

.flash, .alert { margin: 0 0 18px; padding: 11px 14px; border-radius: var(--radius-s); font-weight: 500; }
.flash { background: var(--leaf-wash); color: var(--leaf-deep); }
.alert { background: var(--petal-wash); color: #8e2448; }

.empty {
  display: grid; justify-items: start; gap: 14px;
  padding: 40px 28px; border: 1px dashed var(--line); border-radius: var(--radius-m);
  background: var(--paper);
}
.empty-inline { padding: 16px 0; color: var(--ink-soft); }

/* ------------------------------------------------------------ search */

.search { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.search input[type="search"] { flex: 1 1 280px; }

/* ------------------------------------------------------------ tables */

.table-wrap { overflow-x: auto; background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius-m); }

.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: 11px 14px; text-align: left; vertical-align: top; }
.table th.num, .table td.num { text-align: right; }
.table thead th { font-size: 13px; font-weight: 600; color: var(--ink-soft); border-bottom: 1px solid var(--line); white-space: nowrap; }
.table tbody tr + tr td { border-top: 1px solid var(--line-soft); }
.table-wrap .table tbody tr:hover td { background: #f7f9f6; }
.table tfoot td { border-top: 2px solid var(--ink); font-weight: 700; }
.table.compact th, .table.compact td { padding: 8px 10px; }
.table.compact th:first-child, .table.compact td:first-child { padding-left: 0; }
.table.compact th:last-child, .table.compact td:last-child { padding-right: 0; }

.name-cell { min-width: 11em; }
.row-actions { white-space: nowrap; text-align: right; }

@media (max-width: 1200px) {
  .hide-md { display: none; }
}
.row-actions a + a { margin-left: 12px; }

.badge {
  display: inline-block; padding: 2px 9px; border-radius: 99px;
  font-size: 12px; font-weight: 600; white-space: nowrap;
}
.badge.paid { background: var(--leaf-wash); color: var(--leaf-deep); }
.badge.unpaid { background: var(--petal-wash); color: #8e2448; }

/* ------------------------------------------------------------- forms */

input, select, textarea {
  width: 100%; min-height: 40px; padding: 8px 11px;
  border: 1px solid var(--line); border-radius: var(--radius-s);
  background: var(--paper); color: var(--ink);
  font: inherit;
}
textarea { resize: vertical; min-height: 64px; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--leaf); outline-offset: -1px; border-color: var(--leaf); }
[aria-invalid="true"] { border-color: var(--petal); background: #fffafb; }
select, input[type="search"] { width: auto; }
.search input[type="search"] { width: auto; }

.panel { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius-m); padding: 24px; }
.panel + .panel { margin-top: 20px; }
.panel.narrow { max-width: 560px; }
.panel h2 { margin-bottom: 4px; }

.stack { display: grid; gap: 16px; }

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px 20px; }
.form-grid .wide { grid-column: 1 / -1; }

.field { display: grid; gap: 6px; align-content: start; }
.field > span { font-size: 14px; font-weight: 600; }
.field > span em { font-style: normal; font-weight: 400; color: var(--ink-soft); margin-left: 4px; }
.field select, .field input { width: 100%; }
.error { color: #a12a52; font-size: 13px; font-weight: 500; }

.form-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding-top: 6px; }
.live-total { margin-right: auto; font-size: 15px; color: var(--ink-soft); }
.live-total strong { margin-left: 6px; font-size: 20px; color: var(--ink); }

fieldset.items-edit { border: 0; padding: 0; margin: 0; display: grid; gap: 10px; }
fieldset.items-edit [data-add] { justify-self: start; }
fieldset.items-edit legend { font-size: 14px; font-weight: 600; padding: 0; margin-bottom: 8px; }
.items-edit .table td { vertical-align: middle; }
.items-edit .qty { width: 80px; text-align: right; }
.items-edit .price { width: 130px; text-align: right; }
.items-edit [data-amount] { min-width: 110px; color: var(--ink-soft); }
.items-edit .table th:nth-child(1) { width: 100%; }

.danger-zone {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 16px;
  margin-top: 28px; padding: 18px 24px;
  border: 1px solid #ecc9d4; border-radius: var(--radius-m); background: #fffafb;
}
.danger-zone h2 { font-size: 15px; margin-bottom: 2px; }

.details-list { margin: 16px 0 0; display: grid; gap: 10px; }
.details-list div { display: grid; grid-template-columns: 90px 1fr; gap: 12px; }
.details-list dt { color: var(--ink-soft); }
.details-list dd { margin: 0; }

/* ------------------------------------------- printable sheet (record + receipt) */

.sheet {
  position: relative;
  max-width: 820px;
  padding: 44px 48px 36px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-top: 6px solid var(--leaf);
  border-radius: 4px var(--radius-s) var(--radius-s) 4px;
  box-shadow: 0 1px 0 var(--line), 0 18px 40px -28px rgba(33, 63, 49, 0.45);
  display: grid; gap: 30px;
}

.sheet-head {
  display: flex; justify-content: space-between; align-items: flex-start; gap: 24px;
  padding-bottom: 24px; border-bottom: 1px solid var(--line);
}
.shop { display: flex; gap: 14px; align-items: flex-start; }
.shop .mark { color: var(--petal); flex: none; margin-top: 2px; }
.shop-name { display: block; font: 400 22px/1.2 var(--display); margin-bottom: 4px; }

.doc-id { text-align: right; display: grid; gap: 2px; }
.doc-id h2 { font: 400 26px/1.1 var(--display); color: var(--leaf); margin-bottom: 4px; }
.doc-id .idno { font-size: 16px; }

.details dl { margin: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 32px; }
.details dl .wide { grid-column: 1 / -1; }
.details dt { font-size: 13px; color: var(--ink-soft); margin-bottom: 2px; }
.details dd { margin: 0; }

.notes {
  margin-top: 22px; padding: 14px 16px;
  background: #f7f9f6; border-left: 3px solid var(--leaf); border-radius: 0 var(--radius-s) var(--radius-s) 0;
}
.notes h3 { margin-bottom: 4px; }

.section-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 8px; margin-bottom: 6px; }
.section-head h3 { font-size: 16px; color: var(--ink); }

/* receipt */

.bill-to { display: flex; justify-content: space-between; align-items: flex-start; gap: 24px; }
.bill-to h3 { margin-bottom: 6px; }
.bill-to p + p { margin-top: 2px; }

/* The rubber stamp: the one loud thing on the page. */
.stamp {
  display: grid; justify-items: center;
  padding: 8px 18px 7px;
  border: 3px solid currentColor; border-radius: 8px;
  font: 400 30px/1 var(--display); letter-spacing: 0.04em;
  transform: rotate(-7deg);
  color: var(--leaf);
  opacity: 0.88;
  mix-blend-mode: multiply;
  box-shadow: inset 0 0 0 2px var(--paper), inset 0 0 0 3px currentColor;
}
.stamp small { font: 600 11px/1.4 var(--font); letter-spacing: 0.02em; margin-top: 4px; }
.stamp.unpaid { color: var(--petal); }

.receipt .items thead th { border-bottom: 2px solid var(--ink); color: var(--ink); }
.receipt .items th:first-child, .receipt .items td:first-child { padding-left: 0; }
.receipt .items th:last-child, .receipt .items td:last-child { padding-right: 0; }

.totals { display: flex; justify-content: flex-end; margin-top: -14px; }
.totals dl { margin: 0; min-width: 300px; display: grid; gap: 6px; }
.totals dl div { display: flex; justify-content: space-between; gap: 24px; }
.totals dt { color: var(--ink-soft); }
.totals dd { margin: 0; text-align: right; }
.totals .grand { padding: 10px 0; margin: 4px 0; border-top: 2px solid var(--ink); border-bottom: 1px solid var(--line); }
.totals .grand dt { color: var(--ink); font-weight: 700; }
.totals .grand dd { font: 400 24px/1 var(--display); }

.sheet-foot { padding-top: 18px; border-top: 1px dashed var(--line); text-align: center; color: var(--ink-soft); font-size: 13px; }

/* ------------------------------------------------------------- login */

.login-page { display: grid; place-items: center; min-height: 100vh; padding: 24px 16px; background: var(--leaf-deep); }
.login {
  width: 100%; max-width: 380px; padding: 36px 32px 32px;
  background: var(--paper); border-radius: var(--radius-m);
  border-top: 6px solid var(--petal);
}
.login-brand { color: var(--petal); margin-bottom: 14px; }
.login h1 { font-size: 28px; }
.login-sub { color: var(--ink-soft); margin: 6px 0 22px; }

/* -------------------------------------------------------- responsive */

@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar {
    position: static; height: auto;
    flex-direction: row; flex-wrap: wrap; align-items: center; gap: 12px 20px;
    padding: 12px 16px;
  }
  .sidebar nav { display: flex; gap: 4px; }
  .sidebar nav a[aria-current="page"] { box-shadow: inset 0 -3px 0 #f2a7bd; }
  .signout { margin: 0 0 0 auto; padding: 0; grid-auto-flow: column; align-items: center; gap: 10px; }
  .signout span { display: none; }
  .main { padding-top: 24px; }
  .hide-sm { display: none; }
  .form-grid { grid-template-columns: 1fr; }
  .sheet { padding: 28px 20px; }
  .sheet-head, .bill-to { flex-direction: column; }
  .doc-id { text-align: left; }
  .details dl { grid-template-columns: 1fr; }
  .totals dl { min-width: 0; width: 100%; }
  .items-edit .table thead { display: none; }
  .items-edit .table tr { display: grid; grid-template-columns: 1fr 70px 100px auto; gap: 6px; padding: 8px 0; }
  .items-edit .table td { padding: 0; border: 0 !important; }
  .items-edit [data-amount] { display: none; }
  .items-edit .qty, .items-edit .price { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; transition: none !important; }
}

/* ------------------------------------------------------------- print */

@media print {
  @page { size: A4; margin: 14mm 14mm 16mm; }

  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }

  body { background: #fff; font-size: 12.5px; }
  .shell { display: block; }
  .sidebar, .no-print, .flash, .alert, .search, .actions, .row-actions, .danger-zone { display: none !important; }
  .main { padding: 0; max-width: none; }

  a { color: inherit; text-decoration: none; }

  .sheet { max-width: none; padding: 0; border: 0; box-shadow: none; border-radius: 0; gap: 24px; }
  .sheet::before {
    content: ""; display: block; height: 5px; background: var(--leaf); margin-bottom: -6px;
  }

  .table-wrap { border: 0; overflow: visible; border-radius: 0; }
  .table th, .table td { padding: 7px 8px; }
  .table tr { break-inside: avoid; }
  .table thead { display: table-header-group; }
  .hide-sm, .hide-md { display: table-cell; }

  .stamp { mix-blend-mode: normal; }
  .totals, .notes, .sheet-foot, .bill-to { break-inside: avoid; }

  h1 { font-size: 22px; }
  .page-head { margin-bottom: 12px; }
}
