/* ==========================================================================
   Project: Budget App
   File: style_grouped.css (annotated)
   Note: Same rule order as source to preserve cascade & specificity.
         Only comments were added. No declarations removed or reordered.
   ========================================================================== */


/* ========================= Root variables ========================= */
:root {
  --accent: #35a26e;
  --bg: #0f172a;
  --card: #111827;
  --content-max: 1200px;
  --danger: #ef4444;
  --muted: #94a3b8;
  --sidebar-w: 220px;
  --text: #f8fafc;
  --topbar-h: 56px;
  --warn: #f59e0b;
}

/* ========================= Base / Reset ========================= */
* {
  box-sizing: border-box;
}

html, body {
  background: var(--bg);
  color: var(--text);
  font-family: ui-sans-serif,system-ui,Segoe UI,Roboto,Helvetica,Arial;
  margin: 0;
  padding: 0;
}

.topbar {
  backdrop-filter: blur(6px);
  background: rgba(15,23,42,0.85);
  border-bottom: 1px solid #1f2937;
  height: var(--topbar-h);
  position: sticky;
  top: 0;
  z-index: 1000;
}

.topbar-inner {
  align-items: center;
  display: flex;
  height: 100%;
  justify-content: space-between;
  margin: 0 auto;
  max-width: 1100px;
  padding: 0 16px;
}

/* ========================= Typography & Badges ========================= */
.topbar h1 {
  align-items: center;
  display: flex;
  font-size: 18px;
  gap: 8px;
  margin: 0;
}

/* ========================= Utilities / Misc ========================= */
.topbar .user {
  align-items: center;
  color: var(--muted);
  display: flex;
  font-size: 14px;
  gap: 8px;
}

.menu-toggle {
  background: #0b1220;
  border: 1px solid #334155;
  border-radius: 8px;
  color: #cbd5e1;
  cursor: pointer;
  display: none;
  height: 36px;
  width: 36px;
}

.menu-toggle:active {
  transform: scale(0.98);
}

/* ========================= Layout & Cards ========================= */
.container {
  margin: 0 auto;
  max-width: 1100px;
  padding: 16px;
}

.grid {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(12, 1fr);
}

.card {
  background: var(--card);
  border: 1px solid #1f2937;
  border-radius: 14px;
  box-shadow: 0 8px 30px rgba(0,0,0,0.2);
  padding: 16px;
}

.card h3 {
  margin-top: 0;
}

.stat {
  font-size: 26px;
  font-weight: 700;
}

.badge {
  border-radius: 999px;
  font-size: 12px;
  padding: 2px 8px;
}

.badge.income {
  background: rgba(34,197,94,0.15);
  color: #bbf7d0;
}

.badge.expense {
  background: rgba(239,68,68,0.15);
  color: #fecaca;
}

/* ========================= Tables ========================= */
.table {
  border-collapse: collapse;
  width: 100%;
}

.table th, .table td {
  border-bottom: 1px solid #1f2937;
  padding: 10px;
  text-align: left;
}

.table th {
  color: var(--muted);
  font-weight: 600;
}

/* ========================= Buttons ========================= */
.btn {
  background: #1f2937;
  border: 1px solid #334155;
  border-radius: 10px;
  color: var(--text);
  cursor: pointer;
  display: inline-block;
  padding: 10px 14px;
  text-decoration: none;
}

.btn:hover {
  background: #171d26;	
}

.btn.primary {
  background: var(--accent);
  border-color: #35a26e;
}

.btn.primary:hover {
  background: #1f7a40;
}

.btn.warn {
  background: #b45309;
  border-color: #b45309;
}

.btn.danger {
  background: #b91c1c;
  border-color: #b91c1c;
  color: #fff;
}

.btn.danger a {
  align-items: center;
  background: #b91c1c;
  color: #fff;
  display: inline-flex;
  font-size: 14px;
  text-decoration: none;
  transition: background .2s, color .2s, border-color .2s;
}

.btn.danger a:hover {
  align-items: center;
  background: #941313;
  color: #fff;
  display: inline-flex;
  font-size: 14px;
  text-decoration: none;
  transition: background .2s, color .2s, border-color .2s;
}

.btn.danger:hover {
  background: #941313;
  border-color: #b91c1c;
}

.btn.small {
  font-size: 13px;
  padding: 6px 10px;
}

/* ========================= Forms & Inputs ========================= */
.input, select, textarea {
  background: #0b1220;
  border: 1px solid #1f2937;
  border-radius: 10px;
  color: var(--text);
  padding: 10px 12px;
  width: 100%;
}

.row {
  display: flex;
  gap: 10px;
}

.row > * {
  flex: 1;
}

.progress {
  background: #0b1220;
  border: 1px solid #1f2937;
  border-radius: 999px;
  height: 10px;
  overflow: hidden;
}

.progress > div {
  background: var(--warn);
  height: 100%;
}

.progress.over > div {
  background: var(--danger);
}

.alert {
  background: #052e1b;
  border: 1px solid #14532d;
  border-radius: 10px;
  color: #bbf7d0;
  padding: 10px 12px;
}

.alert.warn {
  background: #3a1f04;
  border-color: #713f12;
  color: #fde68a;
}

.alert.danger {
  background: #3a0d0d;
  border-color: #7f1d1d;
  color: #fecaca;
}

.footer {
  border-top: 1px solid #1f2937;
  color: var(--muted);
}

form .actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

small.help {
  color: var(--muted);
}

a.link {
  color: #60a5fa;
}

.expand-btn {
  background: transparent;
  border: none;
  color: #ccc;
  cursor: pointer;
  font-size: 18px;
  position: absolute;
  right: 8px;
  top: 8px;
}

.expand-btn:hover {
  color: #fff;
}

/* ========================= Charts ========================= */
.card.chart-fullscreen {
  align-items: center !important;
  background: rgba(10, 14, 25, 0.98) !important;
  border-radius: 0 !important;
  display: flex !important;
  flex-direction: column !important;
  gap: 10px;
  inset: 0 !important;
  justify-content: center !important;
  margin: 0 !important;
  padding: 20px !important;
  position: fixed !important;
  z-index: 10000 !important;
}

.card.chart-fullscreen h3 {
  margin: 0 0 8px 0 !important;
  text-align: center;
}

.card.chart-fullscreen .expand-btn {
  font-size: 22px;
  position: fixed !important;
  right: 12px;
  top: 10px;
  z-index: 10001;
}

.card.chart-fullscreen canvas {
  height: min(85vh, 900px) !important;
  max-height: 85vh !important;
  max-width: 95vw !important;
  width: min(95vw, 1400px) !important;
}

.card.chart-fullscreen.chart-pie canvas,
.chart-pie.card.chart-fullscreen canvas {
  height: min(92vmin, 1100px) !important;
  width: min(92vmin, 1100px) !important;
}

html.no-scroll, body.no-scroll {
  overflow: hidden !important;
}

.sidebar {
  background: #0b1220;
  border-right: 1px solid #1f2937;
  bottom: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  left: 0;
  overflow-x: hidden;
  overflow-y: auto;
  padding: 12px;
  position: fixed;
  top: var(--topbar-h);
  width: var(--sidebar-w);
  z-index: 999;
}

.sidebar a {
  align-items: center;
  border: 1px solid transparent;
  border-radius: 10px;
  color: var(--muted);
  display: flex;
  gap: 10px;
  line-height: 1.25;
  padding: 10px 12px;
  text-decoration: none;
  transition: background .2s, color .2s, border-color .2s;
  white-space: normal;
  word-break: break-word;
}

.sidebar a i {
  text-align: center;
  width: 22px;
}

.sidebar a:hover{
  background: var(--accent);
  border-color: #35a26e;
  color: #fff;
}

.sidebar a.active {
  background: var(--accent);
  border-color: #35a26e;
  color: #fff;
}

.menu-overlay {
  background: rgba(0,0,0,.45);
  display: none;
  inset: 0;
  position: fixed;
  z-index: 998;
}

body.menu-open .menu-overlay {
  display: block;
}

body.menu-open {
  overflow: hidden;
}

input[type="date"], input[type="month"] {
  box-sizing: border-box;
  display: block;
  max-width: 100%;
  min-width: 0;
  width: 100%;
}

.user {
  margin-left: auto;
  padding: 6px 12px;
}

.user a {
  align-items: center;
  background: #1f2937;
  border: 1px solid #334155;
  border-radius: 10px;
  color: var(--muted);
  display: inline-flex;
  font-size: 14px;
  gap: 6px;
  padding: 8px 14px;
  text-decoration: none;
  transition: background .2s, color .2s, border-color .2s;
}

.user a.active {
  background: var(--accent);;
  border-color: var(--accent);
  color: #fff;
}

.user a:hover {
  background: var(--accent);;
  border-color: var(--accent);
  color: #fff;
}

.title {
  margin-left: auto;
  padding: 6px 12px;
}

.title a {
  align-items: center;
  background: 1f2937;
  border: 1px solid #334155;
  border-radius: 10px;
  color: var(--muted);
  display: inline-flex;
  font-size: 14px;
  gap: 6px;
  padding: 8px 14px;
  text-decoration: none;
  transition: background .2s, color .2s, border-color .2s;
}

.title a:hover {
  background: var(--accent);;
  border-color: var(--accent);
  color: #fff;
}

.title a.active {
  background: var(--accent);;
  border-color: var(--accent);
  color: #fff;
}

/* ========================= Calendar ========================= */
.cal-header {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  justify-content: space-between;
  margin-bottom: 10px;
}

.cal-month-title {
  align-items: center;
  display: flex;
  gap: 10px;
}

.cal-month-title h2 {
  font-size: 18px;
  margin: 0;
}

.calendar {
  margin-top: 16px;
}

.cal-grid {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(7, 1fr);
}

.cal-head > div {
  border-bottom: 1px solid #1f2937;
  color: var(--muted);
  font-weight: 600;
  padding-bottom: 6px;
  text-align: center;
}

.cal-body {
  margin-top: 8px;
}

.cal-cell {
  background: var(--card);
  border: 1px solid #1f2937;
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-height: 110px;
  padding: 8px;
  position: relative;
}

.cal-cell.muted {
  opacity: 0.5;
}

.cal-cell.today {
  box-shadow: inset 0 0 0 1px #22c55e33;
  outline: 1px solid #22c55e55;
}

.cal-daynum {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.cal-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.pill {
  align-items: center;
  background: #111827;
  border: 1px solid #334155;
  border-radius: 999px;
  color: #ddd;
  display: inline-flex;
  font-size: 12px;
  padding: 2px 8px;
  white-space: nowrap;
}

.pill.income {
  background: rgba(34,197,94,0.15);
  border-color: #14532d;
  color: #bbf7d0;
}

.pill.expense {
  background: rgba(239,68,68,0.15);
  border-color: #7f1d1d;
  color: #fecaca;
}

.pill.net.pos {
  background: rgba(34,197,94,0.10);
  color: #bbf7d0;
}

.pill.net.neg {
  background: rgba(239,68,68,0.10);
  color: #fecaca;
}

.cal-details summary {
  color: #cbd5e1;
  cursor: pointer;
  font-size: 12px;
  list-style: none;
}

.cal-details summary::-webkit-details-marker {
  display: none;
}

.cal-list {
  display: grid;
  gap: 6px;
  list-style: none;
  margin: 6px 0 0 0;
  margin-top: 6px;
  padding: 0;
}

.cal-list li {
  align-items: center;
  display: grid;
  font-size: 12px;
  gap: 8px;
  grid-template-columns: 1fr auto;
}

.cal-list .cattag {
  background: #111827;
  border: 1px solid #334155;
  border-radius: 6px;
  color: #cbd5e1;
  display: inline-block;
  max-width: 100%;
  overflow: hidden;
  padding: 2px 6px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cal-list .cattag.income {
  background: rgba(34,197,94,0.12);
  border-color: #14532d;
  color: #bbf7d0;
}

.cal-list .cattag.expense {
  background: rgba(239,68,68,0.12);
  border-color: #7f1d1d;
  color: #fecaca;
}

.cal-list .amt {
  white-space: nowrap;
}

.cal-list .desc {
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cal-list .recur {
  margin-left: 4px;
  opacity: 0.9;
}

.cal-actions {
  margin-top: 6px;
}

.cal-head,
.cal-grid {
  display: grid !important;
  gap: 6px !important;
  grid-template-columns: repeat(7, minmax(0, 1fr)) !important;
}

.pill.net {
  background: #0b1220;
  border: 1px dashed #334155;
  color: #cbd5e1;
}

.cal-grid, .cal-head {
  overflow: hidden;
}

input[type="date"].input,
input[type="month"].input,
input[type="time"].input,
input[type="datetime-local"].input,
input[type="number"].input,
input[type="text"].input {
  font-size: 16px !important;
}

.hidden {
  display: none !important;
}

/* --- Brand in topbar --- */
.topbar .brand a{
  display:flex; align-items:center; gap:10px;
  text-decoration:none;
}

.brand-logo{
  height:48px; width:auto; display:block; object-fit:contain;
  /* Optionnel si PNG raster: */
  image-rendering: -webkit-optimize-contrast;
}

@media (min-width:1024px){
  .brand-logo{ height:48px; }
}

.brand-name{
  font-weight:700; font-size:18px; line-height:1; margin:0;
  color:inherit; /* hérite de la couleur de la topbar */
}

@media (max-width:480px){
  /* Sur mobile, on peut n’afficher que le logo si tu veux */
  .brand-name{ display:none; }
}


/* ========================= Responsive ========================= */
@media (max-width: 720px) {
.menu-toggle {
  align-items: center;
  display: inline-flex;
  justify-content: center;
}
}

@media (min-width: 721px) {
body:has(.sidebar) {
  padding-left: var(--sidebar-w);
}

body:not(:has(.sidebar)) {
  padding-left: 0;
}

main.container {
  margin-left: auto;
  margin-right: auto;
  max-width: var(--content-max);
  padding: 20px;
}
}

@media (max-width: 720px) {
body {
  padding-left: 0 !important;
}

main.container {
  margin: 0 !important;
  max-width: 100% !important;
  padding: 10px;
}
}

@media (max-width: 720px) {
.sidebar {
  transform: translateX(-100%);
  transition: transform .25s ease;
}

.container {
  margin: 0;
  max-width: 100% !important;
  padding: 12px;
  width: 100% !important;
}

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

@media (max-width: 720px) {
.grid {
  display: grid;
  gap: 12px;
  grid-template-columns: 1fr;
}

.grid > .card {
  grid-column: 1 / -1 !important;
}

.card canvas {
  height: 260px !important;
}

.row {
  flex-direction: column;
  gap: 8px;
}

.row > * {
  width: 100%;
}

.table-wrap {
  -webkit-overflow-scrolling: touch;
  overflow-x: auto;
}

.table {
  min-width: 640px;
}
}

@media (max-width: 720px) {
:where(main, .container, .content, .wrap, .page) {
  box-sizing: border-box;
  margin: 0 !important;
  max-width: 100% !important;
  padding-left: 10px;
  padding-right: 10px;
  width: 100% !important;
}

.grid {
  display: grid;
  gap: 12px;
  grid-template-columns: minmax(0, 1fr);
}

.grid > .card {
  grid-column: 1 / -1 !important;
  width: 100% !important;
}

html, body {
  overflow-x: hidden;
}

.card canvas {
  height: 260px !important;
  width: 100% !important;
}
}

@supports (-webkit-touch-callout: none) {
input[type="date"], input[type="month"] {
  font-size: 16px;
  padding-right: 28px;
}

input[type="date"]::-webkit-calendar-picker-indicator,
  input[type="month"]::-webkit-calendar-picker-indicator {
  margin-inline-start: -4px;
}
}

@media (max-width: 720px) {
input[type="date"],
  input[type="month"],
  input[type="time"],
  input[type="datetime-local"] {
  font-size: 16px !important;
  line-height: 1.2;
}

.flatpickr-input,
  .form .input,
  input.input {
  font-size: 16px !important;
}

.flatpickr-mobile {
  box-sizing: border-box;
  font-size: 16px !important;
  width: 100% !important;
}
}

@media (max-width: 720px) {
.topbar {
  left: 0;
  position: fixed;
  right: 0;
  top: 0;
  z-index: 2000;
}

main.container {
  padding-top: calc(var(--header-h, 56px) + 8px);
}
}

@media (max-width: 720px) {
.cal-cell {
  min-height: 100px;
}

.cal-list li {
  grid-template-columns: 1fr auto;
}

.cal-list .desc {
  display: none;
}
}

@media (max-width: 720px) {
.calendar {
  margin-top: 12px;
}

.cal-grid {
  gap: 4px;
}

.cal-head > div {
  font-size: 12px;
  padding-bottom: 4px;
}

.cal-cell {
  border-radius: 8px;
  min-height: 70px;
  padding: 4px;
}

.cal-daynum {
  font-size: 12px;
  font-weight: 600;
}

.cal-pills {
  flex-direction: column;
  gap: 2px;
}

.pill {
  font-size: 11px;
  padding: 1px 4px;
}

.cal-details summary {
  font-size: 11px;
}

.cal-list {
  gap: 2px;
}

.cal-list li {
  font-size: 11px;
  grid-template-columns: 1fr auto;
}

.cal-list .desc {
  display: none;
}

.cal-month-title h2 {
  font-size: 16px;
}

.cal-month-title .btn.small {
  font-size: 12px;
  padding: 2px 6px;
}
}

@media (max-width: 720px) {
.cal-head,
  .cal-grid {
  gap: 4px !important;
}

.cal-head > div {
  font-size: 12px;
  padding-bottom: 4px;
}

.cal-cell {
  border-radius: 10px;
  min-height: 72px;
  padding: 6px;
}

.cal-daynum {
  font-size: 12px;
}

.cal-pills {
  flex-direction: column;
  gap: 2px;
}

.pill {
  font-size: 11px;
  padding: 1px 6px;
}

.cal-details summary {
  font-size: 11px;
}

.cal-list {
  gap: 2px;
}

.cal-list li {
  font-size: 11px;
}

.cal-list .desc {
  display: none;
}
}

@media (max-width: 720px) {
.cal-pills {
  flex-direction: row;
  flex-wrap: nowrap;
  gap: 4px;
}

.cal-pills .pill {
  border: none;
  border-radius: 50%;
  font-size: 0;
  height: 10px;
  line-height: 0;
  padding: 0;
  width: 10px;
}

.cal-pills .pill.income {
  background: #22c55e;
}

.cal-pills .pill.expense {
  background: #ef4444;
}

.cal-pills .pill.net {
  display: none;
}
}