/* Woodworks & Co — one font (Outfit), walnut & brass palette */

:root {
  --ink: #2e2318;
  --ink-soft: #6b5d4d;
  --paper: #eceae4;
  --card: #ffffff;
  --line: #ddd6ca;
  --walnut: #4a3423;
  --brass: #a97a24;
  --brass-soft: #f2e7d2;
  --danger: #a03b2e;
  --radius: 14px;
  --shadow: 0 10px 30px rgba(46, 35, 24, 0.08);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: "Outfit", system-ui, sans-serif;
  font-size: 16px;
}

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

.view { display: none; }
.view.active { display: block; }

.shell {
  max-width: 960px;
  margin: 0 auto;
  padding: 20px 16px 64px;
}

/* sawtooth signature strip */
.sawtooth {
  height: 10px;
  background: linear-gradient(135deg, var(--walnut) 25%, transparent 25%) 0 0 / 14px 14px,
              linear-gradient(225deg, var(--walnut) 25%, transparent 25%) 0 0 / 14px 14px;
  background-repeat: repeat-x;
}

header.appbar {
  position: sticky;
  top: 0;
  z-index: 5;
  background: var(--paper);
  border-bottom: 1px solid var(--line);
}

.appbar-inner {
  max-width: 960px;
  margin: 0 auto;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.brand {
  font-weight: 700;
  letter-spacing: 0.02em;
  font-size: 18px;
  cursor: pointer;
  user-select: none;
}
.brand span { color: var(--brass); }

.appbar nav { display: flex; gap: 8px; }

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

.btn {
  font-family: inherit;
  font-size: 15px;
  font-weight: 600;
  border: 1px solid var(--walnut);
  background: var(--walnut);
  color: #fff;
  padding: 10px 18px;
  border-radius: 999px;
  cursor: pointer;
  transition: transform 0.08s ease, background 0.15s ease;
}
.btn:hover { background: #5d422c; }
.btn:active { transform: scale(0.98); }

.btn.ghost {
  background: transparent;
  color: var(--walnut);
}
.btn.ghost:hover { background: var(--brass-soft); }

.btn.brass { background: var(--brass); border-color: var(--brass); }
.btn.brass:hover { background: #8f6317; }

.btn.danger {
  background: transparent;
  border-color: var(--danger);
  color: var(--danger);
}
.btn.danger:hover { background: #f7e8e5; }

.btn.small { padding: 7px 14px; font-size: 13.5px; }
.btn:focus-visible { outline: 3px solid var(--brass); outline-offset: 2px; }

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

.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.login-card .inner { padding: 32px 28px; text-align: center; }

.login-card h1 {
  margin: 0 0 4px;
  font-size: 26px;
  font-weight: 700;
}
.login-card h1 span { color: var(--brass); }

.login-card p {
  margin: 0 0 22px;
  color: var(--ink-soft);
  font-size: 14.5px;
}

.field { text-align: left; margin-bottom: 14px; }
.field label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-soft);
  margin-bottom: 6px;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}
.field input, .field textarea, .field select {
  width: 100%;
  font-family: inherit;
  font-size: 15.5px;
  padding: 11px 13px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fdfcfa;
  color: var(--ink);
}
.field input:focus, .field textarea:focus {
  outline: 2px solid var(--brass);
  border-color: var(--brass);
}

.error-msg {
  color: var(--danger);
  font-size: 14px;
  min-height: 20px;
  margin: 6px 0 10px;
}

/* ---------- home ---------- */

.home-title {
  margin: 36px 0 6px;
  font-size: clamp(28px, 5vw, 40px);
  font-weight: 700;
}
.home-sub {
  margin: 0 0 32px;
  color: var(--ink-soft);
}

.home-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
}

.home-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 28px 24px;
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  box-shadow: var(--shadow);
  transition: transform 0.12s ease, border-color 0.12s ease;
}
.home-card:hover { transform: translateY(-3px); border-color: var(--brass); }
.home-card .icon { font-size: 30px; margin-bottom: 12px; }
.home-card h2 { margin: 0 0 6px; font-size: 20px; }
.home-card p { margin: 0; color: var(--ink-soft); font-size: 14.5px; }

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

.page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 24px 0 18px;
  flex-wrap: wrap;
}
.page-head h1 { margin: 0; font-size: 24px; }
.pill {
  background: var(--brass-soft);
  color: var(--walnut);
  border-radius: 999px;
  padding: 6px 14px;
  font-weight: 600;
  font-size: 14px;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px 20px;
  margin-bottom: 18px;
  box-shadow: var(--shadow);
}
.card h3 {
  margin: 0 0 16px;
  font-size: 15px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--brass);
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
@media (max-width: 640px) {
  .grid-2 { grid-template-columns: 1fr; }
}

.item-head {
  display: grid;
  grid-template-columns: 1fr 110px 110px 32px;
  gap: 10px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin-bottom: 8px;
}

.item-row {
  display: grid;
  grid-template-columns: 1fr 110px 110px 32px;
  gap: 10px;
  margin-bottom: 10px;
  align-items: start;
}
@media (max-width: 560px) {
  .item-head { grid-template-columns: 1fr 84px 84px 28px; font-size: 10.5px; }
  .item-row { grid-template-columns: 1fr 84px 84px 28px; }
}
.item-row textarea {
  resize: vertical;
  min-height: 44px;
}
.row-remove {
  border: none;
  background: transparent;
  color: var(--danger);
  font-size: 22px;
  cursor: pointer;
  padding: 8px 4px;
  line-height: 1;
}

.totals-line {
  display: flex;
  justify-content: space-between;
  padding: 10px 0;
  font-size: 15.5px;
  border-top: 1px dashed var(--line);
}
.totals-line.total {
  font-weight: 700;
  font-size: 19px;
  border-top: 2px solid var(--walnut);
}

.actions-bar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 6px;
}

/* ---------- lists / backend ---------- */

.tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 18px;
}
.tab {
  font-family: inherit;
  font-size: 15px;
  font-weight: 600;
  padding: 9px 20px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink-soft);
  cursor: pointer;
}
.tab.active {
  background: var(--walnut);
  border-color: var(--walnut);
  color: #fff;
}

.doc-list { display: flex; flex-direction: column; gap: 12px; }

.doc-item {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
}
.doc-item .meta { min-width: 200px; }
.doc-item .num { font-weight: 700; font-size: 16px; }
.doc-item .sub { color: var(--ink-soft); font-size: 14px; margin-top: 2px; }
.doc-item .amount { font-weight: 700; font-size: 17px; color: var(--walnut); }
.doc-item .row-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.badge {
  display: inline-block;
  font-size: 12px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--brass-soft);
  color: var(--brass);
  margin-left: 8px;
}

.empty {
  text-align: center;
  color: var(--ink-soft);
  padding: 48px 16px;
  background: var(--card);
  border: 1px dashed var(--line);
  border-radius: var(--radius);
}

/* ---------- A4 document ---------- */

.doc-toolbar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin: 20px 0;
}

.doc-scroll { overflow-x: auto; padding-bottom: 24px; }

.a4 {
  width: 210mm;
  min-height: 296mm;
  margin: 0 auto;
  background: #fff;
  color: #2e2318;
  padding: 15mm 16mm;
  box-shadow: var(--shadow);
  font-size: 13px;
  position: relative;
  display: flex;
  flex-direction: column;
}

.a4 .doc-saw {
  height: 8px;
  margin: -15mm -16mm 10mm;
  background: linear-gradient(135deg, #4a3423 25%, transparent 25%) 0 0 / 12px 12px,
              linear-gradient(225deg, #4a3423 25%, transparent 25%) 0 0 / 12px 12px;
  background-repeat: repeat-x;
}

.doc-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 20px;
  margin-bottom: 22px;
}
.doc-head .biz h1 {
  margin: 0;
  font-size: 27px;
  font-weight: 700;
  color: #4a3423;
  letter-spacing: 0.01em;
}
.doc-head .biz .tag {
  color: #a97a24;
  font-weight: 600;
  font-size: 12.5px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  margin-top: 2px;
}
.doc-head .biz .contact {
  margin-top: 8px;
  color: #6b5d4d;
  font-size: 12px;
  line-height: 1.55;
}

.doc-head .docmeta { text-align: right; }
.doc-head .doctype {
  font-size: 21px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: #a97a24;
}
.doc-head .docmeta table { margin-left: auto; margin-top: 8px; font-size: 12.5px; }
.doc-head .docmeta td { padding: 2px 0 2px 14px; }
.doc-head .docmeta td:first-child { color: #6b5d4d; }
.doc-head .docmeta td:last-child { font-weight: 600; }

.doc-client {
  background: #f7f4ee;
  border-radius: 8px;
  padding: 12px 14px;
  margin-bottom: 20px;
}
.doc-client .label {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #a97a24;
  margin-bottom: 4px;
}
.doc-client .name { font-weight: 700; font-size: 14.5px; }
.doc-client .detail { color: #6b5d4d; font-size: 12px; margin-top: 2px; }

table.doc-items {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 14px;
}
table.doc-items th {
  text-align: left;
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #a97a24;
  border-bottom: 2px solid #4a3423;
  padding: 7px 6px;
}
table.doc-items th.r, table.doc-items td.r { text-align: right; }
table.doc-items td {
  padding: 8px 6px;
  border-bottom: 1px solid #eae4d8;
  vertical-align: top;
  font-size: 12.5px;
}

.doc-totals {
  margin-left: auto;
  width: 240px;
  font-size: 13px;
}
.doc-totals .line {
  display: flex;
  justify-content: space-between;
  padding: 5px 6px;
}
.doc-totals .line.grand {
  font-weight: 700;
  font-size: 16px;
  border-top: 2px solid #4a3423;
  margin-top: 4px;
  padding-top: 8px;
  color: #4a3423;
}

.doc-notes {
  margin-top: 14px;
  font-size: 12px;
  color: #6b5d4d;
  white-space: pre-wrap;
}

.doc-bank {
  margin-top: auto;
  padding-top: 18px;
}
.doc-bank .box {
  border: 1.5px solid #a97a24;
  border-radius: 8px;
  padding: 12px 14px;
}
.doc-bank .label {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #a97a24;
  margin-bottom: 6px;
}
.doc-bank table { font-size: 12px; border-collapse: collapse; }
.doc-bank td { padding: 1.5px 0; }
.doc-bank td:first-child { color: #6b5d4d; padding-right: 16px; }
.doc-bank td:last-child { font-weight: 600; }

.doc-footer {
  text-align: center;
  color: #6b5d4d;
  font-size: 11px;
  margin-top: 14px;
}

/* ---------- responsive & print ---------- */

@media (max-width: 860px) {
  .a4 { transform-origin: top left; }
}

@media print {
  body * { visibility: hidden; }
  #doc-page, #doc-page * { visibility: visible; }
  #doc-page {
    position: absolute;
    left: 0;
    top: 0;
    width: 210mm;
    box-shadow: none;
    margin: 0;
  }
  header.appbar, .doc-toolbar { display: none !important; }
}

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