:root {
  --bg: #0d0d0d;
  --panel: #161616;
  --panel-alt: #1e1e1e;
  --border: rgba(212, 160, 23, 0.18);
  --text: #ffffff;
  --muted: #888888;
  --dim: #444444;
  --primary: #d4a017;
  --primary-hover: #f0c040;
  --primary-dark: #b8960c;
  --danger: #ef4444;
  --success: #22c55e;
  --warn: #f59e0b;
  --purple: #a855f7;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body, #root { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-size: 0.88rem;
}

button, input, select {
  font-family: inherit;
  font-size: 0.88rem;
}

h1, h2, h3 { font-weight: 900; letter-spacing: -0.02em; }

/* ---- Scrollbar ---- */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #333; border-radius: 3px; }
* { scrollbar-width: thin; scrollbar-color: #333 transparent; }

.full-screen-center {
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ---- PIN screen ---- */
.pin-screen { background: radial-gradient(circle at top, #1a1a1a, var(--bg)); }

.pin-title { font-size: 1.6rem; margin-bottom: 0.25rem; letter-spacing: -0.02em; }
.pin-subtitle { color: var(--muted); margin-bottom: 1.5rem; font-size: 0.85rem; }

.pin-status { min-height: 1.4rem; color: var(--danger); font-size: 0.82rem; margin-bottom: 0.25rem; }

@keyframes shake {
  10%, 90% { transform: translateX(-2px); }
  20%, 80% { transform: translateX(4px); }
  30%, 50%, 70% { transform: translateX(-8px); }
  40%, 60% { transform: translateX(8px); }
}

/* ---- Simple PIN login (plain input, no keypad) ---- */
.simple-login-card {
  width: 320px;
  text-align: center;
  padding: 1.75rem;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  transition: box-shadow 0.25s ease;
}
.simple-login-card:hover { box-shadow: 0 0 20px rgba(212, 160, 23, 0.08); }
.simple-login-card.shake { animation: shake 0.4s; }
.simple-login-label {
  display: block;
  text-align: left;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 600;
  color: var(--muted);
  margin: 1rem 0 0.4rem;
}
.simple-login-input {
  width: 100%;
  padding: 0.6rem 0.9rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--panel-alt);
  color: var(--text);
  font-size: 1.3rem;
  letter-spacing: 0.4em;
  text-align: center;
  margin-bottom: 0.75rem;
  box-sizing: border-box;
  outline: none;
  transition: border-color 0.15s ease;
}
.simple-login-input:focus { border-color: var(--primary-dark); }
.simple-login-card .btn-lg { width: 100%; margin-top: 0.25rem; }

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

.app-header {
  display: flex; align-items: center; justify-content: space-between;
  height: 58px;
  padding: 0 1.5rem;
  background: var(--bg);
  border-bottom: 1px solid var(--primary-dark);
  position: sticky;
  top: 0;
  z-index: 20;
}
.app-header h1 { font-size: 1.05rem; margin: 0; letter-spacing: -0.01em; }
.header-actions { display: flex; gap: 0.5rem; }

.tab-nav {
  display: flex; gap: 0.25rem; overflow-x: auto;
  padding: 0.5rem 1.5rem;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
}

.tab-btn {
  padding: 0.55rem 1rem;
  background: transparent;
  border: none;
  color: var(--muted);
  cursor: pointer;
  border-radius: 6px;
  white-space: nowrap;
  font-size: 0.82rem;
  font-weight: 600;
  transition: background 0.15s ease, color 0.15s ease;
}
.tab-btn:hover { background: var(--panel-alt); color: var(--text); }
.tab-btn.active { background: var(--primary); color: #000; }

.app-main { flex: 1; padding: 1.5rem; max-width: 1200px; width: 100%; margin: 0 auto; }

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.25rem;
  transition: box-shadow 0.25s ease;
}
.panel h2 { margin-top: 0; font-size: 1.15rem; }
.panel-header-row { display: flex; justify-content: space-between; align-items: center; }

/* ---- Buttons ---- */
.btn {
  padding: 0.55rem 1.1rem;
  border-radius: 6px;
  border: 1px solid transparent;
  cursor: pointer;
  font-weight: 700;
  text-decoration: none;
  display: inline-block;
  font-size: 0.85rem;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.btn-primary { background: var(--primary); color: #000; font-weight: 800; }
.btn-primary:hover:not(:disabled) { background: var(--primary-hover); }
.btn-secondary { background: transparent; color: var(--primary); border: 1.5px solid var(--primary-dark); }
.btn-secondary:hover { background: rgba(212, 160, 23, 0.08); }
.btn-ghost { background: transparent; color: var(--muted); border-color: var(--border); }
.btn-ghost:hover { color: var(--text); border-color: var(--primary-dark); }
.btn-danger { background: rgba(239, 68, 68, 0.12); color: var(--danger); border-color: rgba(239, 68, 68, 0.35); }
.btn-danger:hover { background: rgba(239, 68, 68, 0.22); }
.btn-lg { padding: 0.8rem 1.5rem; font-size: 0.95rem; margin-top: 1rem; }
.btn:disabled { opacity: 0.6; cursor: not-allowed; }

/* ---- Tables ---- */
.data-table { width: 100%; border-collapse: collapse; margin-top: 1rem; }
.data-table thead { background: var(--panel-alt); }
.data-table th, .data-table td { text-align: left; padding: 0.6rem 0.7rem; border-bottom: 1px solid var(--border); }
.data-table th { color: var(--muted); font-weight: 600; font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.06em; }
.data-table tbody tr:hover { background: rgba(255, 255, 255, 0.02); }
.data-table input, .data-table select { padding: 0.4rem 0.6rem; border-radius: 6px; border: 1px solid var(--border); background: var(--panel-alt); color: var(--text); width: 100%; }
.empty-row { text-align: center; color: var(--muted); padding: 2rem 0; }
.row-actions { display: flex; gap: 0.4rem; }

/* ---- Forms ---- */
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1rem; margin: 1rem 0; }
.form-grid label {
  display: flex; flex-direction: column; gap: 0.35rem;
  font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.06em; font-weight: 600;
  color: var(--muted);
}
.form-grid .span-2 { grid-column: span 2; }
.form-grid input, .form-grid select {
  padding: 0.5rem 0.8rem; border-radius: 6px; border: 1px solid var(--border);
  background: var(--panel-alt); color: var(--text); font-size: 0.88rem; text-transform: none; letter-spacing: normal; font-weight: 400;
  outline: none;
  transition: border-color 0.15s ease;
}
.form-grid input:focus, .form-grid select:focus { border-color: var(--primary-dark); }
.checkbox-row { flex-direction: row !important; align-items: center; gap: 0.5rem !important; flex-wrap: wrap; }
.checkbox-row input { width: auto; }

.checkbox-inline, .form-grid .checkbox-inline {
  display: inline-flex !important; flex-direction: row !important; align-items: center;
  gap: 0.35rem; text-transform: none; font-size: 0.85rem; font-weight: 400;
  color: var(--text); margin-right: 0.9rem;
}
.checkbox-inline input { width: auto; }
.currencies-cell { display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; }
.currencies-cell .edit-currencies { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }

.inline-form { display: flex; gap: 0.5rem; align-items: center; }
.inline-form input { flex: 1; padding: 0.5rem 0.8rem; border-radius: 6px; border: 1px solid var(--border); background: var(--panel-alt); color: var(--text); }

.search-input {
  width: 100%; padding: 0.55rem 0.9rem; border-radius: 6px;
  border: 1px solid var(--border); background: var(--panel-alt); color: var(--text); margin-bottom: 0.5rem;
  outline: none;
}
.search-input:focus { border-color: var(--primary-dark); }

.banner-msg { background: rgba(212, 160, 23, 0.1); border: 1px solid rgba(212, 160, 23, 0.35); color: var(--text); padding: 0.6rem 1rem; border-radius: 8px; margin-bottom: 1rem; font-size: 0.85rem; }
.banner-msg.error { background: rgba(239, 68, 68, 0.12); border-color: rgba(239, 68, 68, 0.35); }

.preview-card { margin-top: 1.5rem; padding: 1rem; border-radius: 10px; background: var(--panel-alt); border: 1px solid var(--border); }
.preview-card h3 { margin-top: 0; font-size: 0.95rem; }
.muted { color: var(--muted); }

/* ---- Toggles ---- */
.toggle-list { display: flex; flex-direction: column; gap: 0.75rem; margin-top: 1rem; }
.toggle-row { display: flex; align-items: center; gap: 1rem; padding: 0.75rem 1rem; background: var(--panel-alt); border: 1px solid var(--border); border-radius: 10px; }
.toggle-row span:first-child { flex: 1; font-weight: 600; }

.toggle-switch {
  width: 44px; height: 24px; border-radius: 999px; border: none; cursor: pointer;
  background: var(--dim); position: relative; transition: background 0.2s;
}
.toggle-switch.on { background: var(--primary); }
.toggle-knob { position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: transform 0.2s; }
.toggle-switch.on .toggle-knob { transform: translateX(20px); background: #000; }

.status-pill { padding: 2px 8px; border-radius: 4px; font-size: 0.66rem; font-weight: 700; border: none; cursor: pointer; text-transform: uppercase; letter-spacing: 0.03em; }
.status-pill.ok, .status-pending { background: rgba(245, 158, 11, 0.18); color: var(--warn); }
.status-pill.off { background: rgba(136, 136, 136, 0.15); color: var(--muted); }
.status-paid { background: rgba(34, 197, 94, 0.18); color: var(--success); }
.status-cancelled { background: rgba(239, 68, 68, 0.18); color: var(--danger); }

/* ---- Modal ---- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,0.75);
  display: flex; align-items: center; justify-content: center; z-index: 50; padding: 1rem;
}
.modal {
  background: var(--panel); border: 1px solid var(--border); border-radius: 10px;
  padding: 1.5rem; width: 100%; max-width: 680px; max-height: 90vh; overflow-y: auto;
  box-shadow: 0 0 40px rgba(212, 160, 23, 0.08);
}
.modal-actions { display: flex; justify-content: flex-end; gap: 0.5rem; margin-top: 1rem; }
.id-preview { max-width: 160px; margin-top: 0.5rem; border-radius: 6px; }

/* ---- Billing: new transaction ---- */
.sender-search { position: relative; margin-bottom: 1rem; }
.sender-search input { width: 100%; padding: 0.55rem 0.9rem; border-radius: 6px; border: 1px solid var(--border); background: var(--panel-alt); color: var(--text); outline: none; }
.sender-search input:focus { border-color: var(--primary-dark); }
.autocomplete-list {
  position: absolute; z-index: 10; background: var(--panel-alt); border: 1px solid var(--border);
  border-radius: 8px; margin-top: 0.25rem; list-style: none; padding: 0.25rem; width: 100%; max-height: 220px; overflow-y: auto;
}
.autocomplete-list li { padding: 0.5rem 0.6rem; cursor: pointer; border-radius: 6px; }
.autocomplete-list li:hover { background: var(--panel); }
.selected-chip { margin-top: 0.5rem; color: var(--success); font-size: 0.85rem; }

.method-toggle { display: flex; align-items: center; gap: 0.75rem; margin-bottom: 1rem; flex-wrap: wrap; }
.sub-toggle { display: flex; gap: 0.5rem; margin-left: 1rem; }

.input-with-btn { display: flex; gap: 0.5rem; }
.input-with-btn input { flex: 1; }

.section-title { margin-top: 1.5rem; margin-bottom: 0; border-top: 1px solid var(--border); padding-top: 1rem; font-size: 1rem; }

.calc-preview {
  display: flex; gap: 2rem; flex-wrap: wrap; padding: 1rem;
  background: var(--panel-alt); border: 1px solid var(--border); border-radius: 10px; margin: 1rem 0;
  font-size: 0.85rem;
}

/* ---- Ledger ---- */
.stat-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 0.75rem; margin-bottom: 1rem; }
.stat-card {
  background: var(--panel-alt); border: 1px solid var(--border); border-radius: 10px;
  padding: 1rem; text-align: center; transition: box-shadow 0.25s ease;
}
.stat-card:hover { box-shadow: 0 0 20px rgba(212, 160, 23, 0.08); }
.stat-value { font-size: 1.4rem; font-weight: 900; }
.stat-label { color: var(--muted); font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.06em; margin-top: 0.3rem; }

.filter-row { display: flex; gap: 0.6rem; flex-wrap: wrap; align-items: center; margin-bottom: 0.5rem; }
.filter-row select, .filter-row input { padding: 0.5rem 0.75rem; border-radius: 6px; border: 1px solid var(--border); background: var(--panel-alt); color: var(--text); }
.full-day-export { display: flex; gap: 0.4rem; align-items: center; margin-left: auto; }
