/* =====================================================================
   Technica Fund Management — Design System
   Cream base, deep-emerald + antique-gold accents, warm serif display.
   ===================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Fraunces:opsz,wght@9..144,500;9..144,600;9..144,700&family=Manrope:wght@400;500;600;700;800&display=swap');

:root {
  /* palette */
  --cream:        #F6EFE1;
  --cream-deep:   #EFE5D0;
  --surface:      #FFFDF7;
  --ink:          #2B2620;
  --ink-soft:     #766B5B;
  --line:         #E4D9BF;
  --primary:      #1E6B54;
  --primary-deep: #144A3A;
  --primary-mist: #E3EEE8;
  --gold:         #B4872B;
  --gold-mist:    #F4E9CE;
  --danger:       #A8432E;
  --danger-mist:  #F4E1DA;

  /* system */
  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 22px;
  --shadow-1: 0 1px 2px rgba(43,38,32,.06), 0 8px 24px rgba(43,38,32,.06);
  --shadow-2: 0 4px 10px rgba(43,38,32,.08), 0 16px 40px rgba(43,38,32,.10);
  --ease: cubic-bezier(.22,.8,.28,1);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; overflow-x: hidden; }

body {
  margin: 0;
  font-family: 'Manrope', system-ui, sans-serif;
  background: var(--cream);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, .display {
  font-family: 'Fraunces', Georgia, serif;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--ink);
  margin: 0;
}

a { color: inherit; text-decoration: none; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}

/* ---------------------------------------------------------------------
   Auth / login page — simple centered card, list of names
   --------------------------------------------------------------------- */
.auth-center {
  min-height: 100vh; display:flex; align-items:center; justify-content:center;
  background: var(--cream); padding: 24px;
}
.auth-card-simple {
  width: 100%; max-width: 420px; background: var(--surface);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-2);
  padding: 32px 28px; text-align: left;
  animation: rise .5s var(--ease) both;
}
.auth-header-row { display:flex; align-items:center; gap:10px; margin-bottom: 4px; }
.auth-header-row i { font-size: 19px; color: var(--ink); }
.auth-card-simple h2 { font-size: 21px; margin:0; }
.auth-card-simple .sub { color: var(--ink-soft); font-size: 13.5px; margin: 6px 0 22px; }

.profile-list { display:flex; flex-direction:column; gap: 10px; max-height: 56vh; overflow-y:auto; text-align:left; padding: 2px; }
.profile-row {
  display:flex; align-items:center; justify-content:space-between; gap:12px;
  width: 100%; min-width: 0; padding: 14px 16px; border: 1.5px solid var(--line); border-radius: var(--radius-md);
  background: var(--surface); cursor: pointer; font-family: inherit;
  transition: border-color .18s var(--ease), transform .15s var(--ease), box-shadow .18s var(--ease);
  opacity: 0; transform: translateY(6px); animation: rise .4s var(--ease) forwards;
}
.profile-list .profile-row:nth-child(1){animation-delay:.02s} .profile-list .profile-row:nth-child(2){animation-delay:.06s}
.profile-list .profile-row:nth-child(3){animation-delay:.10s} .profile-list .profile-row:nth-child(4){animation-delay:.14s}
.profile-list .profile-row:nth-child(5){animation-delay:.18s} .profile-list .profile-row:nth-child(n+6){animation-delay:.22s}
.profile-row:hover { border-color: var(--primary); box-shadow: var(--shadow-1); transform: translateY(-2px); }
.profile-row:active { transform: translateY(0) scale(.99); }
.profile-row-name { font-weight: 700; font-size: 15px; color: var(--ink); min-width:0; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.role-tag {
  background: var(--gold-mist); color:#8a6b1f; font-size: 11px; font-weight:700;
  text-transform: uppercase; letter-spacing:.04em; padding: 5px 12px; border-radius: 999px; flex-shrink:0;
}

@media (max-width: 480px) {
  .auth-card-simple { padding: 24px 18px; }
  .profile-row { padding: 12px 14px; }
}

.field { margin-bottom: 18px; }
.field label { display:block; font-size: 13px; font-weight: 600; color: var(--ink-soft); margin-bottom: 6px; }
.field input, .field select, .field textarea {
  width: 100%; padding: 12px 14px; font-size: 15px; font-family: inherit;
  border: 1.5px solid var(--line); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--ink);
  transition: border-color .18s var(--ease), box-shadow .18s var(--ease);
}
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--primary); box-shadow: 0 0 0 4px var(--primary-mist); outline: none;
}
.field .hint { font-size: 12px; color: var(--ink-soft); margin-top: 5px; }

.item-row { display:flex; gap:8px; margin-bottom:8px; align-items:center; }
.item-row input[type="text"] { flex: 1.6; min-width:0; }
.item-row input[type="number"] { flex: 1; min-width:0; }
.remove-item-row {
  flex-shrink:0; width:38px; height:38px; border-radius:9px; border:1.5px solid var(--line);
  background: var(--surface); color: var(--danger); cursor:pointer; font-family:inherit;
  display:flex; align-items:center; justify-content:center;
  transition: background .15s var(--ease), border-color .15s var(--ease);
}
.remove-item-row:hover:not(:disabled) { background: var(--danger-mist); border-color: var(--danger); }
.remove-item-row:disabled { opacity:.35; cursor:not-allowed; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px 20px; border-radius: var(--radius-sm); border: none;
  font-family: inherit; font-weight: 700; font-size: 14.5px; cursor: pointer;
  transition: transform .15s var(--ease), box-shadow .2s var(--ease), background .2s var(--ease);
}
.btn:active { transform: translateY(1px) scale(.99); }
.btn-primary { background: var(--primary); color: #FBF7EC; box-shadow: 0 6px 16px rgba(30,107,84,.28); }
.btn-primary:hover { background: var(--primary-deep); box-shadow: 0 8px 22px rgba(30,107,84,.35); }
.btn-block { width: 100%; }
.btn-ghost { background: transparent; color: var(--ink); border: 1.5px solid var(--line); }
.btn-ghost:hover { border-color: var(--primary); color: var(--primary); }
.btn-gold { background: var(--gold); color: #2B2110; }
.btn-gold:hover { background: #9c7523; }
.btn-danger { background: var(--danger); color: #FBF1EC; }
.btn-danger:hover { background: #8a3524; }
.btn-sm { padding: 8px 14px; font-size: 13px; border-radius: 9px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

.error-box {
  background: var(--danger-mist); color: var(--danger); border: 1px solid #E7C4B6;
  padding: 12px 14px; border-radius: var(--radius-sm); font-size: 13.5px; margin-bottom: 18px;
  animation: shake .4s var(--ease);
}
.success-box {
  background: var(--primary-mist); color: var(--primary-deep); border: 1px solid #C7DFD3;
  padding: 12px 14px; border-radius: var(--radius-sm); font-size: 13.5px; margin-bottom: 18px;
}

@keyframes rise { from { opacity:0; transform: translateY(14px);} to {opacity:1; transform:none;} }
@keyframes shake { 0%,100%{transform:translateX(0)} 25%{transform:translateX(-6px)} 75%{transform:translateX(6px)} }

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

.sidebar {
  width: 250px; flex-shrink: 0; background: var(--primary-deep); color: #E9F1EC;
  padding: 26px 18px; display:flex; flex-direction:column; gap: 4px;
  position: sticky; top:0; height: 100vh; overflow-y:auto;
  transition: transform .25s var(--ease);
}
.sidebar .brand { display:flex; align-items:center; gap:10px; padding: 4px 10px 22px; }
.sidebar .brand .dot { width:10px;height:10px;border-radius:50%; background: var(--gold); }
.sidebar .brand span { font-family:'Fraunces',serif; font-size: 17px; color:#FBF7EC; }
.sidebar .role-pill {
  margin: 0 10px 18px; padding: 6px 12px; font-size: 11.5px; font-weight:700;
  text-transform: uppercase; letter-spacing:.04em; border-radius: 999px;
  background: rgba(244,233,206,.14); color: var(--gold-mist); width: fit-content;
}
.nav-link {
  display:flex; align-items:center; gap:10px; padding: 11px 12px; border-radius: 10px;
  color: #CBDCD3; font-size: 14px; font-weight: 600; margin-bottom: 2px;
  transition: background .18s var(--ease), color .18s var(--ease), padding-left .18s var(--ease);
}
.nav-link i { width: 18px; text-align:center; opacity:.9; }
.nav-link:hover { background: rgba(255,255,255,.06); color:#fff; padding-left:16px; }
.nav-link.active { background: var(--gold); color:#2B2110; }
.nav-group-label { font-size: 11px; text-transform: uppercase; letter-spacing:.08em; color:#8FAA9E; margin: 16px 10px 6px; }
.sidebar .logout-link { margin-top:auto; }

.main { flex: 1; min-width: 0; }
.topbar {
  display:flex; align-items:center; justify-content:space-between;
  padding: 18px 32px; background: var(--surface); border-bottom: 1px solid var(--line);
  position: sticky; top:0; z-index: 20;
}
.topbar .page-title { font-size: 21px; }
.topbar .page-sub { color: var(--ink-soft); font-size: 13px; margin-top:2px; }
.topbar .who { display:flex; align-items:center; gap:12px; }
.avatar {
  width:40px;height:40px;border-radius:50%; background: var(--gold-mist); color:var(--primary-deep);
  display:flex;align-items:center;justify-content:center; font-weight:700; font-family:'Fraunces',serif;
}

.notif-wrap { position: relative; }
.notif-bell {
  position: relative; background:none; border:none; cursor:pointer; font-size:18px;
  color: var(--ink); padding: 9px; border-radius: 10px; transition: background .15s var(--ease);
}
.notif-bell:hover { background: var(--cream-deep); }
.notif-badge {
  position: absolute; top:2px; right:2px; background: var(--danger); color:#fff;
  font-size: 10px; font-weight:700; min-width:16px; height:16px; border-radius:999px;
  display:flex; align-items:center; justify-content:center; padding:0 4px; line-height:1;
}
.notif-dropdown {
  position: absolute; top: calc(100% + 10px); right: -8px; width: 320px; max-width: 88vw;
  max-height: 420px; overflow-y:auto; background: var(--surface); border:1px solid var(--line);
  border-radius: var(--radius-md); box-shadow: var(--shadow-2); z-index: 60;
  opacity:0; transform: translateY(-8px); pointer-events:none;
  transition: opacity .18s var(--ease), transform .18s var(--ease);
}
.notif-dropdown.open { opacity:1; transform:none; pointer-events:auto; }
.notif-dropdown-head { padding: 13px 16px; font-weight:700; font-size:13px; border-bottom:1px solid var(--line); }
.notif-item { display:block; padding: 12px 16px; border-top:1px solid var(--line); font-size:13px; color:var(--ink); transition: background .15s var(--ease); }
.notif-item:hover { background: var(--cream); }
.notif-item.unread { background: var(--primary-mist); }
.notif-msg { display:block; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.notif-item .notif-time { display:block; font-size:11px; color:var(--ink-soft); margin-top:3px; }
.notif-empty { padding: 26px 16px; text-align:center; color:var(--ink-soft); font-size:13px; }

.nav-badge {
  margin-left:auto; background: var(--gold); color:#2B2110; font-size:11px; font-weight:800;
  min-width:20px; height:20px; border-radius:999px; display:inline-flex; align-items:center;
  justify-content:center; padding:0 6px; line-height:1;
}

.menu-toggle { display:none; background:none; border:none; font-size:20px; cursor:pointer; color:var(--ink); }
.sidebar-backdrop {
  display:none; position: fixed; inset:0; background: rgba(20,17,12,.45); z-index: 40;
  opacity:0; transition: opacity .2s var(--ease);
}
@media (max-width: 980px) {
  .sidebar { position: fixed; z-index: 50; transform: translateX(-100%); box-shadow: var(--shadow-2); }
  .sidebar.open { transform: translateX(0); }
  .menu-toggle { display:block; }
  .sidebar-backdrop.show { display:block; opacity:1; }
}

.content { padding: 28px 32px 60px; max-width: 1280px; }

@media (max-width: 640px) {
  .topbar { padding: 14px 16px; }
  .content { padding: 18px 14px 48px; }
  .topbar .who-text { display: none; }
  .stat-card .stat-value { font-size: 24px; }
  .card { padding: 16px; }
  .modal-box { padding: 20px; max-width: 94vw; }
  .auth-card { max-width: 100%; }
}

/* ---------------------------------------------------------------------
   Cards / KPIs / grids
   --------------------------------------------------------------------- */
.grid { display:grid; gap: 18px; }
.grid > * { min-width: 0; }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.split-side { grid-template-columns: 380px 1fr; align-items: start; }
@media (max-width: 980px) { .grid-4, .grid-3 { grid-template-columns: repeat(2,1fr); } .split-side { grid-template-columns: 1fr; } }
@media (max-width: 640px) { .grid-4, .grid-3, .grid-2 { grid-template-columns: 1fr; } }

.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-md);
  padding: 22px; box-shadow: var(--shadow-1);
}
.stat-card { position:relative; overflow:hidden; }
.stat-card .stat-label { font-size: 12.5px; color: var(--ink-soft); font-weight:700; text-transform:uppercase; letter-spacing:.05em; }
.stat-card .stat-value { font-family:'Fraunces',serif; font-size: 30px; margin-top:8px; }
.stat-card .stat-icon {
  position:absolute; right:18px; top:18px; width:38px;height:38px;border-radius:11px;
  display:flex;align-items:center;justify-content:center; font-size:16px;
}
.stat-card.balance .stat-icon { background: var(--primary-mist); color: var(--primary); }
.stat-card.expense .stat-icon { background: var(--danger-mist); color: var(--danger); }
.stat-card.pending .stat-icon { background: var(--gold-mist); color:#8a6b1f; }
.stat-card.count   .stat-icon  { background:#EDE7F5; color:#5A4A8A; }

/* staggered entrance for dashboard cards (single orchestrated moment) */
.stagger-in > * { opacity:0; transform: translateY(10px); animation: rise .55s var(--ease) forwards; }
.stagger-in > *:nth-child(1){ animation-delay:.02s }
.stagger-in > *:nth-child(2){ animation-delay:.08s }
.stagger-in > *:nth-child(3){ animation-delay:.14s }
.stagger-in > *:nth-child(4){ animation-delay:.20s }
.stagger-in > *:nth-child(5){ animation-delay:.26s }
.stagger-in > *:nth-child(6){ animation-delay:.32s }

.section-head { display:flex; align-items:center; justify-content:space-between; margin: 30px 0 14px; }
.section-head h3 { font-size: 18px; }

/* ---------------------------------------------------------------------
   Tables
   --------------------------------------------------------------------- */
.table-card { background: var(--surface); border:1px solid var(--line); border-radius: var(--radius-md); overflow-x:auto; -webkit-overflow-scrolling: touch; box-shadow: var(--shadow-1); }
table { width:100%; min-width: 560px; border-collapse: collapse; font-size: 14px; }
thead th {
  text-align:left; font-size: 11.5px; text-transform:uppercase; letter-spacing:.05em;
  color: var(--ink-soft); background: var(--cream-deep); padding: 13px 18px; font-weight:700;
}
tbody td { padding: 14px 18px; border-top: 1px solid var(--line); vertical-align: middle; }
tbody tr { transition: background .15s var(--ease); }
tbody tr:hover { background: #FBF7EC; }
.amount-add { color: var(--primary); font-weight:700; }
.amount-expense { color: var(--danger); font-weight:700; }
.empty-row td { text-align:center; color: var(--ink-soft); padding: 40px; }

.badge { display:inline-flex; align-items:center; gap:5px; padding: 4px 11px; border-radius:999px; font-size:11.5px; font-weight:700; text-transform:uppercase; letter-spacing:.03em; }
.badge-pending  { background: var(--gold-mist); color:#8a6b1f; }
.badge-approved { background: var(--primary-mist); color: var(--primary-deep); }
.badge-rejected { background: var(--danger-mist); color: var(--danger); }
.badge-active   { background: var(--primary-mist); color: var(--primary-deep); }
.badge-inactive { background: #EFE9DC; color: var(--ink-soft); }
.badge-role     { background:#EDE7F5; color:#5A4A8A; }

/* ---------------------------------------------------------------------
   Modal
   --------------------------------------------------------------------- */
.modal-overlay {
  position: fixed; inset:0; background: rgba(35,30,22,.42); backdrop-filter: blur(2px);
  display:flex; align-items:center; justify-content:center; z-index: 100;
  opacity:0; pointer-events:none; transition: opacity .2s var(--ease);
}
.modal-overlay.show { opacity:1; pointer-events:auto; }
.modal-box {
  background: var(--surface); border-radius: var(--radius-lg); padding: 28px; width: 100%; max-width: 460px;
  box-shadow: var(--shadow-2); transform: translateY(16px) scale(.98); opacity:0;
  transition: transform .25s var(--ease), opacity .25s var(--ease); max-height: 88vh; overflow-y:auto;
}
.modal-overlay.show .modal-box { transform: translateY(0) scale(1); opacity:1; }
.modal-head { display:flex; align-items:center; justify-content:space-between; margin-bottom:18px; }
.modal-head h3 { font-size: 19px; }
.modal-close { background:none; border:none; font-size:20px; cursor:pointer; color: var(--ink-soft); }
.modal-close:hover { color: var(--danger); }

/* ---------------------------------------------------------------------
   Misc
   --------------------------------------------------------------------- */
.toolbar { display:flex; align-items:center; justify-content:space-between; gap: 12px; flex-wrap: wrap; }
.shop-card { display:flex; align-items:flex-start; gap:14px; }
.shop-icon { width:44px;height:44px;border-radius:12px; background: var(--gold-mist); color:#8a6b1f; display:flex; align-items:center; justify-content:center; font-size:17px; flex-shrink:0; }
.shop-name { font-weight:700; font-size:15px; }
.shop-meta { color: var(--ink-soft); font-size:13px; margin-top:2px; }

.toast {
  position: fixed; bottom: 24px; right: 24px; background: var(--primary-deep); color:#F3EFE1;
  padding: 13px 20px; border-radius: var(--radius-sm); font-size: 14px; font-weight:600;
  box-shadow: var(--shadow-2); z-index: 200; transform: translateY(16px); opacity:0;
  transition: transform .3s var(--ease), opacity .3s var(--ease);
}
.toast.show { transform: translateY(0); opacity:1; }
.toast.err { background: var(--danger); }

.perm-row { display:flex; align-items:center; justify-content:space-between; padding: 14px 0; border-top:1px solid var(--line); }
.perm-row:first-child { border-top:none; }
.switch { position:relative; width:44px; height:26px; flex-shrink:0; }
.switch input { opacity:0; width:0; height:0; }
.switch .track { position:absolute; inset:0; background:#DED2B2; border-radius:999px; cursor:pointer; transition:background .2s var(--ease); }
.switch .track::before { content:""; position:absolute; width:20px;height:20px; left:3px; top:3px; background:#fff; border-radius:50%; transition: transform .2s var(--ease); box-shadow: 0 1px 3px rgba(0,0,0,.25); }
.switch input:checked + .track { background: var(--primary); }
.switch input:checked + .track::before { transform: translateX(18px); }

.empty-state { text-align:center; padding: 60px 20px; color: var(--ink-soft); }
.empty-state .glyph { font-size: 34px; margin-bottom: 12px; color: var(--gold); }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--line); border-radius: 10px; }
