/* =========================================================
   CHIFRANDO MONEY BOOK
   Mobile-app inspired UI
   ========================================================= */

*,
*::before,
*::after {
  box-sizing: border-box;
}

:root {
  --primary: #204da7;
  --primary-dark: #0b2448;
  --primary-light: #edf3ff;
  --text: #182230;
  --muted: #78869a;
  --background: #f4f6fa;
  --surface: #ffffff;
  --border: #e6eaf0;
  --danger: #e6334c;
  --danger-soft: #fff0f2;
  --success: #16a36a;
  --success-soft: #eaf9f2;
  --warning: #e6a51d;
  --shadow: 0 8px 24px rgba(21, 48, 88, 0.07);
  --radius: 16px;
  --app-width: 1180px;
}

html {
  min-height: 100%;
  background: #eef1f6;
}

body {
  min-height: 100%;
  margin: 0;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(32, 77, 167, 0.08), transparent 30%),
    var(--background);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
    "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid rgba(32, 77, 167, 0.16);
  outline-offset: 2px;
}

/* =========================================================
   APP SHELL
   ========================================================= */

.app-shell {
  width: min(100%, var(--app-width));
  min-height: 100vh;
  margin: 0 auto;
  display: flex;
  background: var(--surface);
}

.sidebar {
  position: fixed;
  inset: 0 auto 0 max(0px, calc((100vw - var(--app-width)) / 2));
  width: 250px;
  padding: 22px 14px;
  color: #fff;
  background: linear-gradient(180deg, #092247 0%, #0b2d5b 100%);
  z-index: 30;
  display: flex;
  flex-direction: column;
}

.main {
  width: calc(100% - 250px);
  min-height: 100vh;
  margin-left: 250px;
  background: var(--background);
}

/* =========================================================
   SIDEBAR
   ========================================================= */

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 3px 9px 22px;
}

.brand-mark {
  width: 38px;
  height: 38px;
  flex: 0 0 38px;
  display: grid;
  place-items: center;
  border-radius: 11px;
  color: var(--primary);
  background: #fff;
  font-size: 17px;
  font-weight: 900;
}

.brand strong {
  display: block;
  font-size: 14px;
  letter-spacing: 0.35px;
}

.brand span {
  display: block;
  margin-top: 2px;
  color: #b8c7db;
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 1.6px;
}

.owner-card {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-bottom: 17px;
  padding: 10px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 13px;
  background: rgba(255, 255, 255, 0.055);
}

.owner-copy {
  min-width: 0;
  flex: 1;
}

.owner-copy strong {
  display: block;
  overflow: hidden;
  color: #fff;
  font-size: 11px;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.owner-copy span {
  display: block;
  margin-top: 2px;
  color: #aebed2;
  font-size: 9px;
}

.side-nav {
  display: grid;
  gap: 4px;
}

.nav-item {
  width: 100%;
  border: 0;
  border-radius: 10px;
  padding: 10px 11px;
  display: flex;
  align-items: center;
  gap: 11px;
  color: #c7d4e5;
  background: transparent;
  font-size: 11px;
  font-weight: 600;
  text-align: left;
  transition:
    background 0.16s ease,
    color 0.16s ease,
    transform 0.16s ease;
}

.nav-item span {
  width: 17px;
  color: inherit;
  font-size: 14px;
  text-align: center;
}

.nav-item:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.07);
}

.nav-item.active {
  color: #fff;
  background: #1f5fc8;
  box-shadow: 0 5px 15px rgba(12, 50, 105, 0.25);
}

.sidebar-note {
  margin-top: auto;
  padding: 11px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  color: #bdcbe0;
  background: rgba(255, 255, 255, 0.035);
  font-size: 9px;
  line-height: 1.5;
}

.sidebar-note strong {
  color: #fff;
  font-size: 10px;
}

.sidebar-note p {
  margin: 5px 0 0;
}

/* =========================================================
   TOP BAR
   ========================================================= */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  height: 68px;
  padding: 0 25px;
  display: flex;
  align-items: center;
  gap: 13px;
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(12px);
}

.topbar h1 {
  margin: 2px 0 0;
  font-size: 18px;
  line-height: 1.1;
  letter-spacing: -0.25px;
}

.page-kicker {
  color: var(--primary);
  font-size: 8px;
  font-weight: 800;
  letter-spacing: 1.4px;
}

.top-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 7px;
}

.icon-btn,
.menu-btn {
  width: 34px;
  height: 34px;
  border: 1px solid var(--border);
  border-radius: 10px;
  display: grid;
  place-items: center;
  color: #59687c;
  background: #fff;
  font-size: 15px;
}

.menu-btn {
  display: none;
}

.top-avatar {
  border: 0;
  background: #e8efff;
}

/* =========================================================
   CONTENT
   ========================================================= */

.content {
  width: 100%;
  max-width: 950px;
  margin: 0 auto;
  padding: 25px 27px 45px;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.welcome-row,
.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 19px;
}

.welcome-row h2,
.page-head h2 {
  margin: 0 0 5px;
  font-size: 20px;
  letter-spacing: -0.35px;
}

.welcome-row p,
.page-head p {
  margin: 0;
  color: var(--muted);
  font-size: 11px;
}

.quick-actions {
  display: flex;
  gap: 7px;
}

/* =========================================================
   BUTTONS
   ========================================================= */

.btn {
  min-height: 36px;
  border: 0;
  border-radius: 9px;
  padding: 9px 13px;
  font-size: 11px;
  font-weight: 750;
  transition:
    transform 0.15s ease,
    box-shadow 0.15s ease,
    opacity 0.15s ease;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn-primary {
  color: #fff;
  background: var(--primary);
  box-shadow: 0 6px 14px rgba(32, 77, 167, 0.18);
}

.btn-danger {
  color: #fff;
  background: var(--danger);
  box-shadow: 0 6px 14px rgba(230, 51, 76, 0.15);
}

.btn-success {
  color: #fff;
  background: var(--success);
  box-shadow: 0 6px 14px rgba(22, 163, 106, 0.15);
}

.btn-secondary {
  color: #405069;
  background: #edf1f6;
}

.btn-danger-outline {
  color: var(--danger);
  border: 1px solid #efb0ba;
  background: #fff;
}

.btn.full {
  width: 100%;
  margin-top: 14px;
}

.text-btn {
  border: 0;
  padding: 4px;
  color: var(--primary);
  background: transparent;
  font-size: 10px;
  font-weight: 750;
}

/* =========================================================
   DASHBOARD SUMMARY CARDS
   ========================================================= */

.summary-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 11px;
  margin-bottom: 24px;
}

.summary-card {
  position: relative;
  min-height: 117px;
  padding: 16px;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: #fff;
  box-shadow: var(--shadow);
}

.summary-card::after {
  position: absolute;
  right: -25px;
  bottom: -30px;
  width: 90px;
  height: 90px;
  border-radius: 50%;
  background: currentColor;
  content: "";
  opacity: 0.025;
}

.summary-label {
  color: #6f7c8f;
  font-size: 10px;
  font-weight: 700;
}

.summary-value {
  margin: 10px 0 11px;
  font-size: 22px;
  font-weight: 850;
  letter-spacing: -0.5px;
}

.summary-foot {
  color: #8995a5;
  font-size: 9px;
}

.summary-foot span {
  margin-left: 4px;
  font-weight: 900;
}

.expense-card .summary-value,
.expense-card .summary-foot span {
  color: var(--danger);
}

.income-card .summary-value,
.income-card .summary-foot span {
  color: var(--success);
}

.balance-card .summary-value {
  color: var(--primary);
}

/* =========================================================
   CARDS / TABLES
   ========================================================= */

.card {
  border: 1px solid var(--border);
  border-radius: 14px;
  background: #fff;
  box-shadow: var(--shadow);
}

.table-card {
  overflow: hidden;
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 0 0 10px;
}

.section-heading.compact {
  margin-bottom: 14px;
}

.section-heading h3 {
  margin: 0;
  font-size: 13px;
}

.section-heading p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 9px;
}

.table-wrap {
  overflow-x: auto;
}

.transaction-table {
  width: 100%;
  min-width: 680px;
  border-collapse: collapse;
}

.transaction-table th {
  padding: 10px 13px;
  border-bottom: 1px solid var(--border);
  color: #8995a5;
  background: #fafbfd;
  font-size: 8px;
  font-weight: 800;
  letter-spacing: 0.55px;
  text-align: left;
  text-transform: uppercase;
}

.transaction-table td {
  padding: 12px 13px;
  border-bottom: 1px solid #eef1f5;
  font-size: 10px;
}

.transaction-table tr:last-child td {
  border-bottom: 0;
}

.transaction-title {
  font-weight: 750;
}

.transaction-sub {
  margin-top: 2px;
  color: var(--muted);
  font-size: 8px;
}

.amount {
  font-weight: 850;
  text-align: right;
  white-space: nowrap;
}

.amount.income {
  color: var(--success);
}

.amount.expense {
  color: var(--danger);
}

.type-pill,
.category-pill {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 4px 7px;
  font-size: 8px;
  font-weight: 800;
  white-space: nowrap;
}

.type-pill.income {
  color: #11855a;
  background: var(--success-soft);
}

.type-pill.expense {
  color: #c8283e;
  background: var(--danger-soft);
}

.category-pill {
  color: var(--primary);
  background: var(--primary-light);
}

.action-btn {
  border: 0;
  border-radius: 7px;
  padding: 5px 7px;
  color: #536277;
  background: #f1f4f8;
  font-size: 8px;
}

.empty {
  padding: 45px 20px;
  color: var(--muted);
  font-size: 10px;
  text-align: center;
}

.empty strong {
  display: block;
  margin-bottom: 4px;
  color: #34445a;
  font-size: 11px;
}

/* =========================================================
   FILTERS / FORMS
   ========================================================= */

.filters {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr;
  gap: 8px;
  margin-bottom: 13px;
  padding: 10px;
}

.input {
  width: 100%;
  border: 1px solid #dfe4ec;
  border-radius: 9px;
  padding: 9px 10px;
  color: var(--text);
  background: #fff;
  outline: 0;
  font-size: 10px;
  transition:
    border-color 0.15s ease,
    box-shadow 0.15s ease;
}

.input:focus {
  border-color: #7aa0e8;
  box-shadow: 0 0 0 3px rgba(32, 77, 167, 0.07);
}

label {
  display: block;
  margin: 0 0 5px;
  color: #45546a;
  font-size: 9px;
  font-weight: 750;
}

label span {
  color: var(--danger);
}

label .optional {
  color: #9ca6b4;
  font-weight: 500;
}

.textarea {
  min-height: 82px;
  resize: vertical;
}

/* =========================================================
   INCOME / EXPENSE PAGE STAT
   ========================================================= */

.mini-stat {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 13px;
  padding: 15px 17px;
  border-radius: 13px;
}

.mini-stat span {
  font-size: 10px;
  font-weight: 750;
}

.mini-stat strong {
  font-size: 19px;
}

.income-stat {
  color: #107c55;
  background: var(--success-soft);
}

.expense-stat {
  color: #c92d43;
  background: var(--danger-soft);
}

/* =========================================================
   REPORTS
   ========================================================= */

.report-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 11px;
  margin-bottom: 14px;
}

.report-card {
  padding: 17px;
}

.report-card span {
  display: block;
  color: var(--muted);
  font-size: 9px;
}

.report-card strong {
  display: block;
  margin-top: 7px;
  font-size: 20px;
}

.category-report {
  padding: 17px;
}

.category-row {
  display: grid;
  grid-template-columns: 140px 1fr 85px;
  align-items: center;
  gap: 10px;
  margin: 11px 0;
}

.category-name {
  overflow: hidden;
  font-size: 9px;
  font-weight: 750;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bar {
  height: 7px;
  overflow: hidden;
  border-radius: 999px;
  background: #edf0f5;
}

.bar i {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: var(--primary);
}

.category-value {
  color: #405069;
  font-size: 9px;
  font-weight: 800;
  text-align: right;
}

/* =========================================================
   SETTINGS
   ========================================================= */

.settings-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 13px;
}

.settings-card {
  padding: 18px;
}

.settings-card h3 {
  margin: 0 0 14px;
  font-size: 13px;
}

.settings-card p {
  color: var(--muted);
  font-size: 10px;
  line-height: 1.6;
}

.settings-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 13px;
}

.file-label {
  display: inline-flex;
  align-items: center;
  cursor: pointer;
}

/* =========================================================
   MOBILE APP BOTTOM NAV
   ========================================================= */

.mobile-nav {
  display: none;
}

/* =========================================================
   MODAL
   ========================================================= */

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 18px;
  background: rgba(7, 22, 43, 0.48);
  backdrop-filter: blur(4px);
}

.modal-backdrop.open {
  display: flex;
}

.modal {
  width: min(530px, 100%);
  max-height: 92vh;
  overflow: auto;
  padding: 20px;
  border: 1px solid rgba(255, 255, 255, 0.6);
  border-radius: 18px;
  background: #fff;
  box-shadow: 0 25px 80px rgba(0, 0, 0, 0.2);
}

.modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 16px;
}

.modal-head h2 {
  margin: 3px 0 0;
  font-size: 18px;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.modal form > label {
  margin-top: 11px;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 200;
  padding: 10px 13px;
  border-radius: 10px;
  color: #fff;
  background: #14243b;
  font-size: 10px;
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
  transition: 0.2s ease;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

/* =========================================================
   TABLET
   ========================================================= */

@media (max-width: 900px) {
  :root {
    --app-width: 100%;
  }

  .sidebar {
    left: 0;
    transform: translateX(-100%);
    transition: transform 0.22s ease;
    box-shadow: 12px 0 30px rgba(4, 24, 52, 0.18);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .main {
    width: 100%;
    margin-left: 0;
  }

  .menu-btn {
    display: grid;
  }

  .content {
    max-width: 100%;
  }
}

/* =========================================================
   PHONE
   ========================================================= */

@media (max-width: 600px) {
  html,
  body {
    background: #f5f6f9;
  }

  .app-shell {
    display: block;
    min-height: 100dvh;
  }

  .main {
    min-height: 100dvh;
    padding-bottom: 74px;
  }

  .topbar {
    height: 61px;
    padding: 0 14px;
    border-bottom-color: #e8ebf0;
  }

  .topbar h1 {
    font-size: 16px;
  }

  .page-kicker {
    font-size: 7px;
  }

  .top-actions .icon-btn:not(.top-avatar) {
    display: none;
  }

  .content {
    padding: 18px 13px 30px;
  }

  .welcome-row,
  .page-head {
    align-items: flex-start;
    flex-direction: column;
    margin-bottom: 16px;
  }

  .welcome-row h2,
  .page-head h2 {
    font-size: 18px;
  }

  .quick-actions {
    width: 100%;
  }

  .quick-actions .btn {
    flex: 1;
  }

  .summary-grid {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-bottom: 22px;
  }

  .summary-card {
    min-height: 105px;
    padding: 13px;
    border-radius: 13px;
  }

  .summary-card.balance-card {
    grid-column: 1 / -1;
    min-height: 96px;
  }

  .summary-value {
    margin: 8px 0 9px;
    font-size: 19px;
  }

  .summary-foot {
    font-size: 8px;
  }

  .section-heading {
    margin-bottom: 8px;
  }

  .section-heading h3 {
    font-size: 12px;
  }

  .section-heading p {
    font-size: 8px;
  }

  .table-card {
    border-radius: 13px;
  }

  .transaction-table {
    min-width: 620px;
  }

  .filters {
    grid-template-columns: 1fr;
    border-radius: 13px;
  }

  .report-grid {
    grid-template-columns: 1fr;
  }

  .settings-grid {
    grid-template-columns: 1fr;
  }

  .category-row {
    grid-template-columns: 100px 1fr 70px;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }

  .modal-backdrop {
    align-items: flex-end;
    padding: 0;
  }

  .modal {
    width: 100%;
    max-height: 90dvh;
    border-radius: 20px 20px 0 0;
    padding: 18px 16px 24px;
  }

  .modal-head h2 {
    font-size: 17px;
  }

  .mobile-nav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 40;
    height: 66px;
    padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    border-top: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.97);
    box-shadow: 0 -7px 25px rgba(25, 45, 80, 0.08);
    backdrop-filter: blur(15px);
  }

  .mobile-nav button {
    border: 0;
    border-radius: 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    color: #8a95a4;
    background: transparent;
    font-size: 8px;
    font-weight: 700;
  }

  .mobile-nav button span {
    font-size: 16px;
    line-height: 1;
  }

  .mobile-nav button.active {
    color: var(--primary);
    background: var(--primary-light);
  }

  .mini-stat {
    padding: 13px 14px;
  }

  .mini-stat strong {
    font-size: 17px;
  }
}

/* =========================================================
   VERY SMALL PHONES
   ========================================================= */

@media (max-width: 380px) {
  .summary-value {
    font-size: 17px;
  }

  .quick-actions .btn {
    padding-inline: 9px;
    font-size: 10px;
  }

  .content {
    padding-inline: 10px;
  }
}
