:root {
  --bg: #f6f4ed;
  --card-bg: #fffdf7;
  --text: #1f1f1f;
  --muted: #5e5e5e;
  --primary: #0e6e5c;
  --primary-hover: #0b5b4b;
  --danger: #b42318;
  --success: #067647;
  --border: #d8d4c8;
  --shadow: 0 18px 40px rgba(0, 0, 0, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Source Sans 3", "Segoe UI", sans-serif;
  color: var(--text);
  background: radial-gradient(circle at top right, #efe8d3 0%, transparent 45%), radial-gradient(circle at bottom left, #d4ece5 0%, transparent 50%), var(--bg);
}

h2 {
  margin: 0;
  font-size: 1.1rem;
}

.auth-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1.5rem;
}

.auth-card {
  width: min(460px, 100%);
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 1rem;
  box-shadow: var(--shadow);
  padding: 2rem;
}

.setup-overlay {
  position: fixed;
  inset: 0;
  z-index: 1200;
  background: rgba(16, 17, 18, 0.56);
  display: grid;
  place-items: center;
  padding: 1.25rem;
}

.setup-card {
  width: min(460px, 100%);
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 1rem;
  box-shadow: var(--shadow);
  padding: 1.4rem 1.2rem;
}

.setup-card h2 {
  margin-bottom: 0.35rem;
}
.auth-card h1 {
  margin: 0;
  font-size: 1.6rem;
  line-height: 1.2;
}

.auth-subtitle {
  margin: 1.5rem 0 0 0;
  color: var(--muted);
}

.auth-form {
  display: grid;
  gap: 0.75rem;
}
.auth-form label {
  font-weight: 600;
  font-size: 0.95rem;
}
.auth-form input {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 0.55rem;
  padding: 0.7rem 0.8rem;
  font-size: 1rem;
  background: #fff;
}
.auth-form input:focus {
  outline: 2px solid color-mix(in srgb, var(--primary), white 65%);
  border-color: var(--primary);
  outline-offset: 1px;
}
.auth-form button {
  margin-top: 0.5rem;
  border: 0;
  border-radius: 0.6rem;
  padding: 0.8rem 1rem;
  font-size: 1rem;
  font-weight: 700;
  color: #fff;
  background: var(--primary);
  cursor: pointer;
  transition: background 120ms ease;
}
.auth-form button:hover {
  background: var(--primary-hover);
}
.auth-form button:disabled {
  opacity: 0.65;
  cursor: not-allowed;
}

.field-hint {
  margin: -0.2rem 0 0.3rem;
  font-size: 0.88rem;
  color: var(--muted);
}

.field-hint.is-hidden {
  display: none;
}

.app-shell {
  width: min(980px, 100%);
  margin: 0 auto;
  padding: 2rem 1.25rem 2.5rem;
}
.app-shell .app-header {
  display: flex;
  gap: 1rem;
  align-items: flex-end;
  justify-content: space-between;
  margin-bottom: 1.4rem;
}
.app-shell .app-header h1 {
  margin: 0.1rem 0 0;
  font-size: 2rem;
}
.app-shell section.insights-grid {
  margin-bottom: 50px;
}
.app-shell section.summary-grid {
  margin-top: 50px;
}

.eyebrow {
  margin: 0;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: 0.78rem;
  color: var(--muted);
  font-weight: 700;
}

.header-actions {
  display: flex;
  gap: 0.6rem;
}

.header-actions form {
  margin: 0;
}

.ghost-btn {
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  border-radius: 0.6rem;
  padding: 0.55rem 0.9rem;
  font-size: 0.94rem;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
}
.ghost-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
}
.ghost-btn:disabled {
  opacity: 0.65;
  cursor: not-allowed;
}

.summary-grid {
  margin-bottom: 1rem;
}

.summary-grid .table {
  margin-top: 0.6rem;
}

.stat-card,
.panel {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 0.9rem;
  box-shadow: var(--shadow);
}

.stat-card {
  padding: 1rem;
}

.stat-value {
  margin: 0.55rem 0 0;
  font-size: 1.35rem;
  font-weight: 700;
}

.panel {
  padding: 1rem;
}

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

.project-item {
  display: flex;
  justify-content: space-between;
  gap: 0.8rem;
  padding: 0.7rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 0.6rem;
  background: #fff;
}
.project-item span {
  color: var(--muted);
}

.auth-message {
  min-height: 1.4rem;
  margin: 1rem 0 0;
  font-weight: 600;
}
.auth-message.is-error {
  color: var(--danger);
}
.auth-message.is-success {
  color: var(--success);
}

.toast-stack {
  position: fixed;
  inset: 0;
  z-index: 1100;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 0.6rem;
  padding: 1rem;
  background: rgba(23, 27, 34, 0.45);
  backdrop-filter: blur(1px);
}

.auth-toast {
  position: relative;
  width: min(32rem, 100vw - 2rem);
  border-radius: 0.75rem;
  border: 1px solid var(--border);
  background: var(--card-bg);
  box-shadow: var(--shadow);
  padding: 0.75rem 2.4rem 0.75rem 0.85rem;
  transition: opacity 0.2s ease, transform 0.2s ease;
}
.auth-toast.is-success {
  border-color: color-mix(in srgb, var(--success), white 55%);
  background: color-mix(in srgb, #fff, #eafaf2 35%);
}
.auth-toast.is-error {
  border-color: color-mix(in srgb, var(--danger), white 58%);
  background: color-mix(in srgb, #fff, #fdeceb 34%);
}
.auth-toast.is-dismissing {
  opacity: 0;
  transform: translateY(-8px);
}

.auth-toast-text {
  margin: 0;
  font-size: 0.93rem;
  line-height: 1.35;
  color: var(--text);
}

.auth-toast-close {
  position: absolute;
  top: 0.35rem;
  right: 0.35rem;
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 0.1rem;
  cursor: pointer;
}
.auth-toast-close .material-icons {
  margin-right: 0;
  font-size: 1rem;
}
.auth-toast-close:hover {
  color: var(--text);
}

@media (max-width: 760px) {
  .summary-grid {
    grid-template-columns: 1fr;
  }
  .app-header {
    flex-direction: column;
    align-items: flex-start;
  }
  .user-line {
    flex-direction: column;
  }
}
@media (max-width: 520px) {
  .auth-card {
    padding: 1.25rem;
  }
  .project-item {
    flex-direction: column;
  }
}
.header-actions form {
  margin: 0;
}

.timesheet-form {
  display: grid;
  gap: 0.7rem;
  margin-top: 0.7rem;
}
.timesheet-form label {
  font-weight: 600;
  font-size: 0.92rem;
}
.timesheet-form input,
.timesheet-form select {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 0.55rem;
  padding: 0.65rem 0.75rem;
  font-size: 0.98rem;
  background: #fff;
}
.timesheet-form button {
  margin-top: 0.4rem;
  border: 0;
  border-radius: 0.6rem;
  padding: 0.75rem 1rem;
  font-size: 1rem;
  font-weight: 700;
  color: #fff;
  background: var(--primary);
  cursor: pointer;
}

.api-output {
  margin: 0.9rem 0 0;
  padding: 0.8rem;
  border: 1px solid var(--border);
  border-radius: 0.6rem;
  background: #fff;
  overflow: auto;
  font-size: 0.83rem;
}

.timesheet-inline {
  display: flex;
  gap: 0.6rem;
}

.timesheet-form .secondary-btn {
  background: #fff;
  border: 1px solid var(--border);
  color: var(--text);
}

.stat-list {
  margin: 0.55rem 0 0;
  padding-left: 1rem;
  display: grid;
  gap: 0.25rem;
  font-size: 0.92rem;
}

.stat-list li {
  line-height: 1.35;
}

.user-line {
  margin: 0 0 1rem;
  color: var(--muted);
  font-size: 0.95rem;
  text-align: right;
  padding: 0 1rem 0 0;
}

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

.pattern-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  margin-top: 0.5rem;
}

.pattern-chip {
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  border-radius: 999px;
  padding: 0.45rem 0.8rem;
  font-size: 0.9rem;
  cursor: pointer;
}

.pattern-chip:hover,
.pattern-chip.is-active {
  border-color: var(--primary);
  color: var(--primary);
  background: color-mix(in srgb, var(--primary), white 92%);
}

.form-tabs {
  display: flex;
  gap: 0.6rem;
  margin: 0.5rem 0 2rem;
}

.tab-btn {
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  border-radius: 0.6rem;
  padding: 0.45rem 0.85rem;
  font-size: 0.92rem;
  font-weight: 700;
  cursor: pointer;
}

.tab-btn.is-active {
  border-color: var(--primary);
  color: var(--primary);
  background: color-mix(in srgb, var(--primary), white 92%);
}

.tab-panel {
  display: none;
}

.tab-panel.is-active {
  display: block;
}

.project-chip-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
}

.project-chip {
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  border-radius: 999px;
  padding: 0.45rem 0.8rem;
  font-size: 0.9rem;
  cursor: pointer;
}

.project-chip:hover,
.project-chip.is-active {
  border-color: var(--primary);
  color: var(--primary);
  background: color-mix(in srgb, var(--primary), white 92%);
}

.form-row {
  display: grid;
  gap: 0.7rem;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.field-col {
  display: grid;
  gap: 0.4rem;
}

.project-chip-grid {
  gap: 0.4rem;
}

.project-chip {
  border-color: #e6e3da;
  background: #fcfcfa;
  color: #4f4f4f;
  padding: 0.34rem 0.62rem;
  font-size: 0.84rem;
  font-weight: 500;
}

.project-chip:hover,
.project-chip.is-active {
  border-color: #b7b3a7;
  color: #2f2f2f;
  background: #f2f0e8;
}

.activity-quick-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 0.2rem;
}

.activity-quick-chip {
  border: 1px dashed #d2cec1;
  background: #faf9f5;
  color: #4d4d4d;
  border-radius: 999px;
  padding: 0.3rem 0.58rem;
  font-size: 0.8rem;
  cursor: pointer;
}

.activity-quick-chip:hover,
.activity-quick-chip.is-active {
  border-style: solid;
  border-color: #b8b39f;
  background: #f0eee5;
}

.project-chip,
.activity-quick-chip {
  border: 0;
  background: transparent;
  border-radius: 0;
  padding: 0;
  margin: 0;
  font-size: 1rem;
  font-weight: 400;
  color: var(--primary);
  line-height: 1.25;
  text-decoration: none;
}

.project-chip:hover,
.project-chip.is-active,
.activity-quick-chip:hover,
.activity-quick-chip.is-active {
  border: 0;
  background: transparent;
  color: var(--primary-hover);
  text-decoration: underline;
}

.timesheet-form .project-chip,
.timesheet-form .activity-quick-chip {
  appearance: none;
  -webkit-appearance: none;
  border: 0;
  background: transparent;
  border-radius: 0;
  padding: 0;
  margin: 0;
  min-height: 0;
  box-shadow: none;
  font: inherit;
  font-size: 0.9rem;
  font-weight: 400;
  line-height: 1.25;
  color: var(--primary);
  text-decoration: none;
}

.timesheet-form .project-chip:hover,
.timesheet-form .project-chip.is-active,
.timesheet-form .activity-quick-chip:hover,
.timesheet-form .activity-quick-chip.is-active {
  border: 0;
  background: transparent;
  color: var(--primary-hover);
  text-decoration: underline;
}

.duration-split {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.5rem;
}

.material-icons {
  font-size: 1.1rem;
  vertical-align: text-bottom;
  margin-right: 0.2rem;
}

.summary-panel {
  background: transparent;
  border: 0;
  box-shadow: none;
  padding: 1rem;
}

.summary-panel .table,
.summary-panel .table thead th,
.summary-panel .table tbody td {
  background-color: transparent !important;
}

.insights-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.9rem;
}

.inline-check {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.92rem;
  color: var(--muted);
}

.inline-check input[type=checkbox] {
  width: auto;
  margin: 0;
}

@media (max-width: 760px) {
  .insights-grid {
    grid-template-columns: 1fr;
  }
  .form-actions-row {
    flex-direction: column;
    align-items: stretch;
  }
  .form-actions-row > button[type=submit] {
    margin-left: 0;
    width: 100%;
  }
}
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.7rem;
}

.repetitive-edit-toggle {
  border: 0;
  background: transparent;
  padding: 0;
  margin: 0;
  color: var(--muted);
  cursor: pointer;
}

.repetitive-edit-toggle:hover {
  color: var(--primary);
}

.repetitive-panel.is-editing .repetitive-edit-toggle {
  color: var(--primary);
}

.repetitive-edit-toggle .material-icons {
  margin-right: 0;
}

.repetitive-item {
  position: relative;
  display: inline-flex;
}

.repetitive-delete-btn {
  position: absolute;
  top: -0.45rem;
  right: -0.45rem;
  display: none;
}

.repetitive-panel.is-editing .repetitive-delete-btn {
  display: inline-flex;
}

.repetitive-delete-btn {
  border: 0;
  border-radius: 999px;
  background: #fff;
  color: #b42318;
  width: 1.5rem;
  height: 1.5rem;
  padding: 0;
  align-items: center;
  justify-content: center;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.15);
  cursor: pointer;
}

.repetitive-delete-btn .material-icons {
  margin-right: 0;
  font-size: 1rem;
}

.repetitive-chip {
  display: grid;
  justify-items: start;
  gap: 0.08rem;
}

.repetitive-chip-project {
  font-size: 0.74rem;
  color: var(--muted);
  line-height: 1.15;
}

.repetitive-chip-label {
  line-height: 1.2;
}

.timesheet-form {
  gap: 1rem;
}

.timesheet-form .entry-group {
  display: grid;
  gap: 0.6rem;
  padding: 0.85rem 0.9rem;
  border: 1px solid #e6e2d7;
  border-radius: 0.7rem;
  background: #fcfbf7;
}

.timesheet-form .entry-group .form-row {
  margin: 0;
}

.timesheet-form .inline-check {
  margin-top: 0.2rem;
}

.timesheet-form > button[type=submit] {
  margin-top: 0.15rem;
}

.form-actions-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
}

.form-actions-row .inline-check {
  margin-top: 0;
}

.form-actions-row > button[type=submit] {
  margin-top: 0;
  margin-left: auto;
}

.quick-links-label {
  display: inline-flex;
  align-items: center;
  color: var(--muted);
  white-space: nowrap;
  font-size: 0.9rem;
}

.app-shell {
  width: 100%;
  max-width: none;
  padding: 1.5rem 2rem 2rem;
  display: grid;
  grid-template-columns: minmax(0, 3fr) minmax(320px, 2fr);
  grid-template-areas: "header header" "user user" "add insights";
  column-gap: 1rem;
  row-gap: 1rem;
}

.app-shell .app-header {
  grid-area: header;
  margin-bottom: 0;
}

.app-shell .user-line {
  grid-area: user;
  margin: 0;
}

.app-shell > .panel {
  grid-area: add;
}

.app-shell .insights-grid {
  grid-area: insights;
  display: grid;
  grid-template-columns: 1fr;
  grid-template-rows: auto auto minmax(0, 1fr);
  align-content: start;
  align-items: start;
  gap: 1rem;
  margin: 0;
  min-height: 0;
}

.app-shell .insights-grid > .panel {
  height: auto;
  align-self: start;
}

.app-shell .insights-grid > .repetitive-panel {
  order: 1;
}

.app-shell .insights-grid > .most-used-panel {
  order: 2;
}

.app-shell .insights-grid > .day-summary-panel {
  order: 3;
  align-self: stretch;
  height: 100%;
  min-height: 0;
}

@media (max-width: 980px) {
  .app-shell {
    padding: 1.2rem 1rem 1.5rem;
    grid-template-columns: 1fr;
    grid-template-areas: "header" "user" "add" "insights";
  }
}
.day-summary-panel table {
  font-size: 0.9rem;
}
.day-summary-panel table th, .day-summary-panel table td {
  background-color: transparent;
}
.day-summary-panel table tr:last-child td {
  border-bottom: none;
}

.last-added-day + .last-added-day {
  margin-top: 1rem;
}

.last-added-date {
  margin: 0 0 0.45rem;
  font-size: 0.98rem;
  font-weight: 700;
}

.last-added-day .table tbody tr:last-child td {
  border-bottom: 0;
}

.last-added-day .table {
  table-layout: fixed;
}

.last-added-day .table th:nth-child(1),
.last-added-day .table td:nth-child(1) {
  width: 8.5rem;
  min-width: 8.5rem;
  max-width: 8.5rem;
}

.last-added-day .table th:nth-child(2),
.last-added-day .table td:nth-child(2),
.last-added-day .table th:nth-child(3),
.last-added-day .table td:nth-child(3) {
  width: 22%;
  min-width: 10rem;
}

.summary-switch-links {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  margin: 0.5rem 0;
  font-size: 0.9rem;
}

.summary-switch-links a {
  color: var(--primary);
  text-decoration: none;
}

.summary-switch-links a:hover,
.summary-switch-links a.is-active {
  color: var(--primary-hover);
  text-decoration: underline;
}

.summary-mode-links {
  display: inline-flex;
  gap: 0.4rem;
  margin: 0.2rem 0 0.7rem;
}

.summary-mode-link {
  border: 1px solid var(--border);
  background: #fff;
  color: var(--muted);
  border-radius: 999px;
  font-size: 0.82rem;
  line-height: 1;
  padding: 0.32rem 0.72rem;
  cursor: pointer;
}

.summary-mode-link.is-active {
  border-color: color-mix(in srgb, var(--primary) 55%, #ffffff);
  color: var(--primary);
  background: color-mix(in srgb, var(--primary) 9%, #ffffff);
}

.summary-mode-panel {
  display: none;
  min-height: 0;
}

.summary-mode-panel.is-active {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
}

.summary-chart-wrap {
  position: relative;
  min-height: 12rem;
  height: 100%;
  width: 100%;
}

.summary-chart-wrap canvas {
  width: 100%;
  height: 100%;
}

.summary-chart-empty {
  margin-top: 0.5rem;
}

.summary-loading {
  display: none;
  align-items: center;
  gap: 0.45rem;
  color: var(--muted);
  font-size: 0.92rem;
  position: absolute;
  top: 1rem;
  right: 1rem;
  z-index: 2;
  margin: 0;
  pointer-events: none;
}

.summary-loading-spinner {
  width: 0.95rem;
  height: 0.95rem;
  border: 2px solid #d8d4c8;
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: summary-spin 0.75s linear infinite;
}

@keyframes summary-spin {
  to {
    transform: rotate(360deg);
  }
}
.day-summary-panel {
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: 0;
  height: 100%;
  overflow: hidden;
}

.day-summary-panel > h2 {
  padding-right: 7.5rem;
}

.day-summary-panel.is-loading .summary-loading {
  display: inline-flex;
}

.day-summary-panel.is-loading #summary-panel-content {
  opacity: 0.55;
  pointer-events: none;
}

.day-summary-panel .table-responsive {
  overflow-x: auto;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  min-height: 0;
  height: auto;
  max-height: none;
}

.day-summary-panel .table {
  width: max-content;
  min-width: 68rem;
  table-layout: auto;
}

.day-summary-panel .table th,
.day-summary-panel .table td {
  white-space: nowrap;
  padding-left: 0.9rem;
  padding-right: 0.9rem;
}

#summary-panel-content {
  min-height: 0;
  flex: 1 1 auto;
  height: 100%;
  display: flex;
  flex-direction: column;
}

.summary-panel-footer {
  margin-top: auto;
  padding-top: 0.55rem;
  border-top: 1px solid var(--border);
  color: var(--muted);
}

.day-summary-panel .table-responsive {
  flex: 1 1 auto;
  min-height: 10.5rem;
}

#summary-panel-content > .field-hint {
  margin-top: 0.6rem;
}

/* Prevent row stretch feedback loop and force summary table scrolling */
.app-shell {
  align-items: start;
}

.app-shell > .panel {
  align-self: start;
}
