/* Mobile-first, responsive */
:root {
  --bg: #0f1419;
  --surface: #1a2332;
  --text: #e6edf3;
  --muted: #8b949e;
  --accent: #58a6ff;
  --success: #3fb950;
  --error: #f85149;
  --radius: 8px;
  --font: 'DM Sans', system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  line-height: 1.5;
}

.container {
  width: 100%;
  max-width: 960px;
  margin: 0 auto;
  padding: 0 1rem;
}

/* Full-width container for wide tables (e.g. admin users) */
.container--wide {
  max-width: none;
}

.header {
  background: var(--surface);
  border-bottom: 1px solid rgba(255,255,255,.06);
  padding: 0.75rem 0;
  position: sticky;
  top: 0;
  z-index: 10;
}

.container--header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.header-greeting {
  color: var(--muted);
  font-size: 0.95rem;
  margin-right: 0.5rem;
}

.header-greeting span { color: var(--text); font-weight: 500; }

.header .container {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

/* App body: sidebar + main content area */
.app-body {
  display: flex;
  flex: 1;
  min-height: calc(100vh - 52px - 48px);
}

/* Left sidebar – admin only */
.sidebar {
  width: 240px;
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid rgba(255,255,255,.06);
  padding: 1rem 0;
  display: flex;
  flex-direction: column;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  flex: 1;
}

.sidebar-link--bottom {
  margin-top: auto;
}

.sidebar-icon {
  display: inline-flex;
  align-items: center;
  margin-right: 0.5rem;
  vertical-align: middle;
}

.sidebar-icon svg {
  flex-shrink: 0;
}

.sidebar-link {
  display: block;
  padding: 0.5rem 1.25rem;
  color: var(--muted);
  text-decoration: none;
  font-size: 0.95rem;
  border-left: 3px solid transparent;
}

.sidebar-link:hover {
  color: var(--text);
  background: rgba(255,255,255,.04);
}

.sidebar-link--active {
  color: var(--accent);
  border-left-color: var(--accent);
  background: rgba(88, 166, 255, .08);
}

.sidebar-group-title {
  display: block;
  padding: 0.6rem 1.25rem 0.25rem;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}

.sidebar-link--sub {
  padding-left: 2rem;
  font-size: 0.9rem;
}

.brand {
  font-weight: 700;
  font-size: 1.25rem;
  color: var(--text);
  text-decoration: none;
}

.brand-wrap {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: var(--text);
  text-decoration: none;
}

.header-logo {
  height: 40px;
  width: auto;
  display: block;
}

.brand-text {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}

.brand-title {
  font-weight: 700;
  font-size: 1.25rem;
  line-height: 1.2;
}

.brand-subtitle {
  font-size: 0.8rem;
  color: var(--muted);
  font-weight: 500;
}

.nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
}

.nav a {
  color: var(--muted);
  text-decoration: none;
  font-size: 0.9rem;
}

.nav a:hover {
  color: var(--accent);
}

.logout-form button {
  background: transparent;
  border: 1px solid var(--muted);
  color: var(--muted);
  padding: 0.35rem 0.75rem;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 0.9rem;
}

.logout-form button:hover {
  border-color: var(--error);
  color: var(--error);
}

.main {
  flex: 1;
  padding: 1.5rem 1rem;
  overflow: auto;
}

.app-body .main .container {
  max-width: 960px;
}

.app-body .main .container--wide {
  max-width: none;
}

.alert {
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  margin-bottom: 1rem;
}

.alert-success { background: rgba(63, 185, 80, .15); color: var(--success); }
.alert-error   { background: rgba(248, 81, 73, .15); color: var(--error); }
.alert-warning { background: rgba(210, 153, 34, .15); color: #d29922; }

.alert ul { margin: 0; padding-left: 1.25rem; }

.card {
  background: var(--surface);
  border: 1px solid rgba(255,255,255,.06);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-bottom: 1rem;
}

.card h1, .card h2 { margin-top: 0; font-size: 1.25rem; }

.dashboard-stats {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.stat-card {
  background: var(--surface);
  border: 1px solid rgba(255,255,255,.06);
  border-radius: var(--radius);
  padding: 1rem;
  text-align: center;
}

.stat-value {
  display: block;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--accent);
}

.stat-label {
  font-size: 0.8rem;
  color: var(--muted);
}

.user-nav {
  display: flex;
  gap: 1rem;
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid rgba(255,255,255,.06);
}

.user-nav a {
  color: var(--muted);
  text-decoration: none;
  font-size: 0.95rem;
}

.user-nav a:hover,
.user-nav a.user-nav--active {
  color: var(--accent);
}

.checkbox-group { display: flex; flex-wrap: wrap; gap: 0.75rem 1.5rem; }
.checkbox-group--large { gap: 0.75rem 1.25rem; }
.checkbox-label { display: flex; align-items: center; gap: 0.35rem; cursor: pointer; }
.checkbox-label--large { gap: 0.5rem; font-size: 1rem; }
.checkbox-label--large input[type="checkbox"] { width: 1.125rem; height: 1.125rem; cursor: pointer; }

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
select,
textarea {
  width: 100%;
  max-width: 320px;
  padding: 0.6rem 0.75rem;
  border: 1px solid rgba(255,255,255,.15);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text);
  font-size: 1rem;
}

textarea.form-control--match-name {
  min-height: 8em;
  resize: vertical;
}

label {
  display: block;
  margin-bottom: 0.25rem;
  font-size: 0.9rem;
  color: var(--muted);
}

.form-group {
  margin-bottom: 1rem;
}

.form-group .currency-symbol {
  display: inline-block;
  margin-right: 0.5rem;
  font-weight: 600;
  color: var(--muted);
}

.error {
  display: block;
  margin-top: 0.25rem;
  font-size: 0.875rem;
  color: var(--error);
}

.form-inline {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: flex-end;
}

.form-inline input { max-width: 200px; }
.muted { color: var(--muted); font-size: 0.9rem; }

/* Form control - match text inputs (e.g. report search) */
.form-control {
  width: 100%;
  max-width: 320px;
  padding: 0.6rem 0.75rem;
  border: 1px solid rgba(255,255,255,.15);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text);
  font-size: 1rem;
}

.report-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.75rem;
}

.report-toolbar .report-search-group { margin-bottom: 0; }
.report-toolbar .report-search-group .form-control { max-width: 320px; }
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); border: 0; }

/* User wizard: Next/Previous at top (web), < > next to heading (mobile) */
.wizard-nav { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; margin-bottom: 1rem; flex-wrap: wrap; }
.wizard-nav--top { padding: 0 0 0.5rem; border-bottom: 1px solid rgba(255,255,255,.06); }
.wizard-nav--mobile { display: none; }
.wizard-nav-btn { padding: 0.4rem 0.75rem; font-size: 0.9rem; color: var(--accent); text-decoration: none; border: 1px solid rgba(255,255,255,.15); border-radius: var(--radius); background: var(--surface); }
.wizard-nav-btn:hover { background: rgba(88, 166, 255, .1); }
.wizard-nav-btn--icon { min-width: 2.5rem; text-align: center; }
.wizard-step-label { color: var(--muted); font-size: 0.9rem; }
.wizard-heading { margin: 0 0 1rem; font-size: 1.25rem; }
@media (max-width: 768px) {
  .wizard-nav--top { display: none; }
  .wizard-nav--mobile { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; margin-bottom: 0.75rem; }
  .wizard-nav--mobile .wizard-step-label { font-size: 0.85rem; }
}

.btn {
  display: inline-block;
  padding: 0.6rem 1.25rem;
  border-radius: var(--radius);
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  border: none;
  text-decoration: none;
  text-align: center;
}

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

.btn-primary:hover {
  filter: brightness(1.1);
}

.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border: 1px solid rgba(255,255,255,.15);
}

.btn-danger {
  background: rgba(248, 81, 73, .2);
  color: var(--error);
}

.btn-icon {
  padding: 0.5rem;
  min-width: 2.5rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.btn-icon svg {
  flex-shrink: 0;
}

.table-wrap {
  overflow-x: auto;
  margin: 1rem 0;
  width: 100%;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

th, td {
  padding: 0.6rem 0.75rem;
  text-align: left;
  border-bottom: 1px solid rgba(255,255,255,.06);
}

th {
  color: var(--muted);
  font-weight: 600;
}

.actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.page-heading {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.page-heading h1 { margin: 0; }

.page-heading-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1rem;
}

.filter-form {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.filter-form label { margin: 0; }

.filter-form select {
  max-width: 160px;
  margin: 0;
}

.footer {
  padding: 1rem;
  text-align: center;
  color: var(--muted);
  font-size: 0.85rem;
  border-top: 1px solid rgba(255,255,255,.06);
}

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

/* File input styled like button */
.file-input-wrap {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.file-input {
  position: absolute;
  width: 0.1px;
  height: 0.1px;
  opacity: 0;
  overflow: hidden;
  z-index: -1;
}

.file-input-label {
  margin: 0;
  cursor: pointer;
  display: inline-block;
}

.file-input-wrap .file-input:focus + .file-input-label,
.file-input-wrap .file-input-label:hover {
  filter: brightness(1.1);
}

/* Login / OTP pages - centered */
.page-center {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

.page-center-logo {
  height: 56px;
  width: auto;
  display: block;
  margin: 0 auto 1.25rem;
}

.login-page {
  min-height: 60vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-box {
  width: 100%;
  max-width: 380px;
}

.login-box h1 { margin-bottom: 1rem; font-size: 1.5rem; }

.pending-amount {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--accent);
  margin: 0.5rem 0 1rem;
}

/* User sidebar: burger on mobile */
.sidebar-burger {
  display: none;
  position: fixed;
  top: 3.5rem;
  left: 0;
  z-index: 20;
  width: 48px;
  height: 48px;
  background: var(--surface);
  border: 1px solid rgba(255,255,255,.1);
  border-left: none;
  border-radius: 0 var(--radius) var(--radius) 0;
  color: var(--text);
  cursor: pointer;
  align-items: center;
  justify-content: center;
  padding: 0;
}
.sidebar-burger-icon {
  display: block;
  width: 20px;
  height: 2px;
  background: currentColor;
  box-shadow: 0 -6px 0 currentColor, 0 6px 0 currentColor;
}
.sidebar-logout-form { margin-top: auto; }
.sidebar-link--as-btn {
  width: 100%;
  background: none;
  border: none;
  cursor: pointer;
  font: inherit;
  color: inherit;
  text-align: left;
  padding: 0.5rem 1.25rem;
  border-left: 3px solid transparent;
}
.sidebar-link--as-btn:hover { color: var(--text); background: rgba(255,255,255,.04); }

.sidebar--user.sidebar--open { transform: none; opacity: 1; visibility: visible; }

@media (max-width: 768px) {
  .header-logo { display: none !important; }
  .sidebar-burger { display: flex; }
  .sidebar--user {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    z-index: 15;
    transform: translateX(-100%);
    opacity: 0;
    visibility: hidden;
    transition: transform .2s, opacity .2s, visibility .2s;
    box-shadow: 4px 0 20px rgba(0,0,0,.3);
  }
  .sidebar--user.sidebar--open {
    transform: translateX(0);
    opacity: 1;
    visibility: visible;
  }
  .sidebar {
    width: 100%;
    border-right: none;
    border-bottom: 1px solid rgba(255,255,255,.06);
  }
  .app-body {
    flex-direction: column;
  }
  .sidebar-nav {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 0.5rem;
    padding: 0 1rem;
  }
  .sidebar--user .sidebar-nav { flex-direction: column; padding: 1rem; }
  .sidebar-group { display: flex; flex-wrap: wrap; align-items: center; gap: 0.25rem; }
  .sidebar-group-title { padding: 0.5rem 0.25rem 0 0; }
  .sidebar-link--sub { padding-left: 1rem; }
}

@media (max-width: 640px) {
  .nav { width: 100%; }
  .main { padding: 1rem 0.75rem; }
  th, td { padding: 0.5rem; font-size: 0.85rem; }
}
