:root {
  --bg: #FCF9F0;
  --surface: #fff;
  --text: #1D2435;
  --text-muted: #2B3A5D;
  --accent: #B39973;
  --accent-hover: #9a8260;
  --border: #EBE2D5;
  --danger: #b54a4a;
  --font: 'Montserrat', system-ui, sans-serif;
  --shadow: 0 2px 12px rgba(29,36,53,0.08);
  --radius: 10px;
}
* { box-sizing: border-box; }
body { margin: 0; font-family: var(--font); background: var(--bg); color: var(--text); line-height: 1.5; }
input, select, button { font-family: inherit; font-size: 1rem; }
button { cursor: pointer; border: none; background: none; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.layout { min-height: 100vh; display: flex; flex-direction: column; }
.header { background: var(--surface); border-bottom: 1px solid var(--border); }
.header-inner { max-width: 1200px; margin: 0 auto; padding: 1rem 1.5rem; display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 0.75rem; }
.logo { font-size: 1.25rem; font-weight: 600; margin: 0; color: var(--text); }
.main { flex: 1; max-width: 1200px; margin: 0 auto; padding: 1.5rem; width: 100%; }

.btn { display: inline-flex; align-items: center; justify-content: center; padding: 0.6rem 1.2rem; border-radius: var(--radius); font-weight: 500; text-decoration: none; border: none; cursor: pointer; font-size: 1rem; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-secondary { background: var(--border); color: var(--text); }
.btn-ghost { background: none; color: var(--text-muted); }
.btn-ghost:hover { color: var(--text); }

.toolbar { display: flex; flex-wrap: wrap; gap: 1rem; align-items: center; margin-bottom: 1.5rem; }
.search-input { max-width: 320px; padding: 0.6rem 1rem; border: 1px solid var(--border); border-radius: var(--radius); }

.table-wrap { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); overflow: auto; }
.data-table { width: 100%; border-collapse: collapse; }
.data-table th, .data-table td { padding: 0.75rem 1rem; text-align: left; border-bottom: 1px solid var(--border); }
.data-table th { font-weight: 600; color: var(--text-muted); font-size: 0.85rem; }
.data-table tbody tr:hover { background: var(--bg); }
.td-actions { text-align: right; white-space: nowrap; }
.badge { display: inline-block; padding: 0.2rem 0.5rem; border-radius: 6px; font-size: 0.8rem; background: var(--border); }
.muted { color: var(--text-muted); padding: 1.5rem; }

.login-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 1.5rem; }
.login-card { max-width: 380px; width: 100%; background: var(--surface); padding: 2rem; border-radius: var(--radius); box-shadow: var(--shadow); }
.login-title { font-size: 1.75rem; margin: 0 0 0.25rem; text-align: center; }
.login-subtitle { color: var(--text-muted); font-size: 0.9rem; text-align: center; margin: 0 0 1.5rem; }
.login-form label { display: block; margin-bottom: 1rem; }
.login-form label span { display: block; font-size: 0.85rem; color: var(--text-muted); margin-bottom: 0.35rem; }
.login-form input { width: 100%; padding: 0.6rem 0.75rem; border: 1px solid var(--border); border-radius: var(--radius); }
.login-form .btn { width: 100%; margin-top: 0.5rem; padding: 0.75rem; }
.login-error { color: var(--danger); font-size: 0.9rem; margin-top: 0.5rem; }

.page-title { font-size: 1.35rem; font-weight: 600; margin: 0 0 1.5rem; }
.form-section { background: var(--surface); padding: 1.5rem; border-radius: var(--radius); margin-bottom: 1.5rem; box-shadow: var(--shadow); }
.form-section h3 { font-size: 1rem; margin: 0 0 1rem; color: var(--text-muted); font-weight: 600; }
.input { width: 100%; padding: 0.6rem 0.75rem; border: 1px solid var(--border); border-radius: var(--radius); }
.input-num { max-width: 100px; }
.invoice-meta { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.form-hint { font-size: 0.85rem; color: var(--text-muted); margin: 0 0 1rem; }
.price-type-label { display: inline-flex; margin-top: 1rem; }
.price-type-label span { display: block; font-size: 0.85rem; color: var(--text-muted); margin-bottom: 0.35rem; }
.line-items-header { display: grid; grid-template-columns: 1fr 60px 100px 90px; gap: 0.5rem; padding: 0.5rem 0; font-size: 0.85rem; color: var(--text-muted); font-weight: 600; }
.line-item-row { display: grid; grid-template-columns: 1fr 60px 100px 90px; gap: 0.5rem; align-items: center; margin-bottom: 0.5rem; }
.row-total { font-weight: 500; }
.summary-table { width: 100%; max-width: 320px; }
.summary-table td { padding: 0.4rem 0; border-bottom: 1px solid var(--border); }
.summary-table .grand-total { font-weight: 700; font-size: 1.1rem; }
.form-error { color: var(--danger); margin: 1rem 0 0; }
.form-actions { display: flex; gap: 1rem; margin-top: 1.5rem; flex-wrap: wrap; }

.customer-picker-wrap { display: block; margin-bottom: 1rem; }
.customer-picker-label { display: block; font-size: 0.85rem; color: var(--text-muted); margin-bottom: 0.35rem; }
.customer-picker { max-width: 520px; }
.customer-picker-trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  width: 100%;
  padding: 0.85rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  text-align: left;
  min-height: 52px;
  touch-action: manipulation;
}
.customer-picker-trigger:hover,
.customer-picker-trigger:focus {
  border-color: var(--accent);
  outline: none;
}
.customer-picker-display {
  flex: 1;
  font-size: 0.95rem;
  color: var(--text);
  line-height: 1.4;
  word-break: break-word;
}
.customer-picker-display.is-placeholder { color: var(--text-muted); }
.customer-picker-action {
  flex-shrink: 0;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--accent);
}

body.customer-modal-open { overflow: hidden; }
.customer-modal[hidden] { display: none !important; }
.customer-modal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 10000;
}
.customer-modal.is-open {
  display: block;
}
.customer-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(29, 36, 53, 0.45);
}
.customer-modal-dialog {
  position: absolute;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
  width: min(560px, 100%);
  max-height: min(88vh, 720px);
  background: var(--surface);
  border-radius: 18px 18px 0 0;
  box-shadow: 0 -8px 32px rgba(29, 36, 53, 0.18);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
@media (min-width: 640px) {
  .customer-modal-dialog {
    top: 50%;
    bottom: auto;
    transform: translate(-50%, -50%);
    border-radius: var(--radius);
    max-height: min(80vh, 680px);
  }
}
.customer-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
}
.customer-modal-header h3 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 600;
}
.customer-modal-close {
  width: 40px;
  height: 40px;
  border-radius: 999px;
  background: var(--bg);
  color: var(--text-muted);
  font-size: 1.5rem;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.customer-modal-search-wrap {
  padding: 0.85rem 1.25rem;
  border-bottom: 1px solid var(--border);
}
.customer-modal-results {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.customer-modal-option {
  display: block;
  width: 100%;
  padding: 1rem 1.25rem;
  min-height: 52px;
  border: none;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  text-align: left;
  font-weight: 600;
  font-size: 1rem;
  color: var(--text);
  cursor: pointer;
  touch-action: manipulation;
}
.customer-modal-option:last-child { border-bottom: none; }
.customer-modal-option:hover,
.customer-modal-option:focus,
.customer-modal-option:active {
  background: var(--bg);
  outline: none;
}
.customer-modal-option.is-selected {
  background: rgba(179, 153, 115, 0.12);
}
.customer-modal-empty {
  padding: 2rem 1.25rem;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.95rem;
}

.success-main { display: flex; align-items: center; justify-content: center; min-height: 60vh; }
.success-card { background: var(--surface); padding: 2rem; border-radius: var(--radius); box-shadow: var(--shadow); max-width: 480px; width: 100%; text-align: center; }
.success-title { font-size: 1.35rem; font-weight: 600; margin: 0 0 0.5rem; }
.success-text { color: var(--text-muted); margin: 0 0 1.5rem; }
.success-actions { display: flex; flex-direction: column; gap: 0.75rem; }
.success-actions .btn { width: 100%; }
