:root {
  --bg: #f5f7fb;
  --surface: #ffffff;
  --surface-2: #eef2f7;
  --text: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --brand: #0f172a;
  --brand-2: #1e293b;
  --success: #15803d;
  --warning: #b45309;
  --danger: #b91c1c;
  --shadow: 0 12px 30px rgba(15, 23, 42, .08);
  --radius: 22px;
}

* { box-sizing: border-box; }
html { background: var(--bg); }
body {
  margin: 0;
  font-family: Tahoma, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  padding-bottom: 92px;
}
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }
input, textarea, select { outline: none; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 15px max(18px, env(safe-area-inset-right));
  background: rgba(245,247,251,.94);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid rgba(226,232,240,.75);
}
.brand { font-weight: 900; letter-spacing: .5px; font-size: 20px; }
.brand span { font-weight: 700; color: var(--muted); }
.subbrand { font-size: 11px; color: var(--muted); margin-top: 2px; }
.role-btn {
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 999px;
  padding: 9px 14px;
  font-weight: 800;
  color: var(--brand);
}

.app-shell { width: min(920px, 100%); margin: 0 auto; padding: 18px; }
.view { display: none; animation: enter .18s ease; }
.view.active { display: block; }
@keyframes enter { from { opacity: .4; transform: translateY(4px);} to { opacity:1; transform:none;} }

.hero {
  background: linear-gradient(135deg, var(--brand), #334155);
  color: white;
  border-radius: 28px;
  padding: 24px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 18px;
  box-shadow: var(--shadow);
}
.hero h1 { margin: 5px 0 9px; font-size: clamp(25px, 6vw, 36px); }
.eyebrow { font-size: 12px; font-weight: 800; color: #94a3b8; }
.hero .eyebrow { color: #cbd5e1; }
.connection-badge {
  display: inline-flex;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
  padding: 6px 9px;
  background: rgba(255,255,255,.12);
}
.connection-badge.live { background: rgba(34,197,94,.22); color: #dcfce7; }
.balance-card { text-align: left; min-width: 118px; }
.balance-card span { display:block; color:#cbd5e1; font-size:12px; margin-bottom:7px; }
.balance-card strong { display:block; font-size: 22px; white-space: nowrap; }

.stats-grid {
  display:grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-top: 14px;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 16px;
}
.stat-card span { display:block; color:var(--muted); font-size:12px; margin-bottom:8px; }
.stat-card strong { font-size: 18px; }

.quick-grid {
  display:grid;
  grid-template-columns: 1fr 1fr;
  gap:12px;
  margin: 14px 0;
}
.quick-card {
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 20px;
  padding: 18px;
  display:flex;
  gap: 12px;
  align-items:center;
  text-align:right;
  color:var(--text);
}
.quick-card.primary { background: #e8eef8; border-color: #d5deec; }
.quick-card strong, .quick-card small { display:block; }
.quick-card small { color:var(--muted); margin-top:4px; font-size:11px; }
.quick-icon {
  width: 42px; height: 42px; border-radius: 14px;
  display:grid; place-items:center; background:var(--brand); color:white;
  font-size:24px; flex:0 0 auto;
}

.panel, .form-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: 0 8px 26px rgba(15,23,42,.04);
}
.section-head, .page-head, .invoice-head {
  display:flex; align-items:center; justify-content:space-between; gap:14px;
}
.section-head h2, .page-head h1 { margin:0; }
.link-btn, .ghost-btn, .danger-link {
  background:none; border:0; font-weight:800; color:var(--brand);
}
.ghost-btn {
  border:1px solid var(--line);
  background:var(--surface);
  padding:9px 13px;
  border-radius:12px;
}
.danger-link { color: var(--danger); }

.page-head { margin-bottom: 14px; }
.page-head h1 { margin-top:4px; }

.form-grid {
  display:grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
label > span { display:block; font-size:12px; font-weight:800; color:#334155; margin:0 3px 7px; }
.form-grid input, .form-grid textarea, .filters input, .filters select, #noInvoiceReason {
  width:100%;
  border:1px solid var(--line);
  border-radius:14px;
  padding:13px 14px;
  background:#fff;
  color:var(--text);
  transition:.15s;
}
.form-grid input:focus, .form-grid textarea:focus, .filters input:focus, .filters select:focus, #noInvoiceReason:focus {
  border-color:#94a3b8;
  box-shadow:0 0 0 3px rgba(148,163,184,.16);
}
.full { grid-column: 1 / -1; }
.money-input { position:relative; }
.money-input input { padding-left:45px; }
.money-input b { position:absolute; left:15px; top:50%; transform:translateY(-50%); color:var(--muted); }

.invoice-box {
  margin-top:16px;
  border:1px dashed #cbd5e1;
  border-radius:18px;
  padding:16px;
  background:#f8fafc;
}
.invoice-head small { display:block; color:var(--muted); margin-top:4px; }
.upload-btn {
  background:var(--brand);
  color:#fff;
  border-radius:13px;
  padding:11px 14px;
  font-weight:800;
  white-space:nowrap;
}
.invoice-preview { margin-top:14px; }
.invoice-preview img {
  width:100%;
  max-height:340px;
  object-fit:contain;
  background:#fff;
  border:1px solid var(--line);
  border-radius:14px;
  display:block;
  margin-bottom:10px;
}
.no-invoice {
  margin-top:12px;
  display:flex;
  align-items:center;
  gap:8px;
}
.no-invoice span { margin:0; }
#noInvoiceReason { margin-top:9px; }

.submit-btn {
  width:100%;
  border:0;
  border-radius:15px;
  padding:14px 18px;
  margin-top:16px;
  background:var(--brand);
  color:white;
  font-weight:900;
  min-height:50px;
  display:flex; align-items:center; justify-content:center; gap:10px;
}
.submit-btn.secondary { background:#334155; }
.submit-btn:disabled { opacity:.65; cursor:not-allowed; }
.loader {
  width:18px; height:18px; border-radius:50%;
  border:2px solid rgba(255,255,255,.35); border-top-color:#fff;
  animation:spin .7s linear infinite;
}
@keyframes spin { to { transform:rotate(360deg); } }

.form-error {
  margin-top:14px;
  padding:11px 13px;
  border-radius:12px;
  color:#991b1b;
  background:#fee2e2;
  font-size:13px;
  font-weight:700;
}

.filters {
  display:grid;
  grid-template-columns: 1fr 180px;
  gap:10px;
  margin-bottom:12px;
}
.transaction-list { display:grid; gap:10px; }
.empty-box {
  color:var(--muted);
  text-align:center;
  padding:24px;
  border:1px dashed var(--line);
  border-radius:16px;
}
.tx-card {
  text-align:right;
  border:1px solid var(--line);
  background:var(--surface);
  border-radius:18px;
  padding:15px;
}
.tx-top, .tx-bottom {
  display:flex; align-items:center; justify-content:space-between; gap:10px;
}
.tx-title { font-weight:900; }
.tx-amount { font-size:18px; font-weight:900; white-space:nowrap; }
.tx-meta { color:var(--muted); font-size:11px; margin-top:6px; }
.tx-description { color:#334155; font-size:13px; line-height:1.7; margin:9px 0; }
.status {
  display:inline-flex; align-items:center;
  border-radius:999px; padding:5px 8px;
  font-size:10px; font-weight:900;
}
.status.pending { background:#fef3c7; color:#92400e; }
.status.approved { background:#dcfce7; color:#166534; }
.status.rejected { background:#fee2e2; color:#991b1b; }
.invoice-link { font-size:12px; font-weight:800; color:#1d4ed8; text-decoration:none; }
.review-actions { display:flex; gap:8px; margin-top:12px; }
.review-actions button {
  flex:1; border:0; border-radius:12px; padding:10px; font-weight:900;
}
.approve-btn { background:#dcfce7; color:#166534; }
.reject-btn { background:#fee2e2; color:#991b1b; }

.security-note {
  background:#fff7ed;
  color:#9a3412;
  border:1px solid #fed7aa;
  border-radius:14px;
  padding:12px 14px;
  margin-bottom:12px;
  font-size:12px;
  line-height:1.7;
}
.code-line {
  direction:ltr;
  text-align:left;
  background:#0f172a;
  color:#e2e8f0;
  border-radius:12px;
  padding:12px;
  overflow:auto;
  margin:12px 0;
  font-family:monospace;
  font-size:12px;
}
.connection-result { margin-top:12px; font-weight:800; font-size:13px; }

.bottom-nav {
  position:fixed;
  z-index:30;
  bottom:0; left:0; right:0;
  display:flex;
  justify-content:center;
  gap:2px;
  background:rgba(255,255,255,.96);
  backdrop-filter: blur(16px);
  border-top:1px solid var(--line);
  padding:8px 8px max(8px, env(safe-area-inset-bottom));
}
.nav-item {
  width:min(110px, 20vw);
  border:0;
  background:none;
  border-radius:14px;
  padding:7px 5px;
  color:var(--muted);
}
.nav-item span, .nav-item small { display:block; }
.nav-item span { font-size:20px; line-height:1; }
.nav-item small { font-size:10px; margin-top:4px; }
.nav-item.active { background:#eef2f7; color:var(--brand); font-weight:900; }

.toast {
  position:fixed;
  z-index:100;
  bottom:95px;
  left:50%;
  transform:translateX(-50%);
  max-width:min(420px, calc(100% - 30px));
  background:#0f172a;
  color:#fff;
  border-radius:14px;
  padding:12px 16px;
  box-shadow:var(--shadow);
  font-size:13px;
  font-weight:800;
}

@media (max-width: 640px) {
  .app-shell { padding:14px; }
  .hero { padding:20px; border-radius:23px; }
  .stats-grid { grid-template-columns:1fr 1fr; }
  .stats-grid .stat-card:last-child { grid-column:1/-1; }
  .quick-grid { grid-template-columns:1fr; }
  .form-grid { grid-template-columns:1fr; }
  .full { grid-column:auto; }
  .filters { grid-template-columns:1fr; }
  .invoice-head { align-items:flex-start; flex-direction:column; }
  .upload-btn { width:100%; text-align:center; }
}


/* ===== v10 Auth + Admin ===== */
[hidden] { display: none !important; }

.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at top right, rgba(51,65,85,.16), transparent 32%),
    var(--bg);
}

.login-card {
  width: min(430px, 100%);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 28px;
  padding: 28px;
  box-shadow: var(--shadow);
}

.login-logo {
  width: 58px;
  height: 58px;
  display: grid;
  place-items: center;
  background: var(--brand);
  color: white;
  border-radius: 18px;
  font-size: 30px;
  font-weight: 900;
  margin-bottom: 16px;
}

.login-brand {
  font-weight: 900;
  font-size: 21px;
}
.login-brand span { color: var(--muted); }
.login-card h1 { margin: 7px 0 4px; }
.login-card p { color: var(--muted); margin: 0 0 20px; }

.login-card label { display:block; margin-top: 13px; }
.login-card input,
.compact-form input,
.compact-form select {
  width:100%;
  border:1px solid var(--line);
  border-radius:14px;
  padding:13px 14px;
  background:#fff;
}

.user-area {
  display:flex;
  align-items:center;
  gap:10px;
}

.user-chip {
  text-align:left;
}
.user-chip strong, .user-chip small { display:block; }
.user-chip small { color:var(--muted); font-size:10px; margin-top:2px; }

.safe-summary-grid {
  display:grid;
  grid-template-columns:repeat(3, 1fr);
  gap:10px;
  margin-top:14px;
}

.safe-card {
  border:1px solid var(--line);
  border-radius:16px;
  padding:13px;
  background:#f8fafc;
}
.safe-card strong, .safe-card span, .safe-card small { display:block; }
.safe-card span { margin-top:7px; font-weight:800; }
.safe-card small { margin-top:5px; color:var(--muted); line-height:1.5; }

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

.tx-tags {
  display:flex;
  gap:6px;
  flex-wrap:wrap;
  margin:8px 0;
}
.tx-tags span {
  background:#f1f5f9;
  color:#475569;
  border-radius:999px;
  padding:4px 7px;
  font-size:10px;
  font-weight:800;
}

.users-list {
  display:grid;
  gap:10px;
  margin-top:14px;
}

.user-row {
  background:var(--surface);
  border:1px solid var(--line);
  border-radius:17px;
  padding:14px;
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
}
.user-row strong, .user-row small { display:block; }
.user-row small { color:var(--muted); margin-top:4px; }

.user-row-actions {
  display:flex;
  gap:7px;
  align-items:center;
  flex-wrap:wrap;
}
.user-row-actions button {
  border:1px solid var(--line);
  background:white;
  border-radius:10px;
  padding:7px 9px;
  font-size:11px;
  font-weight:800;
}

.compact-form { margin-bottom:14px; }

@media (max-width: 640px) {
  .safe-summary-grid { grid-template-columns:1fr; }
  .user-area .user-chip { display:none; }
  .user-row { align-items:flex-start; flex-direction:column; }
  .user-row-actions { width:100%; }
}


/* ===== v11 Multi Workbook ===== */
.admin-workbook-picker {
  margin: 14px 0 10px;
}

.admin-workbook-picker select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 13px 14px;
  background: #fff;
  font-weight: 800;
}

.workbook-card {
  text-align: right;
  width: 100%;
  cursor: pointer;
  font: inherit;
}

.workbook-card.selected {
  outline: 2px solid #0f172a;
  background: #eef2f7;
}


/* ===== v13 Returned Transaction Edit ===== */
.review-note {
  margin: 10px 0;
  padding: 10px 12px;
  border-radius: 12px;
  background: #fff7ed;
  border: 1px solid #fed7aa;
  font-size: 12px;
  line-height: 1.7;
}

.review-note strong {
  font-weight: 900;
}

.edit-mode-banner {
  margin-bottom: 16px;
  padding: 13px 14px;
  border-radius: 16px;
  border: 1px solid #f59e0b;
  background: #fffbeb;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
}

.edit-mode-banner strong,
.edit-mode-banner span,
.edit-mode-banner a {
  display: block;
}

.edit-mode-banner span {
  margin-top: 4px;
  font-size: 12px;
  line-height: 1.6;
}

.edit-mode-banner a {
  margin-top: 7px;
}


/* ===== v15 PLACES+ Branding + Auth Splash ===== */
:root {
  --places-navy: #0f1f35;
  --places-navy-2: #172c48;
  --places-gold: #c49a5a;
}

.boot-screen {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at 25% 10%, rgba(196,154,90,.13), transparent 28%),
    linear-gradient(160deg, #0b1728, var(--places-navy));
}

.boot-card {
  width: min(360px, 92vw);
  text-align: center;
  color: #fff;
}

.boot-places-logo {
  display: block;
  width: min(270px, 82%);
  margin: 0 auto 26px;
  object-fit: contain;
}

.boot-spinner {
  width: 30px;
  height: 30px;
  margin: 0 auto 15px;
  border-radius: 50%;
  border: 3px solid rgba(255,255,255,.18);
  border-top-color: var(--places-gold);
  animation: placesSpin .75s linear infinite;
}

@keyframes placesSpin {
  to { transform: rotate(360deg); }
}

.boot-card strong {
  display: block;
  font-size: 15px;
}

.boot-card small {
  display: block;
  margin-top: 7px;
  color: #aebdd0;
  font-size: 11px;
  direction: ltr;
}

.places-login-logo {
  display: block;
  width: min(260px, 82%);
  height: auto;
  margin: 0 auto 18px;
  object-fit: contain;
}

.created-by {
  margin-top: 24px;
  padding-top: 17px;
  border-top: 1px solid var(--line);
  text-align: center;
}

.created-by > span {
  display: block;
  direction: ltr;
  font-size: 10px;
  letter-spacing: 1.1px;
  color: var(--muted);
  margin-bottom: 9px;
  text-transform: uppercase;
}

.created-by img {
  display: block;
  width: min(185px, 62%);
  height: auto;
  margin: 0 auto;
  border-radius: 12px;
}

.places-top-brand {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

.places-top-brand img {
  width: 155px;
  height: 40px;
  object-fit: contain;
  object-position: left center;
}

.places-top-brand .subbrand {
  margin-top: -2px;
  padding-left: 3px;
}

.login-card {
  border-top: 3px solid var(--places-gold);
}

.submit-btn,
.quick-card.primary {
  border-color: var(--places-navy) !important;
}

.submit-btn {
  background: var(--places-navy) !important;
}

@media (max-width: 640px) {
  .places-top-brand img {
    width: 132px;
    height: 34px;
  }

  .created-by img {
    width: 155px;
  }
}


/* ===== v15.2 Official PLACES+ Logo ===== */
.boot-places-logo {
  width: min(360px, 88vw);
  max-width: 360px;
  height: auto;
  object-fit: contain;
}

.places-login-logo {
  width: min(330px, 88%);
  max-width: 330px;
  height: auto;
  margin: 0 auto 20px;
  object-fit: contain;
}

.places-top-brand img {
  width: 168px;
  height: auto;
  max-height: 44px;
  object-fit: contain;
  object-position: left center;
}

@media (max-width: 640px) {
  .boot-places-logo {
    width: min(300px, 86vw);
  }

  .places-login-logo {
    width: min(270px, 84vw);
  }

  .places-top-brand img {
    width: 138px;
    max-height: 38px;
  }
}
