@import url("https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600;700&family=Manrope:wght@500;600;700;800&display=swap");

:root {
  color-scheme: light;
  --ink: #1d2738;
  --muted: #778196;
  --line: #e8ebf1;
  --canvas: #f5f7fb;
  --paper: #fff;
  --accent: #6259d9;
  --accent-dark: #4d45c3;
  --teal: #24a789;
  --danger: #cf4355;
  font-family: "DM Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--canvas);
  font-synthesis: none;
  text-rendering: optimizeLegibility;
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; min-height: 100vh; background: var(--canvas); }
button, input { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.muted { color: var(--muted); }
.eyebrow { margin: 0 0 9px; color: var(--accent); font-size: 10px; font-weight: 700; letter-spacing: .14em; }

.login-page { min-height: 100vh; display: grid; place-items: center; padding: 28px 18px; background: radial-gradient(ellipse at 50% 5%, #e8e8ff 0, transparent 39%), var(--canvas); }
.login-card { width: min(100%, 410px); padding: 38px 40px 30px; border: 1px solid rgba(226,230,240,.9); border-radius: 20px; background: var(--paper); box-shadow: 0 24px 70px rgba(48,55,96,.1); }
.brand-mark { width: 48px; height: 48px; display: grid; place-items: center; margin: 0 auto 26px; border-radius: 15px; color: #fff; background: linear-gradient(140deg, #7971ed, #5149c8); font: 800 24px "Manrope", sans-serif; box-shadow: 0 8px 18px rgba(98,89,217,.25); }
.login-card .eyebrow, .login-card h1, .login-intro { text-align: center; }
.login-card h1 { margin: 0; font: 800 30px "Manrope", sans-serif; letter-spacing: -.04em; }
.login-intro { margin: 9px 0 28px; font-size: 14px; }
.login-card form { display: grid; gap: 10px; }
.login-card label, .field label { color: #4d586b; font-size: 12px; font-weight: 700; }
.login-card input, .field input, .month-filter input { min-width: 0; height: 46px; padding: 0 13px; border: 1px solid #e1e5ed; border-radius: 9px; outline: 0; color: var(--ink); background: #fff; transition: border-color .15s, box-shadow .15s; }
.login-card input:focus, .field input:focus, .month-filter input:focus, .search-box:focus-within { border-color: #968ff0; box-shadow: 0 0 0 3px rgba(98,89,217,.11); }
.login-card label:not(:first-child) { margin-top: 9px; }
.form-error { min-height: 18px; margin: 1px 0 0; color: var(--danger); font-size: 12px; line-height: 1.45; }
.login-footnote { display: flex; align-items: center; justify-content: center; gap: 8px; margin: 23px 0 0; color: #8a93a3; font-size: 11px; }
.lock-icon { color: var(--teal); font-size: 8px; }

.button { min-height: 40px; display: inline-flex; align-items: center; justify-content: center; gap: 9px; padding: 0 16px; border: 1px solid transparent; border-radius: 9px; font-size: 12px; font-weight: 700; transition: transform .12s, background .15s, border-color .15s; }
.button:active { transform: translateY(1px); }
.button:disabled { cursor: wait; opacity: .7; }
.button-primary { color: #fff; background: var(--accent); box-shadow: 0 5px 12px rgba(98,89,217,.17); }
.button-primary:hover { background: var(--accent-dark); }
.button-wide { width: 100%; min-height: 48px; margin-top: 2px; font-size: 13px; }
.button-wide span { font-size: 17px; }
.button-quiet { color: #566176; border-color: #e4e7ee; background: #fff; }
.button-quiet:hover { background: #f8f9fc; border-color: #cfd4e0; }
.button-danger { color: #fff; background: var(--danger); }
.button-danger:hover { background: #b83245; }

.dashboard { min-height: 100vh; }
.sidebar { position: fixed; inset: 0 auto 0 0; z-index: 3; width: 228px; display: flex; flex-direction: column; padding: 24px 16px 18px; border-right: 1px solid var(--line); background: #fff; }
.brand { display: flex; align-items: center; gap: 10px; margin: 0 6px 53px; color: var(--ink); text-decoration: none; font: 800 15px "Manrope", sans-serif; letter-spacing: -.04em; }
.brand-light { color: #748096; font-weight: 600; }
.brand-mark-small { width: 34px; height: 34px; flex: none; margin: 0; border-radius: 11px; font-size: 18px; }
.side-section-label { margin: 0 10px 12px; color: #a0a8b7; font-size: 9px; font-weight: 700; letter-spacing: .13em; }
.side-link { width: 100%; min-height: 42px; display: flex; align-items: center; gap: 12px; padding: 0 12px; border: 0; border-radius: 8px; color: #737e91; background: transparent; text-align: left; font-size: 12px; font-weight: 600; }
.side-link.active { color: var(--accent); background: #f0efff; }
.side-icon { width: 17px; text-align: center; font-size: 17px; }
.sidebar-bottom { margin-top: auto; }
.secure-note { display: flex; align-items: center; gap: 10px; padding: 13px 10px 18px; border-bottom: 1px solid var(--line); color: var(--teal); }
.secure-note div { display: grid; gap: 3px; }
.secure-note strong { color: #566176; font-size: 10px; }
.secure-note small { color: #99a2b1; font-size: 9px; }
.logout-link { margin-top: 10px; }

.main-area { min-height: 100vh; margin-left: 228px; }
.topbar { height: 68px; display: flex; align-items: center; gap: 12px; padding: 0 42px; border-bottom: 1px solid var(--line); background: rgba(255,255,255,.85); }
.topbar-spacer { flex: 1; }
.user-chip { display: flex; align-items: center; gap: 9px; color: #475368; font-size: 11px; font-weight: 600; }
.avatar { width: 30px; height: 30px; display: grid; place-items: center; border-radius: 50%; color: #5048be; background: #efeeff; font-size: 11px; font-weight: 700; }
.mobile-brand, .mobile-logout { display: none; }
.content { width: min(100%, 1160px); margin: 0 auto; padding: 40px 42px 24px; }
.page-heading { display: flex; align-items: center; justify-content: space-between; gap: 18px; margin-bottom: 27px; }
.page-heading h1 { margin: 0; font: 800 26px "Manrope", sans-serif; letter-spacing: -.045em; }
.page-heading .muted { margin: 7px 0 0; font-size: 12px; }
.plus { font-size: 18px; font-weight: 400; line-height: 0; }
.notice { margin: -9px 0 18px; padding: 11px 14px; border: 1px solid #f0d7b6; border-radius: 8px; color: #865a1d; background: #fff9ee; font-size: 12px; }

.summary-grid { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 15px; margin-bottom: 23px; }
.summary-card { min-height: 126px; padding: 17px 19px; border: 1px solid var(--line); border-radius: 12px; background: var(--paper); box-shadow: 0 3px 12px rgba(35,45,75,.025); }
.summary-top { display: flex; align-items: center; justify-content: space-between; }
.summary-label { color: #9099a9; font-size: 9px; font-weight: 700; letter-spacing: .09em; }
.summary-icon { width: 29px; height: 29px; display: grid; place-items: center; border-radius: 9px; font-size: 14px; }
.summary-icon.violet { color: #655bd2; background: #f0efff; }
.summary-icon.mint { color: #168a70; background: #e7f7f2; }
.summary-icon.amber { color: #be8429; background: #fff4df; }
.summary-value { margin-top: 10px; font: 800 24px "Manrope", sans-serif; letter-spacing: -.04em; }
.summary-caption { margin-top: 3px; color: #98a1af; font-size: 10px; }

.expenses-panel { overflow: hidden; border: 1px solid var(--line); border-radius: 12px; background: var(--paper); box-shadow: 0 3px 12px rgba(35,45,75,.025); }
.panel-heading { display: flex; align-items: center; justify-content: space-between; padding: 19px 21px 14px; }
.panel-heading h2 { margin: 0; font: 700 16px "Manrope", sans-serif; letter-spacing: -.025em; }
.panel-heading .muted { margin: 5px 0 0; font-size: 10px; }
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 0 21px 14px; }
.search-box { width: min(360px, 100%); height: 37px; display: flex; align-items: center; gap: 8px; padding: 0 10px; border: 1px solid #e6e9f0; border-radius: 8px; color: #8d96a6; transition: border-color .15s, box-shadow .15s; }
.search-box span { font-size: 18px; }
.search-box input { width: 100%; min-width: 0; padding: 0; border: 0; outline: 0; color: var(--ink); background: transparent; font-size: 10px; }
.search-box input::placeholder { color: #a5adba; }
.month-filter input { height: 37px; padding: 0 10px; color: #647086; font-size: 10px; }
.table-wrap { min-height: 228px; border-top: 1px solid #eff1f5; }
table { width: 100%; border-collapse: collapse; text-align: left; }
thead { background: #fafbfc; }
th { padding: 11px 15px; color: #a0a8b5; font-size: 8px; font-weight: 700; letter-spacing: .08em; }
th:first-child, td:first-child { padding-left: 21px; }
th:last-child, td:last-child { padding-right: 21px; }
td { padding: 13px 15px; border-top: 1px solid #f0f2f6; color: #647086; font-size: 10px; }
td.expense-name { color: var(--ink); font-size: 11px; font-weight: 700; }
.expense-description { display: block; max-width: 300px; margin-top: 4px; overflow: hidden; color: #99a2b0; font-size: 9px; font-weight: 400; text-overflow: ellipsis; white-space: nowrap; }
.category-dot { width: 7px; height: 7px; display: inline-block; margin-right: 9px; border-radius: 50%; background: #897ff0; vertical-align: 1px; }
.amount-column, td.amount { text-align: right; }
td.amount { color: #303a4d; font-size: 11px; font-weight: 700; white-space: nowrap; }
.payment-pill { display: inline-flex; padding: 5px 8px; border-radius: 6px; color: #6d7789; background: #f3f5f8; font-size: 9px; }
.row-actions { display: flex; justify-content: flex-end; gap: 4px; }
.row-action { width: 28px; height: 28px; display: grid; place-items: center; border: 0; border-radius: 6px; color: #8c96a6; background: transparent; font-size: 13px; }
.row-action:hover { color: var(--accent); background: #f1f0ff; }
.row-action.delete:hover { color: var(--danger); background: #fff0f1; }
.empty-state, .loading-state { min-height: 220px; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 24px; text-align: center; }
.empty-illustration { width: 43px; height: 43px; display: grid; place-items: center; margin-bottom: 12px; border-radius: 13px; color: #7770df; background: #f1f0ff; font-size: 21px; }
.empty-state h3 { margin: 0; font: 700 14px "Manrope", sans-serif; }
.empty-state p { margin: 6px 0 14px; font-size: 10px; }
.empty-state .button { min-height: 35px; }
.loading-state { flex-direction: row; gap: 10px; color: #7d8798; font-size: 11px; }
.spinner { width: 16px; height: 16px; border: 2px solid #e6e4ff; border-top-color: var(--accent); border-radius: 50%; animation: spin .75s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.app-footer { padding: 17px 3px; color: #a2aab8; text-align: center; font-size: 9px; }

.expense-dialog, .confirm-dialog { width: min(calc(100% - 28px), 480px); max-height: min(90vh, 760px); padding: 0; border: 1px solid #e6e8f0; border-radius: 16px; color: var(--ink); background: #fff; box-shadow: 0 25px 80px rgba(29,39,56,.22); }
.expense-dialog::backdrop, .confirm-dialog::backdrop { background: rgba(29,39,56,.35); backdrop-filter: blur(2px); }
.expense-dialog form { padding: 23px 24px 20px; }
.dialog-heading { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 20px; }
.dialog-heading .eyebrow { margin-bottom: 5px; }
.dialog-heading h2, .confirm-dialog h2 { margin: 0; font: 800 20px "Manrope", sans-serif; letter-spacing: -.035em; }
.icon-button { width: 34px; height: 34px; display: grid; place-items: center; border: 1px solid #eaecf2; border-radius: 9px; color: #7c8698; background: #fff; font-size: 19px; }
.icon-button:hover { background: #f7f8fb; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 12px; }
.field { min-width: 0; display: grid; gap: 7px; }
.field input { width: 100%; height: 42px; font-size: 12px; }
.field input::placeholder { color: #b2b9c5; }
.field .optional { color: #a0a8b5; font-weight: 400; }
.full-field { grid-column: 1 / -1; }
.amount-input { position: relative; }
.amount-input input { padding-left: 13px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 13px; }
.confirm-dialog { width: min(calc(100% - 28px), 370px); padding: 25px; text-align: center; }
.confirm-icon { width: 42px; height: 42px; display: grid; place-items: center; margin: 0 auto 13px; border-radius: 50%; color: #bd6c24; background: #fff2dd; font-weight: 800; }
.confirm-dialog h2 { font-size: 17px; }
.confirm-dialog .muted { margin: 8px 0 0; font-size: 11px; }
.confirm-dialog .dialog-actions { margin-top: 17px; }
.toast { position: fixed; right: 22px; bottom: 20px; z-index: 10; max-width: min(400px, calc(100vw - 36px)); padding: 12px 16px; border-radius: 9px; color: #fff; background: #253148; box-shadow: 0 8px 24px rgba(29,39,56,.2); font-size: 11px; }

@media (max-width: 900px) {
  .sidebar { width: 190px; }
  .main-area { margin-left: 190px; }
  .topbar { padding: 0 25px; }
  .content { padding: 32px 25px 20px; }
  .summary-card { padding: 15px; }
  .summary-label { font-size: 8px; }
  th, td { padding-right: 10px; padding-left: 10px; }
}
@media (max-width: 680px) {
  .sidebar { display: none; }
  .main-area { margin-left: 0; }
  .topbar { height: 58px; padding: 0 16px; }
  .mobile-brand { display: flex; align-items: center; gap: 8px; color: var(--ink); font: 800 13px "Manrope", sans-serif; }
  .mobile-brand .brand-mark-small { width: 30px; height: 30px; font-size: 16px; }
  .topbar-spacer { flex: 1; }
  .user-chip { font-size: 10px; }
  .user-chip .avatar { width: 27px; height: 27px; }
  .mobile-logout { display: grid; width: 30px; height: 30px; font-size: 15px; }
  .content { padding: 28px 15px 16px; }
  .page-heading { align-items: flex-start; margin-bottom: 20px; }
  .page-heading h1 { font-size: 22px; }
  .page-heading .muted { max-width: 220px; font-size: 11px; line-height: 1.5; }
  .page-heading > .button { flex: none; min-height: 37px; padding: 0 10px; font-size: 10px; }
  .summary-grid { grid-template-columns: 1fr 1fr; gap: 9px; margin-bottom: 16px; }
  .summary-card { min-height: 106px; padding: 12px; }
  .summary-card:first-child { grid-column: 1 / -1; }
  .summary-card:first-child .summary-value { font-size: 27px; }
  .summary-value { font-size: 20px; }
  .summary-label { font-size: 8px; }
  .summary-icon { width: 25px; height: 25px; }
  .panel-heading { padding: 16px 14px 12px; }
  .toolbar { flex-wrap: wrap; padding: 0 14px 12px; }
  .search-box { width: 100%; }
  .month-filter { margin-left: auto; }
  table, tbody, tr, td { display: block; }
  thead { display: none; }
  tr { position: relative; padding: 10px 14px 12px; border-top: 1px solid #f0f2f6; }
  td { display: inline-block; padding: 3px 7px 3px 0; border: 0; font-size: 9px; vertical-align: middle; }
  td:first-child { width: calc(100% - 88px); padding-left: 0; }
  td.amount { position: absolute; top: 13px; right: 14px; padding: 3px 0; font-size: 11px; }
  td:last-child { position: absolute; right: 7px; bottom: 5px; padding-right: 0; }
  td:nth-child(2) { padding-left: 16px; }
  td:nth-child(2)::before { position: absolute; left: 14px; content: "·"; color: #aab1bd; }
  td:nth-child(3) { padding-left: 7px; }
  .payment-pill { padding: 3px 6px; font-size: 8px; }
  .expense-description { max-width: calc(100vw - 115px); }
  .expense-dialog form { padding: 19px 17px 16px; }
}
@media (max-width: 380px) {
  .login-card { padding: 30px 24px 25px; }
  .page-heading { flex-direction: column; }
  .page-heading > .button { align-self: flex-end; }
  .user-chip > span:last-child { display: none; }
  .summary-label { letter-spacing: .04em; }
}
