:root {
  --bg: #cece9d;
  --panel: #ffffff;
  --header: #1f2a44;
  --accent: #b8870b;
  --accent-red: #9b2222;
  --line: #b8b870;
  --ink: #222;
  --muted: #6b6b50;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Arial, Helvetica, sans-serif;
  font-size: 13px;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---- Header ---- */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--header);
  color: #fff;
  padding: 10px 18px;
  border-bottom: 3px solid var(--accent);
}
.brand { display: flex; align-items: baseline; gap: 8px; }
.brand-mark {
  font-weight: 800;
  letter-spacing: 1px;
  color: var(--accent);
  border: 2px solid var(--accent);
  padding: 1px 6px;
  border-radius: 3px;
}
.brand-name { font-size: 15px; letter-spacing: 1px; text-transform: uppercase; }
.header-right { display: flex; align-items: center; gap: 16px; font-size: 12px; }
.header-right .user { font-weight: bold; }
.header-right .logout { color: #fff; border: 1px solid rgba(255,255,255,.4); padding: 3px 10px; border-radius: 3px; }
.header-right .logout:hover { background: rgba(255,255,255,.12); text-decoration: none; }

/* ---- Nav ---- */
.main-nav { background: #dcdcba; border-bottom: 1px solid var(--line); }
.menu { list-style: none; margin: 0; padding: 0 8px; display: flex; flex-wrap: wrap; }
.menu > li { position: relative; }
.menu > li > a {
  display: block;
  padding: 9px 14px;
  color: #3a3a20;
  font-weight: bold;
  text-transform: uppercase;
  font-size: 12px;
  letter-spacing: .5px;
}
.menu > li > a:hover { background: #c9c98f; text-decoration: none; }
.menu a.active { background: #c9c98f; }
.menu ul {
  position: absolute;
  left: 0; top: 100%;
  list-style: none;
  margin: 0; padding: 4px 0;
  background: #fff;
  border: 1px solid var(--line);
  box-shadow: 2px 3px 6px rgba(0,0,0,.25);
  min-width: 190px;
  display: none;
  z-index: 50;
}
.menu > li:hover > ul { display: block; }
.menu ul li a { display: block; padding: 7px 14px; color: var(--ink); font-size: 12px; text-transform: none; }
.menu ul li a:hover { background: #f0f0d8; text-decoration: none; }
.menu a.stub { color: #9a9a78; cursor: default; }
.menu a.stub:hover { background: transparent; text-decoration: none; }

/* ---- Content ---- */
.content { max-width: 1180px; margin: 18px auto; padding: 0 18px; }
h1 { font-size: 20px; margin: 6px 0 16px; }
h2 { font-size: 16px; margin: 22px 0 10px; }
h2 .count { color: var(--muted); font-weight: normal; font-size: 13px; }

/* ---- Alerts ---- */
.alert { padding: 9px 14px; border-radius: 4px; margin: 0 0 14px; font-size: 13px; }
.alert-error { background: #f7dede; border: 1px solid #d99; color: #8a1f1f; }
.alert-success { background: #e0f0d8; border: 1px solid #9c9; color: #2f5f2f; }

/* ---- Login ---- */
.login-wrap { display: flex; justify-content: center; padding: 60px 16px; }
.login-card {
  background: var(--panel); padding: 28px 30px; border-radius: 6px;
  box-shadow: 0 6px 20px rgba(0,0,0,.2); width: 340px;
}
.login-brand { font-size: 17px; font-weight: bold; text-transform: uppercase; letter-spacing: 1px; }
.login-card .muted { color: var(--muted); margin: 4px 0 18px; }
.login-card label { display: block; margin-bottom: 14px; font-weight: bold; font-size: 12px; }
.login-card input { width: 100%; padding: 9px; margin-top: 5px; border: 1px solid #bbb; border-radius: 4px; font-size: 14px; }
.login-card button, .btn {
  background: var(--header); color: #fff; border: 0; padding: 10px 18px;
  border-radius: 4px; font-size: 14px; cursor: pointer; font-weight: bold;
}
.login-card button { width: 100%; }
.login-card button:hover, .btn:hover { background: #2a3a5e; text-decoration: none; }

/* ---- Stats ---- */
.stats { display: flex; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.stat {
  background: var(--panel); border: 1px solid var(--line); border-radius: 6px;
  padding: 16px 22px; min-width: 150px; text-align: center; color: var(--ink);
}
a.stat:hover { box-shadow: 0 3px 8px rgba(0,0,0,.15); text-decoration: none; }
.stat .num { display: block; font-size: 26px; font-weight: bold; color: var(--header); }
.stat .lbl { display: block; color: var(--muted); text-transform: uppercase; font-size: 11px; letter-spacing: .5px; margin-top: 4px; }

/* ---- Search form ---- */
.search-form { background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 16px; margin-bottom: 14px; }
.search-form .grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px 14px; }
.search-form label { font-size: 11px; font-weight: bold; color: #444; text-transform: uppercase; display: flex; flex-direction: column; gap: 4px; }
.search-form label.wide { grid-column: span 2; }
.search-form input, .search-form select { padding: 7px; border: 1px solid #bbb; border-radius: 4px; font-size: 13px; }
.form-actions { margin-top: 14px; display: flex; gap: 10px; align-items: center; }
.form-actions button { background: var(--header); color: #fff; border: 0; padding: 9px 22px; border-radius: 4px; font-weight: bold; cursor: pointer; }
.btn-reset { padding: 9px 16px; border: 1px solid #bbb; border-radius: 4px; color: #555; background: #f3f3e6; }

.legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 11px; font-weight: bold; margin: 6px 0 10px; }
.result-meta { color: var(--muted); font-size: 12px; margin-bottom: 8px; }

/* ---- Data table ---- */
table.data { width: 100%; border-collapse: collapse; background: var(--panel); }
table.data th, table.data td { border: 1px solid var(--line); padding: 7px 9px; text-align: left; vertical-align: top; }
table.data thead th { background: #dcdcba; font-size: 11px; text-transform: uppercase; letter-spacing: .5px; }
table.data tbody tr:nth-child(even) { background: #faf7e8; }
table.data td.empty { text-align: center; color: var(--muted); padding: 22px; }
.status { font-weight: bold; }

/* ---- Pager ---- */
.pager { display: flex; gap: 12px; align-items: center; justify-content: center; margin: 16px 0; font-size: 13px; }
.pager a { padding: 5px 10px; border: 1px solid var(--line); border-radius: 4px; background: var(--panel); }

/* ---- Customer card ---- */
.back { margin-bottom: 8px; }
.cust-card { background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 16px; line-height: 1.6; }
.cust-name { font-size: 16px; }
.cust-contact { margin-top: 8px; display: flex; gap: 22px; flex-wrap: wrap; color: var(--muted); }

/* ---- Error / footer ---- */
.error-box { background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 20px; }
.error-msg { white-space: pre-wrap; background: #f6f6ec; padding: 12px; border-radius: 4px; overflow: auto; }
.app-footer { text-align: center; color: var(--muted); font-size: 11px; padding: 22px; }

/* ---- Inline search / filter bars ---- */
.inline-search {
  display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap;
  background: var(--panel); border: 1px solid var(--line); border-radius: 6px;
  padding: 12px 14px; margin-bottom: 14px;
}
.inline-search label { display: flex; flex-direction: column; gap: 4px; font-size: 11px; font-weight: bold; text-transform: uppercase; color: #444; }
.inline-search input, .inline-search select { padding: 7px; border: 1px solid #bbb; border-radius: 4px; font-size: 13px; }
.inline-search button { background: var(--header); color: #fff; border: 0; padding: 9px 18px; border-radius: 4px; font-weight: bold; cursor: pointer; }

.note { color: var(--muted); font-size: 12px; font-style: italic; margin: 10px 0; }
.swatch { display: inline-block; width: 12px; height: 12px; border: 1px solid #999; vertical-align: middle; margin-right: 4px; }

/* ---- Tally / report cards ---- */
.tally-grid { display: flex; gap: 18px; flex-wrap: wrap; }
.tally-card { background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 16px 20px; min-width: 300px; flex: 1; }
.tally-card h3 { margin: 0 0 12px; font-size: 14px; text-transform: uppercase; letter-spacing: .5px; color: var(--header); border-bottom: 2px solid var(--line); padding-bottom: 6px; }
.tally-card.paid h3 { color: #006600; }
.tally-card.unpaid h3 { color: #9b2222; }
.tally-row { display: flex; justify-content: space-between; padding: 6px 0; border-bottom: 1px dotted #ddd; font-size: 14px; }
.tally-row span { color: var(--muted); }

/* ---- Edit form / actions ---- */
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.edit-form .grid { grid-template-columns: repeat(4, 1fr); }

.sub-actions details { font-size: 12px; }
.sub-actions summary { cursor: pointer; color: var(--accent); font-weight: bold; list-style: none; }
.sub-actions summary::-webkit-details-marker { display: none; }
.action-panel { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; min-width: 240px; }
.action-panel form { display: flex; gap: 5px; align-items: center; }
.action-panel input[type=text], .action-panel input[type=number] { padding: 4px 6px; border: 1px solid #bbb; border-radius: 3px; font-size: 12px; flex: 1; }
button.mini { background: var(--header); color: #fff; border: 0; padding: 5px 10px; border-radius: 3px; font-size: 11px; font-weight: bold; cursor: pointer; white-space: nowrap; }
button.mini.warn { background: var(--accent-red); }
button.mini:hover { opacity: .9; }

/* ---- Add wizard ---- */
.head-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.wizard-steps { color: var(--muted); font-size: 13px; margin: -6px 0 16px; }
.wizard-steps strong { color: var(--header); }
.pay-form { background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 14px 16px; max-width: 560px; }
.pay-form .radio { display: block; margin: 8px 0; font-size: 14px; cursor: pointer; }
.muted-inline { color: var(--muted); font-size: 12px; }

@media (max-width: 760px) {
  .search-form .grid { grid-template-columns: 1fr 1fr; }
  .search-form label.wide { grid-column: span 2; }
  .edit-form .grid { grid-template-columns: 1fr 1fr; }
  .menu { flex-direction: column; }
  .tally-grid { flex-direction: column; }
}
