:root {
  --bg: #17150F;
  --surface: #221F19;
  --surface-2: #2B2820;
  --border: #3A362C;
  --text: #F2EEE5;
  --text-muted: #A79E8C;
  --accent: #D4A24C;
  --accent-contrast: #17150F;
  --ok: #4FB3A0;
  --error: #E5645A;
  --radius: 10px;
  --mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
}

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

button, input, textarea {
  font-family: inherit;
  color: inherit;
}

a { color: var(--accent); }

.hidden { display: none !important; }

/* ---------- Login ---------- */
#login-view {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.login-card {
  width: 100%;
  max-width: 360px;
}

.brand-mark {
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.08em;
  color: var(--accent);
  margin-bottom: 6px;
}

.login-card h1 {
  font-size: 26px;
  font-weight: 600;
  margin: 0 0 28px 0;
}

.field {
  margin-bottom: 14px;
}

.field label {
  display: block;
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 6px;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
textarea,
select {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  font-size: 15px;
  outline: none;
}

input:focus, textarea:focus, select:focus {
  border-color: var(--accent);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: none;
  border-radius: var(--radius);
  padding: 13px 18px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  width: 100%;
}

.btn-primary {
  background: var(--accent);
  color: var(--accent-contrast);
}

.btn-primary:disabled {
  opacity: 0.55;
  cursor: default;
}

.btn-ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
}

.btn-danger {
  background: var(--error);
  color: #fff;
}

.btn-sm {
  padding: 8px 12px;
  font-size: 13px;
  width: auto;
}

.error-text {
  color: var(--error);
  font-size: 13px;
  margin-top: 10px;
}

/* ---------- App shell ---------- */
#app-view {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

header.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 5;
}

header.topbar .title {
  font-weight: 600;
  font-size: 17px;
}

header.topbar .subtitle {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-muted);
}

main.screen {
  flex: 1;
  padding: 18px 16px 100px 16px;
  max-width: 640px;
  width: 100%;
  margin: 0 auto;
}

nav.bottom-tabs {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  border-top: 1px solid var(--border);
  background: var(--bg);
  z-index: 10;
}

nav.bottom-tabs button {
  flex: 1;
  background: none;
  border: none;
  padding: 12px 4px 14px 4px;
  color: var(--text-muted);
  font-size: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  cursor: pointer;
}

nav.bottom-tabs button .icon {
  font-size: 18px;
}

nav.bottom-tabs button.active {
  color: var(--accent);
}

/* ---------- Cards ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 14px;
}

.card h2 {
  font-size: 16px;
  font-weight: 600;
  margin: 0 0 16px 0;
}

.muted { color: var(--text-muted); font-size: 13px; }

.row-between {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.stat-num {
  font-family: var(--mono);
  font-weight: 600;
  color: var(--accent);
}

/* ---------- Product search dropdown ---------- */
.searchable {
  position: relative;
}

.searchable-results {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  max-height: 220px;
  overflow-y: auto;
  z-index: 20;
}

.searchable-results .opt {
  padding: 11px 14px;
  font-size: 14px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
}

.searchable-results .opt:last-child { border-bottom: none; }
.searchable-results .opt:hover { background: var(--border); }
.searchable-results .opt .stock {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-muted);
}

/* ---------- Lists ---------- */
.tx-row, .product-row {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 10px;
}

.tx-row .top-line {
  display: flex;
  justify-content: space-between;
  font-weight: 600;
  font-size: 14px;
}

.tx-row .amount {
  font-family: var(--mono);
  color: var(--accent);
}

.tx-row .meta {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
}

.product-row .name { font-weight: 600; font-size: 15px; }
.product-row .subtitle { font-size: 13px; color: var(--text-muted); margin-top: 2px; }
.product-row .stock-line {
  font-family: var(--mono);
  font-size: 12px;
  margin-top: 6px;
}
.stock-ok { color: var(--text-muted); }
.stock-out { color: var(--error); }

.row-actions {
  display: flex;
  gap: 8px;
  margin-top: 10px;
  justify-content: flex-end;
}

/* ---------- FAB ---------- */
.fab {
  position: fixed;
  bottom: 82px;
  right: 20px;
  width: 54px;
  height: 54px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-contrast);
  border: none;
  font-size: 26px;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 6px 16px rgba(0,0,0,0.4);
  z-index: 15;
}

/* ---------- Modal ---------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 50;
}

@media (min-width: 640px) {
  .modal-backdrop { align-items: center; }
}

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px 16px 0 0;
  width: 100%;
  max-width: 460px;
  max-height: 85vh;
  overflow-y: auto;
  padding: 22px;
}

@media (min-width: 640px) {
  .modal { border-radius: 16px; }
}

.modal h3 {
  margin: 0 0 16px 0;
  font-size: 17px;
}

.report-text {
  font-family: var(--mono);
  font-size: 12.5px;
  white-space: pre-wrap;
  line-height: 1.5;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
}

.toast {
  position: fixed;
  bottom: 100px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--surface-2);
  border: 1px solid var(--border);
  padding: 12px 18px;
  border-radius: var(--radius);
  font-size: 13px;
  z-index: 60;
  max-width: 90%;
  text-align: center;
}

.toast.error { border-color: var(--error); color: var(--error); }

select { appearance: none; }
