@import url("https://fonts.googleapis.com/css2?family=Manrope:wght@400;600;700;800&family=IBM+Plex+Mono:wght@500&display=swap");

:root {
  --bg-1: #0f1720;
  --bg-2: #1a2431;
  --bg-3: #2f3f4d;
  --panel: rgba(252, 250, 244, 0.95);
  --panel-soft: rgba(255, 255, 255, 0.72);
  --text: #1f2a36;
  --muted: #5f6f7b;
  --accent: #0f766e;
  --accent-2: #c2410c;
  --border: #d5dde2;
  --danger: #9f1239;
  --shadow: 0 12px 28px rgba(10, 16, 24, 0.16);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Manrope", "Avenir Next", "Segoe UI", sans-serif;
  color: var(--text);
  background:
    radial-gradient(1200px 500px at 10% -10%, rgba(194, 65, 12, 0.16), transparent 60%),
    radial-gradient(900px 450px at 90% -20%, rgba(15, 118, 110, 0.24), transparent 55%),
    linear-gradient(150deg, var(--bg-1), var(--bg-2) 45%, var(--bg-3));
  min-height: 100vh;
}

.topbar {
  padding: 1.35rem 1rem;
  border-bottom: 1px solid rgba(213, 221, 226, 0.28);
  background: rgba(7, 11, 17, 0.44);
  backdrop-filter: blur(9px);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

#refresh-btn {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #f6fbfd;
  font-size: 1.4rem;
  width: 2.4rem;
  height: 2.4rem;
  border-radius: 50%;
  cursor: pointer;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

#refresh-btn:active {
  background: rgba(255, 255, 255, 0.2);
}

.topbar h1 {
  margin: 0;
  font-size: clamp(1.35rem, 2.2vw, 1.9rem);
  font-weight: 800;
  letter-spacing: -0.03em;
  color: #f6fbfd;
}

.topbar p {
  margin: 0.35rem 0 0;
  color: #d5e6ed;
}

.layout {
  max-width: 1240px;
  margin: 1rem auto 2rem;
  padding: 0 0.95rem;
  display: grid;
  gap: 0.9rem;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
}

.card-wide {
  grid-column: 1 / -1;
}

.view-pane {
  display: none;
  grid-column: 1 / -1;
  gap: 0.9rem;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  align-items: start;
}

.view-pane.view-active {
  display: grid;
}

/* Auth bar: full form when disconnected, slim status strip when connected */
.auth-bar {
  background: var(--panel);
  border: 1px solid rgba(213, 221, 226, 0.76);
  border-radius: 16px;
  padding: 0.68rem 0.8rem;
  box-shadow: var(--shadow);
}

.auth-bar.connected {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.45rem 0.9rem;
  border-radius: 10px;
}

.auth-bar.connected form {
  display: none;
}

.auth-bar.connected::before {
  content: "●";
  color: var(--accent);
  font-size: 0.75rem;
}

.auth-bar.connected .auth-status-slim {
  font-size: 0.82rem;
  color: var(--muted);
}

/* Three equal log cards (Media / Life / Work) */
.log-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.9rem;
  align-items: start;
}

/* Body log compact horizontal layout */
.body-compact-form {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(155px, 1fr));
  gap: 0.7rem 1rem;
  align-items: end;
}

.body-submit {
  align-self: end;
}

/* Existing day notes display (read-only, above form) */
.daynotes-existing {
  white-space: pre-wrap;
  font-size: 0.88rem;
  color: #2e4a52;
  background: #eef6f9;
  border-left: 3px solid #6aacbd;
  padding: 0.6rem 0.8rem;
  border-radius: 4px;
  margin-bottom: 0.7rem;
  line-height: 1.5;
}

.daynotes-status {
  font-size: 0.85rem;
  font-weight: 600;
  margin-top: 0.4rem;
  padding: 0.3rem 0;
}

/* Today at a Glance — notes section below chip cards */
.glance-notes {
  margin-top: 0.9rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.note-row {
  display: flex;
  gap: 0.6rem;
  font-size: 0.87rem;
  line-height: 1.4;
}

.note-label {
  flex-shrink: 0;
  font-weight: 600;
  color: #4a7a8a;
  min-width: 90px;
}

.note-text {
  color: #1a2a30;
  white-space: pre-wrap;
}

/* Notes field spanning full width in body-compact-form */
.notes-field {
  grid-column: 1 / -1;
}

.notes-field textarea,
.grid-form textarea {
  width: 100%;
  resize: vertical;
  font-family: inherit;
  font-size: 0.9rem;
  padding: 0.4rem 0.5rem;
  border: 1px solid #b0c8d4;
  border-radius: 4px;
  background: #fff;
  color: #1a2a30;
  box-sizing: border-box;
}

/* Day Notes form: date | textarea | button in a row */
.daynotes-form {
  display: grid;
  grid-template-columns: 170px 1fr auto;
  gap: 0.7rem;
  align-items: end;
}

.daynotes-form textarea {
  resize: vertical;
  font-family: inherit;
  font-size: 0.9rem;
  padding: 0.4rem 0.5rem;
  border: 1px solid #b0c8d4;
  border-radius: 4px;
  background: #fff;
  color: #1a2a30;
  width: 100%;
  box-sizing: border-box;
}

/* Export two-column layout */
.export-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1.2rem;
}

.export-group {
  display: grid;
  gap: 0.5rem;
}

.export-group-label {
  margin: 0 0 0.2rem;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

/* Body log grouped layout */
.body-full-form {
  display: grid;
  gap: 0.7rem;
}

.body-group {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 0.5rem;
  padding: 0.6rem;
  border: 1px solid #dce6eb;
  border-radius: 10px;
  background: linear-gradient(148deg, #f8fbfc, #f1f6f9);
}

/* Work category auto-fill display */
.category-display {
  display: flex;
  gap: 0.4rem;
  align-items: center;
}

.category-display input {
  flex: 1;
  background: #f3f7f9;
  color: var(--muted);
}

.category-source {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 0.18rem 0.4rem;
  border-radius: 6px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.category-auto {
  background: #dcf5ec;
  color: #0f5e4a;
  border: 1px solid #a8dfc8;
}

.category-default {
  background: #f3f0e6;
  color: #6b5d36;
  border: 1px solid #d9ceab;
}

.card {
  background: var(--panel);
  border: 1px solid rgba(213, 221, 226, 0.76);
  border-radius: 16px;
  padding: 1rem;
  box-shadow: var(--shadow);
}

.card h2 {
  margin: 0 0 0.7rem;
  font-size: 1.02rem;
  font-weight: 800;
  letter-spacing: -0.01em;
  color: #15202b;
}

.compact-connect {
  padding: 0.68rem 0.8rem;
}

.auth-inline {
  display: grid;
  grid-template-columns: 140px minmax(180px, 320px) 120px 1fr;
  align-items: center;
  gap: 0.55rem;
}

.auth-inline h2 {
  margin: 0;
}

.view-switch {
  display: flex;
  gap: 0.5rem;
  padding: 0.5rem;
}

.view-switch button {
  flex: 1;
  background: linear-gradient(145deg, #425a66, #536f7d);
  border-color: #344955;
}

.view-switch button.active {
  background: linear-gradient(145deg, var(--accent), #0e8f84);
  border-color: #0a625c;
}

.grid-form {
  display: grid;
  gap: 0.58rem;
}

label {
  display: grid;
  gap: 0.2rem;
  font-size: 0.82rem;
  font-weight: 700;
  color: #2f3f4d;
}

input,
select,
button {
  font: inherit;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.52rem 0.63rem;
  background: #fff;
}

input,
select {
  color: var(--text);
}

input:focus,
select:focus {
  outline: 2px solid rgba(15, 118, 110, 0.2);
  border-color: #7cb8b3;
}

button {
  cursor: pointer;
  background: linear-gradient(145deg, var(--accent), #0e8f84);
  color: #f8fbfc;
  border: 1px solid #0a625c;
  font-weight: 700;
}

button:hover {
  filter: brightness(0.97);
}

.actions {
  display: grid;
  gap: 0.55rem;
}

.quick-count-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(130px, 1fr));
  gap: 0.5rem;
  margin-bottom: 0.66rem;
}

.quick-count-actions button {
  width: 100%;
  background: linear-gradient(150deg, #0e7490, #0f766e);
  border-color: #0a5a67;
}

.list {
  display: grid;
  gap: 0.5rem;
}

.timer-item {
  border: 1px solid #c9d5dd;
  border-radius: 10px;
  padding: 0.6rem;
  background: linear-gradient(145deg, #f6fafb, #edf4f7);
}

.timer-item p {
  margin: 0.15rem 0;
}

.timer-controls {
  display: flex;
  gap: 0.4rem;
  margin-top: 0.46rem;
}

.timer-controls button {
  flex: 1;
}

.summary {
  color: #2e3d49;
  font-size: 0.91rem;
  line-height: 1.45;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 0.55rem;
}

.metric-card {
  padding: 0.6rem 0.62rem;
  border-radius: 11px;
  border: 1px solid #cbd6dd;
  background: linear-gradient(155deg, #ffffff, #f2f7fa);
  display: grid;
  gap: 0.13rem;
}

.metric-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #61727e;
  font-weight: 700;
}

.metric-value {
  font-size: 1.05rem;
  font-weight: 800;
  color: #17212b;
}

.metric-sub {
  font-size: 0.8rem;
  color: #546674;
}

.stack {
  display: grid;
  gap: 0.4rem;
  margin-top: 0.58rem;
}

.glance-layout {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.6rem;
}

.glance-card {
  border: 1px solid #d3dde3;
  background: linear-gradient(145deg, #fcfeff, #f1f6f9);
  border-radius: 12px;
  padding: 0.56rem;
}

.glance-card h3 {
  margin: 0 0 0.4rem;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #4f6471;
}

.chip-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(92px, 1fr));
  gap: 0.36rem;
}

.chip {
  border: 1px solid #dde5ea;
  background: #ffffff;
  border-radius: 10px;
  padding: 0.35rem 0.42rem;
  display: grid;
  gap: 0.1rem;
}

.chip span {
  font-size: 0.67rem;
  color: #5f7280;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 700;
}

.chip strong {
  font-size: 0.9rem;
  color: #1f2f3a;
}

.info-line {
  display: grid;
  grid-template-columns: minmax(120px, 160px) 1fr;
  gap: 0.55rem;
  padding: 0.44rem 0.5rem;
  border-radius: 9px;
  background: var(--panel-soft);
  border: 1px solid #d5e0e7;
}

.info-line span {
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #60717d;
  font-weight: 700;
}

.range-title {
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.8rem;
  color: #51636f;
  margin-bottom: 0.45rem;
}

.compare-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 0.52rem;
  margin-top: 0.52rem;
}

.delta-card {
  border-radius: 11px;
  padding: 0.5rem 0.58rem;
  border: 1px solid #d2dde4;
  background: #f7fafb;
}

.delta-card.trend-up {
  border-color: #8fd0bc;
  background: #edf9f3;
}

.delta-card.trend-down {
  border-color: #f4b5bf;
  background: #fff2f4;
}

.delta-card.trend-flat {
  border-color: #d4e1e8;
  background: #f5f9fb;
}

.entry-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  border: 1px solid #d4dde3;
  border-radius: 10px;
  padding: 0.5rem 0.58rem;
  background: linear-gradient(148deg, #f7fbfd, #eef4f7);
}

.entry-row-actions {
  display: flex;
  gap: 0.35rem;
  flex-shrink: 0;
}

.entry-row button,
.entry-row-actions button {
  padding: 0.35rem 0.6rem;
}

.btn-entry-edit {
  background: linear-gradient(145deg, #2563eb, #1d4ed8);
  border-color: #1e40af;
}

.entry-row-actions button:not(.btn-entry-edit) {
  background: linear-gradient(145deg, var(--danger), #be123c);
  border-color: #831035;
}

/* Today's Entries (capture view) still uses direct button */
.entry-row > button {
  background: linear-gradient(145deg, var(--danger), #be123c);
  border-color: #831035;
  padding: 0.35rem 0.6rem;
}

.inline-edit-form {
  background: #f0f7fc;
  border: 1px solid #b0cdd8;
  border-radius: 10px;
  padding: 0.8rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.inline-edit-fields {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 0.4rem 0.6rem;
}

.inline-edit-fields label {
  display: flex;
  flex-direction: column;
  font-size: 0.75rem;
  font-weight: 600;
  gap: 0.2rem;
  color: #3a5a66;
}

.inline-edit-fields input,
.inline-edit-fields select,
.inline-edit-fields textarea {
  font-size: 0.82rem;
  padding: 0.25rem 0.4rem;
  border-radius: 5px;
  border: 1px solid #b0cdd8;
  background: #fff;
}

.inline-edit-actions {
  display: flex;
  gap: 0.5rem;
}

.btn-save {
  background: linear-gradient(145deg, var(--accent), #1a7a5a);
  border-color: #155f45;
}

.btn-cancel {
  background: linear-gradient(145deg, #6b7280, #4b5563);
  border-color: #374151;
}

.recent-entries-list {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.recent-day-heading {
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: #4a7e91;
  margin-top: 0.7rem;
  padding-bottom: 0.2rem;
  border-bottom: 1px solid #c8dde4;
}

.recent-day-heading:first-child {
  margin-top: 0;
}

.recent-subtitle {
  font-size: 0.78rem;
  font-weight: 400;
  color: #7a9aaa;
  text-transform: none;
  letter-spacing: 0;
}

.history-controls {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0.5rem;
  margin-bottom: 0.7rem;
}

footer {
  text-align: center;
  color: #deedf2;
  font-size: 0.82rem;
  padding: 0.9rem;
}

@media (max-width: 760px) {
  .layout {
    grid-template-columns: 1fr;
    padding: 0 0.7rem;
  }

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

  .body-compact-form {
    grid-template-columns: repeat(2, minmax(120px, 1fr));
  }

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

  .info-line {
    grid-template-columns: 1fr;
  }

  .compare-grid,
  .metric-grid {
    grid-template-columns: repeat(auto-fit, minmax(135px, 1fr));
  }

  .chip-grid {
    grid-template-columns: repeat(2, minmax(90px, 1fr));
  }

  .auth-inline {
    grid-template-columns: 1fr;
  }
}
