:root {
  color-scheme: light;
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #f4f7fb;
  color: #10233f;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: linear-gradient(180deg, #f9fbff 0%, #eef4fb 100%);
  color: #10233f;
}

.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.login-panel {
  width: min(920px, 100%);
  display: grid;
  gap: 22px;
}

.login-panel h1 {
  text-align: center;
  font-size: clamp(2rem, 6vw, 4.5rem);
}

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

.login-status {
  min-height: 1.4em;
  text-align: center;
  color: #b22f2f;
}

.emoji-button {
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  padding: 0;
  border-radius: 8px;
  background: #ffffff;
  border: 1px solid #dce7f3;
  color: #10233f;
  box-shadow: 0 8px 24px rgba(16, 35, 63, 0.08);
  font-size: clamp(1.35rem, 4vw, 2.2rem);
  line-height: 1;
}

.emoji-button:hover {
  background: #eef5ff;
}

.emoji-button.selected {
  background: #0f5cf4;
  border-color: #0f5cf4;
  color: #ffffff;
}

.app-shell {
  max-width: 1440px;
  margin: 0 auto;
  padding: 20px 24px 48px;
}

.session-toolbar {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 12px;
}

.top-dashboard {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  gap: 20px;
  align-items: stretch;
  margin-bottom: 20px;
}

.hero {
  display: flex;
  gap: 24px;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.24em;
  font-size: 0.8rem;
  color: #5b7c99;
  margin: 0 0 8px;
}

h1, h2, h3, p { margin: 0; }

.subtitle { margin-top: 8px; color: #51667d; max-width: 600px; }

.dashboard-grid {
  display: grid;
  grid-template-columns: 0.95fr 1.05fr;
  gap: 20px;
  margin-bottom: 20px;
}

.card {
  background: white;
  border-radius: 24px;
  padding: 22px;
  box-shadow: 0 18px 42px rgba(16, 35, 63, 0.08);
}

.highlight-card {
  min-width: 0;
  background: linear-gradient(135deg, #0f5cf4, #3e8cff);
  color: white;
  align-self: stretch;
}

.card-label { font-size: 0.95rem; opacity: 0.85; }
.highlight-card h2 { margin: 8px 0; font-size: clamp(1.8rem, 4vw, 2.4rem); }
.highlight-card #summary-text { margin-bottom: 18px; opacity: 0.9; }
.refund-form { gap: 8px; }
.refund-form label { font-size: 0.85rem; }
.refund-form input, .refund-form textarea { padding: 8px 10px; }
.refund-form button { background: white; color: #0f5cf4; }
.refund-form button:hover { background: #eef5ff; }
.refund-form-status { min-height: 1.2em; font-size: 0.85rem; }

.card-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }

form {
  display: grid;
  gap: 12px;
}

label { display: grid; gap: 6px; font-size: 0.95rem; }
input, select, textarea, button {
  font: inherit;
  border-radius: 10px;
  border: 1px solid #dce7f3;
  padding: 10px 12px;
}

textarea { resize: vertical; }

.date-range-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.date-range-row input {
  flex: 1;
}

button {
  background: #0f5cf4;
  color: white;
  border: none;
  cursor: pointer;
  font-weight: 600;
}

button:hover { background: #0c4ed1; }

.metrics {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.metric-label { display: block; color: #6d83a1; font-size: 0.9rem; margin-bottom: 4px; }

.category-summary ul {
  margin: 8px 0 0;
  padding-left: 1.2rem;
  list-style: disc inside;
}

.category-summary li {
  margin: 4px 0;
  font-size: 0.95rem;
  color: #10233f;
  display: flex;
  align-items: center;
  gap: 8px;
}

.category-summary .badge {
  font-size: 0.8rem;
  padding: 4px 8px;
}

.expense-list {
  display: grid;
  gap: 12px;
}

.expense-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  border: 1px solid #e7eef7;
  border-radius: 14px;
  padding: 12px 14px;
}

.expense-main { display: flex; flex-direction: column; gap: 4px; }
.expense-meta { color: #6d83a1; font-size: 0.9rem; }
.company-manager {
  margin-top: 16px;
}
.company-manager-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}
.company-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.company-tag {
  background: rgba(15, 92, 244, 0.08);
  color: #0f5cf4;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 0.9rem;
}
.company-empty {
  color: #6d83a1;
  font-size: 0.9rem;
}
.badge {
  display: inline-block;
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
  background: #eef5ff;
  color: #0f5cf4;
}

.badge.corrente { background: rgba(46, 204, 113, 0.15); color: #2ecc71; }
.badge.gas { background: rgba(52, 152, 219, 0.15); color: #3498db; }
.badge.acqua { background: rgba(91, 192, 222, 0.15); color: #5bc0de; }
.badge.internet { background: rgba(231, 76, 60, 0.12); color: #e74c3c; }
.badge.paid { background: #e6f8ee; color: #19804d; }
.badge.bolletta { background: #fef3df; color: #995d00; }
.badge.refund { background: #e6f8ee; color: #19804d; }

.issue-label {
  display: inline-block;
  margin-right: 0.5rem;
}

.category-select {
  color: #10233f;
}

.category-select option[value="corrente"] { color: #2ecc71; }
.category-select option[value="gas"] { color: #3498db; }
.category-select option[value="acqua"] { color: #5bc0de; }
.category-select option[value="internet"] { color: #e74c3c; }

.delete-btn {
  background: #ffefef;
  color: #b22f2f;
  padding: 7px 10px;
  border: none;
  border-radius: 999px;
}

.delete-btn:hover { background: #ffd9d9; }

.edit-btn {
  background: #eef5ff;
  color: #0f5cf4;
  padding: 7px 10px;
  border: none;
  border-radius: 999px;
}

.edit-btn:hover { background: #dfeeff; }

.modal {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal.open {
  display: flex;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(16, 35, 63, 0.45);
}

.modal-dialog {
  position: relative;
  width: min(560px, calc(100% - 24px));
  background: white;
  border-radius: 20px;
  padding: 20px;
  box-shadow: 0 24px 60px rgba(16, 35, 63, 0.2);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
}

.modal-close {
  background: transparent;
  color: #10233f;
  border: none;
  font-size: 1.4rem;
  padding: 0;
}

.modal-actions {
  display: flex;
  gap: 10px;
  margin-top: 8px;
}

.secondary-btn {
  background: #f1f5fb;
  color: #10233f;
  border: 1px solid #dce7f3;
}

.secondary-btn:hover { background: #e5edf7; }

.chart-card { overflow: hidden; }

.chart-wrapper {
  margin-top: 8px;
  border-radius: 16px;
  background: linear-gradient(180deg, #f9fbff 0%, #f2f7ff 100%);
  padding: 16px 12px 8px;
}

.chart-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.chart-nav-btn {
  background: #eef5ff;
  color: #0f5cf4;
  border: 1px solid #d9e8ff;
  border-radius: 999px;
  padding: 6px 10px;
  min-width: 34px;
}

.chart-nav-btn:hover {
  background: #dfeeff;
}

.chart-caption {
  color: #6d83a1;
  font-size: 0.9rem;
}

#expenses-chart {
  width: 100%;
  height: auto;
  display: block;
}

.chart-label {
  font-size: 0.72rem;
  fill: #6d83a1;
}

.chart-value {
  font-size: 0.72rem;
  fill: #10233f;
  font-weight: 600;
}

.chart-empty {
  font-size: 0.95rem;
  fill: #6d83a1;
}

.empty-state {
  padding: 18px;
  text-align: center;
  color: #6d83a1;
  border: 1px dashed #d6e2ef;
  border-radius: 14px;
}

@media (max-width: 1024px) {
  .top-dashboard { grid-template-columns: 1fr; }
  .hero { flex-direction: column; align-items: flex-start; }
  .dashboard-grid { grid-template-columns: 1fr; }
  .highlight-card { min-width: 100%; }
}

@media (max-width: 820px) {
  .hero { gap: 14px; }
  .metrics { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 640px) {
  .emoji-grid {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }
}
