:root {
  --bg: #f6f6fb;
  --surface: #ffffff;
  --surface-2: #f0eefb;
  --text: #211f2d;
  --muted: #706d7d;
  --line: #e4e1ed;
  --primary: #6f4cff;
  --primary-strong: #5534e8;
  --primary-soft: #eee9ff;
  --success: #178a5b;
  --success-soft: #e4f6ef;
  --danger: #c63f4b;
  --danger-soft: #fff0f1;
  --warning: #a96700;
  --warning-soft: #fff4dd;
  --shadow: 0 12px 32px rgba(38, 31, 75, 0.08);
  --radius: 18px;
  --radius-sm: 12px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
a { color: inherit; }

.hidden { display: none !important; }
.muted { color: var(--muted); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-warning { color: var(--warning); }
.nowrap { white-space: nowrap; }

.auth-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(360px, .9fr);
}
.auth-hero {
  padding: clamp(32px, 6vw, 88px);
  background:
    radial-gradient(circle at 15% 15%, rgba(255,255,255,.22), transparent 30%),
    linear-gradient(145deg, #28185d, #6f4cff 58%, #9f82ff);
  color: #fff;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 100vh;
}
.brand-mark {
  width: 52px;
  height: 52px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  background: rgba(255,255,255,.18);
  border: 1px solid rgba(255,255,255,.22);
  font-weight: 900;
  letter-spacing: -.04em;
  overflow: hidden;
}
.brand-mark img { width: 100%; height: 100%; object-fit: contain; }
.auth-hero h1 {
  max-width: 750px;
  font-size: clamp(38px, 6vw, 74px);
  line-height: .98;
  letter-spacing: -.055em;
  margin: 24px 0 18px;
}
.auth-hero p { max-width: 650px; font-size: 18px; line-height: 1.65; color: rgba(255,255,255,.82); }
.hero-pills { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 26px; }
.hero-pill { padding: 10px 14px; border-radius: 999px; background: rgba(255,255,255,.12); border: 1px solid rgba(255,255,255,.18); font-size: 14px; }
.auth-panel { display: grid; place-items: center; padding: 30px; }
.auth-card { width: min(100%, 470px); background: var(--surface); border: 1px solid var(--line); border-radius: 28px; padding: 30px; box-shadow: var(--shadow); }
.auth-card h2 { margin: 0 0 8px; font-size: 28px; letter-spacing: -.03em; }
.auth-card > p { margin-top: 0; color: var(--muted); }
.auth-tabs { display: grid; grid-template-columns: 1fr 1fr; background: var(--surface-2); padding: 4px; border-radius: 12px; margin: 22px 0; }
.auth-tab { border: 0; background: transparent; padding: 10px; border-radius: 9px; font-weight: 700; color: var(--muted); }
.auth-tab.active { background: #fff; color: var(--text); box-shadow: 0 3px 12px rgba(38,31,75,.09); }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 260px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; height: 100vh; background: #21183d; color: #fff; padding: 22px 16px; display: flex; flex-direction: column; z-index: 20; }
.sidebar-brand { display: flex; gap: 12px; align-items: center; padding: 6px 8px 22px; }
.sidebar-brand .brand-mark { width: 42px; height: 42px; border-radius: 13px; }
.sidebar-brand strong { display: block; font-size: 15px; }
.sidebar-brand small { display: block; margin-top: 3px; color: rgba(255,255,255,.56); }
.nav { display: grid; gap: 6px; }
.nav-link { border: 0; text-align: left; display: flex; align-items: center; gap: 12px; width: 100%; padding: 12px 14px; border-radius: 12px; color: rgba(255,255,255,.68); background: transparent; font-weight: 700; }
.nav-link:hover, .nav-link.active { background: rgba(255,255,255,.1); color: #fff; }
.nav-icon { width: 22px; text-align: center; font-size: 18px; }
.sidebar-bottom { margin-top: auto; padding: 14px 8px 0; border-top: 1px solid rgba(255,255,255,.1); }
.user-chip { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.avatar { width: 38px; height: 38px; border-radius: 50%; background: rgba(255,255,255,.14); display: grid; place-items: center; font-weight: 800; }
.user-chip strong, .user-chip small { display: block; max-width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-chip small { color: rgba(255,255,255,.55); font-size: 12px; margin-top: 2px; }

.main { min-width: 0; }
.topbar { min-height: 76px; padding: 16px clamp(18px, 3vw, 34px); display: flex; align-items: center; justify-content: space-between; gap: 16px; border-bottom: 1px solid var(--line); background: rgba(246,246,251,.88); backdrop-filter: blur(12px); position: sticky; top: 0; z-index: 15; }
.topbar h1 { margin: 0; font-size: clamp(21px, 3vw, 28px); letter-spacing: -.035em; }
.topbar p { margin: 4px 0 0; color: var(--muted); font-size: 13px; }
.topbar-actions { display: flex; gap: 8px; align-items: center; }
.content { padding: clamp(20px, 3vw, 34px); max-width: 1520px; margin: 0 auto; }

.demo-banner { margin-bottom: 18px; border: 1px solid #f2cc7b; background: var(--warning-soft); color: #6f4500; border-radius: 14px; padding: 12px 14px; font-size: 14px; line-height: 1.5; }

.grid { display: grid; gap: 18px; }
.grid.cards-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid.cards-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.two { grid-template-columns: minmax(0, 1.65fr) minmax(280px, .9fr); }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 6px 18px rgba(38,31,75,.045); }
.card-pad { padding: 20px; }
.metric-card { padding: 20px; position: relative; overflow: hidden; }
.metric-card::after { content: ""; position: absolute; width: 110px; height: 110px; right: -42px; top: -48px; border-radius: 50%; background: var(--primary-soft); }
.metric-label { color: var(--muted); font-size: 13px; font-weight: 700; }
.metric-value { margin-top: 9px; font-size: clamp(24px, 2.8vw, 34px); font-weight: 850; letter-spacing: -.045em; }
.metric-note { margin-top: 8px; color: var(--muted); font-size: 12px; }
.section-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; margin-bottom: 16px; }
.section-head h2 { margin: 0; font-size: 19px; letter-spacing: -.025em; }
.section-head p { margin: 5px 0 0; color: var(--muted); font-size: 13px; }

.btn { border: 1px solid transparent; border-radius: 11px; min-height: 42px; padding: 10px 14px; font-weight: 750; display: inline-flex; align-items: center; justify-content: center; gap: 8px; transition: .15s ease; }
.btn:hover { transform: translateY(-1px); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-strong); }
.btn-secondary { background: #fff; border-color: var(--line); color: var(--text); }
.btn-ghost { background: transparent; color: inherit; border-color: transparent; }
.btn-danger { background: var(--danger-soft); color: var(--danger); }
.btn-sm { min-height: 34px; padding: 7px 10px; font-size: 13px; border-radius: 9px; }
.btn-block { width: 100%; }
.icon-btn { width: 40px; height: 40px; padding: 0; border-radius: 11px; }

.field { display: grid; gap: 7px; }
.field label { font-size: 13px; font-weight: 750; }
.field small { color: var(--muted); line-height: 1.4; }
.input, .select, .textarea { width: 100%; border: 1px solid var(--line); background: #fff; color: var(--text); border-radius: 11px; padding: 11px 12px; outline: none; transition: .15s; }
.input:focus, .select:focus, .textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(111,76,255,.12); }
.textarea { min-height: 92px; resize: vertical; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 14px; }
.form-grid .full { grid-column: 1 / -1; }
.form-actions { display: flex; justify-content: flex-end; gap: 9px; margin-top: 20px; }
.input-group { position: relative; }
.input-group .prefix { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.input-group .input { padding-left: 40px; }

.table-wrap { width: 100%; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: 11px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 13px 12px; border-bottom: 1px solid var(--line); font-size: 14px; vertical-align: top; }
tr:last-child td { border-bottom: 0; }
.row-title { font-weight: 780; }
.row-sub { color: var(--muted); font-size: 12px; margin-top: 4px; }
.amount-in { color: var(--success); font-weight: 800; }
.amount-out { color: var(--danger); font-weight: 800; }

.badge { display: inline-flex; align-items: center; gap: 5px; border-radius: 999px; padding: 5px 9px; font-size: 11px; font-weight: 800; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.badge.success { background: var(--success-soft); color: var(--success); }
.badge.danger { background: var(--danger-soft); color: var(--danger); }
.badge.warning { background: var(--warning-soft); color: var(--warning); }
.badge.primary { background: var(--primary-soft); color: var(--primary-strong); }

.event-grid { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 16px; }
.event-card { padding: 18px; cursor: pointer; transition: .16s ease; }
.event-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); border-color: #d6d0ea; }
.event-card h3 { margin: 10px 0 5px; font-size: 18px; letter-spacing: -.02em; }
.event-meta { display: flex; flex-wrap: wrap; gap: 8px 12px; color: var(--muted); font-size: 12px; }
.event-finance { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line); }
.event-finance small { display: block; color: var(--muted); }
.event-finance strong { display: block; margin-top: 4px; font-size: 13px; }

.empty { padding: 42px 20px; text-align: center; color: var(--muted); }
.empty-icon { font-size: 38px; margin-bottom: 10px; }
.empty h3 { margin: 0 0 6px; color: var(--text); }
.empty p { margin: 0 auto 16px; max-width: 520px; line-height: 1.55; }

.reimbursement-list { display: grid; gap: 10px; }
.reimbursement-item { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px; border: 1px solid var(--line); border-radius: 12px; }
.reimbursement-item strong { display: block; }
.reimbursement-item small { display: block; color: var(--muted); margin-top: 3px; }

.progress { height: 9px; background: var(--surface-2); border-radius: 999px; overflow: hidden; }
.progress > span { display: block; height: 100%; min-width: 2px; background: var(--primary); border-radius: inherit; }
.breakdown { display: grid; gap: 14px; }
.breakdown-row { display: grid; grid-template-columns: 130px minmax(0,1fr) auto; gap: 12px; align-items: center; font-size: 13px; }

.page-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
.toolbar-left, .toolbar-right { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.search { width: min(360px, 100%); }

.workspace-shell { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: linear-gradient(145deg, #f5f2ff, #fbfbfe); }
.workspace-card { width: min(100%, 760px); background: #fff; border: 1px solid var(--line); border-radius: 24px; padding: 28px; box-shadow: var(--shadow); }
.workspace-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 22px; }
.workspace-option { border: 1px solid var(--line); border-radius: 17px; padding: 20px; }
.workspace-option h3 { margin-top: 0; }

.modal-backdrop { position: fixed; inset: 0; background: rgba(20,15,38,.55); display: grid; place-items: center; padding: 18px; z-index: 100; backdrop-filter: blur(3px); }
.modal { width: min(100%, 680px); max-height: calc(100vh - 36px); overflow-y: auto; background: #fff; border-radius: 22px; box-shadow: 0 28px 90px rgba(15,10,35,.3); }
.modal-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; padding: 20px 22px; border-bottom: 1px solid var(--line); }
.modal-head h2 { margin: 0; font-size: 21px; }
.modal-head p { margin: 5px 0 0; color: var(--muted); font-size: 13px; }
.modal-body { padding: 22px; }

.settings-grid { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(300px, .8fr); gap: 18px; }
.invite-code { display: flex; align-items: center; justify-content: space-between; gap: 12px; background: var(--primary-soft); border: 1px dashed #b4a6ff; border-radius: 14px; padding: 14px; }
.invite-code code { font-size: 22px; font-weight: 900; letter-spacing: .12em; color: var(--primary-strong); }
.member-list { display: grid; gap: 9px; }
.member { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--line); }
.member:last-child { border-bottom: 0; }
.member-main { display: flex; gap: 10px; align-items: center; }
.member .avatar { background: var(--primary-soft); color: var(--primary-strong); }
.member strong, .member small { display: block; }
.member small { color: var(--muted); margin-top: 2px; }

.toast-root { position: fixed; right: 18px; bottom: 18px; z-index: 200; display: grid; gap: 10px; }
.toast { width: min(390px, calc(100vw - 36px)); background: #211f2d; color: #fff; padding: 13px 15px; border-radius: 13px; box-shadow: var(--shadow); animation: toast-in .2s ease; }
.toast.success { background: #116744; }
.toast.error { background: #9f2631; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

.mobile-nav { display: none; }

@media (max-width: 1120px) {
  .grid.cards-4 { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .event-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .grid.two, .settings-grid { grid-template-columns: 1fr; }
}

@media (max-width: 820px) {
  .auth-shell { grid-template-columns: 1fr; }
  .auth-hero { min-height: auto; padding: 32px 24px; }
  .auth-hero h1 { font-size: 42px; }
  .auth-panel { padding: 20px 16px 34px; }
  .app-shell { display: block; padding-bottom: 74px; }
  .sidebar { display: none; }
  .topbar { top: 0; min-height: 68px; padding: 12px 16px; }
  .topbar-actions .desktop-only { display: none; }
  .content { padding: 18px 14px 28px; }
  .mobile-nav { position: fixed; left: 0; right: 0; bottom: 0; height: 68px; display: grid; grid-template-columns: repeat(5, 1fr); background: rgba(255,255,255,.96); border-top: 1px solid var(--line); z-index: 40; backdrop-filter: blur(12px); }
  .mobile-nav button { border: 0; background: transparent; color: var(--muted); display: grid; place-items: center; align-content: center; gap: 3px; font-size: 10px; font-weight: 750; }
  .mobile-nav button span { font-size: 19px; }
  .mobile-nav button.active { color: var(--primary); }
}

@media (max-width: 620px) {
  .grid.cards-4, .grid.cards-3, .event-grid, .workspace-actions, .form-grid { grid-template-columns: 1fr; }
  .form-grid .full { grid-column: auto; }
  .metric-card { padding: 17px; }
  .section-head, .page-toolbar { align-items: stretch; flex-direction: column; }
  .toolbar-left, .toolbar-right { width: 100%; }
  .toolbar-right .btn, .page-toolbar > .btn { flex: 1; }
  .search { width: 100%; }
  .auth-card { padding: 23px; }
  .auth-hero h1 { font-size: 36px; }
  .breakdown-row { grid-template-columns: 90px minmax(0,1fr) auto; }
  .event-finance { grid-template-columns: 1fr; }
}
