* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Inter, Arial, sans-serif;
  background:
    radial-gradient(circle at top left, rgba(251, 191, 36, 0.20), transparent 24%),
    radial-gradient(circle at top right, rgba(56, 189, 248, 0.18), transparent 22%),
    linear-gradient(180deg, #fff7ed 0%, #eff6ff 42%, #f8fafc 100%);
  color: #172554;
}

.page {
  padding: 24px;
}

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

.eyebrow {
  margin: 0 0 8px;
  color: #f97316;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 12px;
}

h1 {
  margin: 0;
  font-size: 32px;
}

.subtle {
  color: #475569;
}

.workbench {
  display: grid;
  gap: 16px;
  margin-bottom: 16px;
}

.sheet-status-card,
.composer {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: end;
  padding: 18px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.82);
  border: 1px solid #dbeafe;
  box-shadow: 0 20px 45px rgba(59, 130, 246, 0.08);
}

.sheet-status-card {
  align-items: start;
}

.sheet-status-card > div {
  min-width: 0;
  flex: 1;
}

.sheet-total-value {
  margin: 6px 0 0;
  font-size: 28px;
  font-weight: 800;
  color: #1d4ed8;
}

.sheet-status-text {
  margin: 6px 0 0;
  color: #475569;
  line-height: 1.5;
}

.composer {
  margin-bottom: 0;
}

.composer-title {
  margin: 0 0 4px;
  font-weight: 700;
}

.composer-subtle {
  margin: 0;
  color: #64748b;
}

.add-row-controls {
  display: flex;
  gap: 12px;
  align-items: end;
}

.catalog-picker {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.hint-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.hint-chip {
  display: inline-flex;
  align-items: center;
  padding: 7px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.8);
  border: 1px solid #dbeafe;
  color: #475569;
  font-size: 13px;
}

.toolbar {
  display: flex;
  gap: 12px;
  align-items: end;
}

.primary-toolbar {
  flex-wrap: wrap;
  justify-content: flex-end;
}

.toolbar label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 14px;
}

select,
button {
  border-radius: 10px;
  border: 1px solid #bfdbfe;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.92);
  color: #0f172a;
}

.month-picker select,
.catalog-picker select {
  min-width: 220px;
}

button {
  cursor: pointer;
  background: linear-gradient(135deg, #f59e0b, #fb7185);
  border: 0;
  color: white;
}

#write-button {
  background: linear-gradient(135deg, #dc2626, #ea580c);
  color: #fff7ed;
  box-shadow: 0 0 0 1px rgba(124, 45, 18, 0.08), 0 10px 24px rgba(220, 38, 38, 0.24);
  font-weight: 800;
}

#write-button:hover,
#write-button:focus {
  background: linear-gradient(135deg, #b91c1c, #c2410c);
}

#write-button:disabled {
  background: linear-gradient(135deg, #fca5a5, #fdba74);
  color: #7f1d1d;
}

.ghost-button {
  background: rgba(255, 255, 255, 0.82);
  border: 1px solid #cbd5e1;
  color: #1e293b;
}

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

.sheet-wrap {
  overflow: auto;
  border: 1px solid #dbeafe;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 24px 48px rgba(59, 130, 246, 0.08);
}

.sheet {
  width: max-content;
  min-width: 100%;
  border-collapse: separate;
  border-spacing: 0;
}

.sheet th,
.sheet td {
  border-right: 1px solid #e2e8f0;
  border-bottom: 1px solid #e2e8f0;
  padding: 6px 8px;
  text-align: right;
  min-width: 40px;
  background: rgba(255, 255, 255, 0.96);
}

.sheet thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: #eff6ff;
}

.day-header {
  text-align: center !important;
}

.day-header span,
.day-header strong {
  display: block;
}

.weekend-icon {
  margin: 4px 0;
  font-size: 13px;
  line-height: 1;
  color: #f59e0b;
}

.sticky-col {
  position: sticky;
  left: 0;
  z-index: 1;
  text-align: left !important;
  background: #f8fafc !important;
}

.project-col {
  min-width: 240px !important;
  max-width: 240px;
}

.row-title,
.row-subtitle {
  display: block;
}

.row-subtitle {
  color: #64748b;
  font-size: 13px;
  margin-top: 4px;
}

.row-flag {
  display: inline-block;
  margin-top: 6px;
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  background: #e0f2fe;
  color: #0c4a6e;
}

.hour-input {
  width: 100%;
  min-width: 28px;
  border: 1px solid #e2e8f0;
  background: rgba(255, 255, 255, 0.95);
  color: #0f172a;
  border-radius: 8px;
  padding: 6px 4px;
  text-align: right;
}

.day-cell {
  position: relative;
  min-width: 44px;
}

.day-cell .hour-input {
  padding-right: 20px;
}

.note-button {
  position: absolute;
  right: 4px;
  bottom: 4px;
  width: 16px;
  height: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border-radius: 999px;
  border: 1px solid transparent;
  background: transparent;
  color: #94a3b8;
  font-size: 10px;
}

.note-button:hover,
.note-button:focus {
  color: #475569;
  border-color: #cbd5e1;
  background: rgba(255, 255, 255, 0.9);
}

.note-button.has-note {
  color: #0f766e;
  background: #ccfbf1;
  border-color: #99f6e4;
}

.day-cell:has(.note-button.has-note) {
  background: #f0fdfa !important;
}

.day-cell:has(.note-button.has-note) .hour-input {
  border-color: #5eead4;
  background: #f8fffe;
}

.row-total-input {
  width: 100%;
  min-width: 52px;
  border: 1px solid #fcd34d;
  background: rgba(255, 251, 235, 0.95);
  color: #92400e;
  border-radius: 8px;
  padding: 6px 4px;
  text-align: right;
  font-weight: 700;
}

.hour-input:focus {
  outline: none;
  border-color: #f59e0b;
  background: white;
  box-shadow: 0 0 0 3px rgba(251, 191, 36, 0.2);
}

.row-total-input:focus {
  outline: none;
  border-color: #f59e0b;
  background: #fff;
  box-shadow: 0 0 0 3px rgba(251, 191, 36, 0.2);
}

.weekend {
  background: #f8fafc !important;
}

.sheet thead .weekend {
  background: #fff7ed !important;
}

.total-cell {
  font-weight: 700;
  background: #fffbeb !important;
}

tfoot td,
tfoot th {
  font-weight: 700;
}

.action-col {
  min-width: 80px !important;
  text-align: center !important;
  background: #f8fafc !important;
}

.action-col-buttons {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.row-fill-button {
  background: transparent;
  color: #0369a1;
  border: 1px solid #bae6fd;
  padding: 6px 8px;
  font-size: 12px;
}

.row-fill-button:hover,
.row-fill-button:focus {
  background: #e0f2fe;
  border-color: #7dd3fc;
}

.row-remove-button {
  background: transparent;
  color: #b91c1c;
  border: 1px solid #fecaca;
  padding: 6px 8px;
  font-size: 12px;
}

.day-empty-workday {
  background: #fef3c7 !important;
}

.day-over-hours {
  background: #fee2e2 !important;
}

.hour-input.day-empty-workday {
  background: #fffbeb;
  border-color: #fcd34d;
}

.hour-input.day-over-hours {
  background: #fff1f2;
  border-color: #fda4af;
}

.day-dirty {
  box-shadow: inset 0 2px 0 #38bdf8;
}

.auth-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.note-dialog {
  width: min(520px, calc(100vw - 32px));
  border: 1px solid #dbeafe;
  border-radius: 20px;
  padding: 0;
  background: rgba(255, 255, 255, 0.98);
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.2);
}

.note-dialog::backdrop {
  background: rgba(15, 23, 42, 0.35);
}

.note-form {
  padding: 20px;
}

.note-dialog-title {
  margin: 0 0 6px;
  font-size: 20px;
  font-weight: 800;
}

.note-dialog-subtle {
  margin: 0 0 12px;
  color: #475569;
  line-height: 1.5;
}

.note-dialog-warning {
  margin: 0 0 12px;
  padding: 10px 12px;
  border-radius: 12px;
  background: #fff7ed;
  color: #9a3412;
  border: 1px solid #fdba74;
  font-size: 13px;
}

.note-dialog-input {
  width: 100%;
  min-height: 160px;
  border-radius: 14px;
  border: 1px solid #cbd5e1;
  background: white;
  color: #0f172a;
  padding: 12px 14px;
  font: 14px/1.45 Inter, Arial, sans-serif;
  resize: vertical;
}

.note-dialog-input:focus {
  outline: none;
  border-color: #38bdf8;
  box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.18);
}

.note-dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 14px;
}

.auth-card {
  width: min(760px, 100%);
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid #dbeafe;
  border-radius: 28px;
  padding: 32px;
  box-shadow: 0 28px 60px rgba(59, 130, 246, 0.1);
}

.auth-logo {
  margin-bottom: 18px;
}

.auth-subtle {
  color: #475569;
  line-height: 1.5;
}

.auth-steps {
  color: #334155;
  line-height: 1.6;
  padding-left: 20px;
}

.auth-label {
  display: block;
  font-weight: 700;
  margin-bottom: 8px;
}

.auth-textarea {
  width: 100%;
  min-height: 220px;
  border-radius: 16px;
  border: 1px solid #cbd5e1;
  background: white;
  color: #0f172a;
  padding: 14px 16px;
  font: 14px/1.45 ui-monospace, SFMono-Regular, Menlo, monospace;
}

.auth-actions {
  margin-top: 16px;
}

.auth-message {
  margin-top: 14px;
  min-height: 22px;
}

.auth-error {
  color: #b91c1c;
}

.flash-row td,
.flash-row th {
  animation: flash-row 1.2s ease;
}

@keyframes flash-row {
  0% {
    background: rgba(249, 115, 22, 0.28);
  }
  100% {
    background: inherit;
  }
}

@media (max-width: 900px) {
  .page {
    padding: 16px;
  }

  .topbar {
    flex-direction: column;
    align-items: stretch;
  }

  .sheet-status-card,
  .composer,
  .add-row-controls {
    flex-direction: column;
    align-items: stretch;
  }

  .toolbar {
    flex-wrap: wrap;
  }
}
