:root {
  --bg: #f4f6fb;
  --panel: #ffffff;
  --border: #dfe3ec;
  --text: #1b2430;
  --muted: #5f6b7d;
  --accent: #3867d6;
  --accent-alt: #22c58b;
  --radius: 12px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.4;
  padding: 1rem 1.25rem;
}

h1,
h2,
h3,
h4,
h5 {
  margin: 0;
  font-weight: 600;
}

p {
  margin: 0;
}

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

/* === AUTH SCREEN === */
.auth-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.auth-container {
  background: var(--panel);
  border-radius: var(--radius);
  padding: 2rem;
  width: 100%;
  max-width: 360px;
  box-shadow: 0 8px 24px rgba(24, 36, 51, 0.08);
  text-align: center;
}

.auth-lang-selector {
  display: flex;
  justify-content: center;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.auth-container h1 {
  font-size: 1.75rem;
  margin-bottom: 0.25rem;
}

.auth-tagline {
  color: var(--muted);
  font-size: 0.85rem;
  margin-bottom: 1.5rem;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  text-align: left;
}

.auth-form label {
  display: flex;
  flex-direction: column;
  font-size: 0.85rem;
  color: var(--muted);
}

.auth-form input {
  margin-top: 0.25rem;
  padding: 0.6rem 0.75rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  font-size: 0.95rem;
}

.auth-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.auth-actions button {
  flex: 1;
  padding: 0.6rem 1rem;
  border: none;
  border-radius: 999px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.auth-actions button[type="submit"] {
  background: var(--accent);
  color: #fff;
}

.auth-actions button.ghost {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
}

.auth-message {
  min-height: 1rem;
  font-size: 0.8rem;
  color: var(--muted);
  text-align: center;
  margin-top: 0.25rem;
}

.auth-message.error {
  color: #f03e3e;
}

.auth-screen[hidden],
.app-container[hidden] {
  display: none;
}

.user-email {
  font-size: 0.85rem;
  color: var(--muted);
  margin-right: 0.5rem;
}

/* === LANGUAGE SELECTOR === */
.lang-selector {
  display: flex;
  gap: 0.25rem;
  margin-right: 0.75rem;
  padding-right: 0.75rem;
  border-right: 1px solid var(--border);
}

.lang-btn {
  background: transparent;
  border: 2px solid transparent;
  border-radius: 6px;
  padding: 0.2rem 0.3rem;
  font-size: 1.25rem;
  cursor: pointer;
  transition: all 0.2s ease;
  opacity: 0.6;
}

.lang-btn:hover {
  opacity: 1;
}

.lang-btn.active {
  opacity: 1;
  border-color: var(--accent);
  background: rgba(56, 103, 214, 0.1);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* === HEADER === */
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

/* === BALANCE PANEL === */
.balance-panel {
  margin-bottom: 0.75rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
  padding: 0.75rem;
}

.balance-display {
  display: flex;
  align-items: center;
  gap: 2rem;
  flex-wrap: wrap;
}

.balance-main {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.balance-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  color: var(--muted);
  letter-spacing: 0.5px;
}

.balance-value {
  font-size: 2.5rem;
  font-weight: 700;
  color: var(--accent);
  line-height: 1.1;
}

.balance-value.negative {
  color: #f03e3e;
}

.balance-unit {
  font-size: 0.8rem;
  color: var(--muted);
}

.balance-breakdown {
  display: flex;
  gap: 1.5rem;
}

.breakdown-item {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.breakdown-value {
  font-size: 1.25rem;
  font-weight: 600;
}

.breakdown-label {
  font-size: 0.7rem;
  color: var(--muted);
  text-transform: uppercase;
}

.balance-settings {
  display: flex;
  align-items: flex-end;
  gap: 0.5rem;
}

.balance-settings label {
  display: flex;
  flex-direction: column;
  font-size: 0.75rem;
  color: var(--muted);
}

.balance-settings input {
  width: 80px;
  padding: 0.4rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.9rem;
  margin-top: 0.2rem;
}

.balance-settings button {
  padding: 0.4rem 0.8rem;
  font-size: 0.8rem;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 6px;
  cursor: pointer;
}

.app-header h1 {
  font-size: 1.5rem;
}

.app-header p {
  font-size: 0.85rem;
  color: var(--muted);
}

.header-subtitle {
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin: 0.5rem 0 0.25rem 0;
  font-weight: 500;
}

.daily-text-header a {
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
}

.daily-text-header a:hover {
  text-decoration: underline;
}

/* === BUTTONS === */
.header-actions button,
.calendar-header button,
.entries-header button,
.form-actions button,
.project-form button {
  border: none;
  background: var(--accent);
  color: #fff;
  border-radius: 999px;
  padding: 0.45rem 1.1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

button.ghost {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
}

button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

button:not(:disabled):hover {
  opacity: 0.85;
}

/* Primary action button enhancement */
.form-actions button[type="submit"] {
  padding: 0.5rem 1.4rem;
  box-shadow: 0 2px 8px rgba(56, 103, 214, 0.25);
}

.form-actions button[type="submit"]:hover {
  box-shadow: 0 4px 12px rgba(56, 103, 214, 0.35);
  transform: translateY(-1px);
}

/* === MAIN LAYOUT === */
.app-shell {
  display: grid;
  grid-template-columns: minmax(300px, 1fr) minmax(340px, 1.2fr);
  gap: 1rem;
}

.panel {
  background: var(--panel);
  border-radius: var(--radius);
  padding: 1rem;
  box-shadow: 0 8px 24px rgba(24, 36, 51, 0.06);
}

/* === CALENDAR === */
.calendar-header,
.entries-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
}

.calendar-header button {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  font-size: 1.1rem;
  padding: 0;
}

.weekday-row,
.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 0.2rem;
}

.weekday-row {
  margin-top: 0.75rem;
  color: var(--muted);
  font-size: 0.7rem;
  text-transform: uppercase;
  text-align: center;
}

.calendar-grid {
  margin-top: 0.35rem;
}

.calendar-cell {
  border-radius: 8px;
  padding: 0.35rem;
  min-height: 52px;
  border: 1px solid transparent;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  transition: border 0.2s ease, background 0.2s ease;
}

.calendar-cell:hover {
  border-color: var(--border);
}

.calendar-cell.out-month {
  color: #a5acbd;
}

.calendar-cell.today {
  border-color: rgba(56, 103, 214, 0.6);
}

.calendar-cell.selected {
  background: rgba(56, 103, 214, 0.12);
  border-color: var(--accent);
}

.calendar-cell .day-number {
  font-weight: 600;
  font-size: 0.9rem;
}

.calendar-cell .entry-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  margin-top: 0.25rem;
  background: var(--accent-alt);
}

/* === ENTRIES LIST === */
.entries-list {
  list-style: none;
  padding: 0;
  margin: 0.75rem 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.entry-card {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.6rem 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.entry-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.entry-time {
  font-weight: 600;
}

.entry-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  font-size: 0.85rem;
  color: var(--muted);
}

.entry-actions {
  display: flex;
  gap: 0.4rem;
  margin-top: 0.25rem;
}

.entry-actions button {
  padding: 0.2rem 0.5rem;
  font-size: 0.75rem;
}

.entry-actions button.delete {
  background: #f03e3e;
}

/* === ENTRY FORM === */
.entry-form h3 {
  margin-bottom: 0.4rem;
  font-size: 1rem;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 0.5rem;
}

.form-grid label {
  display: flex;
  flex-direction: column;
  font-size: 0.85rem;
  color: var(--muted);
}

.form-grid input,
.form-grid select,
.form-grid textarea {
  margin-top: 0.2rem;
  padding: 0.5rem 0.6rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  font-size: 0.9rem;
  font-family: inherit;
}

.form-grid textarea {
  resize: vertical;
  min-height: 2.5rem;
}

.notes-field {
  grid-column: 1 / -1;
}

.form-actions {
  margin-top: 0.5rem;
  display: flex;
  gap: 0.5rem;
}

.form-message {
  min-height: 1rem;
  font-size: 0.8rem;
  color: var(--muted);
  margin-top: 0.25rem;
}

/* === DAILY GOAL === */
.daily-goal {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--accent);
  margin-top: 0.25rem;
}

.daily-goal.goal-warning {
  color: #f03e3e;
}

/* === PROJECTS PANEL === */
.projects-panel {
  margin-top: 1rem;
  display: grid;
  gap: 0.75rem;
  max-width: 800px;
}

.projects-panel h3 {
  font-size: 1rem;
}

.projects-panel > div > p {
  font-size: 0.8rem;
  color: var(--muted);
}

.project-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.35rem;
}

.project-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.5rem 0.7rem;
}

.project-item span {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.9rem;
}

.project-color {
  width: 12px;
  height: 12px;
  border-radius: 50%;
}

.project-item button {
  background: transparent;
  color: var(--accent);
  border: none;
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
}

.project-form {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: flex-end;
}

.project-form label {
  flex: 1 1 140px;
  display: flex;
  flex-direction: column;
  font-size: 0.85rem;
  color: var(--muted);
}

.project-form input {
  margin-top: 0.2rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  padding: 0.45rem 0.55rem;
  font-size: 0.9rem;
}

.project-form button {
  padding: 0.45rem 0.9rem;
  font-size: 0.85rem;
}

/* === RESPONSIVE: Desktop (1025px+) === */
@media (min-width: 1025px) {
  body {
    padding: 1.25rem 2rem;
  }

  .app-shell {
    grid-template-columns: minmax(320px, 1fr) minmax(380px, 1.3fr);
    gap: 1.25rem;
  }

  .calendar-cell {
    min-height: 56px;
    padding: 0.4rem;
  }

  .panel {
    padding: 1.1rem;
  }
}

/* === RESPONSIVE: iPad / Tablet (769px - 1024px) === */
@media (min-width: 769px) and (max-width: 1024px) {
  body {
    padding: 1rem;
  }

  .app-shell {
    grid-template-columns: minmax(260px, 1fr) minmax(300px, 1.2fr);
    gap: 0.875rem;
  }

  .calendar-cell {
    min-height: 48px;
    padding: 0.3rem;
  }

  .calendar-cell .day-number {
    font-size: 0.85rem;
  }

  .panel {
    padding: 0.875rem;
  }

  .calendar-header button {
    width: 34px;
    height: 34px;
    font-size: 1rem;
  }
}

/* === RESPONSIVE: iPad Mini / Large Phone (481px - 768px) === */
@media (min-width: 481px) and (max-width: 768px) {
  body {
    padding: 0.75rem;
  }

  .app-shell {
    grid-template-columns: 1fr;
    gap: 0.75rem;
  }

  .calendar-panel {
    order: 1;
  }

  .entries-panel {
    order: 2;
  }

  .panel {
    padding: 0.875rem;
  }

  .calendar-cell {
    min-height: 44px;
    padding: 0.3rem;
  }

  .calendar-cell .day-number {
    font-size: 0.85rem;
  }

  .calendar-header button {
    width: 36px;
    height: 36px;
  }

  .form-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .app-header h1 {
    font-size: 1.35rem;
  }
}

/* === RESPONSIVE: iPhone / Mobile (up to 480px) === */
@media (max-width: 480px) {
  body {
    padding: 0.5rem;
  }

  .app-header {
    margin-bottom: 0.75rem;
  }

  .app-header h1 {
    font-size: 1.2rem;
  }

  .app-header p {
    display: none;
  }

  .app-shell {
    grid-template-columns: 1fr;
    gap: 0.5rem;
  }

  .calendar-panel {
    order: 1;
  }

  .entries-panel {
    order: 2;
  }

  .panel {
    padding: 0.65rem;
    border-radius: 10px;
  }

  .calendar-header h2 {
    font-size: 1rem;
  }

  .calendar-header p {
    font-size: 0.75rem;
  }

  .calendar-header button {
    width: 32px;
    height: 32px;
    font-size: 0.95rem;
  }

  .weekday-row {
    font-size: 0.6rem;
    margin-top: 0.5rem;
  }

  .calendar-cell {
    min-height: 40px;
    padding: 0.2rem;
    border-radius: 6px;
  }

  .calendar-cell .day-number {
    font-size: 0.8rem;
  }

  .calendar-cell .entry-dot {
    width: 5px;
    height: 5px;
    margin-top: 0.15rem;
  }

  .entries-header h2 {
    font-size: 0.95rem;
  }

  .entries-header p {
    font-size: 0.75rem;
  }

  .entries-header button {
    padding: 0.35rem 0.8rem;
    font-size: 0.8rem;
  }

  .entries-list {
    margin: 0.5rem 0;
    gap: 0.4rem;
  }

  .entry-card {
    padding: 0.5rem 0.6rem;
    border-radius: 8px;
  }

  .entry-time {
    font-size: 0.9rem;
  }

  .entry-meta {
    font-size: 0.8rem;
  }

  .entry-actions button {
    padding: 0.2rem 0.5rem;
    font-size: 0.75rem;
  }

  .entry-form h3 {
    font-size: 0.9rem;
  }

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

  .form-grid label {
    font-size: 0.8rem;
  }

  .form-grid input,
  .form-grid select,
  .form-grid textarea {
    padding: 0.4rem 0.5rem;
    font-size: 0.85rem;
  }

  .form-actions {
    margin-top: 0.4rem;
  }

  .form-actions button {
    padding: 0.4rem 0.9rem;
    font-size: 0.85rem;
  }

  .projects-panel {
    margin-top: 0.75rem;
    gap: 0.5rem;
  }

  .projects-panel h3 {
    font-size: 0.9rem;
  }

  .projects-panel > div > p {
    font-size: 0.75rem;
  }

  .project-item {
    padding: 0.4rem 0.6rem;
  }

  .project-item span {
    font-size: 0.85rem;
  }

  .project-form {
    gap: 0.4rem;
  }

  .project-form label {
    font-size: 0.8rem;
    flex: 1 1 100px;
  }

  .project-form input {
    padding: 0.4rem 0.5rem;
    font-size: 0.85rem;
  }

  .project-form button {
    padding: 0.4rem 0.75rem;
    font-size: 0.8rem;
  }
}

/* === DARK MODE === */
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1116;
    --panel: #1b1f2a;
    --border: #2c3242;
    --text: #f2f4ff;
    --muted: #99a0b6;
  }

  body {
    color: var(--text);
  }

  .entry-card,
  .project-item,
  .calendar-cell {
    border-color: var(--border);
  }

  .form-grid input,
  .form-grid select,
  .form-grid textarea,
  .project-form input {
    background: var(--bg);
    color: var(--text);
  }
}
