:root {
  --green: #2e8b47;
  --green-dark: #1e6b34;
  --purple: #6c4fd6;
  --purple-dark: #5539b8;
  --gradient: linear-gradient(90deg, var(--green), var(--purple));
  --sidebar-bg: #0e0e14;
  --sidebar-bg-2: #16161f;
  --sidebar-active: linear-gradient(90deg, var(--green), var(--purple));
  --ink: #1c1c28;
  --muted: #6b7280;
  --border: #e8e8ee;
  --bg: #f5f6fa;
  --card: #ffffff;
  --danger: #e0355b;
  --warn: #f5a623;
  --ok: #2e8b47;
  --radius: 14px;
  --shadow: 0 2px 10px rgba(20, 20, 40, 0.06);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: 'Poppins', 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--ink);
}

a { text-decoration: none; color: inherit; }

/* ---------- Login Page ---------- */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at 20% 0%, #fff6e8, #fbe9d0 55%, #f6dfc2 100%);
  position: relative;
  overflow: hidden;
  padding: 40px 16px;
}

.login-card {
  width: 100%;
  max-width: 420px;
  background: var(--card);
  border-radius: 20px;
  box-shadow: 0 20px 60px rgba(30, 20, 10, 0.15);
  padding: 40px 34px;
  text-align: center;
  z-index: 2;
}

.login-logo {
  width: 100px;
  height: 100px;
  border-radius: 50%;
  background: #0e0e14;
  border: 3px solid #3d7bd6;
  margin: -100px auto 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 34px;
  color: #fff;
  overflow: hidden;
}
.login-logo img { width: 100%; height: 100%; object-fit: cover; }

.brand-title {
  font-size: 26px;
  font-weight: 800;
  margin: 6px 0 0;
}
.brand-title .g { color: var(--green); }
.brand-title .p { color: var(--purple); }
.brand-sub { color: var(--muted); font-size: 13px; letter-spacing: 2px; margin: 4px 0 22px; }

.login-card h2 { margin: 0 0 4px; font-size: 22px; }
.login-card p.sub { color: var(--muted); font-size: 13.5px; margin: 0 0 22px; }

.field {
  display: flex;
  align-items: center;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  margin-bottom: 14px;
  text-align: left;
  gap: 10px;
}
.field input {
  border: none;
  outline: none;
  flex: 1;
  font-size: 14.5px;
  font-family: inherit;
  background: transparent;
}
.field svg { flex-shrink: 0; color: #9aa0ab; }

.btn-gradient {
  width: 100%;
  padding: 13px;
  border: none;
  border-radius: 10px;
  background: var(--gradient);
  color: #fff;
  font-weight: 700;
  font-size: 15px;
  cursor: pointer;
  letter-spacing: .5px;
  transition: opacity .15s;
}
.btn-gradient:hover { opacity: .92; }
.btn-gradient:disabled { opacity: .6; cursor: not-allowed; }

.error-msg {
  background: #fdecef;
  color: var(--danger);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 13px;
  margin-bottom: 14px;
  text-align: left;
  display: none;
}
.error-msg.show { display: block; }

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

.sidebar {
  width: 250px;
  flex-shrink: 0;
  background: var(--sidebar-bg);
  color: #d7d7e0;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; bottom: 0; left: 0;
  overflow-y: auto;
  transition: transform .2s;
  z-index: 40;
}
.sidebar-header {
  display: flex; align-items: center; gap: 10px;
  padding: 20px 18px 14px;
  border-bottom: 1px solid #23232f;
}
.sidebar-header .logo-circle {
  width: 44px; height: 44px; border-radius: 50%;
  background: #000; border: 2px solid #3d7bd6;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; flex-shrink: 0; overflow: hidden;
}
.sidebar-header .logo-circle img { width: 100%; height: 100%; object-fit: cover; }
.sidebar-header .title { font-size: 13.5px; font-weight: 700; color: #fff; line-height: 1.3; }
.sidebar-header .title small { display: block; font-size: 10px; color: var(--green); font-weight: 500; letter-spacing: 1px; }

.nav-list { list-style: none; padding: 10px 10px; margin: 0; flex: 1; }
.nav-list li { margin-bottom: 2px; }
.nav-list a {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 14px; border-radius: 10px;
  font-size: 13.5px; color: #b6b6c4; cursor: pointer;
  transition: background .15s, color .15s;
}
.nav-list a:hover { background: #1c1c28; color: #fff; }
.nav-list a.active { background: var(--sidebar-active); color: #fff; }
.nav-list a svg { flex-shrink: 0; width: 18px; height: 18px; }

.sidebar-quote {
  padding: 18px; font-size: 11.5px; color: #8b8b98;
  font-style: italic; border-top: 1px solid #23232f; text-align: center;
}
.sidebar-quote b { display: block; color: var(--green); font-style: normal; margin-top: 6px; }

.main {
  margin-left: 250px;
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.topbar {
  height: 68px; background: #fff; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 24px; position: sticky; top: 0; z-index: 30;
}
.topbar h1 { font-size: 19px; margin: 0; }
.topbar-right { display: flex; align-items: center; gap: 18px; }
.topbar .date-chip {
  display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted);
}
.topbar .avatar {
  width: 38px; height: 38px; border-radius: 50%; background: var(--gradient);
  color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 14px;
  cursor: pointer; user-select: none; border: 2px solid transparent; transition: border-color .15s;
}
.topbar .avatar:hover { border-color: #c7d2fe; }
.user-menu { position: relative; }
.user-menu-dropdown {
  position: absolute; top: calc(100% + 10px); right: 0; background: #fff; border: 1px solid var(--border);
  border-radius: 12px; box-shadow: 0 12px 30px rgba(0,0,0,.12); min-width: 190px; padding: 8px;
  z-index: 100; display: none; opacity: 0; transform: translateY(-6px); transition: opacity .15s, transform .15s;
}
.user-menu-dropdown.show { display: block; opacity: 1; transform: translateY(0); }
.user-menu-dropdown .um-head { padding: 8px 10px 10px; border-bottom: 1px solid var(--border); margin-bottom: 6px; }
.user-menu-dropdown .um-head b { display: block; font-size: 13.5px; }
.user-menu-dropdown .um-head span { font-size: 11.5px; color: var(--muted); }
.user-menu-dropdown button {
  width: 100%; text-align: left; background: none; border: none; padding: 9px 10px; font-size: 13.5px;
  border-radius: 8px; cursor: pointer; color: #dc2626; font-weight: 600; display: flex; align-items: center; gap: 8px;
}
.user-menu-dropdown button:hover { background: #fef2f2; }
.topbar .who { text-align: right; line-height: 1.2; }
.topbar .who b { font-size: 13.5px; display: block; }
.topbar .who span { font-size: 11px; color: var(--muted); }
.menu-toggle { display: none; background: none; border: none; cursor: pointer; }
.back-btn {
  display: none; align-items: center; gap: 6px; background: #f2f4f7; border: 1px solid var(--border);
  border-radius: 8px; padding: 7px 12px; font-size: 13.5px; font-weight: 600; color: var(--ink); cursor: pointer;
}
.back-btn.show { display: flex; }
.back-btn:active { transform: scale(0.97); }

.content { padding: 24px; flex: 1; }

.welcome-line { margin-bottom: 20px; }
.welcome-line h2 { margin: 0 0 4px; font-size: 21px; }
.welcome-line p { margin: 0; color: var(--muted); font-size: 13.5px; }

/* Stat cards */
.stat-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 16px; margin-bottom: 22px;
}
.stat-card {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 18px; display: flex; flex-direction: column; gap: 10px;
}
.stat-card .icon {
  width: 42px; height: 42px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center; font-size: 18px;
}
.stat-card .label { font-size: 12.5px; color: var(--muted); }
.stat-card .value { font-size: 24px; font-weight: 700; }
.stat-card .delta { font-size: 11.5px; color: var(--ok); }

/* Cards / Panels */
.panel {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 20px; margin-bottom: 20px;
}
.panel-head {
  display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px;
}
.panel-head h3 { margin: 0; font-size: 16px; }
.panel-head a.link { font-size: 12.5px; color: var(--purple); font-weight: 600; cursor: pointer; }

.grid-2 { display: grid; grid-template-columns: 2fr 1fr; gap: 20px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 20px; }
@media (max-width: 1100px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }

table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table th { text-align: left; color: var(--muted); font-weight: 600; padding: 8px 10px; border-bottom: 1px solid var(--border); font-size: 12px; text-transform: uppercase; letter-spacing: .4px; }
table td { padding: 10px 10px; border-bottom: 1px solid var(--border); }
table tr:last-child td { border-bottom: none; }

.badge { padding: 4px 10px; border-radius: 20px; font-size: 11.5px; font-weight: 600; display: inline-block; }
.badge.active, .badge.paid { background: #e4f6e9; color: var(--ok); }
.badge.pending { background: #fff3de; color: #b7791f; }
.badge.overdue, .badge.inactive { background: #fdecef; color: var(--danger); }

.btn {
  padding: 9px 16px; border-radius: 8px; border: none; font-size: 13px; font-weight: 600;
  cursor: pointer; display: inline-flex; align-items: center; gap: 6px;
}
.btn-primary { background: var(--gradient); color: #fff; }
.btn-outline { background: #fff; border: 1.5px solid var(--border); color: var(--ink); }
.btn-danger { background: #fdecef; color: var(--danger); }
.btn-sm { padding: 6px 11px; font-size: 12px; }

.quick-actions { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 14px; }
.qa-btn {
  background: var(--card); border-radius: 12px; box-shadow: var(--shadow); padding: 16px 10px;
  text-align: center; cursor: pointer; border: 1px solid var(--border);
}
.qa-btn .icon { width: 38px; height: 38px; border-radius: 10px; margin: 0 auto 8px; display: flex; align-items: center; justify-content: center; }
.qa-btn span { font-size: 12px; font-weight: 600; }

/* Forms / Modals */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(10,10,20,.5);
  display: none; align-items: center; justify-content: center; z-index: 100; padding: 20px;
}
.modal-overlay.show { display: flex; }
.modal {
  background: #fff; border-radius: 16px; width: 100%; max-width: 480px;
  max-height: 88vh; overflow-y: auto; padding: 26px;
}
.modal h3 { margin: 0 0 18px; }
.form-group { margin-bottom: 14px; }
.form-group label { display: block; font-size: 12.5px; font-weight: 600; margin-bottom: 6px; color: var(--muted); }
.form-group input, .form-group select, .form-group textarea {
  width: 100%; padding: 10px 12px; border: 1.5px solid var(--border); border-radius: 8px;
  font-size: 13.5px; font-family: inherit; outline: none;
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus { border-color: var(--purple); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 18px; }

.toolbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; gap: 12px; flex-wrap: wrap; }
.search-box {
  display: flex; align-items: center; gap: 8px; border: 1.5px solid var(--border); border-radius: 8px;
  padding: 8px 12px; background: #fff; min-width: 220px;
}
.search-box input { border: none; outline: none; font-size: 13px; flex: 1; }

.toast {
  position: fixed; bottom: 24px; right: 24px; background: var(--ink); color: #fff;
  padding: 12px 18px; border-radius: 10px; font-size: 13.5px; z-index: 200;
  opacity: 0; transform: translateY(10px); transition: all .25s; pointer-events: none;
}
.toast.show { opacity: 1; transform: translateY(0); }

.empty-state { text-align: center; padding: 40px 20px; color: var(--muted); }
.empty-state .icon { font-size: 40px; margin-bottom: 10px; }

.person-row { display: flex; align-items: center; gap: 10px; }
.person-row .av {
  width: 34px; height: 34px; border-radius: 50%; background: var(--gradient); color: #fff;
  display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; flex-shrink: 0;
}

.sidebar-backdrop { display: none; }

@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main { margin-left: 0; }
  .menu-toggle { display: block; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .sidebar-backdrop.show {
    display: block; position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 39;
  }
}

.text-muted { color: var(--muted); }
.mt-0 { margin-top: 0; }
.hidden { display: none !important; }
